From cbff60c94694b18eb6c8b6d2875636a9f2422568 Mon Sep 17 00:00:00 2001 From: Darren Xu Date: Mon, 15 Jun 2026 07:32:16 -0700 Subject: [PATCH] desktop: fix new chat shortcut (#9659) --- ui/desktop/src/App.test.tsx | 21 +++++++++++++++++++++ ui/desktop/src/App.tsx | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ui/desktop/src/App.test.tsx b/ui/desktop/src/App.test.tsx index 938386993..8fb079adc 100644 --- a/ui/desktop/src/App.test.tsx +++ b/ui/desktop/src/App.test.tsx @@ -273,6 +273,27 @@ describe('App Component - Brand New State', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); + it('should navigate home when the main process emits new-chat', async () => { + mockElectron.getConfig.mockReturnValue({ + GOOSE_DEFAULT_PROVIDER: 'openai', + GOOSE_DEFAULT_MODEL: 'gpt-4', + GOOSE_ALLOWLIST_WARNING: false, + }); + + render(, { wrapper: IntlTestWrapper }); + + await waitFor(() => { + expect(mockElectron.reactReady).toHaveBeenCalled(); + }); + + const newChatHandler = mockElectron.on.mock.calls.find(([channel]) => channel === 'new-chat')?.[1]; + expect(newChatHandler).toBeDefined(); + + newChatHandler?.({} as any); + + expect(mockNavigate).toHaveBeenCalledWith('/'); + }); + it('should seed recipe sessions with the recipe prompt when no initial message is provided', () => { expect( resolveSessionInitialMessage( diff --git a/ui/desktop/src/App.tsx b/ui/desktop/src/App.tsx index e53dcde47..6ec0ae915 100644 --- a/ui/desktop/src/App.tsx +++ b/ui/desktop/src/App.tsx @@ -570,12 +570,12 @@ export function AppInner() { useEffect(() => { const handleNewChat = (_event: IpcRendererEvent, ..._args: unknown[]) => { - window.dispatchEvent(new CustomEvent(AppEvents.TRIGGER_NEW_CHAT)); + navigate('/'); }; window.electron.on('new-chat', handleNewChat); return () => window.electron.off('new-chat', handleNewChat); - }, []); + }, [navigate]); useEffect(() => { const handleFocusInput = (_event: IpcRendererEvent, ..._args: unknown[]) => {