Repository navigation
fix(mobile): keep a Codex chat on screen when Codex shows its idle title on a headless host - #31460
Conversation
…le on headless hosts On a headless host the mobile status builder treated any title without an agent marker as the shell reclaiming the pane. Codex's idle title is its project name, and since OSC 7501 program status gives the pane a PTY state, a Codex turn with no tool call ended with the hook's transcript address withheld, so the phone showed "Can't find this conversation yet". Only a shell or management title now retires the hook identity, matching the renderer projection. Refs #31136.
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ae4b7e31-db85-468c-a43a-d4dee6126884
📒 Files selected for processing: 2
src/main/runtime/orca-runtime-codex-idle-title-chat-address.test.tssrc/main/runtime/runtime-mobile-agent-status-builder.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| // Why: headless serve has no renderer to retain an OSC row, so hook evidence is the | ||
| // only signal a hook-only pane can offer, and an agent that reports over HTTP need | ||
| // never set a title this gate would recognize. With PTY status, only a shell or | ||
| // management title shows the pane was released: Codex's idle title is just its | ||
| // project name (#31136). The status below still follows the PTY title's state. | ||
| ((!pty?.lastAgentStatus || !terminalTitleBlocksExplicitAgentStatus(ptyTitle)) && | ||
| (hookRow.agentType != null || hookRow.providerSession != null)) | ||
| if (!hasLiveHookSignal) { | ||
| return {} | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '45,115p' src/main/runtime/runtime-mobile-agent-status-builder.ts
sed -n '160,225p' src/main/runtime/runtime-mobile-agent-status-builder.ts
sed -n '175,210p' src/main/runtime/runtime-mobile-session-projection.tsRepository: stablyai/orca
Length of output: 7815
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- hook projection and row fields ---'
rg -n -F --glob '*.ts' -e 'providerSessionAgentType' -e 'providerSessionReceivedAt' -e 'selectRuntimeHookAgentRowForPane' -e 'resolveRuntimeHookLiveAgentRow' src/main/runtime
printf '%s\n' '--- relevant hook projection ---'
sed -n '110,195p' src/main/runtime/runtime-mobile-agent-status-projection.ts
printf '%s\n' '--- builder complete logical path ---'
sed -n '1,125p' src/main/runtime/runtime-mobile-agent-status-builder.ts
printf '%s\n' '--- renderer identity and provider-session projection ---'
sed -n '175,215p' src/main/runtime/runtime-mobile-session-projection.ts
printf '%s\n' '--- Chat/provider-session consumers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'providerSession' -e 'agentStatus' src/main src/renderer src 2>/dev/null | rg -i 'chat|conversation|address|providerSessionAgentType|native' | head -160Repository: stablyai/orca
Length of output: 34459
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- ownership resolver and tests ---'
rg -n -F --glob '*.ts' -e 'function resolvePaneAgentOwnerRecord' -e 'resolvePaneAgentOwnerRecord' -e 'foregroundAgent' src/shared src/main/runtime | head -120
sed -n '1,220p' src/shared/pane-agent-owner.ts
rg -n -F --glob '*.test.ts' -e 'foregroundAgent' -e 'providerSessionOnly' -e 'stale' src/main/runtime src/shared | rg 'owner|agent-status|mobile|pane' | head -120
printf '%s\n' '--- mobile Chat address consumer ---'
sed -n '1,95p' src/main/native-chat/native-chat-file-provenance.ts
sed -n '45,80p' src/renderer/src/store/slices/agent-status-provider-session.test.ts
rg -n -F --glob '*.ts' -e 'agentStatus.providerSession' -e 'providerSession.id' -e 'providerSession?.id' src/renderer/src src/main | head -120
printf '%s\n' '--- changed gate in comparison ---'
git diff --unified=12 7f21cc91b8f6cda56c24572fdbe9932bde9e8717 68483e4fcfde57b80623f7d046457af987ed04cc -- src/main/runtime/runtime-mobile-agent-status-builder.tsRepository: stablyai/orca
Length of output: 43364
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- native Chat pane resolution ---'
sed -n '1,85p' src/renderer/src/components/native-chat/native-chat-pane-resolution.ts
printf '%s\n' '--- foreground agent update ---'
sed -n '105,155p' src/main/runtime/runtime-pty-foreground-agent.ts
printf '%s\n' '--- hook row retention contract ---'
sed -n '112,190p' src/main/runtime/runtime-mobile-agent-status-projection.tsRepository: stablyai/orca
Length of output: 7444
Match the hook session agent before using neutral-title evidence.
selectRuntimeHookAgentRowForPane keeps providerSession after the hook agent becomes stale. The builder can then emit pty.foregroundAgent as agentType while attaching the stale Codex providerSession. Native Chat uses both fields and providerSession.id to resolve the conversation, so Chat can open the Codex conversation for a different foreground agent. Compare the known hook session agent with the effective owner before accepting and emitting that provider session. This still accepts same-agent Codex idle-title rows.
Suggested fix
if (!pty?.lastAgentStatus && !retained && !hookRow.agentType && !hookRow.providerSession) {
return {}
}
- const providerSession = hookRow.providerSession
- ? { providerSession: hookRow.providerSession }
+ const ownerRecord = resolvePaneAgentOwnerRecord({
+ launchAgent: tab.launchAgent ?? pty?.launchAgent ?? null,
+ hookAgent: retained?.payload.agentType ?? hookRow.agentType
+ })
+ const ownerAgent = ownerRecord?.agent ?? pty?.foregroundAgent ?? null
+ const hookProviderSessionMatchesOwner =
+ hookRow.providerSessionAgentType == null ||
+ ownerAgent == null ||
+ hookRow.providerSessionAgentType === ownerAgent
+ const providerSession =
+ hookRow.providerSession && hookProviderSessionMatchesOwner
+ ? { providerSession: hookRow.providerSession }
: retained?.providerSession
? { providerSession: retained.providerSession }
: {}
@@
((!pty?.lastAgentStatus || !terminalTitleBlocksExplicitAgentStatus(ptyTitle)) &&
- (hookRow.agentType != null || hookRow.providerSession != null))
+ (hookRow.agentType != null ||
+ (hookRow.providerSession != null && hookProviderSessionMatchesOwner)))
@@
- const ownerRecord = resolvePaneAgentOwnerRecord({
- launchAgent: tab.launchAgent ?? pty?.launchAgent ?? null,
- hookAgent: retained?.payload.agentType ?? hookRow.agentType
- })
- const ownerAgent = ownerRecord?.agent ?? pty?.foregroundAgent ?? null
const ownerOptions = { ownerIsLaunch: ownerRecord?.ownerIsLaunch === true }
ELI5
On a computer running Orca headlessly (
orca serve), the phone finds a Codex terminal's conversation through a session id the host publishes for that tab. The host stopped publishing it whenever Codex's window title had no "Codex" or spinner in it, which is exactly what Codex shows when it is idle (just the project or thread name). The phone then said "Can't find this conversation yet". The host now keeps publishing the session id unless the title really belongs to the shell again.What Changed
Before (reproduced live on an isolated headless serve, Orca 1.4.236 + Codex CLI 0.163): after a Codex turn that ran no tool, the tab's
agentStatusdisappeared fromsession.tabs(state, agent andproviderSessionall gone), so a phone in Chat view drops to "Can't find this conversation yet / Send a message to start one…" until the next turn. The same gap opens at the start of a turn, between the prompt hook and Codex's first spinner title.After: the tab keeps
agentType: codexand itsproviderSession, so the chat stays on screen. The published state still follows the existing title-vs-hook rules (done when idle, working under OSC 7501working).Mechanism:
buildRuntimeMobileAgentStatus(the headless, no-renderer projection) treated any title thatclassifyAgentTitledoes not call an agent title as "the shell took the pane back" and returned no status, unless the pane had no PTY status at all or a tool/question was live. Since OSC 7501 program status (#30261) Codex panes always have PTY status (idle), so Codex's own neutral idle title hid the conversation. Now only a shell or management title (terminalTitleBlocksExplicitAgentStatus) retires the hook identity; a neutral title falls through to the normal status path.Why
This is the rule the desktop-renderer projection in
runtime-mobile-session-projection.tsalready uses ("a merely neutral live title proves nothing"), so headless and desktop hosts now agree. Alternatives considered: special-casing Codex title shapes (brittle, the thread name is model-generated and user-configurable via[tui] terminal_title), or keeping identity only while a fresh hook row exists (would drop the chat again after 30 minutes idle). Shell titles still retire the pane, so the stuck-spinner fix (#1437) is unchanged.Residual (parity, not new): if Codex dies mid-turn and the shell never sends the OSC 133 prompt-start that ends the program, the pane can keep showing
workingunder a neutral title. The renderer path behaves the same way today.Linked Issue
Refs #31136 (reported by @mavolab0114-coder, thank you). This fixes the same empty state on current releases. The report is from 1.4.230, which predates OSC 7501, and its mid-turn timing did not reproduce there with Codex 0.163 hooks and titles replayed through the 1.4.230 runtime, so the issue stays open for the reporter's details.
Visual Proof
N/A: host-side status publication; the phone screen change is the existing chat view staying up instead of the empty state. Before/after is shown by the
session.tabsdata in Testing.Testing
New
src/main/runtime/orca-runtime-codex-idle-title-chat-address.test.tsdrives the real runtime with Codex 0.163's captured title and OSC 7501 frames: idle after a no-tool turn, turn start under the idle title, 7501workingunder a neutral title, identity-only session rows, and a shell title still retiring the pane. 4 of 5 fail on main, all pass with the fix.Replayed a real Codex 0.163 no-tool turn (captured PTY bytes plus real hook payloads) through the real
AgentHookServerand runtime: on mainproviderSessionvanishes at the turn start and after the turn; with the fix it is present throughout.Live (macOS, isolated profile/HOME, port 6931): headless serve 1.4.236 with real Codex 0.163 polled
session.tabs.listevery 250 ms across tool turns, a sub-agent turn and a no-tool turn; only the no-tool turn end lost the session (state/agent/sid all null). The fix itself was verified on the captured replay and unit tests, not on a rebuilt live server.185 affected runtime test files single-worker: all pass except two macOS
/private/vartmpdir path assertions inrepository-project-operations.spec.ts, unrelated to this change.Full local "static analysis and typecheck" job (lint, format, anti-slop, native and type-aware code quality, changed-code gate, React Doctor, typecheck, ratchets, catalogs, localization extraction): pass. The orcad terminal smoke is left to CI.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex review (pinned base 505d671): no findings. Independent Opus review: no P0-P2; its P3s (test 2 state, 7501 working and identity-only coverage, residual spinner note) are addressed above.
Agent skill upstream boundary
Notes
Remote wire compatibility: no wire change; hosts now publish a status they previously omitted, which every mobile version already reads. SSH/relay rows and folder workspaces go through the same builder unchanged apart from this predicate. No platform-specific code.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)