Skip to content

refactor(editor): extract export start settings#567

Merged
meiiie merged 1 commit into
mainfrom
refactor/editor-export-start-settings
May 22, 2026
Merged

refactor(editor): extract export start settings#567
meiiie merged 1 commit into
mainfrom
refactor/editor-export-start-settings

Conversation

@meiiie
Copy link
Copy Markdown
Collaborator

@meiiie meiiie commented May 22, 2026

Description

Extracts the export-start settings builder from VideoEditor.tsx into a small pure module, exportStartSettings.ts.

Motivation

VideoEditor.tsx should coordinate user intent, not own every export request-building detail. This slice moves the dropdown-to-ExportSettings mapping into a focused, tested function while preserving existing MP4/GIF settings behavior.

Type of Change

  • Refactor
  • Tests

Related Issue(s)

None.

Changes Made

  • Added resolveExportStartSettings for constructing ExportSettings from dropdown state and source dimensions.
  • Preserved MP4 settings mapping for quality, encoding mode, FPS, backend preference, and pipeline model.
  • Preserved GIF settings mapping, including GIF preset dimension resolution via calculateOutputDimensions and GIF_SIZE_PRESETS.
  • Updated VideoEditor.tsx to call the resolver when starting an export from the dropdown.
  • Added focused unit tests for MP4 settings, GIF resized dimensions, and original GIF dimensions.

Scope Note

This PR does not change export execution, export routing, native/NVIDIA behavior, save/finalize behavior, UI copy, project persistence, or packaged build settings. It only extracts the existing dropdown settings construction into a tested pure function.

Testing Guide

  1. Open the editor.
  2. Start an MP4 export from the dropdown and confirm the selected MP4 settings are still applied.
  3. Switch to GIF, choose a size preset, and confirm export still uses the expected GIF dimensions/settings.

Checklist

  • Focused branch from latest main
  • Small architecture slice only
  • Added focused tests
  • Typecheck passes
  • Scoped Biome passes
  • No runtime/export behavior intentionally changed

Local Checks

  • npm test -- src/components/video-editor/exportStartSettings.test.ts src/components/video-editor/exportStatusModel.test.ts src/components/video-editor/mp4ExportSettings.test.ts src/components/video-editor/mp4ExportRouting.test.ts src/components/video-editor/useNvidiaCudaExportOptIn.test.ts
  • npx tsc --noEmit --pretty false
  • npx biome check --formatter-enabled=false src/components/video-editor/VideoEditor.tsx src/components/video-editor/exportStartSettings.ts src/components/video-editor/exportStartSettings.test.ts
  • git diff --check

Runtime/Repro Evidence

Not run. This is a pure settings-construction extraction with no exporter/native/runtime path changes.

Summary by CodeRabbit

  • Bug Fixes

    • Video export settings now correctly preserve MP4-specific values and GIF-specific configurations without data loss.
    • GIF exports properly compute output dimensions based on selected presets and clear format-incompatible fields.
    • The GIF original preset now accurately maintains user-provided source dimensions.
  • Tests

    • Added comprehensive test coverage for export settings initialization across all format and preset combinations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 92bea2e5-2c95-4340-ae03-c6283e7a2950

📥 Commits

Reviewing files that changed from the base of the PR and between 9c29d4c and bf16f05.

📒 Files selected for processing (3)
  • src/components/video-editor/VideoEditor.tsx
  • src/components/video-editor/exportStartSettings.test.ts
  • src/components/video-editor/exportStartSettings.ts

📝 Walkthrough

Walkthrough

The PR extracts export settings initialization logic from VideoEditor.tsx into a new utility function resolveExportStartSettings. The function conditionally populates MP4-specific or GIF-specific fields based on export format, computes GIF output dimensions when needed, and includes comprehensive test coverage validating both export paths.

Changes

Export Settings Resolution

Layer / File(s) Summary
Export settings resolver function
src/components/video-editor/exportStartSettings.ts
Introduces resolveExportStartSettings, which takes source dimensions and export configuration (format, encoding mode, quality, backend, pipeline, frame rate, loop, size preset) and conditionally populates MP4 fields (encodingMode, mp4FrameRate, backendPreference, pipelineModel, quality) only for MP4 exports and gifConfig (width, height, frameRate, loop, sizePreset) only for GIF exports, computing GIF dimensions when format is GIF.
Export settings resolver tests
src/components/video-editor/exportStartSettings.test.ts
Vitest suite with baseOptions fixture and three test cases: verifies MP4 exports preserve MP4 dropdown values and omit gifConfig; verifies GIF format clears MP4 fields and computes gifConfig with correct dimensions; verifies GIF original preset retains source dimensions.
VideoEditor export initialization
src/components/video-editor/VideoEditor.tsx
Imports resolveExportStartSettings and replaces inline ExportSettings construction with a function call, passing source dimensions (with 1920×1080 fallback) and current export UI state (format, encoding, quality, backend, pipeline, GIF settings).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • webadderallorg/Recordly#563: Both PRs touch the MP4 export pipelineModel wiring in VideoEditor.tsx—main PR factors export-start ExportSettings creation around the current pipeline model, while the retrieved PR changes that pipeline model (switching it to "modern" when the NVIDIA CUDA opt-in hook enables it).
  • webadderallorg/Recordly#564: Both PRs refactor VideoEditor.tsx's MP4 export configuration by extracting/centralizing logic that determines pipelineModel and backendPreference (main via resolveExportStartSettings, retrieved via resolveMp4ExportRouting).
  • webadderallorg/Recordly#565: Both PRs refactor VideoEditor.tsx export-settings construction by extracting and centralizing MP4-specific precedence logic into resolver helpers (resolveMp4ExportSettings vs resolveExportStartSettings that also populates MP4 fields like quality/encodingMode/mp4FrameRate), so the changes overlap at the code-path level.

Suggested labels

Checked

Poem

🐰 A rabbit hops through settings cleaner,
Extracting logic, making it leaner,
MP4 or GIF, the choice is clear,
Tests confirm what we hold dear,
Refactored wisdom, far and near! 📹

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(editor): extract export start settings' directly and clearly describes the main refactoring: extracting export settings logic into a dedicated module.
Description check ✅ Passed The description includes all key template sections: Description, Motivation, Type of Change, Testing Guide, and comprehensive Checklist items, providing sufficient context for reviewers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/editor-export-start-settings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@meiiie meiiie merged commit 18e93f7 into main May 22, 2026
3 checks passed
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