Repository navigation
Reactively add externally-created nodes to an open QueryNodeViewer - #2019
Conversation
An open type/query view loaded its results once and never listened for new
nodes, so a node created via the CLI, an agent tool call, or another tab/window
didn't appear until the view was remounted (tab switch).
Subscribe the viewer to sharedNodeStore (which tauri-sync-listener already
hydrates from the daemon's node:created event, dropping non-active-database
events) and append nodes that belong to the current view. The decision is a pure
shouldShowCreatedNode() helper: only once the view has settled (guards against
O(n^2) self-appends during the view's own load and against injecting into a view
mid-switch), not already shown, type matches the view ('*' = all-types saved
query), and the node passes the query's client-side filters. Works for all three
view modes since they render from the same loadedNodeIds.
Closes #1996.
Co-Authored-By: Claude <[email protected]>
setNode now fires the new wildcard subscription synchronously, so in a default type view the just-created node is already appended to loadedNodeIds by the subscription before handleCreateInstance's own append runs — producing a duplicate id and crashing the keyed #each in all three views. Guard the +New append with !loadedNodeIds.includes(). A saved query whose filters the new node fails is not appended by the (filter-aware) subscription, so this append still shows it, as before. Severity: 🔴 addressed. Reviewer: pragmatic-code-review on PR #2019. Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review + /address-reviewIndependent review verdict was REQUEST CHANGES on one blocking issue; addressed: 🔴 +New duplicate row → keyed-#each crash (default type view). Real bug — 🟢 confirmed sound by the review: the load-time O(n²)/self-append guard ( 🟡 non-blocking, evaluated & kept: the wildcard also fires on Test note: the 🔴 was a component-interaction bug the pure-function tests couldn't reach. A full QueryNodeViewer render harness doesn't exist and building one for this single interaction is disproportionate (heavy deps; this suite has demonstrated fork-ordering fragility — see #2020). The fix is a structural idempotency guarantee at both append sites; full frontend suite green (192 files / 4459 tests), eslint + svelte-check clean. Re-Review Decision: RE-REVIEW NEEDED — a behavior fix to the +New path. Running |
Pragmatic Code Review — Re-Review (delta
|
Summary
An open type/query view (
QueryNodeViewer) loaded its results once and never listened for new nodes, so a node created via the CLI, an agent tool call, or another tab/window didn't appear until the view was remounted (tab switch). Closes #1996.Change
The daemon's
node:createdevent is already hydrated intosharedNodeStorebytauri-sync-listener(which drops non-active-database events). The viewer now subscribes (sharedNodeStore.subscribeAll) on mount and appends nodes that belong to the current view, unsubscribing on teardown.The decision is a pure, exported helper —
shouldShowCreatedNode(node, gate)inquery-node-model.ts— so the subscription handler stays a one-liner and the logic is unit-testable. A node is folded in only when:queryState === 'success') — this guards against O(n²) self-appends during the view's own load (whosesetNodeloop fires the subscription) and against injecting into a view mid-switch (the fresh query reconciles it);targetType, or'*'for an all-types saved query);Works for all three view modes (List/Table/Kanban) since they render from the same
loadedNodeIds.Tests
+7 unit tests for
shouldShowCreatedNodeinquery-node-model.test.ts(settled+matching → integrate; wrong type; already-shown; still-loading; no targetType;'*'all-types; and filter pass/fail). Follows the project pattern of testing extracted logic directly rather than rendering the component. Full frontend suite green (192 files / 4459 tests); eslint + svelte-check clean; pre-push gate passed.Non-goals honored
node:updated/node:deletedrow reactivity (already viasharedNodeStorerow lookups) and the "+New" self-append are unchanged.🤖 Generated with Claude Code