Skip to content

fix(studio): break all 7 circular dependency cycles + fix rules-of-hooks violation#1422

Merged
miguel-heygen merged 1 commit into
mainfrom
fix/studio-circular-deps
Jun 13, 2026
Merged

fix(studio): break all 7 circular dependency cycles + fix rules-of-hooks violation#1422
miguel-heygen merged 1 commit into
mainfrom
fix/studio-circular-deps

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Summary

  • Eliminates all 7 circular dependency cycles in packages/studio/src/
  • Fixes a runtime rules-of-hooks violation (useMemo after early return in App.tsx) that caused "Rendered more hooks than during the previous render" error

Changes

Rules-of-hooks fix: Moved useMemo for timelineToolbar before the early return in App.tsx so hook count is stable across renders.

Circular dep fixes (14 files, net -10 LOC):

  • Extracted shared types to domEditCommitTypes.ts to break useDomEditCommits ↔ useDomEditPositionPatchCommit/useDomEditTextCommits cycles
  • Restructured DomEditOverlay gesture imports to break overlay ↔ gesture handler cycles
  • Changed barrel file imports (../player) to direct source imports to break player/index.ts cycles
  • Extracted COMPOSITION_ROOT_REGEX to compositionPatterns.ts to break studioHelpers ↔ timelineAssetDrop cycle
  • Restructured useTimelineEditing ↔ useRazorSplit imports

Verification

  • npx madge --circular packages/studio/src/App.tsx0 circular dependencies (was 7)
  • bun run --cwd packages/studio typecheck → pass
  • bun run --cwd packages/studio test → 796 tests pass
  • Browser QA: studio loads, play/pause works, composition switching works, timeline clip selection works, code editor works, inspector panel works

Test plan

  • bun run --cwd packages/studio typecheck passes
  • bun run --cwd packages/studio test passes
  • Studio loads without "Rendered more hooks" error
  • Play/pause, composition switch, element selection all work

@github-actions

Copy link
Copy Markdown

Fallow audit report

Found 26 findings.

Dead code (3)
Severity Rule Location Description
major fallow/unused-export packages/studio/src/hooks/useDomEditCommits.ts:18 Re-export 'GSAP_CSS_FALLBACK_BLOCKED_MESSAGE' is never imported by other modules
major fallow/unused-type packages/studio/src/hooks/useDomEditCommits.ts:52 Type re-export 'PersistDomEditOperations' is never imported by other modules
major fallow/unused-export packages/studio/src/utils/studioHelpers.ts:175 Re-export 'COMPOSITION_ROOT_OPEN_TAG_RE' is never imported by other modules
Duplication (8)
Severity Rule Location Description
minor fallow/code-duplication packages/studio/src/components/editor/propertyPanelFill.tsx:24 Code clone group 1 (6 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/components/editor/propertyPanelFill.tsx:34 Code clone group 2 (15 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/hooks/gsapScriptCommitHelpers.ts:58 Code clone group 3 (8 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/hooks/useDomEditCommits.ts:36 Code clone group 3 (8 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/hooks/useDomEditTextCommits.ts:208 Code clone group 4 (9 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/hooks/useDomEditTextCommits.ts:265 Code clone group 4 (9 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/utils/studioHelpers.ts:27 Code clone group 1 (6 lines, 2 instances)
minor fallow/code-duplication packages/studio/src/utils/studioHelpers.ts:37 Code clone group 2 (15 lines, 2 instances)
Health (15)
Severity Rule Location Description
minor fallow/high-cyclomatic-complexity packages/studio/src/components/editor/DomEditOverlay.tsx:71 'DomEditOverlay' has cyclomatic complexity 26 (threshold: 20)
minor fallow/high-crap-score packages/studio/src/components/editor/DomEditOverlay.tsx:96 'selectionShapeStyles' has CRAP score 49.5 (threshold: 30.0, cyclomatic 13)
minor fallow/high-crap-score packages/studio/src/components/editor/DomEditOverlay.tsx:256 'handleOverlayMouseDown' has CRAP score 43.1 (threshold: 30.0, cyclomatic 12)
minor fallow/high-crap-score packages/studio/src/components/editor/DomEditOverlay.tsx:350 '<arrow>' has CRAP score 43.1 (threshold: 30.0, cyclomatic 12)
minor fallow/high-crap-score packages/studio/src/hooks/timelineEditingHelpers.ts:44 'patchIframeDomTiming' has CRAP score 31.6 (threshold: 30.0, cyclomatic 10)
minor fallow/high-crap-score packages/studio/src/hooks/timelineEditingHelpers.ts:64 'resolveResizePlaybackStart' has CRAP score 31.6 (threshold: 30.0, cyclomatic 10)
major fallow/high-crap-score packages/studio/src/hooks/useDomEditTextCommits.ts:61 'handleDomStyleCommit' has CRAP score 79.4 (threshold: 30.0, cyclomatic 17)
minor fallow/high-crap-score packages/studio/src/hooks/useDomEditTextCommits.ts:151 'handleDomHtmlAttributeCommit' has CRAP score 31.6 (threshold: 30.0, cyclomatic 10)
major fallow/high-crap-score packages/studio/src/hooks/useDomEditTextCommits.ts:190 'handleDomTextCommit' has CRAP score 63.6 (threshold: 30.0, cyclomatic 15)
major fallow/high-crap-score packages/studio/src/hooks/useDomEditTextCommits.ts:252 'commitDomTextFields' has CRAP score 71.3 (threshold: 30.0, cyclomatic 16)
major fallow/high-crap-score packages/studio/src/hooks/useRazorSplit.ts:53 'splitGsapAnimations' has CRAP score 72.0 (threshold: 30.0, cyclomatic 8)
critical fallow/high-crap-score packages/studio/src/hooks/useRazorSplit.ts:224 'handleRazorSplitAll' has CRAP score 210.0 (threshold: 30.0, cyclomatic 14)
minor fallow/high-crap-score packages/studio/src/utils/clipboardPayload.ts:62 'insertAsSibling' has CRAP score 43.1 (threshold: 30.0, cyclomatic 12)
minor fallow/high-crap-score packages/studio/src/utils/clipboardPayload.ts:113 'findClosingTagPosition' has CRAP score 37.1 (threshold: 30.0, cyclomatic 11)
minor fallow/high-cognitive-complexity packages/studio/src/utils/studioHelpers.ts:119 'findMatchingTimelineElementId' has cognitive complexity 18 (threshold: 15)

Generated by fallow.

@miguel-heygen miguel-heygen force-pushed the fix/studio-circular-deps branch 5 times, most recently from 8afedab to 403daca Compare June 13, 2026 23:12
@miguel-heygen miguel-heygen force-pushed the fix/studio-circular-deps branch from 403daca to 24de1c6 Compare June 13, 2026 23:15
@miguel-heygen miguel-heygen merged commit a241f25 into main Jun 13, 2026
41 of 42 checks passed
@miguel-heygen miguel-heygen deleted the fix/studio-circular-deps branch June 13, 2026 23:23
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