desktop: fix new chat shortcut (#9659)

This commit is contained in:
Darren Xu
2026-06-15 07:32:16 -07:00
committed by GitHub
parent 1472e7ee89
commit cbff60c946
2 changed files with 23 additions and 2 deletions
+21
View File
@@ -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(<AppInner />, { 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(
+2 -2
View File
@@ -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[]) => {