Skip to content

fix(macOS): git date cache race and stale keys on vault open#243

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-440a
Draft

fix(macOS): git date cache race and stale keys on vault open#243
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-440a

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 28, 2026

Bug and impact

Opening a git-backed vault could leave gitDateCache empty or stale. The Created/Modified date views and calendar activity could fall back to filesystem timestamps (wrong after clone) or briefly show keys from a previously opened vault when switching workspaces.

Root cause

openFolder called refreshAllFiles() before setupGit(for:). The scan completion runs refreshGitDateCache() on the main queue while gitService was still nil, so that call returned immediately and bumped gitDateCacheGeneration. The subsequent setupGit refresh could then be discarded as stale when the scan’s second refreshGitDateCache ran with a higher generation, leaving an empty cache merged with [:] (no-op merge). Switching vaults without clearing the cache could also retain URLs under the old root until a successful refresh.

Fix

  • Call setupGit before refreshAllFiles so the scan always sees a live gitService.
  • On vault open, increment gitDateCacheGeneration and clear gitDateCache before wiring git.
  • Remove the redundant refreshGitDateCache() from setupGit (the scan owns the initial population).

Validation

  • Added test_openFolder_switchingVaults_clearsGitDateCacheBeforeRepopulating in AppStateGitDateFilteringTests.
  • macOS xcodebuild test not run in this Linux agent environment; CI exercises macOS tests on push.
Open in Web View Automation 

Call setupGit before refreshAllFiles so the file scan's refreshGitDateCache
sees gitService. Invalidate generation and clear cache when switching vaults
to drop stale paths. Add regression test for vault switch.

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