The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keybinds skip IME composition keys; pin draft survival across Settings navigation
Teknium89df391580be
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.test.tsxindex eab570bf428..fd26b57cebb 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-draft.test.tsx@@ -215,6 +215,41 @@ describe('useComposerDraft — rehydrate diagnostic log stays redacted', () => {})})+describe('useComposerDraft — draft survives full unmount (Settings navigation, #41079)', () => {+ afterEach(() => {+ cleanup()+ mainComposerScope.clear()+ clearSessionDraft('session-nav')+ })++ it('stashes the unsent draft on unmount and restores it on remount', () => {+ // The user typed but has not sent; the draft was stashed by the normal+ // typing debounce path at some earlier point.+ stashSessionDraft('session-nav', 'unsent thought', [])++ const { unmount } = render(+ <ProbeHarness activeQueueSessionKey="session-nav" onLayoutSnapshot={() => undefined} sessionId="session-nav" />+ )++ // Navigating to Settings unmounts the chat composer entirely. The swap+ // effect's cleanup must stash the loaded draft back under its scope —+ // NOT drop it with the React state.+ unmount()++ mockComposerApi.setText.mockClear()++ const remount = render(+ <ProbeHarness activeQueueSessionKey="session-nav" onLayoutSnapshot={() => undefined} sessionId="session-nav" />+ )++ // Remount restored the text into the composer core (setText mirrors+ // paintDraft's write path — the editor DOM isn't mounted in this harness).+ expect(mockComposerApi.setText).toHaveBeenCalledWith('unsent thought')++ remount.unmount()+ })+})+describe('useComposerDraft — a closing composer hands the focus-bus key back', () => {afterEach(() => {cleanup()diff --git a/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts b/apps/desktop/src/app/chat/hooks/use-composer-actions.test.tsindex 8fe4e66fafa..eaddeec15e8 100644--- a/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts+++ b/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts@@ -295,7 +295,8 @@ describe('useComposerActions native image drops', () => {add,remove: vi.fn(() => null),target: 'test-composer',- update: vi.fn(() => true)+ update: vi.fn(() => true),+ updateIfCurrent: vi.fn(() => true)}}))@@ -310,11 +311,14 @@ describe('useComposerActions native image drops', () => {expect(saveImageBuffer).toHaveBeenCalledOnce()expect(readFileDataUrl).toHaveBeenCalledWith(durablePath)expect(readFileDataUrl).not.toHaveBeenCalledWith(transientPath)+ // The bounded-preview pipeline no longer retains the full-resolution data+ // URL on the attachment (`previewUrl`); the durable path is the authority+ // and the display thumbnail resolves asynchronously. What matters here is+ // that the attachment is keyed to the DURABLE path, not the transient one.expect(add).toHaveBeenCalledWith(expect.objectContaining({kind: 'image',- path: durablePath,- previewUrl+ path: durablePath}))})diff --git a/apps/desktop/src/app/hooks/use-keybinds.ts b/apps/desktop/src/app/hooks/use-keybinds.tsindex 4f36981d3f4..24982264e3a 100644--- a/apps/desktop/src/app/hooks/use-keybinds.ts+++ b/apps/desktop/src/app/hooks/use-keybinds.ts@@ -292,6 +292,16 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {useEffect(() => {const onKeyDown = (event: KeyboardEvent) => {+ // An active IME composition owns the keyboard. Windows Chinese IMEs+ // (Microsoft Pinyin, Sogou) use Ctrl+, as their punctuation-mode toggle,+ // so without this guard that keystroke ALSO matched `nav.settings` and+ // navigated away mid-word — unmounting the composer and destroying the+ // unsent draft (#41079). The draft stash below makes navigation safe;+ // this makes the IME keystroke not navigate at all.+ if (event.isComposing) {+ return+ }+// Capture mode: the next real key becomes the binding. Swallow everything// so e.g. ⌘K rebinds instead of opening the palette.const capturing = $capture.get()