diff --git a/src/main/codex/codex-pane-account-registry.ts b/src/main/codex/codex-pane-account-registry.ts index 5fdbbff03bc..d74f09809b6 100644 --- a/src/main/codex/codex-pane-account-registry.ts +++ b/src/main/codex/codex-pane-account-registry.ts @@ -16,7 +16,12 @@ import type { * the old account and the user is stuck there with no prompt to escape it. */ -export type CodexPaneHomeRoute = 'real-home' | 'shared-home' | 'account-home' | 'wsl-home' +export type CodexPaneHomeRoute = + | 'real-home' + | 'shared-home' + | 'account-home' + | 'custom-home' + | 'wsl-home' export type CodexPaneAccountRecord = { /** 'host' or 'wsl:' — the selection lane this pane launched from. */ @@ -127,6 +132,7 @@ function isPaneHomeRoute(value: unknown): value is CodexPaneHomeRoute { value === 'real-home' || value === 'shared-home' || value === 'account-home' || + value === 'custom-home' || value === 'wsl-home' ) } diff --git a/src/main/codex/codex-pane-launch-account.test.ts b/src/main/codex/codex-pane-launch-account.test.ts index 135629342dc..76436b19ecb 100644 --- a/src/main/codex/codex-pane-launch-account.test.ts +++ b/src/main/codex/codex-pane-launch-account.test.ts @@ -74,17 +74,17 @@ describe('resolveCodexPaneLaunchAccount', () => { }) }) - it('omits route provenance for a pane-local custom home', () => { + it('records a non-comparable route for a pane-local custom home', () => { expect( resolveCodexPaneLaunchAccount({ pinnedByResume: false, launchCodexHomePath: '/data/codex-runtime-home/home', - recordHomeRoute: false, + recordComparableHomeRoute: false, systemCodexHomePath: SYSTEM_HOME, settings: settings({ host: null }), target: { runtime: 'host' } }) - ).toEqual({ selectionKey: 'host', accountId: null }) + ).toEqual({ selectionKey: 'host', accountId: null, homeRoute: 'custom-home' }) }) it('records the same account a resume pinned to when it is already selected', () => { diff --git a/src/main/codex/codex-pane-launch-account.ts b/src/main/codex/codex-pane-launch-account.ts index 0b8044aff8d..b52ba60dc43 100644 --- a/src/main/codex/codex-pane-launch-account.ts +++ b/src/main/codex/codex-pane-launch-account.ts @@ -32,7 +32,7 @@ type CodexPaneLaunchAccountSettings = Pick< export function resolveCodexPaneLaunchAccount(args: { pinnedByResume: boolean launchCodexHomePath: string | null - recordHomeRoute?: boolean + recordComparableHomeRoute?: boolean shellStartupHomeOverride?: CodexShellStartupHomeOverride environmentHomeOverride?: CodexEnvironmentHomeOverride systemCodexHomePath: string @@ -40,7 +40,8 @@ export function resolveCodexPaneLaunchAccount(args: { target: CodexAccountSelectionTarget }): CodexPaneAccountRecord | null { const selectionKey = getCodexSelectionLaneKey(args.target) - const homeRoute = args.recordHomeRoute === false ? undefined : resolveCodexPaneHomeRoute(args) + const homeRoute = + args.recordComparableHomeRoute === false ? 'custom-home' : resolveCodexPaneHomeRoute(args) if (!args.pinnedByResume) { return { selectionKey, diff --git a/src/main/codex/codex-stale-pane-accounts.test.ts b/src/main/codex/codex-stale-pane-accounts.test.ts index 8261e52f9db..1906d19f360 100644 --- a/src/main/codex/codex-stale-pane-accounts.test.ts +++ b/src/main/codex/codex-stale-pane-accounts.test.ts @@ -102,6 +102,11 @@ describe('codex pane account registry', () => { accountId: null, homeRoute: 'wsl-home' }) + recordCodexPaneAccount('pty-custom', { + selectionKey: 'host', + accountId: null, + homeRoute: 'custom-home' + }) expect(hasRecordedLegacySharedCodexPane()).toBe(false) @@ -303,6 +308,22 @@ describe('listStaleCodexPanes', () => { ).toEqual([]) }) + it('does not compare a pane-local custom home with the selected host route', () => { + recordCodexPaneAccount('pty-1', { + selectionKey: 'host', + accountId: null, + homeRoute: 'custom-home' + }) + + expect( + listStaleCodexPanes({ + ptyIds: ['pty-1'], + settings: settingsWithSelection(null), + activeHostHomeRoute: 'real-home' + }) + ).toEqual([]) + }) + it('does not report a custom-home spelling change that keeps the shared route', () => { recordCodexPaneAccount('pty-1', { selectionKey: 'host', diff --git a/src/main/codex/codex-stale-pane-accounts.ts b/src/main/codex/codex-stale-pane-accounts.ts index 72cc9983192..b74529abc29 100644 --- a/src/main/codex/codex-stale-pane-accounts.ts +++ b/src/main/codex/codex-stale-pane-accounts.ts @@ -35,6 +35,7 @@ export function listStaleCodexPanes(args: { const homeRouteChanged = record.selectionKey === 'host' && record.homeRoute !== undefined && + record.homeRoute !== 'custom-home' && args.activeHostHomeRoute !== undefined && record.homeRoute !== args.activeHostHomeRoute const accountChanged = record.accountId !== activeAccountId diff --git a/src/main/ipc/pty.test.ts b/src/main/ipc/pty.test.ts index b554a8e87a8..0a30c25ae3b 100644 --- a/src/main/ipc/pty.test.ts +++ b/src/main/ipc/pty.test.ts @@ -15059,7 +15059,8 @@ describe('registerPtyHandlers', () => { expect(recordCodexPaneAccountMock).toHaveBeenCalledWith('pty-custom-home', { selectionKey: 'host', - accountId: null + accountId: null, + homeRoute: 'custom-home' }) } ) @@ -15131,7 +15132,8 @@ describe('registerPtyHandlers', () => { expect(recordCodexPaneAccountMock).toHaveBeenCalledWith('pty-pane-env-home', { selectionKey: 'host', - accountId: null + accountId: null, + homeRoute: 'custom-home' }) }) diff --git a/src/main/ipc/pty.ts b/src/main/ipc/pty.ts index 12333592f71..39dd2b63d86 100644 --- a/src/main/ipc/pty.ts +++ b/src/main/ipc/pty.ts @@ -1033,7 +1033,7 @@ function recordCodexPaneAccountForSpawn(args: { launchCodexHomePath: args.launchCodexHomePath, // Why: pane-local overrides cannot be re-derived when a restart builds // a fresh launch env, so route prompts would guess and block valid input. - recordHomeRoute: + recordComparableHomeRoute: args.pinnedByResume || ((customHomeOverride?.source !== 'environment' || recheckableEnvironmentOverride !== undefined) &&