Skip to content

QueryNodeViewer doesn't reactively add externally-created nodes matching its query #1996

Closed

Description

@malibio

Overview

QueryNodeViewer (the schema-type list/table/kanban view opened from the sidebar, e.g. clicking "Project" or "Skill") loads its results once via a one-shot query and never listens for node:created events. A node created through any path other than that viewer's own "+New" button — the CLI, an agent tool call, another tab, another window — does not appear in an already-open matching query view until the view is fully remounted (e.g. switching to another tab and back).

Problem Statement

Reproduction:

  1. Open the project (or skill) query view from the sidebar, leave it open
  2. Create a new project node via another path — reproduced via nodespace node create --type project --content "Sample Project" (the CLI, bypassing the UI entirely)
  3. The already-open query view does not show the new node
  4. Switch to a different tab, then switch back to the query view — the new node now appears

Root cause:

loadedNodeIds (packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:86) is populated by loadAndQuery() (line 175), which runs a single backendAdapter.queryNodes({ nodeType, limit: FETCH_LIMIT }) call. It is invoked from:

  • onMount (line 162)
  • An $effect reacting to nodeId changes (line 393, inside untrack(() => loadAndQuery(nodeId)), itself only reachable via the query-save path)
  • The viewer's own "+New" handler, which appends directly to loadedNodeIds for the node it just created (line 535)

There is no subscription to node:created (or any other signal) that would append an externally-created node matching the viewer's targetType/nodeType into loadedNodeIds while the view is already mounted and open. The daemon does emit the event correctly — packages/desktop-app/src-tauri/src/watcher.rs:186-195 forwards NodeEventKind::Created as node:created with node_type included, and packages/desktop-app/src/lib/services/tauri-sync-listener.ts:365 does listen for it and hydrates the node into sharedNodeStore (queueOrFetchNode, line 387) — but nothing downstream tells QueryNodeViewer to add that id to its own result list. The "reappears on tab switch" behavior is consistent with Svelte remounting the component (re-running onMount → loadAndQuery) when navigating back to the tab, not any reactive update.

Proposed Solution

Add a listener/subscription in QueryNodeViewer for newly-created nodes matching its current query's type, and append matching ids to loadedNodeIds when the view is mounted and the created node's type matches schemaNode.id (default type view) or definition.targetType (saved query mode) — mirroring the same epoch/load-id staleness discipline already used elsewhere in this file (currentLoadId, sharedNodeStore.currentEpoch()) so a node created during a mid-flight query switch isn't injected into a now-stale view.

Given tauri-sync-listener.ts already receives and forwards node:created, the most direct fix is likely a Svelte $effect (or a sharedNodeStore-level subscription, if one exists for this purpose) that watches for newly-hydrated nodes of the matching type and appends them — reusing the existing shouldIntegrateInstance() guard (packages/desktop-app/src/lib/services/schema-authoring.ts:52-57) if it fits, rather than writing a parallel staleness check.

Acceptance Criteria

  • A node created via a path other than the open viewer's own "+New" button (CLI, agent tool call, another tab/window) appears in an already-open matching QueryNodeViewer without requiring a tab switch or remount
  • Update is scoped to the currently-open view's type/query — a project created while a skill view is open must not appear there
  • Respects the existing epoch/load-id staleness discipline — a node created during a mid-flight query reload or database switch is not injected into a stale view
  • Works for all three view modes (List, Table, Kanban) since all three render from the same loadedNodeIds
  • No new test failures (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte — loadedNodeIds state (line 86), loadAndQuery() (line 175), handleCreateInstance()'s existing append pattern (line 535) as a model for how to splice a new id in safely
  • packages/desktop-app/src/lib/services/tauri-sync-listener.ts (lines 364-387) — existing node:created listener; confirms the event reaches the frontend and is already hydrated into sharedNodeStore via queueOrFetchNode
  • packages/desktop-app/src-tauri/src/watcher.rs (lines 186-195) — confirms the daemon-side event forwarding includes node_type, so a type-match filter is possible without an extra fetch
  • packages/desktop-app/src/lib/services/schema-authoring.ts (lines 52-57) — shouldIntegrateInstance(), the existing epoch/load-id staleness guard used by the "+New" path; reuse rather than duplicate if the shape fits

Non-Goals

  • Does not address node:updated/node:deleted reactivity for already-loaded rows in QueryNodeViewer — only presumed already working via sharedNodeStore row-level reactivity (each row calls sharedNodeStore.getNode(id) per the comment at line 83); confirm during implementation and file separately if that turns out to be broken too.
  • Does not change the "+New" button's own append logic (line 535), which already works correctly for self-created nodes.

Related Issues

Activity

  1. added
    bug
    on Aug 7, 2026
  2. added a commit that references this issue on Aug 10, 2026
    e42a527
  3. mstomar125 commented on Aug 10, 2026

    @mstomar125
    Contributor

    Resolved by PR #2019 (merged, main e42a5273). QueryNodeViewer now subscribes to sharedNodeStore on mount and folds in externally-created nodes (CLI, agent tool call, another tab/window) that belong to the current view — via a pure shouldShowCreatedNode gate (settled view + type/'*' match + client-side filters + dedup), unsubscribing on teardown. Works across List/Table/Kanban; the load-time self-append and staleness are guarded via queryState, and the +New path is deduped so it never double-appends. Independent review (2 rounds) APPROVE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions