Repository navigation
Outline rows read their node from the store by id; callback props replace dispatched events - #4415
Conversation
|
APPROVE at 99ff026 Independent review of all 4 commits (de8a3de, 4a49072, f598dc6, 99ff026) and the whole. No blocking issue. What I ran (in a detached worktree at the head sha, removed afterwards):
Dropped dispatches, checked against the base (cb11b0e)
Depth. Backspace oddity. Extension contract (plain answer). BlockingNone. Should-fix (non-blocking)
Nit
🤖 Generated with Claude Code |
NodeUIState no longer carries depth and ReactiveNodeService no longer maintains it by hand: the depth walk in initializeNodes/setExpanded/ peekUIState, the optimistic depth writes in indent, outdent and child promotion, updateDescendantDepths, and the depth rollback in the indent/ outdent/promotion rollbacks are deleted. ReactiveStructureTree.getDepth answers depth from the parent chain, and promoteChildren uses it. visibleNodes()/getVisibleNodesForParent had no production caller (the viewer flattens the tree itself) and are deleted with their tests; the split-pane isolation test only exercised that method. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
BaseNode and the node wrappers (text, header, task, issue, checkbox, code block, quote block, ordered list, date, person, query, table, horizontal line) report through NodeCallbackProps instead of createEventDispatcher, and NodeRow binds the viewer's handlers to those props. Wrappers that only forward spread the callbacks to BaseNode; the ones that transform an event (header, task, query, checkbox, code block, quote block, ordered list, date) override the one callback they change. Dispatches nothing listened to are dropped: focus, blur, nodeReferenceSelected, the iconClick pass-through, a keydown binding BaseNode never fired, and the malformed nodeTypeChanged detail the quote-block and ordered-list wrappers sent on Enter (it carried newNodeType, which the viewer's handler does not read, so it changed nothing). The unused NodeViewerEventDetails type is deleted. outline-viewer-rows.test.ts mounts BaseNodeViewer in Chromium over a seeded store and drives typing, the Enter split, Backspace merge and delete, arrow navigation, indent/outdent, collapse, type conversion, the empty-page placeholder and the same node in two panes. It passes unchanged on the dispatcher-based code. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The viewer derives only an id and a depth per visible row; no row object is a copy of node data. NodeRow takes a row id and reads the node through RowNode, a set of $derived reads of the store by id (node, content, type, child rows, metadata), and every node wrapper does the same instead of receiving content, nodeType, children and metadata as props. The viewer's handlers take the row id and read the node from the store when they need it, and the row list returns the previous array when no id or depth changed. An unsaved placeholder row (the blank row of an empty page, not in the store until the first keystroke) reads as the empty text node built by blankRowNode in row-node-read.ts. The same function builds the node the viewer stores when it promotes the placeholder, so that is the only place that says what a placeholder is. The viewer keeps only the placeholder's id. NodeComponentProps is now nodeId, autoFocus and the callback props. The data-has-children attribute on the row container, which nothing read, is removed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
outline-row-reads.test.ts mounts BaseNodeViewer in Chromium over three rows and counts the reads of a row's derived node (readRowNode, one call per evaluation, tagged by id). Editing one node re-reads that row and none of the others, for a single edit and for successive keystrokes. The empty-page test also asserts that an unsaved placeholder row reads as an empty text node. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
99ff026 to
447c583
Compare
NodeSpace task: "Outline rows read their node from the store by id, with callback props instead of dispatched events" (7ec78f96-1bb1-421a-b9bc-cbe0c486449f). Builds on #4414 (no wrapper
contentwrites, no viewer fallbacks, effect cap 6, unchanged).One PR, three reviewable commits (the callbacks and the store-by-id change touch the same files, so splitting would mean editing every wrapper twice):
Remove stored node depth; depth comes from the structure treeReplace node event dispatchers with typed callback propsOutline rows read their node from the store by id(+ the row-read test)Per criterion
visibleRowsis{ id, depth }[]; there is no row object copying node data (ViewerRenderNodeis deleted). The list is returned as the same array when no id or depth changed, so a content edit leaves the rows' props alone.NodeRowtakes anid;RowNode(row-node.svelte.ts) is a set of$derivedreads of the store by id (node, content, type, child rows, metadata). Text, header, task, issue, checkbox, code-block, quote-block, ordered-list, date, person, query, table and horizontal-line wrappers takenodeId,autoFocusand callbacks only.NodeComponentProps(the extension-facing props) is now the same.outline-row-reads.test.ts(Chromium) counts calls toreadRowNode, which is the row's derived node read (one per evaluation, tagged by id): after an edit (and after successive keystrokes) the edited row's count is >0 and the other rows' is 0. Mutation-checked: reading the whole map inreadRowNode, and reading sibling rows inRowNode.node, each fail both tests.createEventDispatcheris gone fromBaseNodeand all 13 wrappers; they useNodeCallbackProps(typed, innode-row-types.ts), andNodeRowbinds the viewer's handlers. Dispatches nothing listened to are dropped (focus, blur, nodeReferenceSelected, an iconClick pass-through, akeydownbinding BaseNode never fired). The quote-block and ordered-list wrappers sentnodeTypeChangedwith{ nodeId, newNodeType, cleanedContent }on Enter; the viewer readsdetail.nodeType, so it never changed anything, and it is dropped rather than retyped.base-node-reference.sveltestill uses a dispatcher but is an inline reference component, not on this path.NodeUIState.depth,computeDepth(3 copies),updateDescendantDepths, the optimistic depth writes in indent/outdent/promote-children and the matching rollbacks are gone, plusoriginalUIStatecapture/restore in those rollbacks (nothing writes UI state there any more).ReactiveStructureTree.getDepthanswers depth;promoteChildrenuses it.visibleNodes()/getVisibleNodesForParenthad no production caller (the viewer flattens the tree itself) and are deleted with their tests;split-pane-isolation.test.tsonly tested that method and is deleted.outline-viewer-rows.test.tsmounts two viewers (panespane-left,pane-right) over one store: both show the node, an edit in one appears in the other, and the other pane stays a view (no editor).test:changedpasses (Happy-DOM 5810, scripts, Chromium 261); svelte-check, eslint, design tokens, effect allowlist (cap unchanged, no effect added) clean.Unsaved placeholder decision
The blank row of an empty page is not in the store until the first keystroke (two panes on the same empty node must not share one id, so it stays viewer-local rather than being written to the store). A row for it reads as an empty text node:
readRowNode(id)returns the stored node, elseblankRowNode(id), inrow-node-read.ts. That function is the only definition of what a placeholder is; the viewer calls it too to build the node it stores on promotion, so the row and the promoted node cannot drift. The viewer keeps only the placeholder's id (placeholderId). Store-held placeholders (createUnsavedPlaceholder) are in the store and read normally. A code comment inrow-node-read.tsstates this.Behaviour check
outline-viewer-rows.test.tsdrives the real viewer in Chromium: typing, Enter split, Backspace merge and delete, ArrowDown, Tab/Shift+Tab, collapse,- [ ]type conversion, empty-page placeholder promotion, two panes. It was written against current main first and passes there unchanged, then after each commit. Mutation-checked by removing NodeRow'sonCreateNewNode,onNavigateArrow,onIndentNode,onDeleteNodeandonCombineWithPreviousbindings (each fails its test) and by changing the blank node's content.What is left / notes
nodeType(to hide types owned by the parent's viewer), so it re-runs, in O(rows), on a content edit; it returns the same array so nothing downstream changes. Removing that read needs a per-node type source in the store (a design decision), so it is not done here.MergeNodesCommanddecides merge vs delete from the textarea'stextContent(always empty for a real textarea), so Backspace at the start of a non-empty row goes throughonDeleteNode, notonCombineWithPrevious. The browser test setstextContentto reach the merge branch.content/nodeTypeprops to wrappers now seed the store (seedStoredNode,changeStoredNodein test helpers); the test-extension fixture node reads vianodes.getNode.pin-guardallowlist:row-node-read.tsreplaces theperson-node/checkbox-nodeentries (they no longer callgetNode).🤖 Generated with Claude Code