Skip to content

fix(agent-status): keep parent resume when nested Codex shares pane key - #10109

Closed
innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/nested-codex-preserve-parent-resume
Closed

innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/nested-codex-preserve-parent-resume

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep the active parent agent as the pane owner when a nested provider hook reuses the parent's pane key.
  • Ignore nested provider-session claims from a different agent while the parent identity is fresh and non-done.
  • Prevent inherited child metadata from replacing the parent's resume session in the status update path.

Fixes #10105.

Why

When Claude starts a nested Codex worker, both CLIs can inherit the same ORCA_PANE_KEY. The nested hook could then write a Codex resume record or attach the Codex session id to the live Claude row. A later cold restore or Agents return could launch the wrong provider/session file.

Scope and design

  • The guard is applied at both provider-session claim and status-metadata ingress points.
  • A different provider may claim the pane after the existing parent is done or stale.
  • Same-agent session refreshes remain allowed.
  • Existing done-state provider-session retention and recovery semantics on main are preserved.
  • The change is O(1) per identity/provider update and does not change the visible UI model beyond keeping the correct parent identity.

Test plan

  • Parent Claude + nested Codex provider-session regression
  • Inherited identity and stale/done boundary unit tests
  • Existing provider-session suite: 18 passed
  • Typecheck
  • Oxlint, React Doctor lint, Oxfmt, and diff checks
  • Manual: return from Agents after a Claude session starts a nested Codex worker and verify Claude resume remains selected

Screenshots

No visual chrome changes.

Security audit

The guard prevents a nested provider from substituting another account's session file during resume. No new filesystem, network, persistence, or credential behavior is introduced.

Platform review

The identity logic is shared renderer state and applies equally to macOS, Linux, Windows, and SSH/remote panes. It does not depend on a provider-specific shell or path format.

ELI5

Claude can start a Codex helper in the same terminal slot. Orca now remembers that Claude still owns the slot until Claude actually finishes, so returning later does not open the helper's session by mistake.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds nested identity handling for agent statuses and provider sessions. A shared helper ignores differing nested provider-session claims while a fresh parent identity is active, while matching or completed-parent claims remain allowed. Renderer status updates suppress inherited provider sessions and retain the parent identity. Tests cover identity resolution, terminal-status suppression, provider-session filtering, preservation of a live Claude session during nested Codex updates, and two runtime test setup corrections.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also changes unrelated tests in worktree-git-common-watch and orca-runtime that do not appear needed for #10105. Split the unrelated test adjustments into a separate PR unless they are required to verify this agent-status fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests match #10105 by keeping Claude as the primary session and preventing nested Codex claims from overwriting resume identity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes preserving the parent resume identity when nested Codex shares the pane key.
Description check ✅ Passed The description covers the change, rationale, testing, screenshots, security, and platform impact, with minor template sections omitted.

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.

🧹 Nitpick comments (1)
src/shared/agent-status-identity.test.ts (1)

20-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover stale-parent handoff.

The contract allows a different agent to claim the pane once the parent is stale, but this suite only covers the done handoff. Add a case with a small staleAfterMs to protect that boundary.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7be389cb-41d6-4fd3-a1c6-ba97075a91ac

📥 Commits

Reviewing files that changed from the base of the PR and between c3620f0 and 2bb9327e91ca9067fa943fd090e64d217eac0384.

📒 Files selected for processing (4)
  • src/renderer/src/store/slices/agent-status-provider-session.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/shared/agent-status-identity.test.ts
  • src/shared/agent-status-identity.ts

@innocarpe
innocarpe force-pushed the fix/nested-codex-preserve-parent-resume branch from e11736d to 5568050 Compare July 24, 2026 08:41
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (5568050ed)

Rebase onto latest upstream/main (cleanup batch).

Nested workers inherit ORCA_PANE_KEY. While Claude (parent) is still a
fresh non-done identity, nested Codex must not install its provider
session as the pane's resume provenance or demote the live row into a
codex sleeping record — that path cold-restores as Codex and fails
trusted session-file verification when leaving the Agents UI.

Fixes stablyai#10105
@innocarpe
innocarpe force-pushed the fix/nested-codex-preserve-parent-resume branch from 71b4181 to 2f623fd Compare August 4, 2026 13:15
@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by merged #29264 and #29386. The merged host admission rule rejects cross-provider inherited updates before they can replace the parent session or mutate its caches; renderer resume regressions preserve the Claude sleeping record and claude --resume identity. #29386 also covers the idle-but-running foreground process case beyond this PR's fresh/non-done boundary.

The final focused suite passed 197 tests, and Show terminal plus paired mobile transcript selection passed three hidden Electron runs each on macOS and Linux. The original report #10105 is now closed with the remaining platform/version limitations documented.

@nwparker nwparker closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Returning from Agents UI errors when Claude session has a nested Codex worker

3 participants