Skip to content

feat: implement onEditCommit host callback (spec §6.2) - #207

Closed
timurbazhirov wants to merge 1 commit into
feat/upgrade-2026-07-11-separatedfrom
feat/editor-oneditcommit-callback
Closed

feat: implement onEditCommit host callback (spec §6.2)#207
timurbazhirov wants to merge 1 commit into
feat/upgrade-2026-07-11-separatedfrom
feat/editor-oneditcommit-callback

Conversation

@timurbazhirov

Copy link
Copy Markdown
Member

Summary

Completes a host-API gap the TB-persona review of #204 flagged: onEditCommit was listed in docs/design/interactive-editor-spec.md §6.2 (P1 scope, alongside onSelectionChanged/onEditModeChanged) but never actually implemented — only onUpdate's every-edit, source-agnostic channel existed. That's exactly the flood that broke materials-designer's redux history integration with the old modal editor in the first place.

  • Threads a source string through every commit path down to onStructureModified(material, source) in the mixin: "drag" (direct body-drag) vs "gizmo" (TransformControls-driven, translate or rotate alike), "add", "remove", "clone".
  • ThreeDEditor.jsx forwards this to a new onEditCommit(material, {source}) prop, and adds "coordinate-input"/"element-input" for its own typed-panel edits and "undo"/"redo" for handleUndo/handleRedo (which bypass the shared commit path entirely).
  • Extends the spec's original 7-value source enum with "element-input" and "clone", since those two features postdate when §6.2 was written.
  • Fixes a latent bug in tests/helpers/editor.js's simulateAtomDrag: its onStructureModified interceptor only forwarded the first (material) argument, silently dropping source — would have masked this working correctly for the direct-drag path specifically.

Test plan

  • npx tsc --noEmit clean
  • npx eslint clean (pre-existing any warnings only)
  • Full Jest suite green (175/177, 2 pre-existing skips) — 12 new tests covering every source value at both the mixin level (onStructureModified's second argument) and the component level (onEditCommit's {source} shape), plus one confirming the prop is optional
  • npm run build clean

🤖 Generated with Claude Code

Completes the host-API gap the TB-persona review flagged: onEditCommit was
listed in spec §6.2 (P1 scope, alongside onSelectionChanged/
onEditModeChanged) but never implemented - only onUpdate's every-edit,
source-agnostic channel existed, which is exactly the flood that broke
materials-designer's redux history integration in the old modal editor.

Threads a `source` string through every commit path down to
onStructureModified(material, source): the mixin's commitMovedAtom_/
commitMovedAtoms_ now tag "drag" (direct body-drag, endAtomDrag_) vs
"gizmo" (TransformControls "mouseUp" listener, translate or rotate alike);
addAtom/removeSelectedAtom(s)/cloneSelectedAtoms tag "add"/"remove"/"clone".
ThreeDEditor.jsx forwards this to a new onEditCommit(material, {source})
prop via _applyMaterialToViewer, and adds "coordinate-input"/"element-input"
for its own typed-panel edits and "undo"/"redo" for handleUndo/handleRedo
(which bypass handleStructureModified entirely). Extends spec §6.2's
original 7-value source enum with "element-input" and "clone" for this
round's type-to-change and clone-atom features, which postdate the enum.

Also fixes tests/helpers/editor.js's simulateAtomDrag, whose
onStructureModified interceptor only forwarded the first (material)
argument - silently dropping source and would have masked this feature
working correctly for the direct-drag path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member Author

Closing — consolidated into #216 (then #214 on top).

Verified contained: this PR's head 28566da3 is a direct ancestor of claude/uiux-p2-figure-export. The onEditCommit callback from here is what U-9's transient "Moved atom · Ctrl + Z to undo" hint reads from, so it is very much still live — just reviewed in one place now.

The branch feat/editor-oneditcommit-callback stays on the remote.


Generated by Claude Code

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