Skip to content

Added the new recording button so that user does not exit the entire application #307

Merged
siddharthvaddem merged 7 commits intosiddharthvaddem:mainfrom
Ayush765-spec:main
Apr 7, 2026
Merged

Added the new recording button so that user does not exit the entire application #307
siddharthvaddem merged 7 commits intosiddharthvaddem:mainfrom
Ayush765-spec:main

Conversation

@Ayush765-spec
Copy link
Copy Markdown
Contributor

@Ayush765-spec Ayush765-spec commented Apr 3, 2026

Pull Request Template

Description

The PR introduces a dedicated button in the application's top toolbar ,letting users cancel their active session in the editor and bounce straight back into the main recording (HUD) overlay

Motivation

Here's a clean write-up you can use in your PR description:


Why This Change Is Needed

Right now, if a user finishes recording and wants to start a fresh one, there is no way to do it from within the app. The only option is to completely quit OpenScreen and reopen it — which is frustrating, breaks the workflow, and feels like a bug rather than intentional design.

This is especially painful for users who record frequently, like developers making demo videos or tutorials, where starting a new recording is something they do repeatedly in a single session.


What Problems It Solves

1. Eliminates the need to quit the app
Users no longer have to force-quit and reopen just to record again. The app stays running the whole time.

2. Faster workflow
Going from "done editing" to "ready to record again" is now just two clicks — button click + confirm. Previously it meant quitting, waiting for relaunch, and setting everything up again.

3. Accidental data loss prevention
The confirmation dialog ("Start a new recording? Your current recording will be discarded.") makes sure nobody loses their work by accidentally clicking the button.

4. Meets basic user expectations
Almost every screen recorder out there has a "start over" or "new recording" option. Not having it made OpenScreen feel incomplete compared to alternatives.


In Short

A small UI addition that removes a genuinely annoying pain point and makes the core recording loop feel smooth and intentional.

Type of Change

  • New Feature

Related Issue(s)

#247

Screenshots / Video

Screenshot (if applicable):
Screenshot 2026-04-03 185235
Screenshot 2026-04-03 185457
Screenshot 2026-04-03 185445

![Screenshot Description](path/to/screenshot.png)

Video (if applicable):

<video src="path/to/video.mp4" controls width="600"></video>

Testing

Checklist

  • I have performed a self-review of my code.
  • I have added any necessary screenshots or videos.
  • I have linked related issue(s) and updated the changelog if applicable.

Thank you for contributing!

Summary by CodeRabbit

  • New Features

    • Added a "New Recording" button to the video editor toolbar.
    • New confirmation dialog to start a recording; confirming clears the current video and resets the editor.
    • Confirming switches the app back to the HUD-style recording flow and begins a new recording.
  • Localization

    • Added English strings for the new recording dialog (title, description, cancel, confirm).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a07632fa-98f0-482b-b738-eea030254a37

📥 Commits

Reviewing files that changed from the base of the PR and between 735dd2a and 013312b.

📒 Files selected for processing (6)
  • electron/electron-env.d.ts
  • electron/ipc/handlers.ts
  • electron/preload.ts
  • src/components/video-editor/VideoEditor.tsx
  • src/i18n/locales/en/editor.json
  • src/vite-env.d.ts
✅ Files skipped from review due to trivial changes (1)
  • src/i18n/locales/en/editor.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • electron/electron-env.d.ts
  • electron/ipc/handlers.ts
  • electron/preload.ts
  • src/components/video-editor/VideoEditor.tsx

📝 Walkthrough

Walkthrough

Adds two renderer-exposed APIs — switchToHud and startNewRecording — plus IPC handlers. Renderer dialog in the editor invokes startNewRecording (which clears recording state and may call switchToHud), and switchToHud triggers main-process logic to close the editor window (bypassing confirmation) and show the HUD-backed main window.

Changes

Cohort / File(s) Summary
Type Definitions
electron/electron-env.d.ts, src/vite-env.d.ts
Added switchToHud: () => Promise<void> and startNewRecording: () => Promise<{ success: boolean; error?: string }> to window.electronAPI.
IPC Handlers
electron/ipc/handlers.ts
registerIpcHandlers now accepts optional switchToHud?: () => void; added ipcMain.handle("switch-to-hud", ...) and ipcMain.handle("start-new-recording", async ...) which clears recording session state, optionally invokes switchToHud, and returns { success, error? }.
Preload Bridge
electron/preload.ts
Exposed electronAPI.switchToHud() and electronAPI.startNewRecording() via ipcRenderer.invoke(...).
Main Process
electron/main.ts
Added switchToHudWrapper callback registered with IPC: sets isForceClosing, closes existing mainWindow (skipping confirmation), nulls it, and calls showMainWindow() to recreate/show the HUD-backed main window.
Renderer UI
src/components/video-editor/VideoEditor.tsx
Added "New Recording" toolbar button, a controlled confirmation Dialog, and handleNewRecordingConfirm that calls window.electronAPI.startNewRecording(); handles success by closing dialog, handles error by logging and setting component error state. Imports for dialog and Video icon added.
Localization
src/i18n/locales/en/editor.json
Added newRecording translations: title, description, cancel, confirm.

Sequence Diagram

sequenceDiagram
    participant User
    participant VideoEditor as VideoEditor UI
    participant Preload as Preload Bridge
    participant IPC as IPC Main
    participant Main as Main Process

    User->>VideoEditor: Click "New Recording"
    VideoEditor->>VideoEditor: open confirm Dialog
    User->>VideoEditor: Confirm
    VideoEditor->>VideoEditor: clear/reset recording state
    VideoEditor->>Preload: electronAPI.startNewRecording()
    Preload->>IPC: invoke "start-new-recording"
    IPC->>IPC: clear recording session state
    IPC->>IPC: if provided -> call switchToHud callback
    IPC->>Preload: return { success: true } or { success:false, error }
    Preload->>VideoEditor: resolve promise with result
    alt success
        VideoEditor->>VideoEditor: close dialog
    else failure
        VideoEditor->>VideoEditor: set error state / log
    end
    Note right of IPC: separate channel "switch-to-hud" may be invoked
    VideoEditor->>Preload: electronAPI.switchToHud()  (optional/direct)
    Preload->>IPC: invoke "switch-to-hud"
    IPC->>Main: call registered switchToHud callback
    Main->>Main: set isForceClosing = true
    Main->>Main: close mainWindow (skip confirmation) and null it
    Main->>Main: showMainWindow() -> HUD displayed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I tap and twitch — a button bright,
New recording hops into the light.
A gentle close, a HUD re-spun,
The rabbit cheers — the work is done! 🎬

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main feature: adding a new recording button to prevent users from having to exit the application entirely.
Description check ✅ Passed The description is comprehensive, covering purpose, motivation, problem-solving, type of change, related issue, screenshots, and checklist items, though testing steps and code review confirmation are incomplete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🧹 Nitpick comments (2)
src/components/video-editor/VideoEditor.tsx (2)

476-481: Redundant IPC call: setCurrentRecordingSession(null) after clearCurrentVideoPath().

Based on the IPC handler at electron/ipc/handlers.ts:762-765, clearCurrentVideoPath() already calls setCurrentRecordingSessionState(null) internally. The subsequent setCurrentRecordingSession(null) call is redundant.

🔧 Suggested simplification
 const handleNewRecordingConfirm = useCallback(async () => {
   setShowNewRecordingDialog(false);
   await window.electronAPI.clearCurrentVideoPath();
-  await window.electronAPI.setCurrentRecordingSession(null);
   await window.electronAPI.switchToHud();
 }, []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/video-editor/VideoEditor.tsx` around lines 476 - 481, The
handleNewRecordingConfirm callback makes a redundant IPC call:
clearCurrentVideoPath() already clears the recording session state, so remove
the extra await window.electronAPI.setCurrentRecordingSession(null) call from
handleNewRecordingConfirm; keep setShowNewRecordingDialog(false), await
window.electronAPI.clearCurrentVideoPath(), and await
window.electronAPI.switchToHud() intact and ensure handleNewRecordingConfirm
(the useCallback) still has the correct dependencies.

1418-1420: Hardcoded English strings should use internationalization.

The "New Recording" button text (line 1473), dialog title (line 1418), and dialog description (lines 1419-1420) are hardcoded in English, while adjacent UI elements use the internationalization system (ts("project.load"), ts("project.save")).

Consider adding appropriate i18n keys for consistency with the rest of the UI.

Also applies to: 1467-1474

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/video-editor/VideoEditor.tsx` around lines 1418 - 1420,
Replace the hardcoded English UI strings in VideoEditor (the DialogTitle "New
Recording", the DialogDescription "Start a new recording? Your current recording
will be discarded.", and the "New Recording" button label) with calls to the
i18n helper (e.g. ts("recording.new.title"), ts("recording.new.description"),
ts("recording.new.button")). Update the JSX where DialogTitle,
DialogDescription, and the Button label are rendered to use ts(...) instead of
literals, and add corresponding i18n keys to the translation resource files so
the new keys resolve.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/video-editor/VideoEditor.tsx`:
- Around line 476-481: The handleNewRecordingConfirm callback makes a redundant
IPC call: clearCurrentVideoPath() already clears the recording session state, so
remove the extra await window.electronAPI.setCurrentRecordingSession(null) call
from handleNewRecordingConfirm; keep setShowNewRecordingDialog(false), await
window.electronAPI.clearCurrentVideoPath(), and await
window.electronAPI.switchToHud() intact and ensure handleNewRecordingConfirm
(the useCallback) still has the correct dependencies.
- Around line 1418-1420: Replace the hardcoded English UI strings in VideoEditor
(the DialogTitle "New Recording", the DialogDescription "Start a new recording?
Your current recording will be discarded.", and the "New Recording" button
label) with calls to the i18n helper (e.g. ts("recording.new.title"),
ts("recording.new.description"), ts("recording.new.button")). Update the JSX
where DialogTitle, DialogDescription, and the Button label are rendered to use
ts(...) instead of literals, and add corresponding i18n keys to the translation
resource files so the new keys resolve.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fcef48cf-e903-4e9f-99ee-91ca1c14faec

📥 Commits

Reviewing files that changed from the base of the PR and between b101820 and 5259ae5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • electron/electron-env.d.ts
  • electron/ipc/handlers.ts
  • electron/main.ts
  • electron/preload.ts
  • src/components/video-editor/VideoEditor.tsx
  • src/vite-env.d.ts

@Ayush765-spec
Copy link
Copy Markdown
Contributor Author

hi @siddharthvaddem pls do check the pr and pls tell if you expect any further changes or merge if no further issues..looking forward to it...thanks

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 the current code and only fix it if needed.

Inline comments:
In `@src/components/video-editor/VideoEditor.tsx`:
- Around line 1437-1465: The new recording dialog uses hardcoded English strings
in DialogTitle, DialogDescription and the Cancel/Confirm button labels; replace
those literals with the app's i18n calls (e.g., t(...) or ts(...)) so they are
localized, updating the text for DialogTitle, DialogDescription and the two
button children where setShowNewRecordingDialog and handleNewRecordingConfirm
are used; add appropriate translation keys (e.g.,
"videoEditor.newRecording.title", "videoEditor.newRecording.description",
"videoEditor.newRecording.cancel", "videoEditor.newRecording.confirm") and
ensure the same localization pattern is applied to the similar block around
lines 1492-1499.
- Around line 483-488: The handler handleNewRecordingConfirm currently closes
the dialog before awaiting IPC and calls two IPCs that both clear session state;
change it to first sequentially await the necessary IPC calls (remove the
redundant window.electronAPI.setCurrentRecordingSession(null) if
clearCurrentVideoPath already resets session), only close the dialog
(setShowNewRecordingDialog(false)) after the IPCs succeed, and add error
handling around the awaited calls to surface failure to the user (e.g., set an
error state or reopen the dialog and log the error) while keeping a clear
descriptive log message when an IPC fails; target the symbols
handleNewRecordingConfirm, window.electronAPI.clearCurrentVideoPath,
window.electronAPI.setCurrentRecordingSession, window.electronAPI.switchToHud,
and setShowNewRecordingDialog when making these changes.
🪄 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: 764c5d96-51bf-474c-919e-bea93b86dcc6

📥 Commits

Reviewing files that changed from the base of the PR and between 5259ae5 and 98da431.

📒 Files selected for processing (1)
  • src/components/video-editor/VideoEditor.tsx

Comment thread src/components/video-editor/VideoEditor.tsx
Comment thread src/components/video-editor/VideoEditor.tsx
@Ayush765-spec
Copy link
Copy Markdown
Contributor Author

hi @siddharthvaddem resolved the issues flagged by coderabbit

Copy link
Copy Markdown
Owner

@siddharthvaddem siddharthvaddem left a comment

Choose a reason for hiding this comment

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

LGTM overall

might want a few modifications wrt the experience. For instance when I save this as a project and then later try to start a new recording, the recording will be discarded is very misleading. because neither the raw source video is being deleted plus the project file is also saved. if that makes sense?

@Ayush765-spec
Copy link
Copy Markdown
Contributor Author

@siddharthvaddem how about i just change the wordings to "Return to the recoder... Your current session is saved" and also change the colour of the confirm button from red to green for eg... if you confirm i can go ahead and make the changes..

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/components/video-editor/VideoEditor.tsx (1)

125-125: Prevent double-submit on “Confirm” while IPC is in flight.

Rapid clicks can trigger duplicate IPC calls before the first one resolves. Add an in-flight flag and disable both dialog buttons during submission.

Proposed refactor
- const [showNewRecordingDialog, setShowNewRecordingDialog] = useState(false);
+ const [showNewRecordingDialog, setShowNewRecordingDialog] = useState(false);
+ const [isStartingNewRecording, setIsStartingNewRecording] = useState(false);

 const handleNewRecordingConfirm = useCallback(async () => {
+  if (isStartingNewRecording) return;
+  setIsStartingNewRecording(true);
   try {
     await window.electronAPI.clearCurrentVideoPath();
     await window.electronAPI.switchToHud();
     setShowNewRecordingDialog(false);
   } catch (err) {
     console.error("Failed to start new recording:", err);
     setError("Failed to start new recording: " + String(err));
+  } finally {
+    setIsStartingNewRecording(false);
   }
- }, []);
+ }, [isStartingNewRecording]);

 <button
   type="button"
   onClick={() => setShowNewRecordingDialog(false)}
+  disabled={isStartingNewRecording}
   className="px-4 py-2 rounded-md bg-white/10 text-white hover:bg-white/20 text-sm font-medium transition-colors"
 >
   {t("newRecording.cancel")}
 </button>

 <button
   type="button"
   onClick={handleNewRecordingConfirm}
+  disabled={isStartingNewRecording}
-  className="px-4 py-2 rounded-md bg-red-500/80 text-white hover:bg-red-500 text-sm font-medium transition-colors"
+  className="px-4 py-2 rounded-md bg-red-500/80 text-white hover:bg-red-500 disabled:opacity-50 disabled:pointer-events-none text-sm font-medium transition-colors"
 >
   {t("newRecording.confirm")}
 </button>

Also applies to: 488-497, 1490-1503

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/video-editor/VideoEditor.tsx` at line 125, Add an "in-flight"
boolean state (e.g., isSubmitting) alongside showNewRecordingDialog and use it
in the confirm handlers (e.g., handleConfirmNewRecording / the existing confirm
IPC call sites around lines 125, 488-497, 1490-1503) to prevent duplicate sends:
in the confirm handler, if isSubmitting return early; otherwise set isSubmitting
= true, send the IPC call and await its completion, then in finally set
isSubmitting = false and close the dialog via setShowNewRecordingDialog(false)
only on success; also bind the dialog buttons' disabled prop to isSubmitting so
both Confirm and Cancel are disabled while the IPC is in flight.
🤖 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/video-editor/VideoEditor.tsx`:
- Around line 488-496: The current handleNewRecordingConfirm calls
window.electronAPI.clearCurrentVideoPath() and window.electronAPI.switchToHud()
as two separate IPCs which can leave the session in a cleared state if the HUD
switch fails; add a new atomic IPC handler in the main process (in
electron/ipc/handlers.ts) named "start-new-recording" that performs the existing
clear-current-video-path mutation and the switch-to-hud operation together and
returns an explicit { success: boolean } result (and error info on failure),
then update handleNewRecordingConfirm to call
window.electronAPI.startNewRecording(), only setShowNewRecordingDialog(false)
when the returned success is true, and surface the returned error info via
setError/console.error on failure.

---

Nitpick comments:
In `@src/components/video-editor/VideoEditor.tsx`:
- Line 125: Add an "in-flight" boolean state (e.g., isSubmitting) alongside
showNewRecordingDialog and use it in the confirm handlers (e.g.,
handleConfirmNewRecording / the existing confirm IPC call sites around lines
125, 488-497, 1490-1503) to prevent duplicate sends: in the confirm handler, if
isSubmitting return early; otherwise set isSubmitting = true, send the IPC call
and await its completion, then in finally set isSubmitting = false and close the
dialog via setShowNewRecordingDialog(false) only on success; also bind the
dialog buttons' disabled prop to isSubmitting so both Confirm and Cancel are
disabled while the IPC is in flight.
🪄 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: b4b0a5b7-a9ea-4959-ac83-1ac7bdac7eec

📥 Commits

Reviewing files that changed from the base of the PR and between b451bdc and 735dd2a.

📒 Files selected for processing (1)
  • src/components/video-editor/VideoEditor.tsx

Comment thread src/components/video-editor/VideoEditor.tsx
@Ayush765-spec
Copy link
Copy Markdown
Contributor Author

@siddharthvaddem made the changes..

@siddharthvaddem siddharthvaddem merged commit 9024eaa into siddharthvaddem:main Apr 7, 2026
5 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.

2 participants