Skip to content

fix(macOS): invalidate git date cache generation on exitVault#242

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/recent-commits-critical-bugs-d28c
Draft

fix(macOS): invalidate git date cache generation on exitVault#242
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/recent-commits-critical-bugs-d28c

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 27, 2026

Summary

Fixes a race where an in-flight refreshGitDateCache could still commit after the user left a vault, repopulating gitDateCache with URLs from the previous vault while rootURL was already nil—inconsistent with cleared vault state and potentially confusing downstream date lookups.

Root cause

exitVault() bumped scanGeneration to drop stale file scans but did not bump gitDateCacheGeneration, so a background git log that finished after exit could still pass the generation guard and write to gitDateCache after it had been cleared.

Fix

  • Increment gitDateCacheGeneration in exitVault() (mirrors the scan pattern).
  • Expose the counter as private(set) for the existing exit-vault test file.
  • Add test_exitVault_bumpsGitDateCacheGeneration_toInvalidateInFlightRefresh in AppStateExitVaultFullTests.swift.

Validation

  • Web: npm test -- --run (Vitest) — 257 tests passed.
  • macOS unit tests: not executed in this Linux CI environment; please run the Synapse test target in Xcode to confirm.
Open in Web View Automation 

A refreshGitDateCache completion that ran after exit could still match its
captured generation (exit did not bump gitDateCacheGeneration), repopulating
gitDateCache with the previous vault's file URLs while rootURL was nil.
Bump gitDateCacheGeneration alongside scanGeneration and add a unit test.

Validation: web vitest (npm test -- --run) passing; macOS tests not run in CI.

Co-authored-by: Danny Peck <dannypeck@gmail.com>
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