Skip to content

fix: refresh the vault's index only for notes written inside it - #397

Merged
breferrari merged 4 commits into
mainfrom
issue-366-refresh-in-vault
Oct 14, 2026
Merged

breferrari merged 4 commits into
mainfrom
issue-366-refresh-in-vault

Conversation

@breferrari

@breferrari breferrari commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

validate-write started the debounced QMD refresh for any .md write, even one outside the vault: a repo's README edited in another folder, or a note in ~/.claude/. The vault's index can't change from such a write, so the worker was wasted work, at most one per 30 s because of the debounce. Now only a note inside the vault refreshes. Paths inside the vault that validation skips (templates, root docs, a memory folder inside the vault) still refresh, since they are indexed all the same.

Closes #366

Type

  • fix — bug fix

What changed

  • lib/project-dir.ts: isInsideVault(path, vaultRoot) is the one boundary-safe in-vault check ("/vault" doesn't contain "/vaulting/…"), and it ignores case on Windows, where the hook's vault root and a tool's file path can spell the drive differently.
  • lib/qmd-refresh.ts: refreshesVaultIndex(filePath, vaultRoot) is shouldRefreshForPath and isInsideVault.
  • validate-write.ts: its own outside-vault skip uses isInsideVault too. So a note whose drive letter is cased differently from the vault root is now validated; before, it was silently skipped.
  • validate-write.ts, as well: the refresh trigger asks refreshesVaultIndex for each refreshed path, and the comment says why.
  • tests/refresh-in-vault.test.ts (new, spawns nothing):
    • in-vault notes refresh, a template and a root doc included;
    • an outside note and a sibling folder named like the vault refresh nothing;
    • the extension and skip rules still apply.
  • tests/validate-write.test.ts, through the hook on CI: an outside note requests no refresh; an in-vault template still does (the control). Both read the trigger's refresh requested debug line.

Proof

  • Red first: 3e3a9f0. With the helper still ignoring the root, the outside-note test failed.
  • Mutation: each of these fails a test:
    • dropping the / from the boundary check fails the sibling-folder case;
    • dropping the Windows case-fold fails both casing tests.
  • Typecheck clean. The pure test file passes locally. The hook tests and the full suite run on this PR's CI.

Review (small code)

  • /simplify: the in-vault check was duplicated between the refresh and validation's skip, so it is now one shared isInsideVault. A drive letter cased differently would have silently turned the refresh off for every in-vault write on Windows, so the shared check folds case there. The two path-less refresh callers (Stop, PreCompact) were checked and have no outside-path issue.

Note

This PR touches the same validate-write.ts block as #395 (#360, the sentinel path). Whichever merges second needs a one-line rebase.

Checklist

  • PR title follows type: description format
  • Tests pass (cd .claude/scripts && npm test): left to CI on this PR, not run locally
  • No changes to CHANGELOG.md or vault-manifest.json version

🤖 Generated with Claude Code

breferrari and others added 4 commits October 14, 2026 02:53
…ultIndex (#366)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ws (#366)

The refresh trigger and validation's skip both use isInsideVault, so a
drive letter cased differently from the vault root neither skips validation
nor turns the refresh off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@breferrari
breferrari force-pushed the issue-366-refresh-in-vault branch from 5eb3e8e to 3f53b23 Compare October 14, 2026 00:53
@breferrari
breferrari merged commit f6c3591 into main Oct 14, 2026
12 checks passed
@breferrari
breferrari deleted the issue-366-refresh-in-vault branch October 14, 2026 00:59
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.

Skip the QMD refresh for notes written outside the vault

1 participant