Skip to content

fix(recording): preserve browser cursor after WGC fallback#583

Merged
meiiie merged 2 commits into
mainfrom
fix/windows-wgc-browser-fallback-cursor
May 24, 2026
Merged

fix(recording): preserve browser cursor after WGC fallback#583
meiiie merged 2 commits into
mainfrom
fix/windows-wgc-browser-fallback-cursor

Conversation

@meiiie
Copy link
Copy Markdown
Collaborator

@meiiie meiiie commented May 24, 2026

Summary

  • Detect the path where Windows WGC is available but fails to start, then fall back to browser-captured cursor instead of the telemetry overlay path.
  • Skip OS cursor hiding only for that WGC-start-failed browser fallback.
  • Keep the existing browser hidden-cursor policy for regular browser capture.

Motivation

Follow-up for #393 and the v1.3.0 Discord report where native Windows capture fails to start, browser fallback records, and the cursor appears left behind or delayed.

Testing

  • npm test -- src/hooks/useScreenRecorder.test.ts
  • npx tsc --noEmit --pretty false
  • npx biome check --formatter-enabled=false src/hooks/useScreenRecorder.ts src/hooks/useScreenRecorder.test.ts
  • git diff --check

Notes

This does not change successful WGC capture or the native helper. It still needs runtime smoke on a Windows machine where WGC fails and browser fallback is used.

Summary by CodeRabbit

  • New Features

    • Improved cursor handling during screen recordings: when native Windows capture fails, the recorder falls back to keeping the browser's visible cursor and disables automatic OS-cursor hiding; otherwise the OS cursor is hidden and browser stream omits the cursor. This behavior is applied consistently across recording paths.
  • Tests

    • Added unit tests verifying cursor policy and fallback behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 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: 5bf817ba-75e8-41df-992c-6285cad6d2e0

📥 Commits

Reviewing files that changed from the base of the PR and between 7c863e5 and ebac9ba.

📒 Files selected for processing (1)
  • src/hooks/useScreenRecorder.ts

📝 Walkthrough

Walkthrough

The PR adds a BrowserCaptureCursorPolicy and resolveBrowserCaptureCursorPolicy(), tracks native Windows capture start failure, applies the resolved policy in startRecording() to editor/OS cursor hiding and browser media constraints, and adds unit tests for the policy resolver.

Changes

Cursor-Capture Policy Integration

Layer / File(s) Summary
Cursor Policy Type and Resolution Function
src/hooks/useScreenRecorder.ts
Exports BrowserCaptureCursorPolicy type with streamCursor mode and cursor-hiding flags; exports resolveBrowserCaptureCursorPolicy() that returns different policy objects depending on whether native Windows capture startup failed.
Native Capture Failure Detection and Policy Resolution
src/hooks/useScreenRecorder.ts
Tracks nativeWindowsCaptureStartFailed in startRecording() when native Windows capture initialization fails, enabling downstream logic to select the appropriate cursor policy.
Policy-Driven Cursor and Constraint Updates
src/hooks/useScreenRecorder.ts
Applies resolved policy to editor overlay cursor hiding, conditional OS cursor hiding with error handling, and browser media constraints (googCaptureCursor and cursor fields across all getDisplayMedia() paths).
Cursor Policy Unit Tests
src/hooks/useScreenRecorder.test.ts
Verifies default hidden-cursor policy; confirms switch to browser-captured cursor with disabled OS hiding when nativeWindowsCaptureStartFailed: true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • webadderallorg/Recordly#313: Both PRs modify src/hooks/useScreenRecorder.ts's startRecording() logic, with this PR adding cursor-capture policy wiring while the other adjusts start-failure cleanup/reset flow in overlapping code regions.

Suggested labels

Checked

Poem

🐰 I hopped through code tonight, so spry,

A policy to decide the cursor's sky.
When Windows trips, the browser keeps the view,
I hide or show the arrow just for you.
Hoppity-hop — constraints follow through.

🚥 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 summarizes the main change: fixing cursor preservation when Windows WGC (capture) fails and browser fallback is used.
Description check ✅ Passed The pull request description addresses the template requirements with a clear summary, motivation, and testing section, though screenshots/videos and a full checklist are missing.
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 fix/windows-wgc-browser-fallback-cursor

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
Copy link
Copy Markdown
Collaborator Author

meiiie commented May 24, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

🧹 Nitpick comments (1)
src/hooks/useScreenRecorder.test.ts (1)

112-130: 🏗️ Heavy lift

Add one wiring-level regression test for fallback side effects

These tests validate resolver output, but not that startRecording() actually applies the fallback policy (skip hideOsCursor() + request browser cursor capture) when native Windows start fails. A focused mocked-flow test would better lock down the user-facing regression.

🤖 Prompt for 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.

In `@src/hooks/useScreenRecorder.test.ts` around lines 112 - 130, Add a
wiring-level regression test that simulates native Windows capture failing to
start and verifies startRecording() applies the fallback policy: mock/spy the
native capture start path to return failure, spy on hideOsCursor() to assert it
is NOT called, and assert that the browser capture path is invoked (e.g., a call
that triggers request for browser cursor capture or sets streamCursor to
"always"). Use the existing resolver resolveBrowserCaptureCursorPolicy for
expected values and exercise the real startRecording() flow so the test ensures
the side effects (skip hideOsCursor and request browser cursor capture) occur
when nativeWindowsCaptureStartFailed is true.
🤖 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/hooks/useScreenRecorder.ts`:
- Around line 1545-1550: The current call to window.electronAPI.hideOsCursor
inside the browserCursorPolicy.hideOsCursorBeforeRecording block only catches
thrown errors but ignores a non-throwing failure result; update the logic in
useScreenRecorder to await the Promise result from
window.electronAPI.hideOsCursor(), check the returned shape (e.g., { success:
boolean }), and if success is false log a warning (via console.warn or
processLogger) describing the unsuccessful IPC response; keep the existing
try/catch to handle thrown errors and also include the returned-error-path
logging for window.electronAPI.hideOsCursor to avoid silent failures.

---

Nitpick comments:
In `@src/hooks/useScreenRecorder.test.ts`:
- Around line 112-130: Add a wiring-level regression test that simulates native
Windows capture failing to start and verifies startRecording() applies the
fallback policy: mock/spy the native capture start path to return failure, spy
on hideOsCursor() to assert it is NOT called, and assert that the browser
capture path is invoked (e.g., a call that triggers request for browser cursor
capture or sets streamCursor to "always"). Use the existing resolver
resolveBrowserCaptureCursorPolicy for expected values and exercise the real
startRecording() flow so the test ensures the side effects (skip hideOsCursor
and request browser cursor capture) occur when nativeWindowsCaptureStartFailed
is true.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d4f324c4-2ebd-4172-8c7a-13d89161d26b

📥 Commits

Reviewing files that changed from the base of the PR and between c51cc50 and 7c863e5.

📒 Files selected for processing (2)
  • src/hooks/useScreenRecorder.test.ts
  • src/hooks/useScreenRecorder.ts

Comment thread src/hooks/useScreenRecorder.ts
@meiiie
Copy link
Copy Markdown
Collaborator Author

meiiie commented May 24, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@meiiie meiiie marked this pull request as ready for review May 24, 2026 13:25
@meiiie meiiie merged commit 9f1c697 into main May 24, 2026
3 checks passed
@meiiie meiiie deleted the fix/windows-wgc-browser-fallback-cursor branch May 24, 2026 13:25
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