The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: keep refused focus redirects visible and treat editor-anchored selections as inside
teknium13e9ae05fba1a
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex 404d3a2a6d4..6fa6b8795ec 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -335,7 +335,8 @@ so glass and message-bubble transparency do not reveal scrolling text.queues stay session-owned. Docking restores the individual pane composers.In either placement, moving into a chat pane gives its editor typing focusimmediately and preserves its caret. Layout-only hover events and delayed- focus callbacks cannot replace that choice. Movement within the same pane+ focus callbacks cannot replace that choice, and a live transcript selection+ is never cleared by focus-follow. Movement within the same panemust not flush React; deliberate Tab navigation and clicked controls still work.Active dictation or voice conversation pins the recipient until capture ends,keeping the microphone's stop controls and shortcut attached to its owner.diff --git a/apps/desktop/src/app/chat/composer/floating-target-selection-guard.test.ts b/apps/desktop/src/app/chat/composer/floating-target-selection-guard.test.tsindex f3404bb4edb..bc8d5edf04d 100644--- a/apps/desktop/src/app/chat/composer/floating-target-selection-guard.test.ts+++ b/apps/desktop/src/app/chat/composer/floating-target-selection-guard.test.ts@@ -1,5 +1,5 @@// @vitest-environment jsdom-import { afterEach, describe, expect, it } from 'vitest'+import { afterEach, describe, expect, it, vi } from 'vitest'import { registerFloatingComposer } from './floating-target'@@ -68,9 +68,14 @@ describe('floating composer focus-follow vs transcript selection', () => {expect(document.activeElement).not.toBe(editor)// jsdom's own focusing steps collapse the selection afterwards, so the- // observable invariant here is that focus was not redirected into the editor.+ // observable invariant here is that focus was not redirected into the editor+ // and the refused redirect did not swallow the button's focusin from root listeners.+ const focusin = vi.fn()+ document.addEventListener('focusin', focusin)button.focus()+ document.removeEventListener('focusin', focusin)expect(document.activeElement).toBe(button)+ expect(focusin).toHaveBeenCalledTimes(1)})it('still focuses the composer on pointermove when nothing is selected outside it', () => {diff --git a/apps/desktop/src/app/chat/composer/floating-target.ts b/apps/desktop/src/app/chat/composer/floating-target.tsindex 4969d68d11f..f28d8224411 100644--- a/apps/desktop/src/app/chat/composer/floating-target.ts+++ b/apps/desktop/src/app/chat/composer/floating-target.ts@@ -42,7 +42,8 @@ function selectionOutsideComposer(): boolean {return false}- const anchorEl = selection.anchorNode instanceof Node ? selection.anchorNode.parentElement : null+ const { anchorNode } = selection+ const anchorEl = anchorNode instanceof Element ? anchorNode : anchorNode?.parentElement ?? nullreturn !anchorEl?.closest('[data-slot="composer-rich-input"]')}@@ -185,6 +186,12 @@ function trackFocus(event: FocusEvent) {if (keyboardNavigation || (pointerDownTarget && target.contains(pointerDownTarget))) {flushSync(() => selectSurface(id))} else {+ // A refused redirect leaves focus where it landed: that element's focusin+ // must still reach React and other root listeners.+ if (selectionOutsideComposer()) {+ return+ }+event.stopImmediatePropagation()const owner = $floatingComposerOwner.get()