Repository navigation
feat(desktop): recording settings menu with mid-recording microphone and camera switching - #4262
richiemcilroy wants to merge 18 commits into
Conversation
…y's argument limit
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 2 credits · Review details |
…r, retire switched Windows subscriptions alone
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
|
hey @greptileai, please re-review the PR |
| 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; |
There was a problem hiding this comment.
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.
| if generation != this.recording_generation { | ||
| return; | ||
| } |
There was a problem hiding this comment.
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.|
hey @greptileai, please re-review the PR |

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]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, soadd_excluded_windows(new, macOS) keeps it out of the next segments.MicrophoneFeedrefuses 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.The bar
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.Edge cases
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_overcovers 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_windowtests for the window height with the issue card and panel, and the panel's height cap.deeplinkparse test for the debug-onlyswitch_microphoneaction used to script hardware runs.crates/recording/examples/av-sync-record.rsgains--mic,--switch-toand--switch-atfor 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_issuereplaced byfit_controls; only the controls window called it.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-recordingandmain'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-checkreports 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)
main(two runs)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)
mainmainA 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)
mainmainCamera 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):
Recordings of the switch: light, dark.
Not proven
main, so only the comparison withmainis meaningful there.

Confidence 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.
Reviews (7) · Last reviewed commit: "fix(desktop): leave the camera alone whe..." · Reviewed by Greptile