Skip to content

Outline rows read their node from the store by id, with callback props instead of dispatched events #4379

Not planned

Description

@malibio

Overview

In the outline viewer a node's data reaches its control as a copied object passed down through props, and an edit travels back up through three levels of dispatched events. ADR-049 decided that components read the store directly. Forms, tables, kanban and checkbox-node.svelte already do. The outline rows, the product's core surface, do not. This issue makes them.

Findings come from a code-reading review; line numbers must be re-checked.

Problem Statement

  • Read path today: visibleNodesFromStores in base-node-viewer.svelte (around lines 182-249) flattens the structure tree and the store into new {...node, depth, children} objects. Every keystroke rebuilds every row object. These go to NodeRow as props (node-row.svelte, around lines 103-110), then to the type wrapper, then to BaseNode.
  • Write path today: the textarea controller raises contentChanged, BaseNode re-raises it through createEventDispatcher (base-node.svelte, around line 566), the wrapper re-dispatches, NodeRow calls back, and handleContentChanged in the viewer (around line 933) calls nodeManager.updateNodeContent. createEventDispatcher appears about 30 times in non-test frontend code.
  • Depth is stored twice: _uiState[id].depth in reactive-node-service.svelte.ts is maintained by hand through indent, outdent and rollback, although the viewer recomputes depth from the tree.

A row therefore depends on the whole flattened list instead of on its own node, and data the store owns exists in several derived copies between the store and the control.

Proposed Solution

  • The viewer derives only {id, depth} per visible row from the structure tree.
  • NodeRow and the node components read $derived(sharedNodeStore.getNode(id)), as checkbox-node.svelte does (around lines 39-44).
  • Replace createEventDispatcher on the node path with callback props.
  • Derive depth from the tree and delete _uiState.depth and its hand maintenance.

Documentation

  • ADR-049 Decision items 2 and 5 - components read the store directly, and there is exactly one copy of a node's data.
  • Frontend State & Persistence - layers: ReactiveNodeService, SharedNodeStore, ReactiveStructureTree.
  • Component Architecture - the BaseNode / wrapper / BaseNodeViewer hierarchy and naming, which stays as it is.
  • Updates: frontend-state-and-persistence.md (per-viewer UI state no longer holds depth; the read path) and component-architecture.md (callback props replace dispatched events) in the same change.

Architecture Impact

Implements ADR-049 for the outline rows. No decision changes.

Acceptance Criteria

  • The viewer's per-row derived value holds ids and depth only; no row object is a copy of node data
  • NodeRow and every node wrapper read their node from sharedNodeStore.getNode(id)
  • A test shows that editing one node's content does not re-evaluate another row's derived node
  • No createEventDispatcher remains on the path from BaseNode to the viewer; callbacks are typed props
  • _uiState.depth and every hand update of it are deleted; depth comes from the structure tree
  • The same node open in two panes shows the same content in both, and editing in one updates the other
  • bun run test:changed and bun run test:browser pass; 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/node-row.svelte and node-row-types.ts
  • packages/desktop-app/src/lib/design/components/base-node.svelte and the *-node.svelte wrappers
  • packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts

Implementation Details

  • checkbox-node.svelte is the pattern to follow for reading by id.
  • Placeholder nodes exist in the viewer before the store has them; decide how a row for an unsaved placeholder reads its data (see "Placeholder Nodes" in frontend-state-and-persistence.md) and keep that in one place.
  • Use isA from the registry for any type test; no literal nodeType comparisons.
  • No any, no lint suppression; createLogger, not console.*.

Dependencies

Non-Goals

  • The edit session and caret handling.
  • The store's internal structure.

Activity

  1. malibio commented on Nov 28, 2026

    @malibio
    CollaboratorAuthor

    Moved to NodeSpace: the issue "Outline rows read their node from the store by id, with callback props instead of dispatched events" (7ec78f96-1bb1-421a-b9bc-cbe0c486449f) 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