Repository navigation
Route person-schema-form saves through sharedNodeStore.updateNode - #2552
Merged
Merged
Conversation
…oses #2547) person-schema-form.svelte's updateField() called backendAdapter.updateNode directly and discarded the response, the only property form bypassing sharedNodeStore.updateNode — the store-mediated path BaseNodeViewer and every other viewer read titles from. Runtime repro confirmed the effect: after a first/last name edit, the store's cached node (title, and even its own first_name/last_name) stayed completely untouched, since nothing wrote the change back into the store; recovery depended entirely on an external NodeUpdated domain-event round trip that doesn't fire outside a live Tauri runtime and, even when it does, races an in-memory cache that serves the stale entry indefinitely once populated. The backend itself recomputed and persisted the title correctly on every save — this was purely a frontend store-staleness bug, not a data-loss one. updateField() now calls sharedNodeStore.updateNode with a 'viewer' source, matching generic-schema-form.svelte and task-schema-form.svelte (ADR-049): the store applies the properties change optimistically and hands off persistence, then reconciles the node with the backend's response (including the recomputed title) once that resolves — no dependence on the domain-event echo. handleEmailBlur is restructured to call the now- synchronous updateField before awaiting the duplicate-email lookup, keeping the existing suggest-don't-block, save-never-gated ordering guarantee. Test changes: person-schema-form.test.ts's mocks now spy on sharedNodeStore.updateNode instead of backendAdapter.updateNode, matching how every other property form's tests are set up. Two tests are rewritten for the new synchronous (fire-and-forget) save semantics rather than an awaited network promise. A new describe block adds regression coverage: one test asserts the save routes through sharedNodeStore.updateNode with the expected viewer source, and a second exercises the real (unmocked) sharedNodeStore to prove the title resolves to "{first_name} {last_name}" immediately after editing, with no reload. All 4 new/changed assertions were verified to fail against the pre-fix component (mutation-tested by reverting the fix and rerunning). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…escribe title check-code-references.test.ts enforces a zero baseline for embedded issue numbers in code per CLAUDE.md's documentation rule (describe behavior directly, cite ADRs instead of issue numbers). Renamed the describe block to name what it verifies instead. Co-Authored-By: Claude Sonnet 5 <[email protected]>
12 tasks
Contributor
Author
|
Reviewed (adversarial pass): confirmed the runtime-repro test genuinely exercises the real sharedNodeStore singleton, not a bypassed mock. handleEmailBlur's reordering preserves the duplicate-check-never-gated-behind-save guarantee, verified against sharedNodeStore.updateNode's actual synchronous-mutate/background-persist shape. Error handling confirmed strictly improved, not dropped (rollback + OCC resolution + user-visible toast vs. the old silent log.error) — matches task-schema-form's own established pattern exactly. Mutation-testing claim verified by hand-tracing both new assertions against pre-fix code. Scope clean (2 files, the unrelated check-code-references fix is a genuine single-line rename). Merging. |
6 tasks done
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.
Summary
Closes #2547.
person-schema-form.svelte'supdateField()calledbackendAdapter.updateNode(...)directly and discarded the response — the only property form bypassingsharedNodeStore.updateNode, the store-mediated pathBaseNodeViewer(and every other viewer) reads titles from.Runtime repro before fixing anything (per the issue's own acceptance criteria): rendered the real
PersonSchemaFormagainst the realsharedNodeStoresingleton, stubbing only the network boundary (backendAdapter.updateNode) to return exactly what the backend is documented to return — a correctly recomputed title. Result: after blurring first/last name, the store's cached node stayed completely untouched (title stayed"Untitled", and even the node's ownfirst_name/last_nameproperties in the store stayed stale) despite the backend request/response cycle completing successfully. This confirms the issue's hypothesis — it isn't a "delayed" update, it's that nothing writes the change back into the store at all from this path.Going further than the issue's static analysis: the fallback the old code implicitly depended on — an async
NodeUpdateddomain-event round trip re-hydrating the store — doesn't exist at all outside a live Tauri runtime (tauri-sync-listener.tsskips listener initialization entirely when not running under Tauri), and even when it does fire,sharedNodeStore.ensureNode's cache-first read means a node already in memory keeps serving the stale cached copy indefinitely once populated — a real reload/re-fetch would show the correct value (the backend's persistence itself is fine), but nothing short of that recovers it within a running session. This was a pure frontend store-staleness bug, not a data-loss bug.Fix
updateField()now callssharedNodeStore.updateNode(nodeId, { properties }, { type: 'viewer', viewerId: 'person-schema-form' }), matchinggeneric-schema-form.svelteandtask-schema-form.svelte(ADR-049). The store applies the properties change optimistically/synchronously and reconciles with the backend's response (including the recomputed title) once persistence resolves — no dependence on the domain-event echo.handleEmailBluris restructured for the now-synchronous save: it callsupdateField('email', ...)before awaiting the duplicate-email lookup, preserving the existing "save is never gated behind the lookup" guarantee (previously enforced viaPromise.allagainst a real network-await; now trivially true since the store write returns immediately).Test changes
person-schema-form.test.ts's mocks now spy onsharedNodeStore.updateNodeinstead ofbackendAdapter.updateNode, matching how every other property form's tests are set up.sharedNodeStore.updateNodewith the correct{ type: 'viewer', viewerId: 'person-schema-form' }sourcesharedNodeStoreend-to-end to prove the title resolves to"{first_name} {last_name}"in the store immediately after editing, with no reloadTest plan
bun run test(desktop-app unit suite) — 237 files / 4911 tests passedbun run test:all— full unit + browser + scripts + skill + Rust suite greentest:all+cargo build --bin nodespaced+test:e2e) passed on pushbun run quality:fix— 0 ESLint errors/warnings,tsc --noEmitclean,svelte-checkclean,cargo clippy --all-targets -D warningsclean🤖 Generated with Claude Code