Repository navigation
Description
Overview
During manual testing of #1956 (model picker changes), previously-created AI chat conversations rendered as empty (no messages) in the UI after the daemon was restarted several times in one session. The underlying data was never lost — this is a frontend read/cache bug, not a persistence bug.
Problem Statement
The user created 4 AI chat conversations in one session, interacting with Gemma 4 E4B and Gemma 4 26B-A4B. After the daemon was restarted several times (to pick up RUST_LOG/NODESPACE_PROMPT_DUMP env var changes via a launchd plist edit), navigating back to 2 of the 4 previously-created chat nodes showed them as empty in the UI — no messages rendered, despite each having a full multi-turn conversation.
Confirmed NOT a data-loss bug. Querying the database directly (~/.nodespace/database/nodespace.db, node table, properties column) for all 4 chat node IDs shows every one has the full conversation intact:
f54df478-e4a7-40b4-9888-e3b873040a0b— 6 messages (one of the two reported empty in the UI)6418ef13-89e0-47d5-a29b-5f09da2d4fb4— 6 messages (the other reported empty)7b2a0f62-7d17-4809-bc5e-646ba135185e— 8 messages8671f817-096a-4a2b-93fb-642cb510e485— 6 messages
Daemon logs (~/.nodespace/logs/nodespaced.log) confirm all 4 nodes completed ai-chat turn triggered / ai-chat turn complete cycles successfully with no errors, for every turn in every conversation — including the two now showing empty in the UI.
Likely trigger (unconfirmed, needs investigation). Around the time the daemon was restarted, the log shows a WatchNodes stream failure and reconnect storm:
WatchNodes stream failed: WatchNodes stream returned an error item: status: Unknown, message: "h2 protocol error: error reading a body from connection" ... reconnecting in 1s
WatchNodes stream failed: failed to open WatchNodes stream: status: Unavailable, message: "Connection refused (os error 61)" ... reconnecting in 2s
[repeats with backoff until reconnect succeeds ~7 seconds later]
This suggests the frontend's live node-update subscription (WatchNodes, consumed by sharedNodeStore) entered a degraded state during the daemon restart window, and the client-side cache either held an empty/stale entry for those two specific nodes through the outage, or failed to properly refetch/reconcile after the stream recovered.
packages/desktop-app/src/lib/components/viewers/ai-chat-node-viewer.svelte:78 reads via sharedNodeStore.getNode(nodeId). A fallback fetch exists at ai-chat-node-viewer.svelte:399 (backendAdapter.getNode(nodeId)), so the bug is likely in when/whether that fallback fires, or in whether sharedNodeStore correctly overwrites a stale/empty cached entry once a real fetch returns.
Why this matters: if a WatchNodes reconnect can silently leave the UI showing incorrect (empty) state for existing data, that is a reliability problem independent of restart frequency — any transient connection drop (network blip, a production daemon crash/restart, laptop sleep/wake) could trigger the same symptom for a real user, showing a false "this conversation is gone" state when the underlying data is intact.
ADR-049 (../nodespace-docs/decisions/049-canonical-reactivity-store-pattern.md) already names the general class this belongs to: "a recurring regression class we have paid for repeatedly (stale content after edit, blanked cells after delete, reverted node-type after a slash command)" — caused by the local store copy racing asynchronous domain-event echoes from the daemon. This issue's trigger (a WatchNodes reconnect after daemon restart) is a variant of that same race that ADR-049 does not appear to explicitly cover.
Proposed Solution
- Reproduce deterministically: open an AI chat node with content, kill/restart the daemon to trigger a
WatchNodesreconnect, then navigate away and back to that chat node — confirm whether the empty-render state reproduces on demand. - Trace
sharedNodeStore's handling of aWatchNodesstream error/reconnect: does it invalidate cached entries on disconnect, or leave them stale? Does a successful reconnect trigger a refetch of currently-relevant/open nodes, or only newly-navigated-to ones? - Trace the fallback fetch at
ai-chat-node-viewer.svelte:399— under what conditions does it fire, and does it correctly overwrite a stale/empty cached entry once the fetch returns real data? - Determine whether this is specific to
ai-chatnodes or a generalsharedNodeStorereconnect-handling gap affecting any node type.
Acceptance Criteria
- Root cause identified and documented: what state
sharedNodeStoreand/or theai-chat-node-viewercomponent are left in after aWatchNodesreconnect that causes existing content to render empty - Fix applied so a
WatchNodesreconnect (or any daemon-connection interruption) cannot leave a node's UI state showing empty/stale content when the backend has real data - Regression test added covering the reconnect-then-navigate-back scenario
- Confirmed whether the bug is
ai-chat-specific or a generalsharedNodeStoregap; if general, scope the fix accordingly - Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
- AI chat viewer:
packages/desktop-app/src/lib/components/viewers/ai-chat-node-viewer.svelte—nodederivation at line 78 (sharedNodeStore.getNode(nodeId)), fallback fetch at line 399 (backendAdapter.getNode(nodeId)) - Shared node store:
packages/desktop-app/src/lib/services/shared-node-store.svelte.ts— owns the client-side node cache and (per the daemon log evidence) subscribes to theWatchNodesstream - Daemon logs:
~/.nodespace/logs/nodespaced.log— search forWatchNodes stream failedto find reconnect events and their timing relative to node reads
Related Architecture
../nodespace-docs/decisions/049-canonical-reactivity-store-pattern.md— names the general "local store races async daemon echo" regression class this issue's trigger is a variant of
Related Issues
- Expose Gemma 4 12B as a selectable native model (once verified on adequate hardware) #1956 (the session during which this was discovered; unrelated to that issue's actual scope — model picker changes)
Activity
malibio commentedon Aug 5, 2026
Update: found a concrete structural anomaly, not just a timing race
Checked the actual
propertiesJSON for the specific node reported empty ("Create AI Chat with 26B Gemma",6418ef13-89e0-47d5-a29b-5f09da2d4fb4) against the three other AI-chat nodes from the same session.All 4 nodes have their 6-8 messages fully intact (confirmed again by reading the raw JSON, not just counting). But the top-level
propertieskeys differ:8671f817-...["ai-chat"]7b2a0f62-...["ai-chat"]f54df478-...["ai-chat"]6418ef13-...(reported empty)["ai-chat", "text"]6418ef13-...— one of the two nodes reported rendering empty in the UI — is the only one carrying a stray"text": {}key alongside the expected"ai-chat"key. The other reported-empty node (f54df478-...) does not have this extra key, so it isn't a clean 1:1 explanation for both reports, but it's a concrete, reproducible structural difference on at least one of them — not just a timing/cache-staleness guess.This points toward a possible node-type/behavior confusion (something writing an empty
text-node-shaped properties bucket onto anai-chatnode) rather than purely aWatchNodesreconnect race. Worth checking whether the frontend's node-type dispatch (deciding which viewer/behavior to use, or which properties key to read) gets confused when a node'spropertiesblob carries a key for a type other than its ownnode_type(ai-chathere) — that could plausibly cause the message list to read from the wrong place and appear empty, independent of any connection/reconnect issue.The
WatchNodesreconnect-storm timing in the original report may still be a contributing factor (worth checking if thistextkey appeared as a result of something that ran during that window), but this new finding is a more specific, actionable lead than the original "likely a reconnect race" framing — investigation should start with tracing how/why6418ef13-...ended up with atextkey in itspropertiesat all.Expose Gemma 4 26B-A4B as an optional model tier, park 12B, fix per-m…
mstomar125 commentedon Aug 14, 2026
Root-caused and fixed in #2084.
Root cause: the desktop app's WatchNodes bridge (`watcher.rs`) reconnects with backoff on any daemon disruption, but opens a fresh live-forward stream with no catch-up replay — updates that happened during the outage are gone, not delayed. `pane-content.svelte`'s hydration logic only checked whether a node was present in `sharedNodeStore`, never whether it might be missing an update from the gap, so a node cached before an outage kept rendering its pre-outage snapshot forever (matching the exact repro: an AI chat conversation with an intact multi-turn history in the DB rendering empty after navigating back post-restart).
Confirmed general, not ai-chat-specific — the fix lives in `shared-node-store.svelte.ts` (reconnect-generation tracking + `isPossiblyStale`/`ensureNode` re-confirm) and `pane-content.svelte` (hydration gate now checks freshness, not just presence). No changes needed in `ai-chat-node-viewer.svelte` — it already reads the store reactively.
Regression tests added at both the store level (reconnect-then-navigate-back repro through the real write path) and the component level (real `pane-content.svelte` mount, reconnect-triggered refetch). See PR for full details.
Address adversarial review: cover the two other ensureNode call sites…
Re-confirm cached nodes on daemon reconnect instead of trusting prese…