fix: request screen permissions before countdown#298
fix: request screen permissions before countdown#298uriva wants to merge 8 commits intowebadderallorg:mainfrom
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughRefactored permission validation in the screen recorder hook by relocating the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useScreenRecorder.ts (1)
1415-1432:⚠️ Potential issue | 🟡 MinorRe-entrancy window widened by async permission check.
toggleRecordingguards against concurrent invocation viastarting || countdownActive, but neither flag is set beforeawait preparePermissions(). On macOS that await can span several event-loop ticks (IPC + permission dialog), during which a second trigger (hotkey/tray/button) will pass the guard and race into the countdown/startRecordingpath.startInFlightprotects the actual recorder, but the countdown itself can still be initiated twice (setCountdownActive(true)→startCountdowninvoked twice).Consider setting a guard before the await, e.g.:
🔒 Proposed fix
- if (starting || countdownActive) { + if (starting || countdownActive) { return; } if (recording) { stopRecording.current(); return; } - const permissionsReady = await preparePermissions(); - if (!permissionsReady) { - return; - } + setStarting(true); + try { + const permissionsReady = await preparePermissions(); + if (!permissionsReady) { + return; + } + } finally { + setStarting(false); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useScreenRecorder.ts` around lines 1415 - 1432, toggleRecording currently awaits preparePermissions without setting any guard, allowing a second invocation to pass the checks and start a second countdown; to fix, set the re-entrancy guard (reuse the existing starting flag or a dedicated startInProgress flag) immediately before calling await preparePermissions() inside toggleRecording, and ensure you clear that flag on all early exits (permissions false, errors) and after countdown/start completes; reference toggleRecording, preparePermissions, starting, countdownActive, setCountdownActive, startCountdown and startInFlight to place the guard and clear paths so the countdown cannot be initiated twice.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/hooks/useScreenRecorder.ts`:
- Around line 1415-1432: toggleRecording currently awaits preparePermissions
without setting any guard, allowing a second invocation to pass the checks and
start a second countdown; to fix, set the re-entrancy guard (reuse the existing
starting flag or a dedicated startInProgress flag) immediately before calling
await preparePermissions() inside toggleRecording, and ensure you clear that
flag on all early exits (permissions false, errors) and after countdown/start
completes; reference toggleRecording, preparePermissions, starting,
countdownActive, setCountdownActive, startCountdown and startInFlight to place
the guard and clear paths so the countdown cannot be initiated twice.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8ed87c0e-80aa-4c06-81ca-a1799b56f617
📒 Files selected for processing (1)
src/hooks/useScreenRecorder.ts
|
Note: this is still a draft and not yet ready for review. Working on ironing out some timing edge cases with the Wayland portal dialog. |
|
Update: The Wayland timing issue has been resolved. The PR is now ready for review! |
|
Addressed @coderabbitai's feedback regarding re-entrancy in |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me take a look at the current implementation to verify the changes. 🏁 Script executed: Length of output: 56975
Guard at entry: if (starting || countdownActive) return;Prevents any duplicate invocation while permission dialogs, the Wayland portal dialog, or the countdown are in flight.
The redundant Overall the re-entrancy fix is correct and covers all abort paths cleanly. |
|
Quick triage pass: I don’t see any active review threads here right now. This looks mainly blocked by the merge conflict, so if the author still wants to land it, rebasing onto current main seems like the next step before another review pass. |
Summary
preparePermissions) to execute before starting the countdown intoggleRecording.Summary by CodeRabbit