Skip to content

refactoring#12

Merged
ValentinRapp merged 2 commits into
mainfrom
dev
Jun 5, 2026
Merged

refactoring#12
ValentinRapp merged 2 commits into
mainfrom
dev

Conversation

@ValentinRapp

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 5, 2026 14:49
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
yafw Ready Ready Preview, Comment Jun 5, 2026 2:49pm

@ValentinRapp ValentinRapp merged commit 6ca7cd4 into main Jun 5, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/mainview/helpers.ts
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>
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.

2 participants