refactoring#12
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the mainview video editor by extracting previously monolithic App.tsx logic into dedicated hooks (useVideoEditor, useFFmpeg, useElectrobun), shared utilities (helpers, constants, env), and focused UI components for the landing/editor/download flows.
Changes:
- Extracted video editing state + export orchestration into
useVideoEditor, with separate WASM FFmpeg and Electrobun RPC hooks. - Split UI into page-level components (
LandingPage,EditorPage,DownloadPage) and smaller reusable components (encoder/export controls, drop zone, header, toggles). - Centralized constants/environment detection/helpers that were previously embedded in
App.tsx.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mainview/hooks/useVideoEditor.ts | New hook encapsulating editor state and export flow (WASM + native). |
| src/mainview/hooks/useFFmpeg.ts | New hook for loading/probing/exporting via FFmpeg WASM. |
| src/mainview/hooks/useElectrobun.ts | New hook for Electrobun RPC init + hardware encoder detection. |
| src/mainview/helpers.ts | New shared helper functions extracted from App.tsx. |
| src/mainview/env.ts | New environment detection (standalone + mac). |
| src/mainview/constants.ts | New shared constants for formats/codecs/FFmpeg core URL. |
| src/mainview/components/ToggleSwitch.tsx | New reusable switch UI for encoder toggles. |
| src/mainview/components/Timeline.tsx | Minor cleanup (comment removals / small formatting). |
| src/mainview/components/Player.tsx | Minor cleanup (comment removals / small formatting). |
| src/mainview/components/LandingPage.tsx | New landing screen composing drop zone + marketing/download CTA. |
| src/mainview/components/Header.tsx | New top header/navbar extracted from App.tsx. |
| src/mainview/components/FileDropZone.tsx | New drop zone component extracted from App.tsx. |
| src/mainview/components/ExportPanel.tsx | New export status + action panel extracted from App.tsx. |
| src/mainview/components/EncoderSettings.tsx | New encoder settings sidebar extracted from App.tsx. |
| src/mainview/components/EditorPage.tsx | New editor layout composing Player/Timeline/Settings/Export. |
| src/mainview/components/DownloadPage.tsx | New download/install instructions page extracted from App.tsx. |
| src/mainview/components/BitrateHandler.tsx | New bitrate + target file size component extracted from App.tsx. |
| src/mainview/App.tsx | Slimmed down to composition + wiring via useVideoEditor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+8
to
+9
| const { electroview, supportedEncoders, isStandalone } = useElectrobun(); | ||
| const { wasmLoaded, loadWasmFFmpeg, probeWithWasm, exportWasm } = useFFmpeg(); |
Comment on lines
+117
to
+123
| const fullArgs = [ | ||
| "-i", | ||
| inputFilename, | ||
| ...ffmpegArgs, | ||
| ...codecOverrides, | ||
| outputFilename, | ||
| ]; |
Comment on lines
+4
to
+5
| export const getFileExt = (name: string): string => | ||
| (name.split(".").pop() || "mp4").toLowerCase(); |
Comment on lines
+49
to
+59
| <div | ||
| className={`border-2 border-dashed rounded-xl p-12 text-center cursor-pointer transition-all duration-200 ${ | ||
| isDragging | ||
| ? "border-mocha-mauve bg-mocha-mauve/10 scale-[1.02]" | ||
| : "border-mocha-surface2 hover:border-mocha-overlay0" | ||
| }`} | ||
| onDrop={handleDrop} | ||
| onDragOver={handleDragOver} | ||
| onDragLeave={() => setIsDragging(false)} | ||
| onClick={handleClick} | ||
| > |
Comment on lines
+7
to
+13
| export const ToggleSwitch = ({ checked, onChange, disabled }: ToggleSwitchProps) => ( | ||
| <button | ||
| type="button" | ||
| role="switch" | ||
| aria-checked={checked} | ||
| disabled={disabled} | ||
| onClick={onChange} |
Comment on lines
+128
to
+130
| <p className="text-xs text-mocha-subtext0"> | ||
| and don't forget to <a href="https://github.com/ValentinRapp/yafw" target="_blank" rel="noopener noreferrer" className="text-mocha-mauve hover:underline font-bold">star the project on github</a> 😉 | ||
| </p> |
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.
No description provided.