Skip to content

Route person-schema-form saves through sharedNodeStore.updateNode - #2552

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2547-person-title-store-save
Sep 10, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2547-person-title-store-save

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Closes #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) reads titles from.

Runtime repro before fixing anything (per the issue's own acceptance criteria): rendered the real PersonSchemaForm against the real sharedNodeStore singleton, 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 own first_name/last_name properties 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 NodeUpdated domain-event round trip re-hydrating the store — doesn't exist at all outside a live Tauri runtime (tauri-sync-listener.ts skips 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 calls sharedNodeStore.updateNode(nodeId, { properties }, { type: 'viewer', viewerId: 'person-schema-form' }), matching generic-schema-form.svelte and task-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.

handleEmailBlur is restructured for the now-synchronous save: it calls updateField('email', ...) before awaiting the duplicate-email lookup, preserving the existing "save is never gated behind the lookup" guarantee (previously enforced via Promise.all against a real network-await; now trivially true since the store write returns immediately).

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 existing tests rewritten for the new synchronous (fire-and-forget) save semantics rather than an awaited network promise.
  • New regression coverage:
    • asserts the save routes through sharedNodeStore.updateNode with the correct { type: 'viewer', viewerId: 'person-schema-form' } source
    • exercises the real (unmocked) sharedNodeStore end-to-end to prove the title resolves to "{first_name} {last_name}" in the store immediately after editing, with no reload
  • All 4 new/changed assertions were mutation-tested: verified to fail against the pre-fix component (reverted the fix locally, reran, confirmed the expected failures, then restored the fix).

Test plan

  • bun run test (desktop-app unit suite) — 237 files / 4911 tests passed
  • bun run test:all — full unit + browser + scripts + skill + Rust suite green
  • Mutation-tested the 4 new/changed test assertions against the pre-fix component
  • Pre-push gate (test:all + cargo build --bin nodespaced + test:e2e) passed on push
  • bun run quality:fix — 0 ESLint errors/warnings, tsc --noEmit clean, svelte-check clean, cargo clippy --all-targets -D warnings clean

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 10, 2026 06:57
…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]>
@mstomar125

Copy link
Copy Markdown
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.

@mstomar125
mstomar125 merged commit d099de9 into main Sep 10, 2026
@mstomar125
mstomar125 deleted the issue-2547-person-title-store-save branch September 10, 2026 05:26
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.

NodeData proto (daemon) never sends title field — dropped for every client and title-templated node type

1 participant