feat:add ability to pause/resume recordings.#323
feat:add ability to pause/resume recordings.#323Galactic99 wants to merge 3 commits intosiddharthvaddem:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds pause/resume recording controls and state to the recorder hook and LaunchWindow UI; elapsed recording time now excludes paused intervals; UI shows a pause/resume HUD button and applies amber styling when paused; i18n tooltips for pause/resume added. Changes
Sequence DiagramsequenceDiagram
actor User
participant LaunchWindow
participant useScreenRecorder
participant MediaRecorder
User->>LaunchWindow: Click pause button
LaunchWindow->>useScreenRecorder: pauseRecording()
useScreenRecorder->>MediaRecorder: pause()
useScreenRecorder->>useScreenRecorder: set paused=true<br/>record pausedStartedAt
LaunchWindow->>LaunchWindow: swap to resume icon<br/>apply amber styling
User->>LaunchWindow: Click resume button
LaunchWindow->>useScreenRecorder: resumeRecording()
useScreenRecorder->>MediaRecorder: resume()
useScreenRecorder->>useScreenRecorder: accumulate pausedDurationMs<br/>set paused=false
LaunchWindow->>LaunchWindow: swap to pause icon<br/>elapsed resumes (now - start - pausedTotal)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4992b328a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
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)
624-628:⚠️ Potential issue | 🟡 MinorRestart does not work while paused.
The condition at line 628 only checks for
"recording"state, but the restart button remains visible when paused. Users clicking restart while paused will see no effect.🔧 Proposed fix to allow restart from paused state
const restartRecording = async () => { if (restarting.current) return; const activeScreenRecorder = screenRecorder.current; - if (!activeScreenRecorder || activeScreenRecorder.recorder.state !== "recording") return; + if ( + !activeScreenRecorder || + (activeScreenRecorder.recorder.state !== "recording" && + activeScreenRecorder.recorder.state !== "paused") + ) + return;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useScreenRecorder.ts` around lines 624 - 628, The restartRecording guard currently returns unless activeScreenRecorder.recorder.state === "recording", which prevents restart when the recorder is paused; update the condition in restartRecording (and any related early-return checks) to allow both "recording" and "paused" states (e.g., proceed if state === "recording" || state === "paused") so a paused recorder can be restarted; ensure restartRecording uses screenRecorder.current and restarting.current as before and that downstream restart logic correctly handles the paused state (resume/stop/start as appropriate).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/launch/LaunchWindow.tsx`:
- Around line 485-496: The Tooltip for the resume/pause button in
LaunchWindow.tsx uses hardcoded English strings; replace the inline strings
("Resume recording"/"Pause recording") with i18n calls (e.g.,
t("tooltips.resumeRecording") and t("tooltips.pauseRecording")) so the Tooltip
content reads t(paused ? "tooltips.resumeRecording" :
"tooltips.pauseRecording"); update your translation JSON files with those keys
and values; the change should be applied where Tooltip is rendered around the
button that references recording, paused, resumeRecording, pauseRecording, and
getIcon.
---
Outside diff comments:
In `@src/hooks/useScreenRecorder.ts`:
- Around line 624-628: The restartRecording guard currently returns unless
activeScreenRecorder.recorder.state === "recording", which prevents restart when
the recorder is paused; update the condition in restartRecording (and any
related early-return checks) to allow both "recording" and "paused" states
(e.g., proceed if state === "recording" || state === "paused") so a paused
recorder can be restarted; ensure restartRecording uses screenRecorder.current
and restarting.current as before and that downstream restart logic correctly
handles the paused state (resume/stop/start as appropriate).
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: fc29500d-5abc-4786-a0b1-fba16dccc214
📒 Files selected for processing (2)
src/components/launch/LaunchWindow.tsxsrc/hooks/useScreenRecorder.ts
…ed metadata for interrupted paused recordings.
|
@siddharthvaddem, could you take a look whenever you are free? |
Description
This PR adds pause and resume support during active recording in the HUD and updates recording-duration handling so paused intervals are not counted in the user-visible timer and saved recording duration.
Motivation
Users needed the ability to temporarily pause recording without ending the session and starting a new file.
This change solves that by allowing pause and resume in the same recording session, while keeping duration reporting accurate.
Type of Change
Related Issue(s)
#251
Screenshots / Video
Before
Before-Pause-Resume.mp4
After
After-Pause-Resume.mp4
Testing
* Timer does not advance during pause.
* Timer resumes from previous elapsed value after resume.
* Final saved recording duration matches active recording time (paused interval excluded).
* Pause/resume also affects mixed audio capture during paused interval.
Checklist
Thank you for contributing!
Summary by CodeRabbit