feat: pin sessions in the /resume picker#508
Conversation
|
Wouldn't this interfere with searching? |
@mpfaffenberger if a user has a lot of pinned sessions then their first page or two could be all pinned sessions. After that it would default to normal sort for searching. |
|
Please address quality checks. It's weird, the instructions to do so are in the project's |
|
Hi @mpfaffenberger — thanks for the review, and fair questions. Let me address both. Agent setup (full transparency)This PR was built using Code Puppy itself (dogfooding), human-directed by me end-to-end — I reviewed every diff, and ran the checks locally before each push via Quality checksI did run the linters per
The CI failure on the first run was not a lint issue — it was a real test failure in Heads-up: the latest commit's checks are currently sitting in The architectural question I want to raise honestlyYour Golden Rule is clear: new functionality should be a plugin; don't edit The reason: the feature adds a So I'd like your guidance on how you'd prefer this land:
Happy to do the rework whichever way you prefer — just don't want to add a core seam unilaterally. Thanks! |
|
@mpfaffenberger Sounds good. I'll work that as a separate P/R. |
6b22a15 to
4e71c33
Compare
Add the ability to pin/unpin autosave sessions from the /resume (a.k.a. /autosave_load) interactive picker by pressing 'p'. Pinned sessions float to the top of the list (above the named/auto grouping), show a magenta '*' marker + '* Pinned' preview badge, and are protected from automatic cleanup. In search mode 'p' still types normally. Pin state lives in a dedicated pinned_sessions.json registry in the autosaves dir (not per-session _meta.json, which autosave rewrites and would clobber). Writes go through an atomic+fsync helper; toggle_pin prunes ghost pins and refuses to pin nonexistent sessions. Failures in the picker key handlers are logged rather than silently swallowed. Includes unit tests.
_get_session_entries now stamps a 'pinned' flag on every entry's metadata,
so the permission-error case yields {'pinned': False} rather than {}.
4e71c33 to
6374599
Compare
What
Adds the ability to pin sessions in the
/resume(a.k.a./autosave_load) interactive picker.pto pin/unpin it.*marker, and the preview pane shows a* Pinnedbadge.cleanup_sessionsskips them) — otherwise a pin you can lose isn't much of a pin./search mode,pstill types a literalp(the pin binding is registered after the alphabet bindings and defers to search mode).Why
Easy to lose track of an important conversation among a long list of autosaves. Pinning keeps your go-to sessions one keystroke away.
How it works
Pin state lives in a dedicated
pinned_sessions.jsonregistry in the autosaves directory, intentionally decoupled from each session's_meta.json. The meta files get rewritten on every autosave, which would silently clobber a pin flag on the active session — a single small registry is the one source of truth.New helpers in
session_storage.py:load_pins/save_pins/is_pinned/toggle_pin/get_pins_pathsave_pinswrites through a new_atomic_write_text()helper (unique temp file +fsync+ atomicreplace) for crash-safety and concurrency-safety.toggle_pinprunes pins whose sessions no longer exist and refuses to pin a nonexistent session, so the registry never accumulates ghosts.In
autosave_menu.py:_order_entries()helper so the initial load, search filtering, and live pin-toggle all use one rule.logger.warning(..., exc_info=True)) instead of swallowing them silently.Tests
Added unit tests in
tests/test_session_storage.pycovering pin round-trip, missing-session refusal, stale-pin pruning, corrupt-registry resilience, and cleanup protection.ruff check+ruff formatclean.(Two unrelated pre-existing failures in
test_session_storage_edge_cases.py/test_session_storage_extended.pyare Windows-only permission/path quirks present onmainbefore this change.)