fix(server): use --relative in wiki diff so subdir vaults report unsynced entries correctly#75
Merged
Merged
Conversation
…nced entries correctly
When wiki_path points to a subdirectory of the clone root (e.g. "wikis/"),
git diff returns paths relative to the repo root ("wikis/entries/foo.md")
while callers look up vault-relative keys ("entries/foo.md"). The mismatch
caused every entry in a subdir vault to appear synced, disabling the push
button even for locally-committed-but-unpushed entries.
Add --relative to both git diff calls in unsyncedWikiFiles so paths are
always relative to vaultPath regardless of where .git lives. Add a
regression test that sets up a subdir vault, commits a local entry, and
asserts the vault-relative key appears in the unsynced set.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
wiki_pathin a profile points to a subdirectory of the clone root (e.g."wikis/"),git diff --name-only origin/HEAD HEADreturns paths relative to the repo root (wikis/entries/foo.md) while all callers look up vault-relative keys (entries/foo.md). The key never matched, so every entry in a subdir vault appeared synced — disabling the push button even for entries that were locally committed but never pushed.Fix: add
--relativeto bothgit diffcalls inunsyncedWikiFiles. With--relative, git outputs paths relative to the working directory (vaultPath), so the keys match what callers expect regardless of whethervaultPathis the repo root or a subdirectory.Changes
unsyncedWikiFiles: add--relativeto bothgit diffcalls (theorigin/HEADprimary and theorigin/mainfallback).TestUnsyncedWikiFiles_SubdirVaultPath: sets up a repo with awikis/subdir vault, commits a local entry, and asserts the vault-relative key (entries/inv-test.md) appears in the unsynced set while the repo-root-relative key (wikis/entries/inv-test.md) does not.Challenges
The failure was silent by design —
unsyncedWikiFilesreturns an empty map on any git error and the comment explicitly calls this "preferable to a false alarm." The subdir mismatch wasn't an error though; git succeeded and returned paths, they just didn't match the lookup keys. No log, no badge — the push button was simply disabled with "no locally-committed-but-unpushed files to push."Testing
Confirmed against the camunda profile vault (
~/.config/triagent/camunda/wiki/), which haswiki_path: wikisvia its base profile. Before the fix:git diff --name-only origin/HEAD HEADfromwiki/wikis/returnedwikis/entries/inv-gateway-gcs-permission-misdiagnosis.md; the lookup forentries/inv-gateway-gcs-permission-misdiagnosis.mdmissed. After:--relativestrips the prefix, key matches, entry shows as unsynced and the push button becomes active. New regression test covers the subdir case end-to-end. Full server test suite passes with-race.