Skip to content

feat(cli): add 'session cleanup' to purge dead, stale sessions#1602

Open
DoozyX wants to merge 3 commits into
asheshgoplani:mainfrom
DoozyX:feat/session-cleanup-cmd
Open

feat(cli): add 'session cleanup' to purge dead, stale sessions#1602
DoozyX wants to merge 3 commits into
asheshgoplani:mainfrom
DoozyX:feat/session-cleanup-cmd

Conversation

@DoozyX

@DoozyX DoozyX commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1600session cleanup needs tmux.ListSessionNamesOnSocket from that PR, so this branch includes its commit. The diff to review here is the cmd/agent-deck/ files; I'll rebase once #1600 lands.

What

session cleanup purges sessions whose tmux pane is gone and that have been untouched past a threshold. It also routes the existing bulk deletes (session remove --all-errored and friends) through the same single implementation, so the delete paths can't drift apart — previously each had its own notion of what was safe to remove.

Why the liveness probe is per-socket

This is the part worth reviewing carefully, because it's a delete path.

Liveness is probed per socket via ListSessionNamesOnSocket. A flat, name-keyed probe built from a single socket reports sessions living on an isolated socket as missing — and in a delete path, "missing" means purging live work. That's a data-loss bug, not a cosmetic one.

Two safety properties:

  • Liveness is resolved per socket, so isolated-socket sessions are visible.
  • If a socket's probe fails, every session on it is treated as alive and never purged. For an irreversible operation the indeterminate case must fail toward keeping data.

Tests

cmd/agent-deck passes with -race, including new coverage in session_cleanup_cmd_test.go and extended session_remove_kill_test.go.

Adds `session cleanup` to purge sessions whose tmux pane is gone and that
have been untouched past a threshold, and routes the existing bulk deletes
through the same single implementation so they can't drift apart.

Liveness is probed per socket via ListSessionNamesOnSocket: a flat
name-keyed probe built from one socket reports sessions living on an
isolated socket as missing, which for a delete path means purging live
work. If a socket's probe fails, every session on it is treated as alive
and never purged — the safe direction for an irreversible operation.
Copilot AI review requested due to automatic review settings July 12, 2026 20:47
@DoozyX DoozyX requested a review from asheshgoplani as a code owner July 12, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@DoozyX, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7cdadad5-10dc-4bdf-b04f-6289537c199c

📥 Commits

Reviewing files that changed from the base of the PR and between 350a640 and c0d2af7.

📒 Files selected for processing (5)
  • cmd/agent-deck/session_cleanup_cmd.go
  • cmd/agent-deck/session_cleanup_cmd_test.go
  • cmd/agent-deck/session_cmd.go
  • cmd/agent-deck/session_remove_cmd.go
  • cmd/agent-deck/session_remove_kill_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@DoozyX

DoozyX commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

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.

3 participants