mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 08:03:28 +00:00
fix(codex): distinguish pane-local homes
This commit is contained in:
@@ -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:<distro>' — 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'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
+1
-1
@@ -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) &&
|
||||
|
||||
Reference in New Issue
Block a user