Skip to content

fix(persist): Bind session writes to their repository and stack - #48

Merged
mhiro2 merged 3 commits into
mainfrom
fix/persist-save-target
Oct 2, 2026
Merged

mhiro2 merged 3 commits into
mainfrom
fix/persist-save-target

Conversation

@mhiro2

@mhiro2 mhiro2 commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Session operations now write to the repository store that was current when they were requested, so a :cd during an async save, delete or rename no longer overwrites another repository's sessions.
  • The session cache is kept per store file, so listing sessions after a directory change shows the current repository's sessions.
  • Auto save remembers which stack (and store) it is mirroring, so quitting from an unrelated empty split no longer replaces the auto session with an empty stack.

Changes

  • cd42383 : test(user_events): run session event tests in a throwaway repository
    • The save/restore event tests no longer share a store file with persist_sessions_spec running in a parallel process, which could overwrite its fixtures.
  • 894ebeb : fix(persist): bind each session operation to the store it was requested in
    • Save, restore, list, delete and rename resolve the store file once and carry it through the update queue, read, write and cache refresh.
    • The session cache is keyed by store file.
    • Real-file tests in two temporary repositories cover save, delete, rename and queued updates across a directory change.
  • eace374 : fix(persist): save the tracked stack on leave instead of the current window
    • The leave-time save writes the most recently changed stack to its own store, and does nothing if no stack changed during the session.
    • A pending debounced save is written out before a change for another stack or store replaces it, and each timer callback only saves the target it debounced.
    • Once the tracked root window has been closed, the save is skipped instead of saving the current window's stack. README and help describe the auto session target.

mhiro2 added 3 commits October 3, 2026 08:48
The save/restore event tests wrote to the same repository store as
persist_sessions_spec, which runs in a parallel process, so an async save
here could overwrite fixtures there with a stale snapshot. Each test now
runs from its own temporary git repository and removes its store file.
…ed in

The store resolved its file from the current directory on every read and
write, so starting an async save in repository A and running :cd B before
it finished wrote A's sessions over B's store and dropped B's sessions.

- Resolve the store file once when a save, restore, list, delete or rename
  is requested and carry it through the update queue, read, write and
  cache refresh; the store module now takes a file path instead of a scope.
- Key the session cache by store file so a listing after a directory
  change no longer returns the previous repository's sessions.
- Cover save, delete, rename and queued updates across a directory change
  with real store files in two temporary repositories.
…window

save_on_leave() fell back to the current window once the debounced save
had run, so moving to an empty split and quitting overwrote the auto
session with zero items while the original stack still held popups.

- Track the stack to save (root window and store file) separately from the
  debounce state, and save that stack on leave; skip the leave save when no
  stack changed during the session.
- Resolve the store file when a change is observed, flush a pending save
  before a change for another stack or store replaces it, and bind each
  timer callback to the target it debounced.
- Skip saving once the tracked root window is closed instead of saving the
  current window's unrelated stack, and document the auto session target.
@mhiro2
mhiro2 force-pushed the fix/persist-save-target branch from ed12903 to eace374 Compare October 2, 2026 23:48
@mhiro2 mhiro2 self-assigned this Oct 2, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Oct 2, 2026
@mhiro2
mhiro2 merged commit 28a0060 into main Oct 2, 2026
3 checks passed
@mhiro2
mhiro2 deleted the fix/persist-save-target branch October 2, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant