Skip to content

fix(mobile): keep a Codex chat on screen when Codex shows its idle title on a headless host - #31460

Merged
nwparker merged 1 commit into
mainfrom
nwparker/mobile-codex-idle-title-chat
Oct 21, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/mobile-codex-idle-title-chat

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

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 agentStatus disappeared from session.tabs (state, agent and providerSession all 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: codex and its providerSession, so the chat stays on screen. The published state still follows the existing title-vs-hook rules (done when idle, working under OSC 7501 working).

Mechanism: buildRuntimeMobileAgentStatus (the headless, no-renderer projection) treated any title that classifyAgentTitle does 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.ts already 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 working under 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.tabs data in Testing.

Testing

  • New src/main/runtime/orca-runtime-codex-idle-title-chat-address.test.ts drives 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, 7501 working under 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 AgentHookServer and runtime: on main providerSession vanishes 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.list every 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/var tmpdir path assertions in repository-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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The mobile agent status builder now retains hook identity evidence when PTY status is absent or its title does not block agent status. Added Vitest coverage for headless Codex idle-title handling, including transcript-address retention, OSC 7501 working-state precedence, identity-only session retention, and pane retirement after shell title takeover with an exited hook result.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 68483

When a pane changes agents, mobile Chat may open the wrong conversation. Match the hook session to the foreground agent before merging, or explicitly accept this bounded risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description is complete and directly addresses the template requirements. It explains the user impact, mechanism, rationale, linked issue, visual-proof exception, testing, review status, compatibi…
Title check Passed The title clearly identifies the main change: preserving a Codex chat on mobile when Codex shows its idle title on a headless host.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and directly addresses the template requirements. It explains the user impact, mechanism, rationale, linked issue, visual-proof exception, testing, review status, compatibility considerations, and checklist items.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae4b7e31-db85-468c-a43a-d4dee6126884
📥 Commits

Reviewing files that changed from the base of the PR and between 7f21cc9 and 68483e4.

📒 Files selected for processing: 2
  • src/main/runtime/orca-runtime-codex-idle-title-chat-address.test.ts
  • src/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.

Comment on lines +88 to 97
// 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 {}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ts

Repository: 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 -160

Repository: 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.ts

Repository: 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.ts

Repository: 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 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant