feat(capture): automatic session finalization on sessionstart and close#304
Conversation
design: automatic finalization of old buffers on sessionstart, and current session on window close. plan: 8-task breakdown covering capture.py functions, cli command, adapter hooks, comprehensive unit tests, integration test, and documentation.
implement is_stale_buffer() to check file age, and finalize_all_except() to bulk-finalize capture buffers older than a threshold. this enables sessionstart cleanup of orphaned buffers from previous sessions. includes 9 unit tests covering single/multiple buffers, age boundaries, and current session exclusion.
new command finalizes all capture buffers except the given session, if they are older than max_age_seconds (default 3600s). silently succeeds if no kb found. used by sessionstart hook to clean up orphaned buffers from previous sessions. includes 3 unit tests covering option parsing, env fallback, and graceful degradation.
run 'vouch capture finalize-all' as the first sessionstart hook to clean up orphaned buffers from previous sessions before banner and recall commands. ensures old sessions are finalized automatically on next session start.
add comment to sessionstart hook explaining that current session finalization happens on next session start (fallback behavior when windowclose event is not supported by the vs code extension).
add section describing how capture works, configuration options, and the fallback behavior if windowclose event is not available.
verify that old buffers are cleaned up on new session start and current session is finalized on window close (or manual finalize), resulting in two separate proposals.
…rigin when finalize_all_except() cleans up orphaned buffers, those old sessions have unknown origin (no cwd), so we should not attribute the current working directory's git diff to them. this prevents data corruption where old sessions' summaries get current repo changes, and avoids spurious proposals that cross min_observations due to misattributed file counts. added explicit cwd check: if cwd is None (unknown origin), skip git changes. normal finalize calls with explicit cwd still get git context. also fix typo: unfinalzed -> unfinalized in adapter README.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (58)
📝 WalkthroughWalkthroughThis PR adds a Claude session auto-capture pipeline that harvests tool-use into review-gated proposals, a session-start recall hook injecting approved knowledge digests, JSON-merge semantics for adapter settings installation, storage resilience against corrupt YAML, and consistent UTF-8 encoding across file I/O, alongside version bumps and extensive documentation. ChangesSession Auto-Capture Feature
Session-Start Recall Feature
JSON-Merge Install Behavior
Storage Resilience
UTF-8 Encoding Hardening
Release Metadata and General Documentation
Estimated code review effort: 4 (Complex) | ~75 minutes Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
Automatically finalize session capture buffers without user action:
Buffers are rolled into PENDING proposals for review—the review gate is preserved.
What Changed
is_stale_buffer()&finalize_all_except()functions in capture.py for bulk cleanupvouch capture finalize-allCLI command (called by SessionStart hook)Testing
Tested end-to-end in VS Code Claude Code extension:
Commits
5933700feat(capture): add finalize_all_except() for old buffer cleanupf6cb506feat(capture): add 'vouch capture finalize-all' CLI command6ec0fe7feat(adapter): wire capture finalize-all into sessionstart hookd68a376docs(adapter): document windowclose fallback behavior2d76811docs(adapter): explain session capture auto-proposal behaviorb2955f0test(capture): add e2e test for sessionstart cleanup + finalize flow2a5d2d2fix(capture): skip git context when finalizing buffers with unknown originDesign
See:
docs/superpowers/specs/2026-07-01-vscode-session-autoproposal-design.mdSee:
docs/superpowers/plans/2026-07-01-vscode-session-autoproposal.mdAll tests pass (805 tests). Review gate preserved. No Co-Authored-By trailers.
Summary by CodeRabbit
New Features
Bug Fixes