Skip to content

Remove dead editor workarounds and state-writing effects that ADR-049 forbids #4378

Not planned

Description

@malibio

Overview

A code-reading review of the frontend's reactivity found a set of small, independent violations of the canonical store pattern: dead workarounds in the outline viewer, node wrappers that keep a local override of a node's content, two effects that should be derived values, and a stale-result guard that compares too little. None needs a design decision. This issue removes them in place.

Findings come from reading code, not from running it. Line numbers are as of the review and must be re-checked; the three items marked inferred have not been reproduced.

Problem Statement

  • base-node-viewer.svelte holds workarounds that do nothing or that the project rules forbid:
    • requestNodeFocus patches textarea[id="textarea-${nodeId}"] (around lines 519-531), but the textarea's real id is textarea__{paneId}__{nodeId} (base-node.svelte:837), so the selector never matches.
    • "Update the original node's content to itself, which should trigger focus" (around lines 634-642).
    • Two "TRANSITION PERIOD" fallbacks from the structure tree to the store (around lines 195-221). AGENTS.md forbids transition-period code.
  • textarea-controller.svelte.ts has a cleanup-only $effect.pre (around line 1302) that duplicates the onDestroy in base-node.svelte (around line 729).
  • Eight node wrappers assign to their $bindable content prop (header-node.svelte:109, task-node.svelte:98, quote-block-node.svelte:93, ordered-list-node.svelte:122, code-block-node.svelte:235,252, table-node.svelte:73, horizontal-line-node.svelte:48). NodeRow does not bind that prop, so the assignment is a wrapper-local override of data the store owns. Inferred: if the store rejects or alters the write, the wrapper keeps showing its override.
  • Two effects write reactive state that is a pure function of other state:
    • components/settings/settings-pane.svelte:30 corrects activeCategory when it is not visible.
    • components/relationships/relationship-viewer-modal.svelte:216 falls selectedKey back to the first populated group.
  • components/chat/remote-tool-confirmation-card.svelte: credentials is message.confirmationCredentials ?? [] (line 57), a new array on every message update, and the stale guard in the effect at line 71 compares summary and arguments only. Inferred: a message update can reset the check, the arming delay and the buttons.
  • components/layout/database-name-dialog.svelte:33 seeds name on open but also tracks initialValue, so a prop change while the dialog is open overwrites what the user typed.

Proposed Solution

Delete the dead code, make the wrappers read content from their props only (the write already goes to the store through the content-changed event), replace the two corrective effects with a $derived effective value, give the confirmation card a stable empty array and a guard that covers every field the check depends on, and seed the dialog's name in its open handler.

Documentation

  • ADR-049 Decision items 4 and 5 - an effect never writes reactive state, and a component keeps no local copy of node data. Every change here applies those two items.
  • Frontend State & Persistence - the store and structure tree the fallbacks read from.
  • Updates: the review reported these doc statements as not matching the code. Check each and correct the doc (nodespace-docs, direct to main):
    • frontend-state-and-persistence.md says person-schema-form calls backendAdapter.updateNode directly; the code calls sharedNodeStore.updatePersonNode. The same paragraph cites an issue number, which docs must not do.
    • Same doc, "Domain event echo": says an incoming event with an equal or older version is ignored; remote-update-policy.ts applies any database update to a node that is not being edited.
    • Same doc lists the structure tree under services/; it is stores/reactive-structure-tree.svelte.ts.
    • frontend-architecture.md says a viewerless type's fallback viewer is always cached; pane-content.svelte caches nothing in that case.
    • ADR-049 states effects never write reactive state; record the remaining sites or remove them.

Architecture Impact

Implements ADR-049 as written. No decision changes.

Acceptance Criteria

  • The three dead workarounds and both "TRANSITION PERIOD" fallbacks are gone from base-node-viewer.svelte, and merge, split and focus-after-create still work
  • The duplicate cleanup effect in textarea-controller.svelte.ts is gone and the controller is destroyed exactly once
  • No node wrapper assigns to its content prop; content is not $bindable where nothing binds it
  • settings-pane.svelte and relationship-viewer-modal.svelte compute the effective category and selection with $derived, with no corrective effect
  • The confirmation card does not reset its check, arming delay or buttons when the message updates without its confirmation fields changing; a test covers it
  • database-name-dialog.svelte keeps typed text when initialValue changes while open
  • The doc statements listed under Documentation are checked and corrected where wrong
  • bun run test:changed passes and bun run quality:fix is clean

Technical Specifications

Files to Modify

  • packages/desktop-app/src/lib/design/components/base-node-viewer.svelte
  • packages/desktop-app/src/lib/design/components/textarea-controller.svelte.ts
  • packages/desktop-app/src/lib/design/components/{header,task,quote-block,ordered-list,code-block,table,horizontal-line}-node.svelte
  • packages/desktop-app/src/lib/components/settings/settings-pane.svelte
  • packages/desktop-app/src/lib/components/relationships/relationship-viewer-modal.svelte
  • packages/desktop-app/src/lib/components/chat/remote-tool-confirmation-card.svelte
  • packages/desktop-app/src/lib/components/layout/database-name-dialog.svelte

Implementation Details

  • Before deleting each workaround, confirm it is dead: the selector mismatch is verified; for the self-assignment and the fallbacks, check that the behaviour they claim to protect still holds without them.
  • Some wrappers pass bind:content down to BaseNode. Removing the wrapper's own assignment must not break that path; if BaseNode never writes the prop either, drop the binding too.
  • The other state-writing effects the review listed (person-form draft mirrors, dialog reset-on-open, kanban reveal reseed, relationship modal pruning) write component-local UI state and are not race sources; leave them unless they fall out naturally.

Non-Goals

  • Changing how rows receive node data, the edit session, or the store's structure. Those are separate issues.

Activity

  1. malibio commented on Nov 28, 2026

    @malibio
    CollaboratorAuthor

    Moved to NodeSpace: the issue "Remove dead editor workarounds and state-writing effects the reactivity rule forbids" (c6cb44c4-5625-4450-af5e-c84201cfad91) in the NodeSpace workspace. The team's work is tracked there, so this GitHub copy is closed to keep its status in one place.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions