Skip to content

feat(desktop): recording settings menu with mid-recording microphone and camera switching - #4262

Open
richiemcilroy wants to merge 18 commits into
mainfrom
feat/gpui-recording-settings-menu
Open

richiemcilroy wants to merge 18 commits into
mainfrom
feat/gpui-recording-settings-menu

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

The recording bar's settings button was drawn disabled, and the GPUI app had no way to change the microphone or camera once a recording started. This brings back the Tauri app's recording settings menu (in-progress-recording.tsx:737-830): show or hide the camera preview, and switch microphone and camera mid-recording, in both Studio and Instant.

How a switch works

flowchart TD
    A[Pick a device in the bar's settings menu] --> M{Mode}
    M -->|Studio| S1[Pause if running: the segment closes]
    S1 --> S2[Detach the old feed from the segment factory]
    S2 --> S3[Point the app feed at the new device, wait until it is open, lock it]
    S3 -->|fails to open| S5[Reopen and reattach the previous device, show the error]
    S3 --> S4[Attach the new lock, resume if it was running]
    S5 --> S4b[Resume if it was running]
    M -->|Instant mic| I1[Open the new mic on a feed of its own]
    I1 -->|fails to open| I4[Nothing touched the recording, show the error]
    I1 --> I2[MicrophoneSwitch moves the live source onto it]
    I2 --> I3[Old feed released, app selection updated]
    M -->|Instant camera| C1[Point the bubble at the new camera, wait until it opens]
    C1 -->|fails to open| C2[Bring the previous camera back, show the error]
Loading
  • Studio records each input per segment, so a switch is a segment cut through the actor's existing set_mic_feed / set_camera_feed (which only work while paused). The time the cut takes counts as paused, so the bar's timer matches what was recorded. A reopened camera bubble is a new window, so add_excluded_windows (new, macOS) keeps it out of the next segments.
  • Instant keeps one continuous audio track. A locked MicrophoneFeed refuses a different device, so the switch happens at the source instead: MicrophoneSwitch (crates/recording/src/sources/microphone.rs) attaches the running source to another, already-open feed and drops the old one. The source already rebuilds its resampler whenever the incoming rate, channels or format change, so a 44.1 kHz stereo headset after a 48 kHz mono built-in mic needs nothing extra. The mute flag stays on the original lock, which the bar keeps using.
  • Instant "No microphone" mutes: the track keeps its timeline and records silence, the same seam the bar's mute button uses.
  • Instant camera on macOS and Windows is the on-screen bubble; the recording does not hold the camera, so switching is a new preview selection. It is kept only once the new camera opens; if it fails, the previous camera comes back and the bar shows the error.
  • The hand-over between two microphones in Instant (frames still queued for the old one, the new one's first buffer) is filled with silence of exactly its length, so audio after a switch keeps its place on the timeline (see Proof).
  • Not offered (shown with a short note instead of rows): an input the recording started without (there is no track to put it on, as in Tauri), the camera of a camera-only recording, and the camera of a Linux Instant recording (composited into the video).
let (switch, requests) = MicrophoneSwitch::channel();
// instant pipeline: SwitchableMicrophone { lock, switch_requests: requests }
let opened = recording::open_microphone("USB Mic", settings, meter).await?;
switch.switch(opened.lock.clone()).await?; // old feed released only on success

The bar

  • The settings button sits after the marker in Studio and alone in Instant. The bar is 32 px wider so the timer and "Pausing…" keep their room with both buttons.
  • The panel opens above the bar in the bar's own surface (gray-1 card, gray-5 border), and the window grows to fit it the way it grows for the issue card (fit_controls). Rows show a check on the device in use; "Switching…" shows on the heading while a switch runs. Clicking elsewhere or picking a device closes it.
  • "Show camera preview" hides the bubble in place (same window), so a Studio capture keeps excluding it; it comes back when the recording ends.
  • A failed switch reads "Couldn't switch to {device}. The recording continues." in the issue card. Pause, restart and delete wait while a switch runs; requests made during a switch collapse to the newest choice per input.

Edge cases

Case Behaviour
Same device No-op, no segment cut
"None" Studio: next segments have no mic/camera. Instant mic: muted
Device fails to open Studio: previous device reattached, recording resumes. Instant: recording never touched
Rapid repeated switching One switch at a time, newest request per input runs next
Switching while paused Studio swaps without resuming
During the countdown Menu disabled until recording starts
Stop during a switch Switch stops at the next step and never resumes; an Instant camera that fails after Stop is not restored or remembered
Different rate/channels mic Resampler rebuilds per format (test below)

Tests

  • sources::microphone::switch_tests: a running source moves from a 48 kHz mono feed to a 44.1 kHz stereo one, the old feed is released (it can be locked again) and its samples never reach the recording; a switch onto a dead feed fails and recording continues on the current mic.
  • sources::microphone::switch_tests::audio_after_a_switch_keeps_its_place_on_the_timeline: two microphones delivering in real time with a 40 ms hand-over; the new one's first sample must land at 340 ms. Without the fill it lands at 300 ms (14,400 samples instead of 16,320). switch_gap_samples_bridge_only_a_real_hand_over covers overlaps, huge and non-finite gaps.
  • app_windows::tests::a_hidden_linux_camera_preview_is_reopened_after_recording: hiding the preview on Linux (which closes its window) keeps the choice so the end of the recording reopens it.
  • session::input_switch::tests: rapid switches collapse to the newest choice; a camera request waiting behind a mic switch is never dropped.
  • controls_window tests for the window height with the issue card and panel, and the panel's height cap.
  • deeplink parse test for the debug-only switch_microphone action used to script hardware runs.
  • crates/recording/examples/av-sync-record.rs gains --mic, --switch-to and --switch-at for the flash+click sync harness.

Callers checked

  • Microphone::setup_with_channels: Studio and Instant pipelines, the Linux X11 combined source, the feed tests. All but the Instant screen pipeline pass no switch.
  • create_pipeline (instant): one caller. Camera-only Instant gets no switch.
  • fit_controls_to_issue replaced by fit_controls; only the controls window called it.
  • Store keys unchanged: the switch updates Feeds, and the main window's existing observer persists the selection, so the next recording uses the new device.

Proof

A/V sync

A probe branch builds this PR's cap-recording and main's side by side and records a window that flashes white with a click every 2 s, on a Blacksmith macOS 15 runner. The microphone is BlackHole looping the click back in; the second microphone, "Cap Test Mic B", is a CoreAudio aggregate device over BlackHole. av-sync-check reports video minus audio per flash; the table gives the mean of the 14 to 15 flashes before and after the event (SD 9 to 17 ms per side). Recordings are 60 s with the event at 30 s.

Instant microphone switch (run 43988161477, head with the hand-over fix)

Recording Before (ms) After (ms) Change
No switch, this PR -78.3 -79.7 -1.4
No switch, main (two runs) -85.4 / -49.5 -86.4 / -51.9 -1.0 / -2.4
BlackHole to Mic B (two runs) -81.0 / -79.1 -80.0 / -73.9 +1.0 / +5.2
Mic B to BlackHole (two runs) -88.3 / -78.4 -89.1 / -70.9 -0.8 / +7.5

Before the fix the same switch moved the offset by +10 and +16 ms (runs 43982721209 and 43985132765). The muxer lays audio out by sample count and only fills gaps above 70 ms, so the 7 to 24 ms hand-over between the two microphones (frames still queued for the old one, the new one's first buffer) pulled everything after the switch earlier. The source now fills that hand-over with exact silence; the runs above logged gaps of 6.8, 19.4, 21.2 and 24.0 ms being filled.

Studio microphone switch (pause, swap, resume; 96 to 130 ms; runs 43982721209 and 43985132765)

Recording Run 1 change Run 2 change
Switch, this PR +23.3 (-90.9 to -67.6) +33.1 (-88.6 to -55.5)
Pause and resume for the same time, main +24.0 (-107.9 to -83.9) +35.7 (-95.2 to -59.5)
Pause and resume, this PR +7.2 +18.5
No pause, main +3.8 +0.9

A switch moves the next segment's raw offset exactly as main's own pause and resume does, and adds nothing to it. These are raw segment files: the editor lines tracks up with each segment's start times, which this check does not apply.

Microphone unplugged and plugged back in (aggregate destroyed at 20 s, recreated at 30 s; after = once it reconnected; same two runs)

Recording Run 1 change Run 2 change
Instant, this PR / main +2.8 / +2.4 +4.8 / +0.7
Studio, this PR / main -0.6 / +0.4 +2.6 / +0.6

Camera switch, Linux (ubuntu-24.04, Studio, two v4l2loopback cameras fed from the screen so the camera track shows the flashes too, PulseAudio null-sink monitor as the microphone). After switching camera A to camera B mid-recording, the new segment measured screen -24.1 ms and camera +9.8 ms on this PR against -23.6 ms and +10.1 ms for the same steps on main.

Screenshots and recording

Real app on the macOS runner (Studio recording, settings panel opened, then "Cap Test Mic B" picked from it):

Light Dark
Panel open
After the switch

Recordings of the switch: light, dark.

Not proven

  • Camera sync on macOS: the hosted runners have no camera. An Instant camera switch there only changes the on-screen bubble; a Studio one uses the same pause and swap as the microphone, measured above.
  • Before and after inside one Linux recording: the first segment of every Linux recording that later pauses reads about +215 ms raw on both this PR and main, so only the comparison with main is meaningful there.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previous camera-after-Stop issue fixed.

Summary

Adds recording settings with mid-recording microphone and camera switching.

  • The recording bar opens a panel for input choices and camera preview.
  • Recordings switch supported inputs without leaving the recording.
  • Instant microphone switches keep later audio at its place in the timeline.

Reviews (7) · Last reviewed commit: "fix(desktop): leave the camera alone whe..." · Reviewed by Greptile

@sandchest-com

sandchest-com Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Sandchest

Sandchest reviewed 0253920: nothing exploitable found in this change.

Sandchest reviews every change for vulnerabilities an attacker could use · 2 credits · Review details

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found 3 potential issues (2 high, 1 medium).

View 1 other finding in Capy.

Open in Capy

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Nov 17, 2026 12:58am UTC

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found 1 potential issue (1 medium).

Open in Capy

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 14, 2026 17:39 Inactive
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found 1 potential issue (1 medium).

View 1 other finding in Capy.

Open in Capy

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 14, 2026 20:30 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found 1 potential issue (1 medium).

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/desktop-gpui/src/app_windows.rs Resolved
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 17, 2026 00:10 Inactive
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found 1 potential issue (1 medium).

Open in Capy

pub(crate) fn set_camera_preview_shown(shown: bool, cx: &mut App) {
let Some(handle) = cx.global::<AppWindows>().camera else {
if shown {
cx.global_mut::<AppWindows>().camera_preview_hidden = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Linux camera preview stays closed when a clean-capture Studio recording stops

Medium Severity

On Linux, start a Studio recording in clean capture so the clean-capture lease is active, pause so the bar is revealed through show_main_window_after_capture_pause, open settings and switch "Show camera preview" off. That calls set_camera_preview_shown(false), which closes the window and sets camera_preview_hidden = true (app_windows.rs:7294). Stop the recording. The phase observer runs set_camera_preview_shown(true) at app_windows.rs:646 before restore_clean_capture_ui at line 649. That call clears the flag at line 7282 and then calls open_camera_window, which returns at app_windows.rs:4329 because clean_capture_active is still true: the lease's gate.started is only cleared by take() inside restore_clean_capture_ui, which runs afterwards. The flag is already false, so nothing retries and the preview stays closed until the user turns the toggle on again. The fix should keep the flag set until the reopen actually succeeds, or run the clean-capture restore before the camera reopen. The new test does not reach this path because it never drives the phase observer or a clean-capture lease.

Open in Capy

Comment on lines +218 to +220
if generation != this.recording_generation {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Camera returns after Stop

If an Instant recording ends before a camera switch finishes and Cap is set to stay hidden, park_idle_camera_preview() closes the bubble and changes the camera epoch. That makes the pending readiness check fail. This callback checks only recording_generation, which Stop does not change, so it calls show_camera() to restore the previous camera and opens the bubble again.

Check that the recording is still active before restoring or remembering the selection.

Knowledge Base Used: GPUI desktop client

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/session/input_switch.rs
Line: 218-220

Comment:
**Camera returns after Stop**

If an Instant recording ends before a camera switch finishes and Cap is set to stay hidden, `park_idle_camera_preview()` closes the bubble and changes the camera epoch. That makes the pending readiness check fail. This callback checks only `recording_generation`, which Stop does not change, so it calls `show_camera()` to restore the previous camera and opens the bubble again.

Check that the recording is still active before restoring or remembering the selection.

**Knowledge Base Used:** [GPUI desktop client](https://app.greptile.com/-/switch-tenant?tenant=cap&next=%2Fcustom-context%2Fknowledge-base%2Fcapsoftware%2Fcap%2F-%2Fdocs%2Fgpui-desktop-client.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 17, 2026 00:58 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

This branch was successfully deployed

1 active (outdated) and 1 inactive deployments
Preview – cap-status — 0253920f Deployed Nov 17, 2026 by vercel[bot]
Preview – cap-web — 688f4915 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant