Repository navigation
fix(codex): show resumed Chat before session hooks arrive - #23739
JustTalDevelops wants to merge 1 commit into
Conversation
|
| layout?.root?.type === 'leaf' && | ||
| layout.root.leafId === pane.leafId && |
There was a problem hiding this comment.
Old resume claim survives splits If the resumed pane returns to its shell while the tab is split, this check leaves its resume claim in place. After the split collapses back to that pane, a fresh Codex launch can use the old claim before its own hook reports, causing Chat to show the previous conversation. Retire the claim when its owning pane is confirmed back at the shell, even while the tab is split.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughNative chat now uses an eligible automatic resume claim as a fallback session identity until live status data is available. A live provider session takes precedence, and resume metadata applies only when its agent matches. When the matching root pane reports shell foreground, the store clears that tab’s resume claim. Tests cover claim eligibility, identity selection, and draft persistence. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to After a resumed Codex pane returns to the shell, Chat can keep showing the old conversation. Reset the gate's retained resolution on that transition and add a regression test before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to A resumed conversation may remain visible after its terminal pane returns to the shell. The apparent exposure is limited to the local chat pane, but the conversation should be retired when the resume ends. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
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: c9ef5ab5-1f44-445a-967f-63763613f1db
📒 Files selected for processing (7)
src/renderer/src/components/native-chat/NativeChatView-resume-claim.test.tsxsrc/renderer/src/components/native-chat/NativeChatView.test.tsxsrc/renderer/src/components/native-chat/NativeChatView.tsxsrc/renderer/src/components/native-chat/native-chat-pane-resolution.test.tssrc/renderer/src/components/native-chat/native-chat-pane-resolution.tssrc/renderer/src/store/slices/pane-foreground-agent.test.tssrc/renderer/src/store/slices/pane-foreground-agent.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| ownsTabWideLaunchDraft && !shellForeground && resumeClaim | ||
| ? { agent: resumeClaim.launchAgent, providerSession: resumeClaim.providerSession } | ||
| : null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,120p' src/renderer/src/components/native-chat/NativeChatSessionGate.tsx
sed -n '20,90p' src/renderer/src/components/native-chat/NativeChatView.tsxRepository: stablyai/orca
Length of output: 3945
🏁 Script executed:
set -eu
printf '%s\n' '--- relevant files ---'
fd -t f 'NativeChat(View|SessionGate|ResolvedView).*\.tsx$|native-chat-pane-resolution.*' src/renderer/src/components/native-chat
printf '%s\n' '--- declarations and usages ---'
rg -n -A8 -B8 'NativeChatSessionGate|function NativeChatBridgeView|function NativeChatResolvedView|resolveNativeChatSession|shellForeground' src/renderer/src/components/native-chatRepository: stablyai/orca
Length of output: 42010
🏁 Script executed:
set -eu
fd -t f -i 'NativeChat' src/renderer/src/components/native-chat
printf '%s\n' '--- relevant symbols ---'
rg -n -A10 -B10 'NativeChatSessionGate|function NativeChatBridgeView|function NativeChatResolvedView|resolveNativeChatSession|shellForeground' src/renderer/src/components/native-chatRepository: stablyai/orca
Length of output: 41893
🏁 Script executed:
set -eu
sed -n '1,115p' src/renderer/src/components/native-chat/NativeChatView-resume-claim.test.tsx
sed -n '43,72p' src/renderer/src/components/native-chat/native-chat-pane-resolution.tsRepository: stablyai/orca
Length of output: 4103
Clear the retained session when the pane returns to the shell.
When shellForeground becomes true, NativeChatBridgeView passes null for resumeSession. resolveNativeChatSession still returns the codex launch agent with a null session ID, so NativeChatSessionGate reuses the previous session for the same pane and agent. The old session can remain visible after the resume claim becomes ineligible.
Reset the retained resolution on the shell transition. Add a regression test that starts with the resumed session already displayed.
There was a problem hiding this comment.
ℹ️ No critical issues — one retirement gap inline, plus a couple of small notes.
Reviewed changes
- Resume-identity fallback:
resolveNativeChatSessionreturns the hook'sproviderSessionfirst and only falls back to a newresumeSessioninput when itsagentmatches the resolved agent (native-chat-pane-resolution.ts:55-57). - Bridge wiring:
NativeChatBridgeViewsupplies that fallback fromautomaticAgentResumeClaimsByTabId[terminalTabId], gated to the owning pane (ownsTabWideLaunchDraft) and to!shellForeground(NativeChatView.tsx:41-55). - Claim retirement:
setPaneForegroundAgentdeletes the tab's resume claim when the pane is proven back at the shell and the tab is a single leaf (pane-foreground-agent.ts:47-76), so a fresh launch in that pane stops reusing the resumed identity. - Tests: retirement (store), hook precedence plus agent mismatch (resolver), and pre-hook display plus hook-wins (bridge view).
ℹ️ Nitpicks
- The new
NativeChatView.test.tsxcase ("keeps a resumed Codex conversation open when its hook reports later") assertsSession resumed-codexonly after an entry with the same id is supplied, so it still passes with the fallback removed; the pre-hook assertion lives inNativeChatView-resume-claim.test.tsx. Consider asserting the pre-hook resolution here too, or dropping it as a duplicate.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const clearResumeClaim = Boolean( | ||
| entry.shellForeground && | ||
| pane && | ||
| layout?.root?.type === 'leaf' && |
There was a problem hiding this comment.
Retiring the claim only while the tab is already a single leaf misses every shell transition that happens during a split: clearResumeClaim requires layout.root.type === 'leaf' here, so the claim survives the resumed agent exiting in a split tab and is never retired when the split later collapses. Because the owner-leaf routing helper re-satisfies ownsTabWideLaunchDraft once the tab is a single leaf again, a fresh same-type agent launched in the surviving leaf can be rendered with the previous resumed session's transcript until its own hook arrives.
Technical details
# Retire the resume claim on the owning pane's shell return, not only on a single-leaf tab
## Affected sites
- `src/renderer/src/store/slices/pane-foreground-agent.ts:49-55` — `clearResumeClaim` requires `layout?.root?.type === 'leaf'`, so a `shellForeground: true` publish while the tab is split does not retire the claim.
- `src/renderer/src/components/native-chat/use-terminal-pane-chat-state.ts:79-100` — `tabWideAgentHintLeafId` settles once and is never updated, so after a split collapses the owner is still the original resume leaf.
- `src/renderer/src/components/native-chat/native-chat-leaf-routing.ts:49-61` — `nativeChatLeafOwnsTabWideEvidence` then returns true again for that leaf.
- `src/renderer/src/components/native-chat/NativeChatView.tsx:51-55` — `ownsTabWideLaunchDraft && !shellForeground && resumeClaim` re-supplies the stale claim.
- `src/renderer/src/components/native-chat/native-chat-pane-resolution.ts:55-57` — the fallback populates `sessionId` from the stale claim before any hook reports.
## Required outcome
- A shell-foreground publish for the claim's owning pane should retire the claim even when the tab is split, so the identity cannot outlive the agent it was created for.
## Suggested approach (optional)
- The claim carries no leaf id, which is why retirement is shape-gated. Recording the owning leaf on `AutomaticAgentResumeClaim` (created at `src/renderer/src/lib/sleeping-agent-session-launch.ts:101-124`) would let `setPaneForegroundAgent` retire it for the exact pane instead of inferring from layout shape.
## Open questions for the human (optional)
- Is the single-leaf gate meant to cover only split/resize races, or should a split tab also retire the claim when the resumed pane exits?
- Related (and already raised in another review thread): `NativeChatSessionGate` retains the last rendered `sessionId` for the same pane and agent when the new resolution has `sessionId: null` (`src/renderer/src/components/native-chat/NativeChatSessionGate.tsx:27-42`), so the resumed transcript can stay on screen after `resumeSession` turns null even without a split.|
Hi @JustTalDevelops — I reproduced the resumed-session Chat issue locally on macOS with a Codex Desktop-origin session opened through Agent Session History → Resume in Worktree. I have a local proof-of-concept patch that builds on the approach in this PR and addresses the two retirement gaps called out by the automated reviews:
I manually validated the real UI flow:
Focused verification currently passes (44 tests plus typecheck) on the local branch. The patch still needs to be rebased onto current Would you and the Orca maintainers prefer that I:
I will not open a competing PR until you advise. |

ELI5
When Orca resumes a Codex conversation, it already knows that conversation's exact ID. Chat currently waits for Codex to report the ID again. If that report is delayed or misattributed, Terminal works while Chat opens empty. This change lets Chat use the ID from the resume until Codex reports its own ID.
What Changed
Before: an explicitly resumed Codex conversation could show an empty Chat view even though its transcript existed. After: Chat opens the resumed transcript immediately. A later hook report takes precedence. Fresh sessions still wait for their own hook report.
The renderer reads Orca's existing resume claim for the tab. It uses that ID only for the owning pane while an agent remains in the foreground, and clears the claim when that pane returns to the shell. Tests cover the initial resume, later hook, split sibling, and shell transition.
Why
This reuses an exact session ID Orca already captured when it launched the resume. It does not guess from a tab title or scan transcript files, and it does not add another agent-status producer. The execution host's hook status remains authoritative when present.
This is a supplemental fix for resumed desktop sessions. It does not fix fresh sessions or the shared Codex daemon's incorrect pane identity; #23411 addresses that root cause. A local
--no-daemonlaunch workaround remains useful until the daemon fix lands.Linked Issue
Related to #22873. Complements #23411; does not close either.
Visual Proof
The behavior is a timing window: the regression component test renders the Chat bridge before any hook entry and asserts that it receives the resumed session ID; after a hook entry arrives, it asserts that the hook ID wins. No screenshot is attached because the user's active fresh-session recovery came from a server-side backfill, not from this change.
Testing
pnpm teston four focused files: 32 tests passed.pnpm tcpassed.pnpm run check:code-quality:changedpassed with 0 findings.git diff --checkpassed.The focused tests ran on macOS. The code is renderer-only and uses existing tab metadata, with no new RPC fields or SSH commands. Linux, Windows, mobile, and a live delayed-hook replay were not manually tested.
AI Disclosure
OpenAI Codex (GPT-6) prepared the change and tests under user direction. I reviewed the source diff and verification output.
Review
Please check that the resume claim is scoped to the owning pane and cleared when that pane returns to its shell.
Agent skill upstream boundary
Notes
Security: the fallback accepts only the session ID already recorded for this tab's explicit resume. Performance: two existing store selectors; no polling or file scan. Backwards compatibility: no wire or persistence change. Remote SSH: the client only reads its existing resume claim; host status still wins. Mobile: this renderer change does not modify the iOS client.
Checklist