Skip to content

refactor(editor): extract NVIDIA export opt-in hook#563

Merged
meiiie merged 1 commit into
mainfrom
refactor/editor-nvidia-export-opt-in-hook
May 22, 2026
Merged

refactor(editor): extract NVIDIA export opt-in hook#563
meiiie merged 1 commit into
mainfrom
refactor/editor-nvidia-export-opt-in-hook

Conversation

@meiiie
Copy link
Copy Markdown
Collaborator

@meiiie meiiie commented May 22, 2026

Description

Extract the NVIDIA CUDA export opt-in runtime state from VideoEditor.tsx into a focused useNvidiaCudaExportOptIn hook.

Motivation

VideoEditor.tsx should not own device capability probing, app-local opt-in persistence, and the toggle enable guard inline. This keeps the editor component closer to UI/export orchestration while the hook owns the native capability side effect boundary introduced by #562.

Type of Change

  • Refactor
  • Tests

Related Issue(s)

Changes Made

  • Added src/components/video-editor/useNvidiaCudaExportOptIn.ts for NVIDIA CUDA availability probing, local setting persistence, and opt-in gating.
  • Added focused tests for availability parsing, opt-in gating, and persisted app setting behavior.
  • Replaced the inline VideoEditor.tsx state/effect/callback block with the hook return values.

Scope Note

  • No UI copy or layout changes.
  • No exporter behavior changes.
  • No native helper, preload, IPC, or packaging changes.
  • No Linux NVIDIA support is added here. Linux/other OS NVIDIA support remains a separate future slice requiring helper packaging, platform probing, packaged smoke, and real-device QA.
  • No Zustand/Redux/global store added; this remains a small controller hook.

Testing Guide

  1. Open MP4 export settings on a non-NVIDIA or unsupported device and confirm the CUDA switch stays hidden.
  2. On a supported Windows NVIDIA packaged/dev setup, confirm the switch still appears under Lightning MP4 export and enabling it still selects the modern pipeline.
  3. Export with the switch off and confirm the normal Lightning fallback path is unchanged.

Checklist

  • One small architectural slice only
  • Behavior-preserving extraction
  • Focused test coverage for moved decisions
  • No generated binaries or local probes included
  • Ready for architecture review

Local Checks

  • npm test -- src/components/video-editor/useNvidiaCudaExportOptIn.test.ts
  • npm test -- electron/ipc/export/native-video.test.ts
  • npm test -- src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts
  • npx tsc --noEmit --pretty false
  • npx biome check --formatter-enabled=false src/components/video-editor/VideoEditor.tsx src/components/video-editor/useNvidiaCudaExportOptIn.ts src/components/video-editor/useNvidiaCudaExportOptIn.test.ts
  • git diff --check

Runtime/Repro Evidence

Not run. This is a renderer hook extraction with no native/preload/IPC contract change. Hardware runtime behavior remains covered by the #562 validation path and should be smoke-tested on Windows NVIDIA before any release claim.

Summary by CodeRabbit

  • Refactor

    • Improved organization of NVIDIA CUDA export settings management.
  • Tests

    • Added comprehensive test coverage for NVIDIA CUDA export opt-in functionality.

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: 5f8213ea-ffb4-49d5-a5f7-8048b1a3fbf5

📥 Commits

Reviewing files that changed from the base of the PR and between 6e466a3 and db0757c.

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

📝 Walkthrough

Walkthrough

This PR extracts NVIDIA CUDA export opt-in logic from VideoEditor.tsx into a dedicated custom hook, reducing component complexity and improving reusability. The new hook handles asynchronous capability detection, state persistence, and export pipeline switching via callbacks.

Changes

NVIDIA CUDA Export Opt-in Hook Extraction

Layer / File(s) Summary
Hook and utility implementation
src/components/video-editor/useNvidiaCudaExportOptIn.ts
Exports useNvidiaCudaExportOptIn hook and helper functions (isNvidiaCudaExportAvailable, resolveNvidiaCudaExportOptIn, loadInitialNvidiaCudaExportOptIn, saveNvidiaCudaExportOptIn) that manage CUDA export opt-in state, query native capabilities asynchronously from window.electronAPI, and persist settings via Electron app storage with optional onEnabled callback support.
VideoEditor integration
src/components/video-editor/VideoEditor.tsx
Removes inline CUDA export state and imports from the component, replaces them with the useNvidiaCudaExportOptIn hook, and wires the hook's onEnabled callback to set exportPipelineModel to "modern" when opt-in is enabled.
Hook and helper tests
src/components/video-editor/useNvidiaCudaExportOptIn.test.ts
Adds Vitest suite covering availability detection, resolution logic with combined state requirements, persistence via mocked Electron app settings, and default behavior when settings are unavailable, with globalThis.electronAPI cleanup after each test.

Possibly related PRs

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hook hops in, neat and clean,
Extracting logic once unseen,
CUDA opt-in finds its place,
Refactored with graceful haste! ✨

🚥 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 clearly and concisely describes the main refactoring change: extracting NVIDIA export opt-in logic into a dedicated hook.
Description check ✅ Passed The PR description covers all template sections with comprehensive details: clear motivation, explicit type of change, related issues, detailed changes, testing guide, and local checks.
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-nvidia-export-opt-in-hook

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 marked this pull request as ready for review May 22, 2026 14:05
@meiiie meiiie merged commit b7449d5 into main May 22, 2026
4 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