Repository navigation
Content-only edits forced immediate (non-debounced) persistence via redundant nodeType, and property-only updates never synced typed fields back from the backend - #1694
Conversation
… SharedNodeStore (closes #1690) Two related bugs in updateNode()'s persistence path, found via live interactive testing in the Tauri app and browser dev mode. Bug 1: isNodeTypeChange was computed as 'nodeType' in changes (mere key presence), not a value comparison. updateNodeContent() always bundles the current, unchanged nodeType alongside content on every keystroke (a deliberate prior fix protecting in-flight slash-command conversions from a race). That combination forced mode: 'immediate' instead of 'debounce' on every keystroke of every text edit, so each keystroke fired its own RPC round-trip. An early keystroke's echo could land after later keystrokes moved local content on, misclassifying it as a foreign write and firing a spurious "conflicted with a remote change" toast — and under fast typing, visibly corrupted persisted content (reproduced: "Testing conflict reproduction now" persisted as "Tng conflict reproduction nowesti"). Fixed by comparing changes.nodeType !== existingNode.nodeType. Bug 2: after backendAdapter.updateNode() returns the backend's authoritative, flattened response, only .version was copied into the local node — every other field, including type-specific top-level fields (ai-chat's provider/model, task's status/priority) that node_to_typed_value promotes server-side, was discarded. A properties-only optimistic write (e.g. AiChatModelSelector) sends the un-flattened nested shape client-side, so the local node's top-level typed fields never got corrected. Reproduced live: selecting a model in AI Chat left the UI stuck on "Choose a model to get started" indefinitely, textarea never appearing, even though the selection was genuinely persisted (confirmed via direct API read) — a page reload didn't fix it either, ruling out a pure timing explanation. Fixed by applying the full backend response over the local node, re-asserting .content from the pre-update local node afterward so an in-flight newer edit isn't clobbered by the response for an older send. Added a regression test for bug 1 that simulates the exact real-world payload shape updateNodeContent sends (content + redundant unchanged nodeType together) — the existing tests in this file only ever sent { content } alone and so never exercised this path. Verified the new test fails without the fix and passes with it. Co-Authored-By: Claude <[email protected]>
…hared-node-store-sync
Code Review SummaryReview Type: Initial Review Two-bug fix in Requirements Check (issue #1690)
All acceptance criteria are satisfied. Code Review FindingsCritical IssuesNone. Important
Suggestions
Nitpicks
Cross-check with PR #1693 (context only, not reviewed here)No logical inconsistency spotted between this PR's bug 1 fix (mode-selection correctness in Overall AssessmentNet positive, well-diagnosed, low-risk fix with a solid regression test for bug 1 and clean type/lint checks. The one gap worth tracking (properties clobbering, same shape as the Recommendation: APPROVE |
malibio
left a comment
There was a problem hiding this comment.
Pragmatic code review: APPROVE (recommendation — GitHub blocks self-approval on this account, so recording as a comment-type review instead). Full report posted above. Both bugs verified (reverted bug-1 fix locally, confirmed the new regression test fails without it and passes with it). One non-blocking Important finding: the bug-2 Object.assign fix protects .content from in-flight staleness but not .properties, which has the identical exposure (e.g. AiChatModelSelector). Flagged as a fast-follow, not a blocker — net improvement either way.
…), fix stale comment The bug-2 fix only protected setNode()'s persistence closure, but the real-world trigger for the "stuck on Choose a model" bug (AiChatModelSelector's handleModelSelect) calls updateNode(), which has its own, separate persistence closure with the identical .version-only sync gap. Apply the same fix there: spread the backend's typed-field response over the local node, protecting content and properties from being clobbered by a stale/racing response. Also: properties must only be taken from the backend when it actually returned some — TaskNode-shaped responses and task-updater responses for changes they don't map back have no `properties` field, and undefined must never clobber a defined local value (caught by two existing tests exercising exactly this). Drop the stale "issue #424" code comment reference per this repo's convention of describing behavior directly rather than citing ticket numbers. Co-Authored-By: Claude <[email protected]>
Addressed review feedback🟡 Important — While implementing this, I found the fix needed to go further than the review anticipated. The reviewer's finding was framed against Applied the same fix to both closures:
Both now protect One correctness issue surfaced while writing tests for this: the backend doesn't always return a 🟢 Suggestion — missing regression test for bug 2 (addressed): Added 🟢 Suggestion — redundant "issue #424" reference (addressed): Removed from both the source comment and the test comment; described the behavior directly instead, per this repo's documentation convention of not citing ticket numbers in code. 🟢 Suggestion — inline comment length (skipped, as the reviewer anticipated): Left as-is; the reviewer's own framing called the length "justified here given the subtlety being documented." All 166 test files / 4108 frontend tests pass, plus the full Rust test suite via the pre-push gate (including the real-model Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: This wasn't a mechanical touch-up — tracing the actual bug trigger revealed the original fix needed to be duplicated into a second, previously-unpatched code path ( |
Code Review Summary — Re-ReviewReview Type: Re-Review (reviewing only commit This commit does exactly what its message and the PR comment describe: it duplicates the bug-2 fix into Previous Review Follow-up
FindingsCritical IssuesNone. Correctness Analysis (the core of this delta)
Suggested Improvements
Nitpicks
Overall AssessmentThis delta directly and correctly addresses the previous review's only "Important" finding, does so with a more thorough root-cause trace than the finding itself asked for (discovering the actual duplicate closure rather than just patching the one the reviewer looked at), and catches a real correctness bug along the way with test evidence, not just assertion. Both prior 🟢 suggestions were also resolved. No new critical or important issues found in this delta. The remaining suggestions (helper extraction, stringify key-ordering) are genuinely optional polish, not correctness risks. Recommendation: APPROVE |
…hared-node-store-sync
Closes #1690