fix(deep-link): install snippets into the vault the sheet disclosed - #154
Merged
Conversation
The snippet-install spec read installTargetVault() once for the destination note and again inside accept, so the vault named to the user and the vault written to were two separate reads of a store the spec touches directly. Changing the vault selection while the sheet is open redirected the write away from the disclosure. `load` now returns the entry together with the vault it resolved, and both the note and accept read that one value.
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.
Follow-up 2 of 3 from the #150/#152 review (follow-up 1 shipped in #153).
The bug
src/components/terminal/deepLinkConfirmSpecs.tsxresolved the destination vault twice for one snippet-install sheet: once indetailsfor the "installs into " note, and again insideaccept. The spec is not a component, so both reads go straight touseVaultStore.getState()— two reads, two answers. Change the selected vault while the sheet is open and the write lands somewhere the sheet never named.The fix
loadresolves the vault alongside the catalogue entry and returns both (SnippetInstallLoad { entry, vault }); the note andacceptread that one captured value.installTargetVault()had a single call site afterwards and is gone.Practically unreachable today — the sheet is modal — but the disclosure is the whole point of that note, and it should be authoritative rather than incidentally correct.
Tests
DeepLinkConfirmModal.test.tsx: the vault mock became mutable (reset per test), and a new test moves the selection fromteam-atoteam-bafter the sheet has painted its destination, then accepts and assertsinstallCatalogEntriesstill receivesteam-a. Fails ondevwithexpected 'team-b' to be 'team-a', passes here.Verification
node ./node_modules/typescript/bin/tsc --noEmit -p tsconfig.json: exit 0, no output.CI=true vitest run: 479/480 files, 3719/3720 tests. Sole failuretests/pluginBundleBuild.test.ts(35057ms, 5000ms budget) — the documented contention flake. Proven not mine: it passes 8/8 on pristineorigin/dev(detached worktree) and 8/8 twice on this branch run alone. The box is carrying a strayviteprocess at ~88% CPU, load average 4.75 on 2 cores.