Skip to content

Remove remaining dead viewer workarounds, wrapper content writes and state-writing effects (c6cb44c4 part 2) - #4414

Merged
mstomar125 merged 3 commits into
mainfrom
c6cb44c4-part2
Dec 2, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
c6cb44c4-part2

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Second part of c6cb44c4. One PR (about 30 files, mostly small deletions); the commits are per item group.

What changed

  1. Viewer (base-node-viewer): both structure-tree-to-store fallbacks removed. sharedNodeStore.getNodesForParent reads the same structureTree, so it never returned ids the tree lacked (git history: added in the dual-store refactor Refactor BaseNodeViewer to use dual reactive stores #572, kept through the store consolidation). The split path's "update the original node's content to itself to trigger focus" is removed: createNode already focuses the original node when focusNewNode is false (covered by the existing reactive-node-service test "createNode with focusNewNode=false keeps focus on original node"). Existing viewer, merge, enter-key and backspace tests pass (unit and Chromium).
  2. textarea controller: the cleanup-only $effect.pre is gone; the element effect now owns create and destroy (tracks only the element, teardown destroys once). New test counts destroy calls (0 while mounted and re-rendered, 1 on unmount); mutation (teardown without destroy) fails it.
  3. Node wrappers (header, quote, ordered-list, code-block, table, horizontal-line, task) no longer assign to content; content is a plain prop in every wrapper and in base-node, and bind:content became {content}. Task-node uses the cleaned value directly. New test: header wrapper reports the edit as an event and keeps the passed content until the parent changes it; mutation (re-adding the assignment) fails it.
  4. remote-tool-confirmation-card: two Chromium tests, credential change and digest change after the card is intact reset the check and remove the choices, onAnswer never called. Mutations: not tracking credentials, not tracking the digest; each fails its test.
  5. State-writing effects, 13 to 6 (cap lowered to 6):
    • database-name-dialog and collection-move-dialog: state moved into form components mounted with the dialog content (seeded per open, no effect). New collection-move-dialog test (3 cases); mutation (reseed effect) fails the keep-pick case. The existing database-name tests still pass.
    • person-schema-form: two drafts are writable $derived.
    • relationship-viewer-modal: two effects replaced by applyView (prune stale expansion and a stale picker when a view is applied). New test; mutation (no prune) fails it.
    • node-ref-preview: position and placed class written to the element, no coords state. New placement test; mutation fails it. This one is behavior-preserving, so the test also passes on main.
    • The allowlist reasons now say why each remaining one stays.

Effects that stay (need a design decision)

  • remote-tool-confirmation-card intact (async digest result) and armed (arming timer)
  • pane-content viewer loading
  • kanban-view reveal seeding
  • relationship-viewer-modal load and reset on the bound open prop
  • import-options-modal reset and listener on the bound open prop

Not seen by the checker

  • typed-form-shell relationships.load: it writes state inside NodeRelationshipsState from an effect keyed on the node and its persisted status (placeholder promotion). Moving it needs the persisted-state signal as an event, so it stays.
  • code-block-node render() / clearPreview(): the effects push into the renderer, whose results are async (ADR-049); their synchronous resets are its own state. Stays; I corrected the comment that claimed no state is written.
  • ai-chat-pty-session listener: the callback is a platform event handler setting sessionEnded, not a derivation. Not a violation.

Issue c6cb44c4 criteria

Met: viewer workarounds and both fallbacks gone; duplicate cleanup gone and destroyed once; no wrapper assigns content and content is not bindable; cap lowered. Not part of this PR: the docs statements (docs repo, done by the owner).

Verification

Full unit run (348 files) and the confirmation-card Chromium file pass; quality:check and scripts tests pass; push check passed. Docs untouched.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE at b650289

Independent review, code only, at the required head.

Verified

  • Viewer fallbacks: both removed getNodesForParent fallbacks were dead. sharedNodeStore.getNodesForParent is structureTree.getChildren(id) mapped through the node map, and the viewer imports the same structureTree instance, so when getChildren is empty the fallback is empty too.
  • Split focus: with focusOriginalNode true, base-node-viewer.svelte passes focusNewNode=false to createNode. reactive-node-service.svelte.ts createNode ends with if (!shouldFocusNewNode && afterNode) focusManager.focusNode(afterNodeId, paneId). The removed updateNodeContent(afterNodeId, sameContent) was a no-op write, so focus lands where it did.
  • Textarea controller: only the element is tracked and nodeId/type/pane are read once under untrack, exactly as before. One intended difference: an element swapped A->B without passing through null used to keep a controller on the stale element, and now gets a fresh one. Destroy is idempotent (listeners and measurement node only), and base-node's onDestroy still calls the wrapper destroy, so a double call is harmless.
  • Node wrappers: no bind:content exists anywhere in src, so dropping $bindable cannot throw. The wrappers no longer assign content; task-node now uses cleanedContent in taskStateChanged (same value as before).
  • Dialogs: bits-ui is 1.8.0 and Dialog.Content renders through PresenceLayer with present={open || forceMount}. No forceMount is used in src/lib, so the form mounts fresh on each open. The initial render, prop change while open (untrack seed) and Cancel/confirm paths match the old effects.
  • Person form: $derived(firstName) is a writable derived (svelte 5.56.8), and it resets only when the committed value changes, as the old effect did. Typing overrides it until then.
  • Relationship modal: applyView runs the same prune and closeAdd checks as the two removed effects. view is assigned only in load, reload and reset, and reset clears addGroupKey. An expanded-row key cannot become stale between loads.
  • Node-ref preview: the effect's dependencies are unchanged, including cardEl, which still re-runs it when the {#if} re-creates the card. The static class attribute is not rewritten by Svelte, and the :global modifier is correct.
  • Confirmation card: its source is unchanged, only tests were added. Digest, credentials, summary and arguments are all read in the effect, which sets intact = null synchronously, and answer() and armed require intact === true. Mutation check: untracking digest makes "a digest change after intact" fail, and untracking credentialsKey makes "a credential change after intact" fail (Chromium).
  • Allowlist: bun run test:scripts gives 1729 pass and 0 fail, and the checker prints "Every effect is covered". There are 6 writesState entries, matching the cap of 6, and the test pins the cap to the count.
  • Tests: all 6 touched test files pass, including the Chromium file (29/29). The whole desktop-app vitest suite passed (348 files, 5820 tests). src/tests/components passed. navigation-sidebar-collection-moves alone passed (38/38). I could not reproduce the 10 failures in any run. The PR touches nothing the sidebar test imports apart from the dialogs, so it looks like load or timing and not this PR. I did not run main for comparison.

Blocking: none.

Should-fix

  • collection-move-form.svelte:15, test collection-move-dialog.test.ts. The new tests do not pin the seed. Replacing untrack(() => targets[0]?.id ?? '') with '' leaves all 3 tests green, because the browser selects the first option by default and the first test picks a value itself. Add an assertion that Move is enabled right after open with no interaction.
  • relationship-viewer-modal.svelte applyView. Deleting the closeAdd() line also leaves all 9 tests green. Add a test that reloads a view without the add-picker's group.

Nit

  • database-name-form.svelte and collection-move-form.svelte. The "fresh on every open" behavior relies on unmount at close. With an exit animation, bits-ui keeps the content mounted (unmountSuspended) until animationend, about 200ms. A reopen inside that window keeps the old draft or pick, where the old effect would reseed. A person cannot realistically do that, and jsdom has no animation, so the tests cannot see it. A comment or a {#key} on the open count would make it exact.
  • textarea-controller-destroy-once.test.ts, the node-ref, relationship and collection tests. These are equivalence pins: the old code passes them too. Only the header-node and card tests fail when the fix is reverted, so the "exactly once" test cannot detect a regression to the old shape.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Merge queue: #4414 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing origin/main and running bun run test:changed, fix, push, and re-run bun run merge 4414.

cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:warning=sccache: error: Server startup failed: File exists (os error 17)
  cargo:warning=Run with SCCACHE_LOG=debug SCCACHE_NO_DAEMON=1 to get more information
  exit status: 2
  cargo:warning=ToolExecError: command did not execute successfully (status code exit status: 2): env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "/Users/mayanktomar/nodespace/core/.tools/bin/sccache" "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=27.2" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/include" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/pregenerated" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-gfull" "-DNDEBUG" "-o" "/Users/mayanktomar/nodespace/core/.claude/worktrees/_gate/target/debug/build/ring-02464c93aa49b344/out/0bbbd18bda93c05b-aes_nohw.o" "-c" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/crypto/fipsmodule/aes/aes_nohw.c"cargo:warning=sccache: error: Server startup failed: File exists (os error 17)
  cargo:warning=Run with SCCACHE_LOG=debug SCCACHE_NO_DAEMON=1 to get more information
  exit status: 2
  cargo:warning=ToolExecError: command did not execute successfully (status code exit status: 2): env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "/Users/mayanktomar/nodespace/core/.tools/bin/sccache" "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=27.2" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/include" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/pregenerated" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-gfull" "-DNDEBUG" "-o" "/Users/mayanktomar/nodespace/core/.claude/worktrees/_gate/target/debug/build/ring-02464c93aa49b344/out/00c879ee3285a50d-montgomery.o" "-c" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/crypto/fipsmodule/bn/montgomery.c"
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  exit status: 0
  --- stderr
  error occurred in cc-rs: command did not execute successfully (status code exit status: 2): env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "/Users/mayanktomar/nodespace/core/.tools/bin/sccache" "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-macosx" "-mmacosx-version-min=27.2" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/include" "-I" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/pregenerated" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-gfull" "-DNDEBUG" "-o" "/Users/mayanktomar/nodespace/core/.claude/worktrees/_gate/target/debug/build/ring-02464c93aa49b344/out/00c879ee3285a50d-montgomery.o" "-c" "/Users/mayanktomar/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/crypto/fipsmodule/bn/montgomery.c"
error: script "shape:check" exited with code 101
[stage exited with code 101]

  full output: /var/folders/3w/y9kj522n1_j9wqmt6vl_sb6r0000gp/T/nodespace-gate-logs/_gate-merge-2026-12-02T09-34-07-193Z/shape-check-built-in-shape-snapshot-and-change-log.log

✗ shape:check (built-in shape snapshot and change log) failed — merge blocked.
  Fix the failure, push, and re-run: bun run merge <PR#>

mstomar125 and others added 3 commits December 2, 2026 10:47
…per content writes

The outline viewer read child ids from the structure tree and fell back to
sharedNodeStore.getNodesForParent, which reads the same tree, so both
fallbacks never returned anything the tree had not. The split path rewrote
the original node's content to itself to trigger focus, but createNode
already focuses the original node when focusNewNode is false.

createTextareaController destroyed its controller from a cleanup-only
pre-effect and from the element effect. The element effect now owns the
create/destroy pair and tracks only the element.

Node wrappers no longer assign to their content prop and content is no
longer bindable; edits leave as contentChanged events and the store value
flows back down.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ionship modal and the node preview

- DatabaseNameDialog and CollectionMoveDialog move their field and choice
  state into a form component mounted with the dialog content, so it starts
  from the initial value on each open instead of being seeded by an effect.
- PersonSchemaForm name drafts are writable derived values that reset when
  the committed value changes.
- RelationshipViewerModal prunes stale expansion and a stale target picker
  when a view is applied, not in two effects.
- NodeRefPreview writes the card position and placed class to the element
  instead of keeping coordinates as reactive state.
- The effect allowlist drops the removed entries, states why each remaining
  state-writing effect stays, and the cap goes from 13 to 6.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant