feat: configurable auto-pruning, cross-session rewind, and settings command#3
Open
cullendotdev wants to merge 2 commits into
Open
feat: configurable auto-pruning, cross-session rewind, and settings command#3cullendotdev wants to merge 2 commits into
cullendotdev wants to merge 2 commits into
Conversation
…ommand - RewindConfig at ~/.pi/agent/config/rewind.json with PI_REWIND_* env overrides - Cross-session checkpoint persistence (keepOldSessions) with two-step picker - /rewind-settings for live config changes, /rewind-cleanup for stats + prune - getCheckpointStats, pruneAllOldSessions, deleteCheckpointsBulk, diffCheckpoints - Prune old session refs immediately when keepOldSessions toggled off - Cleanup hint in footer status when checkpoints exceed threshold - 6 new unit tests (26 total), updated README, CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I built these changes for my own workflow, I wanted checkpoints to survive restarts and give me more control over retention. Opening a PR in case you're interested or want to take things in a similar direction. Happy to adjust or close if it's not a fit. No expectations either way.
Summary
Adds three user-facing features to pi-rewind while preserving full backward compatibility:
/rewindshows a two-step picker (session → checkpoint)/rewind-settings— interactive menu to change config live, auto-saves to~/.pi/agent/config/rewind.jsonProblem
The original extension hard-coded a 50-checkpoint rolling window per session and unconditionally pruned all checkpoints from previous sessions on startup. There was no way to:
Solution
A
RewindConfigfile at~/.pi/agent/config/rewind.jsonwith three knobs, all defaulting to the original behavior:{ "maxCheckpoints": 50, // 0 = unlimited, never prune "keepOldSessions": false, // true = survive restarts, show cross-session picker "cleanupHintThreshold": 200 // show cleanup hint in footer when exceeded }Two new commands give users direct control:
/rewind-settings/rewind-cleanupWhen
keepOldSessionsis enabled, the/rewindpicker becomes a two-step flow: pick a session (grouped by date), then pick a checkpoint within it. TheEsc+Escshortcut shows current session + the most recent old session for quick access. Footer status shows a warning hint when checkpoints exceed the cleanup threshold.Four new core functions (
getCheckpointStats,pruneAllOldSessions,deleteCheckpointsBulk,diffCheckpoints) support the new commands and keep the two-layer architecture intact — all pure git, no pi dependency.What changed
New files
src/config.ts—RewindConfiginterface, load fromrewind.json, env var overrides (PI_REWIND_*)CHANGELOG.mdBehavioral changes
/rewindpicker becomes two-step whenkeepOldSessionsis enabled◆ N checkpoints (consider /rewind-cleanup))keepOldSessionsoff in/rewind-settingsprunes old refs immediatelyEsc+Escshortcut is cross-session aware (shows current + 1 most recent old session)Testing
npx tsx tests/core.test.ts # 26 tests, 0 failures (was 20)New coverage: cross-session pruning (with UUID-in-ref-name parsing), bulk delete, checkpoint stats, diff output.
Notes
pruneOldSessions/pruneAllOldSessionsextract session IDs from ref names via UUID pattern matching. They only operate on checkpoints created through the standard flow (resume-{uuid}-{ts},turn-{uuid}-{turn}-{ts}). Hand-crafted checkpoint IDs without embedded UUIDs will be skipped./rewindbefore subcommands, so cleanup and settings are registered as standalone commands (rewind-cleanup,rewind-settings) rather than subcommands.