Repository navigation
fix(client): ignore stale import previews after a new file pick - #75
Merged
Merged
Conversation
This was referenced Nov 1, 2026
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.
改了什么? / What changed?
The JSON-import dry-run preview was not tied to the file that produced it.
onFileswitched thedocument synchronously, then unconditionally applied whichever
importPreviewpromise resolvedlast. Picking file A and then file B before A's round-trip returned could display A's
classification while the Run button committed B — in
replacemode that is a whole-ledger swapjustified by a preview the user never saw.
src/client/board/ImportModal.tsx— add a monotonic pick sequence (useRef). Both asynccontinuations (
file.text()andcontroller.importPreview) now ignore results that no longerbelong to the current pick, and the parse-error path is guarded the same way.
tests/import-preview-order.spec.tsx— new regression test: two picks, deferred previewsresolved out of order (B then A). It asserts the displayed create/overwrite stats stay B's and
that Run commits B's payload. Red/green: without the source change the test fails on the stats
assertion.
如何验证? / How verified?
npx vitest run tests/import-preview-order.spec.tsx— passes with the fix; fails when onlyImportModal.tsxis reverted.npx tsc --noEmit— clean.npx vitest run— 46 files / 603 tests pass (includes the new spec).npm run build— clean.Environment: Windows 11, Node 26.13, DSH 0.2.1-rc.5, branch rebased on
dev@fb97e7f.Note: on Node 26 the suite additionally needs the jsdom
localStoragesetup discussed in #71; CI(Node 22) is unaffected by that.
关联 Issue / Related issue
Fixes #72.