Repository navigation
Description
Operating system
Windows
Orca version
Source checkout: package version 1.4.197, commit 197550c952563647802b844ebff643ecdf55276c. This is the version tested in isolation, not a claim about the latest release or the version of the running desktop app.
Details
After accepting a Codex account-switch restart for multiple hidden/unmounted panes, one pending pty.spawn blocks the detached restart sweep from reaching every later pane. The restart questions have already been answered, and input remains blocked for all affected panes.
This matters when the previous account has exhausted its quota: keeping those sessions on the previous account does not let the user continue. The reported Windows workflow currently requires manually finding and resuming affected conversations in Agent History; with many sessions, it is easy to overlook some.
Isolated reproduction
- Seed three local, unmounted Codex panes in the real renderer store, each with an existing synthetic PTY and a valid layout leaf.
- Call
markCodexRestartNoticesfor a synthetic account A-to-B switch, thenqueueCodexPaneRestartsfor all three panes. - Mock only the PTY IPC boundary: make the first
window.api.pty.spawnreturn a deferred promise; subsequent calls would resolve immediately. Mockpty.killas well. - Run the real
sweepUnclaimedCodexPaneRestarts()and advance Vitest's fake clock by 60 seconds. - Inspect the spawn calls, pending queue, and the real notice-state predicates. Resolve the deferred promise in cleanup so the test drains normally.
Observed after 60 seconds of virtual time, not a 60-second measurement of a live terminal:
| Pane | Spawn requested | Awaiting restart answer | Input blocked | Still in pending queue |
|---|---|---|---|---|
| 1 | Yes, unresolved | No | Yes | No |
| 2 | No | No | Yes | Yes |
| 3 | No | No | Yes | Yes |
The progress assertion (spawn.mock.calls.length > 1) fails: only one spawn was requested. An explicit rejection is different: the control test confirms that it reopens the failed pane's restart question, preserves its old PTY, and lets the other two restarts complete.
Expected behavior
One stalled restart should not indefinitely block unrelated accepted restarts. Each affected session needs a visible, recoverable outcome so the user can account for every requested restart without manually searching Agent History. A bounded scheduling/recovery strategy should preserve mounted-pane ownership checks and handle late spawn results without leaking or attaching stale replacement PTYs.
Code evidence at the tested commit
- The detached executor awaits each pane sequentially. It consumes that pane's pending entry before awaiting
pty.spawn; an unresolved promise never reaches its catch/finally recovery. - The scheduler also defers further sweeps while
sweepRunningremains true. This scheduler observation is from source inspection; the reproduction invokes the sweep directly. - Queueing sets
restartRequestedfor the whole batch. The notice predicates then stop asking for an answer while continuing to block input. The table reports those predicates, not a screenshot of a rendered notification.
Scope and related reports
This reproduces the renderer/executor failure when a spawn remains pending. It does not establish why a real Windows spawn might hang, or prove that this is the cause of every reported restart failure. No real account switch, Codex process, ConPTY, Electron window, or orchestration handoff was exercised by this reproduction. All account/session/PTY identifiers in the fixture are synthetic. Remote execution and mounted panes were not tested; the detached executor explicitly skips foreign-machine PTYs.
Related: #19589 covers restarting into a fresh conversation; #20142 reports the Windows restart chip failing to move a running pane; #20374 reports credentials becoming unavailable. This issue isolates batch progress when one spawn does not settle. Fixing conversation resume alone would leave this failure mode.
Executable reproduction
At the pinned checkout with dependencies already installed, save the files below under tmp/codex-account-restart-isolated/, then run the following with ORCA_BACKGROUND_LAUNCH=1 in the test process environment:
node node_modules/vitest/vitest.mjs run --config tmp/codex-account-restart-isolated/vitest.config.ts
Recorded result: four tests, two passing controls and two failing desired-behavior assertions; exit code 1. The other failing assertion is the existing conversation-continuity defect in #19589. The configuration explicitly limits discovery to this fixture.
restart.repro.test.ts
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { useAppStore } from '@/store'
import type { AppState } from '@/store/types'
import { buildAgentResumeStartupPlan } from '../../src/shared/tui-agent-resume-startup'
import { sweepUnclaimedCodexPaneRestarts } from '@/components/terminal-pane/codex-detached-pane-restart'
import { resetCodexDetachedPaneRestartExecutorForTests } from '@/components/terminal-pane/codex-detached-pane-restart-scheduler'
import { awaitsCodexRestartAnswer, blocksCodexPaneInput } from '@/components/codex-restart-notice-state'
type SpawnRequest = { tabId?: string; command?: string; [key: string]: unknown }
const spawn = vi.fn<(request: SpawnRequest) => Promise<{ id: string }>>()
const kill = vi.fn<(id: string) => Promise<void>>()
const WORKSPACE = 'isolated-restart-fixture'
const THREAD = '019f81b9-19a9-7651-a8d1-352d9420bd11'
const providerSession = { key: 'session_id', id: THREAD } as const
function pane(index: number) {
return {
tabId: `fixture-tab-${index}`,
ptyId: `fixture-pty-${index}`,
leafId: `00000000-0000-4000-8000-${String(index).padStart(12, '0')}`
}
}
function seed(count: number): void {
const tabs: AppState['tabsByWorktree'][string] = []
const ptyIdsByTabId: AppState['ptyIdsByTabId'] = {}
const layouts: AppState['terminalLayoutsByTabId'] = {}
const statuses: AppState['agentStatusByPaneKey'] = {}
for (let index = 1; index <= count; index += 1) {
const current = pane(index)
tabs.push({
id: current.tabId,
ptyId: current.ptyId,
worktreeId: WORKSPACE,
title: 'fixture Codex',
customTitle: null,
color: null,
createdAt: index,
sortOrder: index,
startupCwd: 'C:\\isolated-fixture-never-spawned',
launchAgent: 'codex'
})
ptyIdsByTabId[current.tabId] = [current.ptyId]
layouts[current.tabId] = {
root: { type: 'leaf', leafId: current.leafId },
activeLeafId: current.leafId,
expandedLeafId: null,
ptyIdsByLeafId: { [current.leafId]: current.ptyId }
}
const paneKey = `${current.tabId}:${current.leafId}`
statuses[paneKey] = {
paneKey,
tabId: current.tabId,
worktreeId: WORKSPACE,
agentType: 'codex',
state: 'waiting',
prompt: 'Synthetic unfinished task',
updatedAt: 1,
stateStartedAt: 1,
stateHistory: [],
providerSession: { ...providerSession }
}
}
useAppStore.setState({
tabsByWorktree: { [WORKSPACE]: tabs },
ptyIdsByTabId,
terminalLayoutsByTabId: layouts,
agentStatusByPaneKey: statuses
})
const ids = tabs.map((tab) => tab.ptyId).filter((id): id is string => id !== null)
useAppStore.getState().markCodexRestartNotices(ids.map((ptyId) => ({
ptyId,
previousAccountLabel: 'Synthetic A',
nextAccountLabel: 'Synthetic B',
previousAccountId: 'fixture-account-a',
nextAccountId: 'fixture-account-b'
})))
useAppStore.getState().queueCodexPaneRestarts(ids)
}
beforeEach(() => {
vi.useFakeTimers()
resetCodexDetachedPaneRestartExecutorForTests()
useAppStore.setState(useAppStore.getInitialState(), true)
spawn.mockReset().mockImplementation(async ({ tabId }) => ({ id: `replacement-${tabId}` }))
kill.mockReset().mockResolvedValue(undefined)
// No preload, daemon, filesystem-backed auth service, or real process is reachable here.
vi.stubGlobal('window', { api: { pty: { spawn, kill } } })
})
afterEach(() => {
for (const [id] of kill.mock.calls) expect(id).toMatch(/^fixture-pty-/)
useAppStore.setState(useAppStore.getInitialState(), true)
resetCodexDetachedPaneRestartExecutorForTests()
vi.clearAllTimers()
vi.useRealTimers()
vi.unstubAllGlobals()
})
describe('isolated account restart reproduction: real store/executor, simulated IPC only', () => {
it('CONTROL: the history resume builder carries the exact thread on Windows', () => {
const plan = buildAgentResumeStartupPlan({
agent: 'codex', providerSession, cmdOverrides: {}, platform: 'win32', shell: 'powershell'
})
expect(plan?.launchCommand).toContain('resume')
expect(plan?.launchCommand).toContain(THREAD)
expect(spawn).not.toHaveBeenCalled()
})
it('REGRESSION: accepted account restart must resume the captured conversation', async () => {
seed(1)
await sweepUnclaimedCodexPaneRestarts()
expect(spawn).toHaveBeenCalledOnce()
expect(kill).toHaveBeenCalledExactlyOnceWith(pane(1).ptyId)
console.info('continuity-observation', JSON.stringify({
oldThread: THREAD,
replacementCommand: spawn.mock.calls[0]?.[0].command,
pendingRestarts: Object.keys(useAppStore.getState().pendingCodexPaneRestartIds)
}))
expect(spawn.mock.calls[0]?.[0].command).toContain(THREAD)
})
it('REGRESSION: one unresolved spawn must not silently strand every later accepted restart', async () => {
let finishFirst: (value: { id: string }) => void = () => { throw new Error('not armed') }
const first = new Promise<{ id: string }>((resolve) => { finishFirst = resolve })
spawn.mockImplementation(({ tabId }) => tabId === pane(1).tabId
? first : Promise.resolve({ id: `replacement-${tabId}` }))
seed(3)
const sweep = sweepUnclaimedCodexPaneRestarts()
try {
await vi.advanceTimersByTimeAsync(60_000)
const state = useAppStore.getState()
const observations = [1, 2, 3].map((index) => {
const notice = state.codexRestartNoticeByPtyId[pane(index).ptyId]
return {
pane: index,
questionVisible: awaitsCodexRestartAnswer(notice),
inputBlocked: blocksCodexPaneInput(notice),
stillQueued: Boolean(state.pendingCodexPaneRestartIds[pane(index).ptyId])
}
})
console.info('batch-observation-after-60s-virtual', JSON.stringify({
spawnRequests: spawn.mock.calls.length, panes: observations
}))
expect(spawn.mock.calls.length).toBeGreaterThan(1)
} finally {
finishFirst({ id: 'replacement-fixture-tab-1' })
await sweep
}
})
it('CONTROL: an explicit spawn rejection reopens its prompt and lets later panes proceed', async () => {
spawn.mockRejectedValueOnce(new Error('Synthetic account B launch refused'))
seed(3)
await sweepUnclaimedCodexPaneRestarts()
const state = useAppStore.getState()
expect(spawn).toHaveBeenCalledTimes(3)
expect(awaitsCodexRestartAnswer(state.codexRestartNoticeByPtyId[pane(1).ptyId])).toBe(true)
expect(kill).not.toHaveBeenCalledWith(pane(1).ptyId)
expect(state.ptyIdsByTabId[pane(2).tabId]).toEqual(['replacement-fixture-tab-2'])
expect(state.ptyIdsByTabId[pane(3).tabId]).toEqual(['replacement-fixture-tab-3'])
})
})vitest.config.ts
import { defineConfig } from 'vitest/config'
import base from '../../config/vitest.config'
export default defineConfig({
...base,
test: {
...base.test,
include: ['tmp/codex-account-restart-isolated/restart.repro.test.ts'],
maxWorkers: 1,
fileParallelism: false,
reporters: ['default', 'json'],
outputFile: { json: 'tmp/codex-account-restart-isolated/result.json' }
}
})
Activity
AmethystLiang commentedon Sep 22, 2026
thanks for reporting. looking into it
docs(terminal): explain the detached restart concurrency cap
docs(terminal): explain the detached restart concurrency cap
fix(terminal): allow independent hidden account restarts to progress (#…
nwparker commentedon Oct 23, 2026
Thanks @Tauri-EPO for the precise repro. Your stuck-spawn regression tests went into #31994, and you're credited as co-author.
What #31994 fixes:
Still open:
I'm leaving this issue open for those parts.
nwparker commentedon Oct 24, 2026
Fixed in #31994 (v1.4.239): hidden-pane account-switch restarts run in parallel and a stuck spawn is released after 90s. Thanks again @Tauri-EPO for the repro. If it recurs on the latest build, please reply or reopen.