Skip to content

feat(cli): add session prune command - #51254

Closed
DEAD1nsane wants to merge 2 commits into
anomalyco:devfrom
DEAD1nsane:session-prune
Closed

DEAD1nsane wants to merge 2 commits into
anomalyco:devfrom
DEAD1nsane:session-prune

Conversation

@DEAD1nsane

@DEAD1nsane DEAD1nsane commented Sep 25, 2026 •

Copy link
Copy Markdown

Issue for this PR

N/A — feature request.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds opencode session prune <duration> for deleting old session families. It previews eligible families, requires confirmation unless --force is used, supports m/h/d/w durations, and protects shared, compacting, active, and recently-updated families. Candidates are revalidated immediately before deletion, and the new Session.listAll API provides complete project-scoped inventory.

How did you verify your code works?

  • bun test session-prune.test.ts — 6 tests passed.
  • Targeted Prettier and Oxlint checks passed.
  • git diff --check passed.
  • The full package typecheck could not complete in this Android/Termux environment because Node exhausted its heap; CI remains the authoritative check.

Screenshots / recordings

Not applicable; this is a CLI-only change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add `opencode session prune <duration>` to delete old session
families after a dry-run preview and explicit confirmation.

- Supports 30m/12h/30d/2w duration suffixes; rejects zero,
  negative, fractional, and overflowing values.
- Groups sessions into root families, skips shared, compacting,
  and non-idle families, and requires every member to be older
  than the cutoff.
- Re-checks candidates immediately before deleting to avoid
  removing sessions that became active.
- Adds Session.listAll for unbounded project listing while
  keeping the default limit on list.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@DEAD1nsane

Copy link
Copy Markdown
Author

{
"body": "This PR and #51255 are twins — the same session prune feature against different base branches (dev here, v2 there). To avoid maintainer confusion, I'm designating #51255 (v2) as the canonical PR: v2 is the active line and where this command is actually needed day-to-day.\n\nThis dev-targeted twin is being closed as superseded. The canonical PR has been refreshed onto current v2 (head 396e18cd, mergeable) and is awaiting review. Apologies for the noise — happy to reopen if a dev-based version is preferred instead.\n"
}

@DEAD1nsane DEAD1nsane closed this Oct 6, 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.

1 participant