refactor(editor): move the Replace-audio modal to src/replace-audio.js (R2, step 32) - #184
Merged
Merged
Conversation
…s (R2, step 32) Extract the replace-audio flow (swap the session's audio track from a file or a YouTube URL, decode, and re-sync playback) out of the src/main.js monolith into a new native ES module. Clean self-contained leaf: 4 window.editor* handlers re-attached by main.js, 0 back-exports, no new host hooks (draw/updateTimeDisplay already exist). Removed 2 now-dead main.js imports (_uploadAudioForMode, createState) that served only the moved code. main.js drops ~111 lines. 33 modules. Verified: 90/90 JS suites pass, ESLint gate clean (0 errors), strict no-undef clean on replace-audio.js, Codex preflight 0 issues. New headless harness drives the modal: 4 handlers bound, open/close, file/YouTube mode toggle (input visibility + active button), and both apply-with-no-input pre-check messages (editorApplyReplaceAudio routing into the module), zero page errors. Negative-checked by dropping a re-attach. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe replace-audio modal flow moves from ChangesReplace-audio flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
What
Step 32 of the R2 module-extraction refactor: move the Replace-audio modal out of
src/main.jsinto a new native ES modulesrc/replace-audio.js.Swap the session's audio track from a local file or a YouTube URL, decode it, and re-sync playback state (buffer, cursor, scroll bounds, play/sync buttons).
How the seam is drawn
Clean self-contained leaf:
window.editor*handlers (editorShowReplaceAudioModal/editorHideReplaceAudioModal/editorSetReplaceAudioMode/editorApplyReplaceAudio) become named exports, re-attached bymain.js.draw/updateTimeDisplayalready exist, reached throughhost).audio.js(loadAudio/stopPlayback),create.js(_uploadAudioForMode/createState),loop.js(_editorApplyScrollBounds),state,ui.main.jsimports (_uploadAudioForMode,createState) that served only the moved code.main.js drops ~111 lines. 33 modules.
Verification
no-undefclean onreplace-audio.js.verify_replace_audio.py): 4 handlers bound, modal opens (gated onS.sessionId) and closes, file/YouTube mode toggle (input visibility + active button), and both apply-with-no-input pre-check messages ("Choose a file" / "Enter a YouTube URL" — provingeditorApplyReplaceAudioroutes into the module and itscreate.jsimport resolves), zero page errors. Negative-checked by dropping a re-attach.🤖 Generated with Claude Code
Summary by CodeRabbit