The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): boot a peer window onto the fresh draft, not the primary's remembered session
Brooklyn Nicholsonf91451ba9302
diff --git a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsxindex 8ce05a7f36c..ec931d359d1 100644--- a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx+++ b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx@@ -22,7 +22,10 @@ import { useDesktopIntegrations } from './use-desktop-integrations'// Mutable HUD-window flag so the restore tests can flip the window kind the// hook believes it runs in. Default false keeps the pre-existing restore// coverage exercising the real main-window path.-const { hudWindowMock } = vi.hoisted(() => ({ hudWindowMock: vi.fn(() => false) }))+const { hudWindowMock, peerWindowMock } = vi.hoisted(() => ({+ hudWindowMock: vi.fn(() => false),+ peerWindowMock: vi.fn(() => false)+}))vi.mock('@/store/mcp-deeplink-install', () => ({requestMcpInstallFromDeepLink: vi.fn()@@ -41,7 +44,8 @@ vi.mock('@/store/windows', async importOriginal => {return {...actual,- isHudWindow: () => hudWindowMock()+ isHudWindow: () => hudWindowMock(),+ isPeerInstanceWindow: () => peerWindowMock()}})@@ -69,6 +73,7 @@ describe('useDesktopIntegrations', () => {navigate = vi.fn()// Every test starts as a main window; only the HUD describe flips this.hudWindowMock.mockReturnValue(false)+ peerWindowMock.mockReturnValue(false)// Stub the desktop bridge so the hook's useEffect callbacks don't try to// reach real Electron IPC. The established desktop-test pattern assigns a@@ -223,6 +228,25 @@ describe('useDesktopIntegrations', () => {})})+ describe('peer instance windows (#74948)', () => {+ it('does not restore the primary window\'s remembered session into a peer window', () => {+ // Ctrl+Shift+N opens a peer that shares the profile's remembered+ // navigation (the primary window writes it continuously), but the peer+ // must boot into its own blank fresh-draft chat, not the session the+ // primary window has open.+ peerWindowMock.mockReturnValue(true)+ window.localStorage.setItem('hermes.desktop.lastRoute.profile.default', '/remembered-session')+ window.localStorage.setItem('hermes.desktop.lastSessionId.profile.default', 'remembered-session')++ render({ profileReady: true, sessions: [session({ id: 'remembered-session', profile: 'default' })] })++ expect(navigate).not.toHaveBeenCalled()+ // The remembered values stay intact for the primary window's next boot.+ expect(window.localStorage.getItem('hermes.desktop.lastRoute.profile.default')).toBe('/remembered-session')+ expect(window.localStorage.getItem('hermes.desktop.lastSessionId.profile.default')).toBe('remembered-session')+ })+ })+describe('display.resume_last_session', () => {it('stays on the fresh chat when the setting is off, and keeps remembering the open chat', () => {window.localStorage.setItem('hermes.desktop.lastRoute.profile.default', '/remembered-session')diff --git a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.tsindex 2682a697b06..dce969716f3 100644--- a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts+++ b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts@@ -38,7 +38,7 @@ import { $botChatScopes, $sessionTiles, storedSessionIdForRuntimeId } from '@/stimport { onSessionsChanged } from '@/store/session-sync'import { requestSkillInstallFromDeepLink } from '@/store/skill-deeplink-install'import { openUpdatesWindow, startUpdatePoller, stopUpdatePoller } from '@/store/updates'-import { isBrowserWindow, isHudWindow, isSecondaryWindow } from '@/store/windows'+import { isBrowserWindow, isHudWindow, isPeerInstanceWindow, isSecondaryWindow } from '@/store/windows'import type { SessionInfo } from '@/types/hermes'import { requestComposerFocus, requestComposerInsert } from '../../chat/composer/focus'@@ -121,7 +121,12 @@ export function useDesktopIntegrations({// This ref is a one-time lifecycle latch, not a mirror of reactive atom state.// eslint-disable-next-line no-restricted-syntaxuseEffect(() => {- if (!profileReady || isHudWindow() || isBrowserWindow()) {+ // A peer instance window (Ctrl+Shift+N / New Window) boots on the fresh+ // draft route by design: it must not replay the primary window's+ // remembered-route/remembered-session restore, which lands it back on the+ // very session Window 1 has open (#74948). Connections' source+ // restoration already skips peers for the same reason.+ if (!profileReady || isHudWindow() || isBrowserWindow() || isPeerInstanceWindow()) {return}