Skip to content

Add webcam mirror toggle#633

Open
AjTheSpidey wants to merge 2 commits into
siddharthvaddem:mainfrom
AjTheSpidey:codex/webcam-mirror-toggle
Open

Add webcam mirror toggle#633
AjTheSpidey wants to merge 2 commits into
siddharthvaddem:mainfrom
AjTheSpidey:codex/webcam-mirror-toggle

Conversation

@AjTheSpidey
Copy link
Copy Markdown
Contributor

@AjTheSpidey AjTheSpidey commented May 21, 2026

Fixes #632.

Added a Mirror webcam switch in the editor layout panel. When it is on, the webcam flips in the preview and the same flip is used during GIF/MP4 export, so the saved file matches what you see while editing.

Tested locally:

  • npx biome check --write on the touched files
  • npx vitest --run src/components/video-editor/projectPersistence.test.ts src/lib/exporter/frameRenderer.test.ts
  • npm run build-vite

One note: full npm run lint still hits existing formatter/line-ending errors in untouched repo files, so I kept the check scoped to the files changed here.

Summary by CodeRabbit

  • New Features

    • Added a "Mirror webcam" toggle in the settings panel.
    • Mirrored webcam effect shown in playback and applied to video/GIF exports.
    • Mirror setting is saved with projects and restored on load.
  • Localization

    • Added "Mirror webcam" translations across multiple languages.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb289bb3-492d-4fe0-9ca3-7c4ee81644b3

📥 Commits

Reviewing files that changed from the base of the PR and between 411f9a3 and e5f023c.

📒 Files selected for processing (15)
  • src/components/video-editor/SettingsPanel.tsx
  • src/i18n/locales/ar/settings.json
  • src/i18n/locales/en/settings.json
  • src/i18n/locales/es/settings.json
  • src/i18n/locales/fr/settings.json
  • src/i18n/locales/it/settings.json
  • src/i18n/locales/ja-JP/settings.json
  • src/i18n/locales/ko-KR/settings.json
  • src/i18n/locales/ru/settings.json
  • src/i18n/locales/tr/settings.json
  • src/i18n/locales/vi/settings.json
  • src/i18n/locales/zh-CN/settings.json
  • src/i18n/locales/zh-TW/settings.json
  • src/lib/exporter/frameRenderer.test.ts
  • src/lib/exporter/webcamFrameDrawing.ts
✅ Files skipped from review due to trivial changes (6)
  • src/i18n/locales/vi/settings.json
  • src/i18n/locales/en/settings.json
  • src/i18n/locales/es/settings.json
  • src/i18n/locales/ja-JP/settings.json
  • src/i18n/locales/zh-CN/settings.json
  • src/i18n/locales/ar/settings.json

📝 Walkthrough

Walkthrough

PR implements horizontal webcam mirroring across the entire app: adds a mirror toggle to SettingsPanel, threads the setting through editor state and project persistence, applies live preview mirroring via CSS transform in VideoPlayback, and exports mirrored frames via a new canvas utility in GIF and MP4 outputs.

Changes

Webcam Mirroring Feature

Layer / File(s) Summary
Core types and default constant
src/components/video-editor/types.ts, src/lib/exporter/webcamFrameDrawing.ts
Adds DEFAULT_WEBCAM_MIRRORED constant and introduces WebcamFrameCrop and WebcamCanvasContext.
Canvas drawing utility + tests
src/lib/exporter/webcamFrameDrawing.ts, src/lib/exporter/frameRenderer.test.ts
Implements drawWebcamFrameImage with optional horizontal mirroring and unit tests for normal, mirrored, and failure paths.
Export pipeline integration
src/lib/exporter/frameRenderer.ts, src/lib/exporter/gifExporter.ts, src/lib/exporter/videoExporter.ts
Replaces inlined webcam draw with drawWebcamFrameImage and threads webcamMirrored through FrameRenderer, GifExporter, and VideoExporter.
Editor state and project persistence
src/hooks/useEditorHistory.ts, src/components/video-editor/projectPersistence.ts, src/components/video-editor/projectPersistence.test.ts
Adds webcamMirrored: boolean to editor/project state, initializes default, normalizes loaded projects, and tests normalization behavior.
UI controls, preview rendering, and wiring
src/components/video-editor/SettingsPanel.tsx, src/components/video-editor/VideoPlayback.tsx, src/components/video-editor/VideoEditor.tsx
Adds mirror toggle to SettingsPanel, applies scaleX(-1) to webcam preview in VideoPlayback when enabled, and threads the setting through VideoEditor into saves/exports.
Localization updates
src/i18n/locales/*/settings.json
Adds mirrorWebcam (and related noWebcam/webcamSize adjustments) to multiple locale files for the new UI label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • siddharthvaddem/openscreen#241: Modifies webcam rendering/layout plumbing in overlapping UI and export areas; likely related to layout+render integration.

Suggested reviewers

  • siddharthvaddem

Poem

the webcam gets a little mirror, a tiny flip of fate
from toggle in the panel to canvas it migrates
preview wears a scaleX, exports follow suit
a neat thin feature, lowkey cursed but cute ✨

🚥 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 captures the main feature: adding a webcam mirror toggle. It's specific enough to convey the change and matches the PR's core objective.
Description check ✅ Passed The description covers the purpose (fixes #632), what was done (mirror switch in layout panel), behavior (flip in preview and export), and testing steps. While it doesn't follow the template's full structure, it provides sufficient detail for understanding the change.
Linked Issues check ✅ Passed The PR fully addresses issue #632's request for a horizontal flip/mirroring toggle for the webcam. The implementation includes the toggle in the UI, preview mirroring, and export consistency.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to webcam mirroring functionality: UI controls, state management, canvas rendering, exporter configs, and i18n strings. No unrelated refactoring or feature creep detected.

✏️ Tip: You can configure your own custom pre-merge checks in the 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/video-editor/SettingsPanel.tsx`:
- Around line 1194-1199: The "Mirror webcam" label and its aria-label are
hardcoded; replace both with your i18n lookup (e.g., use the t function from
your translation hook) so the text and aria-label are localized. In
SettingsPanel (where webcamMirrored and onWebcamMirroredChange are used) change
"Mirror webcam" to something like t('settings.mirrorWebcam') and the Switch
aria-label to t('settings.mirrorWebcamAria') (and add those keys to the locale
files), ensuring you import/use the existing translation hook (e.g., const { t }
= useTranslation()) in the component.

In `@src/lib/exporter/webcamFrameDrawing.ts`:
- Around line 20-26: The mirrored branch in webcamFrameDrawing uses ctx.save(),
ctx.translate(...), ctx.scale(...), ctx.drawImage(...), then ctx.restore(); but
if drawImage throws the transform leaks—wrap the transform and draw in a
try/finally so ctx.restore() always runs; specifically locate the mirrored
handling block that calls ctx.save(), ctx.translate, ctx.scale and ctx.drawImage
and ensure restore() is invoked in finally before returning from the function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25b5b6c5-a18f-4633-ab71-fa740eb019d9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7f498 and 411f9a3.

📒 Files selected for processing (12)
  • src/components/video-editor/SettingsPanel.tsx
  • src/components/video-editor/VideoEditor.tsx
  • src/components/video-editor/VideoPlayback.tsx
  • src/components/video-editor/projectPersistence.test.ts
  • src/components/video-editor/projectPersistence.ts
  • src/components/video-editor/types.ts
  • src/hooks/useEditorHistory.ts
  • src/lib/exporter/frameRenderer.test.ts
  • src/lib/exporter/frameRenderer.ts
  • src/lib/exporter/gifExporter.ts
  • src/lib/exporter/videoExporter.ts
  • src/lib/exporter/webcamFrameDrawing.ts

Comment thread src/components/video-editor/SettingsPanel.tsx Outdated
Comment thread src/lib/exporter/webcamFrameDrawing.ts
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.

[Feature]: Flip webcam video (horizontal / mirroring)

1 participant