Skip to content

fix(renderer): keep parent session icon under nested Claude/Codex - #14012

Closed
OrcaWin wants to merge 3 commits into
mainfrom
OrcaWin/gh-13341
Closed

OrcaWin wants to merge 3 commits into
mainfrom
OrcaWin/gh-13341

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Bug: Nested Claude↔Codex (and other cross-group) invocations became the foreground process / OSC title and rebranded the parent tab icon while the parent session still owned the pane.
  • Fix: While launch ownership is still active, null different-group process signals and block title reclaim (OpenCode native startup titles remain the one pre-hook exception). After parent exit evidence clears launch, process/title may own the icon again.
  • Also: Title-derived sidebar rows refuse nested non-owner agent titles under a durable owner; pure signal resolution extracted to tab-agent-from-signals.ts for max-lines.

Evidence (repro vs durable identity)

Signal path Before After (#13341)
Claude launch + nested Codex process/title icon → Codex icon stays Claude
Codex launch + nested Claude process/title icon → Claude icon stays Codex
Parent hooks fenced + nested process process could win parent hook/launch wins
launchAgent cleared + child process process owns process owns (genuine reuse)
OpenCode OC | at startup before hooks reclaim OpenCode still reclaim OpenCode

Display-status / model updates on fenced parent hooks remain separate (#13602); this PR only fences durable identity (tab/sidebar agent type icon).

Test plan

  • vitest: use-tab-agent, nested-identity, pi-identity, process-signals, worktree-title-derived-agent-rows (94 tests)
  • oxlint on touched files
  • git diff --check
  • Manual: launch Claude, invoke nested Codex — parent tab icon stays Claude until Claude exits

Fixes #13341

Nested child process and title signals no longer rebrand a tab while
launch ownership is still active; reclaim only after the parent exits.
Fixes #13341.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1310a5a7-f1fc-4368-92a3-f81c7049bdbf

📥 Commits

Reviewing files that changed from the base of the PR and between 00686ad and ef41ba5.

📒 Files selected for processing (5)
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/lib/tab-agent-from-signals.ts
  • src/renderer/src/lib/use-tab-agent-nested-identity.test.ts
  • src/renderer/src/lib/use-tab-agent-opencode-native-title.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/lib/use-tab-agent-opencode-native-title.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/lib/use-tab-agent-nested-identity.test.ts
  • src/renderer/src/lib/tab-agent-from-signals.ts

📝 Walkthrough

Walkthrough

The change centralizes tab-agent signal resolution in tab-agent-from-signals.ts. It adds exit-evidence handling, launch-owner normalization, nested identity filtering, title processing, and ordered signal precedence. use-tab-agent.ts now imports and re-exports the resolver functions. Title-derived ownership rejects conflicting identities under an active owner. Tests cover nested Claude, Codex, OpenCode, OMP, process, hook, and launch identity cases.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug, fix, linked issue, evidence, and tests but omits several required template sections, including visual proof. Add the required ELI5, What Changed, Why, Visual Proof or N/A, Review, Checklist, and Author sections, and document manual testing status.
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes preserving the parent session icon during nested Claude/Codex invocations.
Linked Issues check ✅ Passed The changes directly address issue #13341 by preserving the top-level agent identity during nested Claude/Codex invocations.
Out of Scope Changes check ✅ Passed The signal-resolution extraction, sidebar alignment, and related tests support the linked issue and stated objectives.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts (1)

206-214: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the ownership comments.

Lines 206-214 use nine lines for two rules. Keep the detector rationale and ownership rule in one concise line each.

Proposed change
-    // Why: Claude's task-title spinner heuristic has no provider identity. In
-    // split panes it can match arbitrary terminal spinners, so sidebar rows only
-    // accept Claude when the title itself names Claude.
+    // Require a Claude token because the spinner heuristic is provider-neutral.
...
-    // Why (`#8940` + `#13341`): Claude mentions never steal ownership, and a nested
-    // Claude identity frame under a durable non-Claude owner keeps the parent.
-    // Pane reuse is modeled by clearing launchAgent first (tab-agent path).
+    // Preserve a non-Claude owner; launch ownership clears before pane reuse can reclaim identity.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7cb2c26e-2abc-4e45-bc7b-db34ff9c637a

📥 Commits

Reviewing files that changed from the base of the PR and between 70ad65f and 4b179a9.

📒 Files selected for processing (8)
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/lib/tab-agent-from-signals.ts
  • src/renderer/src/lib/use-tab-agent-nested-identity.test.ts
  • src/renderer/src/lib/use-tab-agent-pi-identity.test.ts
  • src/renderer/src/lib/use-tab-agent-process-signals.test.ts
  • src/renderer/src/lib/use-tab-agent.test.ts
  • src/renderer/src/lib/use-tab-agent.ts

Update CI-failing expectations for #13341 (process/title no longer reclaim
under active launch), add shell/remote/hook edge cases, and use an
agent-attributable working title in WorktreeCard status coverage.
Native OC| titles reclaim and stay OpenCode after process observation, with
sidebar title-derived rows matching tab identity. Nested Claude/Codex still
fenced while launch is active (#13341).
@bbingz

bbingz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Two new reports, #14937 and #14938, exercise the same ownership boundary through task-text titles rather than an actually nested child process. I do not plan to open a competing fix because this PR already changes both affected consumers:

  • resolveTabAgentFromSignals: an active launchAgent: 'claude' fences non-native foreign title identity.
  • resolveTitleDerivedAgentType: a durable Claude owner rejects a mismatched title-derived agent.

The exact regressions worth adding before refresh are:

  1. title: '⠋ Fix the codex plugin launcher', launchAgent: 'claude', no live hook → claude.
  2. The same title with a completed Claude hook and on isRemote: true → claude.
  3. Sidebar/title-derived rows with Claude ownership and that title, including the unknown-hook fallback → one Claude row, never Codex.
  4. A genuine ⠋ Codex identity may still resolve to Codex after launch ownership has actually cleared.

Those cases distinguish a foreign-agent word inside free-form task text from a real identity frame and would let this PR close both new reports without another overlapping implementation. #14634 is also introducing the shared agent-identity-frame seam in these files, so the eventual rebase should preserve that contract rather than restore token-only ownership.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks for the investigation! Nested-agent identity is now handled on main by the nested-hook guards in #29264 and #29386 plus #33572 (the pane's owner reclaims the pane by session). Closing as superseded.

@nwparker nwparker closed this Oct 25, 2026
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.

[Bug]: Nested Claude/Codex invocation changes the parent session icon

3 participants