Skip to content

fix(sidebar): prevent closed agents from returning#9008

Draft
craftowen wants to merge 1 commit into
stablyai:mainfrom
craftowen:fix/closed-agent-retention-race
Draft

fix(sidebar): prevent closed agents from returning#9008
craftowen wants to merge 1 commit into
stablyai:mainfrom
craftowen:fix/closed-agent-retention-race

Conversation

@craftowen

Copy link
Copy Markdown

Summary

  • Prevent a completed agent row from being re-retained after its terminal tab has already closed.
  • Use the existing durable closed-tab marker when retention runs after PTY cleanup removed the live row too early to plant a one-shot suppressor.
  • Keep normal completed rows sticky when their tab is still valid, including when a different tab closed.

Fixes #8970.

Screenshots

No visual change. This fixes renderer state cleanup ordering for an existing sidebar row.

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 regression coverage:

  • src/renderer/src/components/dashboard/useRetainedAgents.test.ts
  • Related sidebar, IPC-cache, retention, and tab-close suites: 242 tests passed.

AI Review Report

Three independent review passes checked teardown ordering, normal completion retention, suppressed restart/hibernation exits, parked background terminals, pane authority/alias behavior, and performance. Review found that an earlier worktree-wide orphan sweep could remove intentional sticky completions; that broader change was removed. The final change performs one O(1) lookup against the existing closed-tab map.

Cross-platform review covered macOS, Linux, and Windows. The fix changes no shortcut, label, path, shell, or Electron platform branch. It uses provider-neutral renderer state shared by local, SSH, and remote-runtime terminal paths and does not alter supported agent or integration behavior.

Security Audit

No new input handling, command execution, path handling, authentication, secrets, dependencies, or IPC surface. The change only reads an existing in-memory tab-lifecycle marker before retaining a completed row. No follow-up security work is needed.

Notes

  • The full test suite and production build were not run locally; focused suites, full lint, and full typecheck passed.
  • X/Twitter handle: N/A (not provided).

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]: Closed agent session still lingers in sidebar on v1.4.143 (regression after #8825 / #8851)

1 participant