Repository navigation
Description
Summary
Typing / in a node (or otherwise converting/creating a node type — e.g. creating a Task) throws a Svelte state_unsafe_mutation error, which wedges the reactivity flush. The edited node visually disappears, node-type creation fails in the UI, and the app becomes sluggish/unresponsive to further interaction.
This is the /-disappears symptom originally reported as step 1 of #1564. That issue bundled four symptoms; the fix that closed it (314b709f, PR #1565) addressed only the date-navigation symptoms (atomic tab-title/content write + stale-hydration guard) and did not touch the slash / node-type-conversion path. So this symptom was closed but never actually fixed.
Environment
Reproduces in both the Tauri webview (bun run dev:tauri) and browser/proxy mode (bun run dev:browser) — it is shared frontend code, not environment-specific.
Root cause (diagnosed)
The daemon and data layer are not at fault. Verified directly:
nodespace schema list→ 25ms;node get→ 9ms.nodespace node create --type task --content "…" --parent <date>→ 91ms, succeeds, node persisted with correct{"task":{"status":"open"}}properties.
So task creation works end-to-end at the daemon; the failure is purely in the frontend render path. The perceived "slow daemon communication" is actually the state_unsafe_mutation breaking the Svelte flush, not backend latency.
The offending path is in packages/desktop-app/src/lib/design/components/base-node-viewer.svelte, in the inline on:slashCommandSelected and on:nodeTypeChanged handlers (they appear twice — the lazy-loaded-component branch and the fallback BaseNode branch). Two synchronous reactive-state writes run during what becomes a render flush:
-
focusManager.focusNodeFromTypeConversion(node.id, …)— called synchronously at the top of every handler (lines ~1519, ~1548, ~1744, ~1802). It writes three$statefields infocus-manager.svelte.ts(_editingNodeId,_editingPaneId,_cursorPosition— declared$stateat lines 66/70/73). -
Non-placeholder branch:
sharedNodeStore.updateNode(node.id, updatePayload, …)— called synchronously (lines ~1624, ~1878). Whennode.idis no longer in the store (e.g. a placeholder just promoted / superseded), this logs the observed warningCannot update non-existent node: <id>(shared-node-store.svelte.ts:1036).
Why it's inconsistent (the tell)
The placeholder-promotion branch already guards against exactly this: it defers its store + focus mutations to tick().then(...) with the comment "CRITICAL FIX (#681): Defer store mutations to next tick … If called during template render, Svelte throws state_unsafe_mutation" (lines ~1478/1480 and ~1591, and mirrored ~1703/1705, ~1845). But the top-level focus write and the non-placeholder updateNode were left un-deferred. So the fix pattern exists in the file — it just wasn't applied to these two call sites.
Component stack from the thrown error (confirms origin under the date viewer, not authored in date-node-viewer.svelte itself, whose own $deriveds are pure):
in <unknown>
in date-node-viewer.svelte
in pane-content.svelte
in tab-system.svelte
in pane-manager.svelte
…
Steps to reproduce
- Open a date page (Daily Journal).
- In the empty/active node, type some text then
/— the slash palette opens, but the node disappears and the console throwsstate_unsafe_mutation(+ oftenCannot update non-existent node: <id>). - Or: type
/taskand select Task — the conversion fails to render and the app goes sluggish.
Expected
Typing / opens the slash palette without the node disappearing; selecting a type (Task, etc.) converts/creates the node and keeps focus, with no state_unsafe_mutation and no Cannot update non-existent node warning.
Proposed fix
Apply the same tick() deferral the placeholder branch uses to the two un-deferred reactive-state writes on the slash / type-conversion path — the top-level focusManager.focusNodeFromTypeConversion(...) and the non-placeholder sharedNodeStore.updateNode(...) — so no reactive $state is written synchronously during the render flush triggered by the keystroke. Also verify the non-placeholder updateNode is not firing against an already-promoted/removed node.id (guard or resolve the current id), which is the source of the Cannot update non-existent node warning. Confirm the fix aligns with the ADR-049 rule (reactive state written from event handlers / store methods, never inside a render/derived path).
Acceptance criteria
- Typing
/in a node no longer makes the node disappear; slash palette opens normally. - Creating/converting to Task (and other types) via
/works in the UI and keeps cursor/focus. - No
state_unsafe_mutationerror on the slash / node-type-conversion path. - No
Cannot update non-existent nodewarning during slash-command node creation. - App remains responsive after these interactions (no flush wedge).
- Verified in both
dev:taurianddev:browser.
Activity
malibio commentedon Jul 7, 2026
Split out from #1564. That issue's step-1 symptom (
/makes the node disappear) was closed alongside the date-navigation fix (314b709f, #1565), but that fix only covered the date-nav symptoms — it did not touch the slash / node-type-conversion path, so this symptom survived. Diagnosed this session: daemon + data layer verified healthy via CLI (task node creates in 91ms and persists correctly); the failure is purely the frontendstate_unsafe_mutationwedging the Svelte flush.malibio commentedon Jul 7, 2026
Frontend baseline: 150 test files passed, 3944 tests passed.
Address review: hoist hasNode guard, clarify guard asymmetry + doc (#…
Fix slash/type-conversion state_unsafe_mutation that wedges the flush (…