Repository navigation
fix(terminal): clear stale agent identity after shell exit - #21714
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change expands shell-process detection and shares Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Important
The pinned decision-table test now fails on this branch, and the resolver-level suppression lands in the palette resolver rather than the tab-bar one. Details below.
Reviewed changes
Reviewed the complete diff at f90e103 (7 files, 1 commit) against main.
- Confirmed shell retires the pane's sleeping record —
onConfirmedShellForegroundclears the pane's sleeping session and provider-session duplicates before the existing title/routing cleanup. - Ladder suppresses the sleeping rung on exit evidence —
resolveTabAgentFromSignalsintab-agent-from-signals.tsgates sleeping onlaunchedAgentExited || processProvesShell. titleShowsNoAgentmoved to shared — extracted intoshared/shell-process-detection.tsand re-exported fromshared/agent-detection.ts.- Wider shell recognition —
ksh,mksh,dash,ash,tcsh,csh,elvish,xonshadded toSHELL_NAMES. - Tests — confirmed-shell cleanup tests in
pty-connection-command-finished-cleanup.test.ts; ladder tests inuse-tab-agent-sleeping-session.test.ts.
️ Pinned decision table is stale and now red
src/renderer/src/lib/tab-agent-identity-decision-table.test.ts:138 fails on this branch. I confirmed it passes against 97763ed's resolver and fails with the new sleeping gate: disagreements 2,622 → 2,634, launch 1,884 → 1,890, completed-hook 478 → 480, sleeping-session 144 → 148. Both the proofFree and freshProof expectations (lines 138 and 150) plus the "Re-derived against…" comment need re-deriving.
Technical details
# Decision-table expectations are pinned to the pre-fix ladder
## Affected sites
- `src/renderer/src/lib/tab-agent-identity-decision-table.test.ts:138` — `proofFree` `toEqual` (2,622) no longer matches.
- `src/renderer/src/lib/tab-agent-identity-decision-table.test.ts:150` — `freshProof` `toEqual` also exercises the changed ladder and must be re-derived.
- `src/renderer/src/lib/tab-agent-from-signals.ts:155` — the gate that shifted the counts.
## Required outcome
- Update both pinned expectation objects (and the explanatory comment above them) to the values the current ladder produces, so the ratchet reflects the intended behavior change.
## Suggested approach (optional)
- Run `pnpm test src/renderer/src/lib/tab-agent-identity-decision-table.test.ts`; the assertion prints the received object, or read the JSON it writes to `orca-pane-agent-identity-decision-table-real.json` in the tmp dir.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const activeSleepingSessionAgent = | ||
| launchedAgentExited || processProvesShell ? null : sleepingSessionAgent |
There was a problem hiding this comment.
resolveTabAgentFromSignals here is only reached by open-tab-occupant-agent.ts (the command palette); the tab-bar icon renders through useTabAgent in use-tab-agent.ts, which keeps its own copy of this ladder with no sleeping gate. For this exact input (title: 'zsh', processShellForeground: true, sleepingSessionAgent: 'codex') that resolver still returns 'codex' where this one returns null, so the new tests and the shared titleShowsNoAgent extraction cover a resolver the icon does not use.
Technical details
# Sleeping suppression does not reach the tab-bar resolver
## Affected sites
- `src/renderer/src/lib/tab-agent-from-signals.ts:155` — new `activeSleepingSessionAgent` gate (this comment).
- `src/renderer/src/lib/use-tab-agent.ts:160-169` — `useTabAgent`'s private resolver keeps `sleepingSessionAgent ??` ahead of `activeLaunchAgent`, with no `launchedAgentExited || processProvesShell` gate.
- `src/renderer/src/lib/use-tab-agent.ts:25-29` — still defines a private `titleShowsNoAgent` rather than importing the newly shared one.
- `src/renderer/src/lib/use-tab-agent-sleeping-session.test.ts:115-153` — new assertions import `./tab-agent-from-signals`, not `useTabAgent`.
## Required outcome
- Decide whether the tab-bar icon is meant to get the ladder-level suppression. If yes, apply the gate in `use-tab-agent.ts` (or collapse the duplicate ladders) and point the new tests at `useTabAgent`; if the store clear in `pane-agent-identity.ts` is the only intended fix for the icon, say so and retitle the tests so they no longer imply tab-icon coverage.
## Suggested approach (optional)
- `useTabAgent` already gathers every input the shared resolver needs, so delegating its final call to the shared resolver would remove one of the two divergent ladders instead of adding the gate a third time. Note the two ladders differ today (`resolvePaneAgentOwner` vs `resolvePaneAgentOwnerRecord`, and owner-normalized vs launch-normalized signals), so this needs its own before/after check.|
CI found the existing renderer decision-table contract also changes when stale sleeping identity is correctly suppressed. Updated expected proof-free totals to 2,634 disagreements (launch 1,890; completed-hook 480; sleeping-session 148) and fresh-proof totals to 670 (launch 594; completed-hook 48; sleeping-session 4). The decision-table test passes locally (2/2); this is a test-contract update for the intended resolver behavior, not a production workaround. |

Fixes #13749.
ELI5
After
/exit, the terminal had returned to a shell, but Orca could still remember the old Pi/OMP session for that pane and redraw its agent icon. Orca now clears that stale sleeping identity only after local shell evidence confirms the agent is gone.What changed
ksh,dash,ash,tcsh, and others).Proof
No visual proof applies: the fix changes pane identity state after a terminal lifecycle event; the regression covers the rendered identity source directly.
Readiness checklist
/exitidentity is retired; active or inconclusive sessions are retained.