refactor: split interactive_structure_editor.ts into focused mixins (TB-ARCH-2) - #209
Closed
timurbazhirov wants to merge 1 commit into
Conversation
…TB-ARCH-2) Extract marquee rubber-band selection into a new MarqueeSelectionMixin and group-transform pivot/centroid math plus the group-only halves of the TransformControls change/mouseUp listeners into a new GroupTransformMixin, composed alongside InteractiveStructureEditorMixin in wave.js. The direct-drag lifecycle (beginAtomDrag_/endAtomDrag_/ cancelAtomDrag_) stays in the base mixin - it's a genuinely unified state machine covering all 4 drag shapes at once, and this round's Esc-cancel regression tests are concentrated exactly there, so forcing a single/group split there would trade real correctness coverage for a readability preference. Base file: 1460 -> 1211 lines. Pure refactor: all 181 pre-existing tests pass unchanged, and behavioral equivalence was further verified live against a real (non-jsdom) WebGL Wave instance - marquee-select, group direct-drag, and gizmo group-rotate all independently confirmed correct. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
Member
Author
|
Closing — consolidated into #216 (then #214 on top). Verified contained: this PR's head Worth noting for TB-ARCH-2's own sake: The branch Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
interactive_structure_editor.tswas 1460 lines, flagged by the TB-persona review (TB-ARCH-2) as "still the largest file insrc/mixins/by a wide margin." Extracts the two most cleanly-separable feature areas into their own composed mixins:MarqueeSelectionMixin(src/mixins/marquee_selection.ts) — rubber-band marquee selection:updateMarqueeState_,showMarqueeOverlay_/updateMarqueeOverlay_/hideMarqueeOverlay_,getAtomsInScreenRect_,finishMarqueeSelection_. Fully self-contained, moved verbatim.GroupTransformMixin(src/mixins/group_transform.ts) — group-transform pivot/centroid math (attachPivotToSelection_,computeCentroid_, moved verbatim) plus four newly-extracted helpers:handleGroupPivotChange_andcommitGroupGizmoDrag_(the group-specific halves of the TransformControlschange/mouseUplisteners —initializeEditor()now calls into these instead of inlining the logic),captureGroupDragStartPositions_(also de-duplicates an identical inline snapshot that was repeated inbeginAtomDrag_), andapplyGroupDragDelta_(the group half of the direct-drag pointer-move handler).interactive_editor_constants.tsholdsDRAG_THRESHOLD_PX, needed by both the base mixin's atom-drag threshold and the new marquee mixin's own activation threshold.Waveinwave.jsimmediately beforeInteractiveStructureEditorMixin(whose constructor still runs last and callsinitializeEditor()/initializeSelectionRaycaster(), by which point the two new mixins' constructors have already set their own state fields to defaults).beginAtomDrag_/endAtomDrag_/cancelAtomDrag_(the direct-drag lifecycle) stay in the base mixin. They're a genuinely unified state machine covering all 4 drag shapes (single/group × direct/gizmo) at once, and this round's Esc-cancel regression tests are concentrated exactly there — forcing a single/group split would trade real, hard-won correctness coverage for a readability preference. Seeplan/interactive-editor-spec-plan.md's "Chained PR stack" section for the full writeup.Test plan
tsc --noEmitsurfaced a real narrowing gap the split introduced (group_transform.ts's fields no longer share a class body withtransformControls_/transformDragStartPosition_, so TS couldn't narrowselectionPivot_'s nullability through a compound guard referencing them) — fixed by capturingselectionPivot_in a local before the guard, not suppressed.Waveinstance: marquee-select correctly selects both atoms via a screen-space rectangle; group direct-drag moves both atoms by an identical delta; gizmo group-rotate preserves the centroid and resets the pivot's quaternion after commit.npm run lintclean (0 errors; only pre-existingno-explicit-anywarnings matching this file's established convention).npm run buildclean.🤖 Generated with Claude Code