Repository navigation
fix(terminal): allow independent hidden account restarts to progress - #31994
Conversation
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
🔇 Additional comments: 4
src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts: 1
35-35: LGTM!Also applies to: 41-49, 52-52, 113-113
src/renderer/src/components/terminal-pane/codex-detached-pane-restart-scheduler.ts: 1
72-74: LGTM!src/renderer/src/components/terminal-pane/account-restart-queue-progress.test.ts: 1
1-245: LGTM!config/reliability-gates.jsonc-88-88: 1
88-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Align blocking promotion with the manifest policy.
If this criterion permits blocking promotion, “or” allows promotion after only one threshold.
policy.blockingPromotionrequires both 100 runs and 14 days. Change “or” to “and,” or state that this criterion applies only to an earlier maturity level.
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
76ab9d88-cd85-4c7a-a67f-fbaa33266486
📒 Files selected for processing: 4
config/reliability-gates.jsoncsrc/renderer/src/components/terminal-pane/account-restart-queue-progress.test.tssrc/renderer/src/components/terminal-pane/codex-detached-pane-restart-scheduler.tssrc/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
41f0f6f to
44f3f7f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
91e923e3-868d-4c9d-be3a-bd1d499426b0
📥 Commits
Reviewing files that changed from the base of the PR and between 62e2eeb and 44f3f7f2d33866ec5b499b976d76a344a511c558.
📒 Files selected for processing: 5
config/reliability-gates.jsoncsrc/renderer/src/components/terminal-pane/account-restart-queue-progress.test.tssrc/renderer/src/components/terminal-pane/codex-detached-pane-restart.tssrc/renderer/src/components/terminal-pane/detached-pane-restart-pty-release.tssrc/renderer/src/components/terminal-pane/detached-pane-restart-slots.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| releaseSlot = holdDetachedRestartSlot(ptyId, () => { | ||
| console.warn('[codex-restart] detached restart spawn stalled; asking again') | ||
| // Why: a late result still adopts and clears this prompt, since main may have stopped the old PTY. | ||
| reopenCurrentCodexRestartPrompt(claimedPane, ptyId) | ||
| onSettled?.() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
set -eu
file='src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts'
printf '%s\n' '--- restart file: relevant symbols and numbered source ---'
rg -n -F -- 'inFlightPtyIds' -e 'restartUnclaimedPane' -e 'sweepUnclaimedCodexPaneRestarts' -e 'holdDetachedRestartSlot' -e 'reopenCurrentCodexRestartPrompt' -e 'executeDetachedCodexPaneRestart' "$file" || true
nl -ba "$file" | sed -n '1,190p'
printf '%s\n' '--- scheduler callers and definitions ---'
rg -n -F --glob '*.ts' -e 'sweepUnclaimedCodexPaneRestarts' -e 'restartUnclaimedPane' -e 'holdDetachedRestartSlot' -e 'inFlightPtyIds' src/renderer/src || true
printf '%s\n' '--- stalled-spawn tests ---'
rg -n -F --glob '*.test.ts' -e 'stalled' -e 'inFlightPtyIds' -e 'reopenCurrentCodexRestartPrompt' -e 'sweepUnclaimedCodexPaneRestarts' src/renderer/src || true
test_files=$(rg -l -F --glob '*.test.ts' -e 'stalled' -e 'sweepUnclaimedCodexPaneRestarts' src/renderer/src || true)
for t in $test_files; do
printf '\n--- %s ---\n' "$t"
nl -ba "$t" | sed -n '1,260p'
doneRepository: stablyai/orca
Length of output: 45609
🏁 Script executed:
set -eu
printf '%s\n' '--- scheduler ---'
nl -ba src/renderer/src/components/terminal-pane/codex-detached-pane-restart-scheduler.ts | sed -n '1,150p'
printf '%s\n' '--- slot helper ---'
nl -ba src/renderer/src/components/terminal-pane/detached-pane-restart-slots.ts | sed -n '1,180p'
printf '%s\n' '--- exact restart-test matches ---'
rg -n -F --glob 'codex-detached-pane-restart.test.ts' \
-e 'stalled' -e 'stall' -e 'asking again' -e 'in-flight' -e 'reopen' -e 'settled' \
src/renderer/src/components/terminal-pane/codex-detached-pane-restart.test.ts || true
printf '%s\n' '--- restart-test focused ranges ---'
nl -ba src/renderer/src/components/terminal-pane/codex-detached-pane-restart.test.ts | sed -n '380,610p'
printf '%s\n' '--- execute tail and prompt helper ---'
nl -ba src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts | sed -n '163,390p'Repository: stablyai/orca
Length of output: 22674
🏁 Script executed:
set -eu
printf '%s\n' '--- dedicated slot/stall tests and references ---'
rg --files src/renderer/src | rg 'detached-pane-restart|account-restart-queue-progress|restart.*slot' || true
rg -n -F --glob '*.ts' \
-e 'STALLED_DETACHED_RESTART_MS' \
-e 'holdDetachedRestartSlot(' \
-e 'asking again' \
-e 'restartRequested' \
-e 'reopenCodexRestartPrompt' \
-e 'queuePaneAccountRestarts' \
src/renderer/src/components/terminal-pane src/renderer/src/store src/renderer/src/lib || true
printf '%s\n' '--- restart action declarations ---'
rg -n -F --glob '*.ts' \
-e 'reopenCodexRestartPrompt:' \
-e 'reopenCodexRestartPrompt =' \
-e 'queuePaneAccountRestarts:' \
-e 'queuePaneAccountRestarts =' \
src/renderer/src/store src/renderer/src || true
printf '%s\n' '--- test files containing stall or slot behavior ---'
for t in $(rg -l -F --glob '*.test.ts' \
-e 'STALLED_DETACHED_RESTART_MS' \
-e 'holdDetachedRestartSlot' \
-e 'asking again' \
-e 'detached restart spawn stalled' \
src/renderer/src || true); do
printf '\n--- %s ---\n' "$t"
nl -ba "$t" | sed -n '1,260p'
doneRepository: stablyai/orca
Length of output: 35957
🏁 Script executed:
set -eu
printf '%s\n' '--- stalled-spawn test remainder ---'
nl -ba src/renderer/src/components/terminal-pane/account-restart-queue-progress.test.ts | sed -n '246,330p'
printf '%s\n' '--- terminal restart state ---'
nl -ba src/renderer/src/store/terminals/terminal-restart-state.ts | sed -n '1,220p'Repository: stablyai/orca
Length of output: 11800
🏁 Script executed:
set -eu
printf '%s\n' '--- restart notice state ---'
nl -ba src/renderer/src/components/terminal-pane/codex-restart-notice-state.ts | sed -n '1,180p'
printf '%s\n' '--- focused helper definitions in queue-progress test ---'
nl -ba src/renderer/src/components/terminal-pane/account-restart-queue-progress.test.ts | sed -n '1,115p'Repository: stablyai/orca
Length of output: 5037
🏁 Script executed:
set -eu
file='src/renderer/src/components/codex-restart-notice-state.ts'
nl -ba "$file" | sed -n '1,180p'Repository: stablyai/orca
Length of output: 1107
Do not reopen the prompt while the original spawn is still in flight.
The stall timer releases the slot, but inFlightPtyIds remains set until executeDetachedCodexPaneRestart settles. A second acceptance queues the same PTY ID, and the guard returns before the restart is consumed or spawned. restartRequested then keeps pane input blocked. If the original spawn never settles, this state can persist indefinitely.
Keep the prompt ambiguous until settlement. If retry is required, add cancellation or claim-generation handling that prevents the late original result from adopting after a new claim starts.
Suggested fix
--- "a/src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts"
+++ "b/src/renderer/src/components/terminal-pane/codex-detached-pane-restart.ts"
@@ -105,11 +105,11 @@
}
inFlightPtyIds.add(ptyId)
const claimedPane = located
releaseSlot = holdDetachedRestartSlot(ptyId, () => {
console.warn('[codex-restart] detached restart spawn stalled; asking again')
- // Why: a late result still adopts and clears this prompt, since main may have stopped the old PTY.
- reopenCurrentCodexRestartPrompt(claimedPane, ptyId)
+ // Keep the prompt blocked until the original spawn settles. A retry would
+ // be skipped by the in-flight claim guard.
onSettled?.()
})
await executeDetachedCodexPaneRestart(located, ptyId, agent)
} catch (err) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| releaseSlot = holdDetachedRestartSlot(ptyId, () => { | |
| console.warn('[codex-restart] detached restart spawn stalled; asking again') | |
| // Why: a late result still adopts and clears this prompt, since main may have stopped the old PTY. | |
| reopenCurrentCodexRestartPrompt(claimedPane, ptyId) | |
| onSettled?.() | |
| releaseSlot = holdDetachedRestartSlot(ptyId, () => { | |
| console.warn('[codex-restart] detached restart spawn stalled; asking again') | |
| // Keep the prompt blocked until the original spawn settles. A retry would | |
| // be skipped by the in-flight claim guard. | |
| onSettled?.() |
The regression tests reproduce the stalled-spawn scenario reported in #22243. Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Tauri-EPO <176725071+Tauri-EPO@users.noreply.github.com>
… stalls A spawn that never settles no longer holds one of the four restart slots or leaves its pane silently input-blocked: after 90s the pane's restart prompt reopens and the slot is released, while the claim stays until main settles so a late result is still adopted or reaped. Co-Authored-By: Claude <noreply@anthropic.com>
44f3f7f to
4208b75
Compare
ELI5
When you switch Codex/Claude accounts, Orca asks whether to restart your running agents. If you say yes, agents in tabs you are not looking at get restarted in the background.
Before: those background restarts ran strictly one at a time. If one restart got stuck (its spawn never answered), every restart after it waited forever: those tabs stayed on the old account with typing blocked and no prompt explaining why.
After:
Addresses the "independent progress" and "visible, recoverable outcome" parts of #22243 (reported by @Tauri-EPO; the regression tests reproduce the stuck-spawn scenario from that issue, so they are credited as co-author). It does not diagnose why a real Windows spawn stalls, so it does not close the issue.
What changed
codex-detached-pane-restart.ts: the sweep starts claims concurrently instead ofawaiting each pane in turn. Each claim reports when it finishes so the scheduler can fill the free slot.detached-pane-restart-slots.ts(new): the shared cap of 4 slots, plus a 90s timer per claim. When the timer fires it frees the slot and reopens that pane's prompt. The per-PTY claim (inFlightPtyIds) stays until main settles, so a pane can't be claimed twice and a late result still goes through the existing adopt-or-reap checks.detached-pane-restart-pty-release.ts(new): the existing reap/release helpers, moved out unchanged to keep the executor under the 300-line lint cap.codex-detached-pane-restart-scheduler.ts: removes the "one sweep at a time" lock. Claims are still guarded per PTY.agent-session.detached-account-restart-progress, updated to cover the stall deadline.Verification
main(28c726855e1d+, which fixes the unrelatedheadless-terminal-tab-close.tsmax-lines failure that had turned the previous CI run red and skipped thetestjob). No conflicts.openai/codexmain,codex-rs/login/src/auth/manager.rsandstorage.rs): ChatGPT token refresh is guarded only within one process (refresh_locksemaphore). Before refreshing it re-readsauth.jsonfrom disk, and on a 401 it re-readsauth.jsonagain. There is no lock across processes, andauth.jsonis written with truncate+write.codex0.163.0 processes at once against a tempCODEX_HOME. The access token was about to expire, and a local fake OAuth server accepted each refresh token only once. Nothing touched real credentials or the network. Results:codex exec: 3 of 4 processes lost the race (refresh_token_reused). All 4 then picked up the winner's tokens from disk; no request used the old token after 2s.codex, 3 runs): no error ever reached the screen, and every backend request used the refreshed token.auth.jsonwas left valid every time..oauth_refresh.lock(stale 60s), withrace_recovered/dead_holder_takeoverhandling. Concurrent Claude restarts are serialized by Claude itself.check:code-quality:changedandcheck:reliability-gatespass.pnpm tcpasses on the rebased head.oxfmt --checkclean on changed files.Scope and compatibility
reserveIdlePaneSpawn).Remaining tradeoffs (honest)
refresh_token_reused. In the harness they recovered silently from disk. Two limits on that evidence: