Skip to content

fix(terminal): restore the shell icon after an agent exits - #13776

Closed
5Hyeons wants to merge 6 commits into
stablyai:mainfrom
5Hyeons:fix/restore-shell-icon-after-agent-exit
Closed

5Hyeons wants to merge 6 commits into
stablyai:mainfrom
5Hyeons:fix/restore-shell-icon-after-agent-exit

Conversation

@5Hyeons

@5Hyeons 5Hyeons commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Restore the terminal icon after a completed agent exits to the shell.
  • Clear resumable sleeping identity only after fresh foreground-process confirmation.
  • Resolve legacy numeric pane keys while preserving other tabs and ambiguous provider sessions.
  • Prevent late done hooks and later workspace sleep from rebuilding the exited identity.

Fixes #13749

Screenshots

orca-agent-icon-before-after-v3

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused PTY coverage: 570 tests passed. Full suite: 49,652 passed, 102 skipped.

AI Review Report

Exact-SHA five-lane review passed for 23fe4a056d9b119f6b36705b72897c1670696d80: goal/constraints, runtime QA, code quality, security, and history/context.

The review explicitly checked macOS, Linux, and Windows behavior, plus SSH and folder workspaces. This change introduces no shortcuts, labels, paths, shell commands, or Electron platform branches; remote PTYs remain excluded from local foreground-process confirmation.

Security Audit

Passed. Cleanup requires fresh pane/PTY-bound shell confirmation. Legacy aliases are limited to the same tab and provider claim; mixed-provider rows fail closed, other tabs are preserved, and provider claims include worktree identity. No command execution, path handling, authentication, secrets, dependencies, or IPC contracts changed.

Notes

Manual macOS dev-app QA confirmed Claude → /exit restores the terminal identity.

@5Hyeons
5Hyeons marked this pull request as ready for review August 11, 2026 08:38
@coderabbitai

coderabbitai Bot commented Aug 11, 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: eaf63c1f-2e6b-466a-9992-9cbfc744de6d

📥 Commits

Reviewing files that changed from the base of the PR and between 931cb03 and ea47081.

📒 Files selected for processing (5)
  • src/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/store/slices/agent-status-manual-sleep-capture.test.ts
  • src/renderer/src/store/slices/agent-status-provider-session.test.ts
  • src/renderer/src/store/slices/agent-status.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/renderer/src/store/slices/agent-status-manual-sleep-capture.test.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/store/slices/agent-status-provider-session.test.ts

📝 Walkthrough

Walkthrough

PTY shell confirmation now safely resolves sleeping-agent records and matching legacy aliases. Conflicting same-tab provider sessions prevent cleanup. Confirmed shell foreground clears matched records before terminal cleanup. Agent-status handling excludes shell-foreground panes from completed sleeping-session capture and resumable recovery identity. Regression tests cover Droid cleanup, legacy alias handling, conflicting sessions, manual capture, and late Claude status updates.

Merge Risk: ⚪ Minimal · up to ea470

The change restores the terminal icon after an agent exits and is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal fix and matches the primary change: restoring the shell icon after an agent exits.
Description check ✅ Passed The description covers the fix, rationale, issue #13749, visual proof, testing, and review details, although it uses custom headings instead of every template section.
Linked Issues check ✅ Passed The changes address issue #13749 by clearing confirmed-shell sleeping identity and preventing stale agent identity from restoring the completed agent icon.
Out of Scope Changes check ✅ Passed All implementation and regression-test changes support shell restoration, sleeping-identity cleanup, legacy alias safety, or prevention of stale identity recovery.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/pty-connection.ts (1)

2071-2078: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Resolve and clear legacy sleeping-session keys.

The new checks use only cacheKey. The existing helper at Lines [1222-1262] also resolves legacy numeric pane keys, and clearSleepingRecordProviderDuplicates at Lines [1267-1287] clears the matched key and its provider-session aliases.

If a sleeping record uses a legacy key, shell confirmation will not recognize it here. Clearing cacheKey also leaves the legacy record behind. The completed agent can remain resumable and restore the stale terminal icon later.

Use getSleepingRecordForPane(state) for identity detection and clear the returned record with clearSleepingRecordProviderDuplicates. Add a regression test for a legacy numeric pane key.

Proposed fix
   const paneHasKnownAgentIdentity = (): boolean => {
     const state = useAppStore.getState()
     const registeredLaunchAgent = state.agentLaunchConfigByPaneKey[cacheKey]?.identity.agentType
     return (
       Boolean(state.paneForegroundAgentByPaneKey[cacheKey]?.agent) ||
       paneHasLiveHookAgentIcon(state) ||
-      Boolean(state.sleepingAgentSessionsByPaneKey[cacheKey]?.agent) ||
+      Boolean(getSleepingRecordForPane(state)?.record.agent) ||
       isTuiAgent(registeredLaunchAgent)
     )
   }

     onConfirmedShellForeground: (reason) => {
-      useAppStore.getState().clearSleepingAgentSession(cacheKey)
+      const state = useAppStore.getState()
+      const sleepingRecord = getSleepingRecordForPane(state)
+      if (sleepingRecord) {
+        clearSleepingRecordProviderDuplicates(state, sleepingRecord)
+      }

Also applies to: 2137-2139


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d487fab4-9eaa-4d5e-8b41-bc71708ff3a8

📥 Commits

Reviewing files that changed from the base of the PR and between b3965f3 and f19bb293e266a43676471fb3a5fcbded4edc3d1c.

📒 Files selected for processing (5)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/store/slices/agent-status-manual-sleep-capture.test.ts
  • src/renderer/src/store/slices/agent-status-provider-session.test.ts
  • src/renderer/src/store/slices/agent-status.ts

@5Hyeons

5Hyeons commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the legacy sleeping-session finding in 23fe4a056d9b119f6b36705b72897c1670696d80: shell confirmation now resolves legacy numeric keys, clears only same-tab/same-provider aliases, fails closed for mixed-provider rows, and preserves other tabs. Added regressions for legacy aliases, mixed-provider ambiguity, and cross-tab preservation. Focused PTY suite: 570 passed; full suite: 49,652 passed. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

@5Hyeons I will review commit 23fe4a056d9b119f6b36705b72897c1670696d80 and its regression coverage.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@5Hyeons
5Hyeons force-pushed the fix/restore-shell-icon-after-agent-exit branch from 23fe4a0 to ea47081 Compare August 15, 2026 10:24
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nwparker nwparker removed the P1 label Aug 19, 2026
@nwparker

nwparker commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded — the linked issue (#13749) has been resolved on main by #14602 (e54cfc1901), #21714 (b6b974cb82). Thanks for the contribution!

@nwparker nwparker closed this Nov 5, 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]: Completed agent icon remains after the pane returns to shell

4 participants