fix(composer): stop the mobile caret misplacing on command mode toggles

The composer frame kept `opacity-95` and `backdrop-blur-md`, so it stayed a
composited layer with the textarea inside it. Repainting that layer whenever
command or mention mode toggled (frame class change, mode badge mount, takeover
list mount, z-index change) still made iOS draw the caret at a stale position
below the typed text, even after the transition was removed.

Render the frosted background as a `before:` pseudo-element and drop the
compositing from the frame, so the textarea's ancestor is never a layer that
repaints on mode changes. Add a regression test pinning the invariant.
This commit is contained in:
Chris Scott committed 2026-10-07 22:01:53 -04:00
1 parent e42ce1bd56
commit 4553af41dc
2 files changed
+14 -1

No files matched your search

@@ -495,6 +495,19 @@ describe('PromptInput command submission', () => {
await waitFor(() => expect(suggestionProps.selectedIndex).toBe(0))
})
it('keeps the composer frame out of a compositing layer so the iOS caret stays aligned', async () => {
renderComponent()
const input = await screen.findByPlaceholderText('Send a message...')
const frame = input.parentElement as HTMLElement
const tokens = frame.className.split(/\s+/)
expect(tokens).not.toContain('transition-all')
expect(tokens.some((token) => token.startsWith('backdrop-blur'))).toBe(false)
expect(tokens.some((token) => token.startsWith('opacity-'))).toBe(false)
expect(tokens).toContain('before:backdrop-blur-md')
})
describe('mobile keybar', () => {
beforeEach(() => {
mocks.useMobile.mockReturnValue(true)
@@ -1472,7 +1472,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
return (
<div className={`relative backdrop-blur-md bg-background opacity-95 border border-border dark:border-border/30 rounded-xl p-2 md:p-3 mb-4 md:mb-1 w-full ${hasPendingPermissionForSession ? 'border-highlight/50 ring-1 ring-highlight/30' : composerModeStyle?.frame ?? ''} ${isTakeoverOpen ? 'z-[60]' : ''}`}>
<div className={`relative isolate border border-border dark:border-border/30 rounded-xl p-2 md:p-3 mb-4 md:mb-1 w-full before:pointer-events-none before:absolute before:-inset-px before:-z-10 before:rounded-xl before:bg-background/95 before:backdrop-blur-md before:content-[''] ${hasPendingPermissionForSession ? 'border-highlight/50 ring-1 ring-highlight/30' : composerModeStyle?.frame ?? ''} ${isTakeoverOpen ? 'z-[60]' : ''}`}>
{composerModeStyle && (
<span
data-testid="composer-mode-badge"