Desktop recording orchestration
Desktop recording orchestration turns a user's capture choice into a managed recording session and then moves the result into local editing or remote media processing. It keeps one session view across the main app, capture controls, native capture services, device feeds, editor surfaces, and sharing paths.
Recording system boundary
The desktop app owns a recording from target selection through stop. Native recording state is the shared source of truth for the app windows, while capture actors produce the media and later services process completed uploads.
Recording ownership
Only one recording session can be pending or active at a time. A shared current-recording view lets each window show the same target, mode, and start state instead of creating separate session state. Device changes use the same shared approach so a late request cannot replace a newer choice.
The GPUI client is a parallel desktop path that uses the same recording concepts and data contracts. A handoff between desktop clients must leave only one client responsible for the active session. See GPUI desktop client and Desktop application for the wider client model.
References: apps/…/lib.rs• L1227-1235 apps/…/lib.rs• L1620-1671 apps/…/lib.rs• L1340-1433 .greptile-internal/…/gpui-desktop-client.md• L5-13
Native command and event boundary
The webview sends recording commands to native code and receives immediate results for actions such as start, stop, pause, resume, restart, delete, and microphone mute. Native code also emits events for changes that may come from another window or from the capture system, such as device loss, recovery, degraded capture, failure, and stop.
Start setup failures use a distinct event from failures in an active session. This lets the main window explain a refused start after the target picker closes without presenting it as a recording that stopped unexpectedly. Queries for current recording state refresh when native change events arrive, while live events carry status and failure detail to the visible surfaces.
References: apps/…/tauri.ts• L70-96 apps/…/tauri.ts• L593-630 apps/…/recording.rs• L1192-1221 apps/…/lib.rs• L1961-2006 apps/…/lib.rs• L2353-2408 apps/…/queries.ts• L249-255
Capture start flow
Recording start is a staged process. The app records the intended target and mode as pending, prepares local and remote resources, creates the capture actors, and marks the session active only after capture is ready.
Target and mode selection
The target picker selects a display, app window, screen area, or camera-only target. It also selects Studio, Instant, or Screenshot mode. Screenshot mode leaves the video session path and produces a still image instead.
The selected target and mode form the start request. Native setup can force Studio mode for an editor re-record and can disable system audio for camera-only capture. These rules ensure that capture settings match the selected target before the engine starts.
References: apps/…/target-select-overlay.tsx• L1993-2037 apps/…/target-select-overlay.tsx• L2064-2092 apps/…/recording.rs• L1935-2004
Recording preferences
The app stores the user's last recording choices in shared persistent state. Recording surfaces load the choices when they open and save later changes so separate windows start from the same defaults.
The app can ask for confirmation when a video recording has no microphone. This check improves the start path but does not replace native device validation. Native setup still handles a device that disappears after selection.
References: apps/…/store.ts• L62-87 apps/…/store.ts• L130-148 apps/…/queries.ts• L196-246 apps/…/general-settings.ts• L21-39
Session preparation
Native setup creates a local .cap project and its in-progress metadata. It checks session ownership and storage, applies the recording name, and opens the controls before capture begins. If storage is low, the app can wait for a user decision. That wait is cancelled when the pending session changes or stops.
Instant mode also creates the remote video record before capture. Screen and window recordings upload media in segments. Camera-only Instant recording uses a complete local MP4 path. Studio mode keeps the result as a local editable project.
Available camera and microphone inputs are locked before actor creation. An optional missing input degrades the session rather than blocking screen capture. A camera-only target requires its camera. Studio also makes a best-effort desktop background snapshot for the project presentation.
References: apps/…/recording.rs• L1307-1375 apps/…/recording.rs• L2105-2242 apps/…/recording.rs• L2260-2437 apps/…/recording.rs• L3649-3683
Capture activation
Capture combines the selected screen target with optional camera, microphone, and system audio feeds. Studio favors an editable local project, while Instant favors fast sharing and progressive upload. Native setup checks that selected inputs still exist, become ready, and produce data before it admits the session as active.
On Linux, an Instant camera overlay has an extra presentation step. The camera window supplies its position, shape, mirror state, and background effect. Native code accepts that presentation only when it still matches the current recording generation, camera choice, window geometry, and preview state.
After capture is ready, native state becomes active and emits the Started event. Start cues are prepared before activation so their timing matches the start boundary. Setup errors can be retried before the start is abandoned. Once active, health events report degraded capture and recovery without changing session ownership.
The start flow is summarized below.
flowchart TD
A[Choose target and mode] --> B[Mark session pending]
B --> C[Prepare local project and remote media]
C --> D[Lock available inputs]
D --> E[Create capture actors and controls]
E --> F{Capture ready?}
F -- No --> G[Clear pending state and show start failure]
F -- Yes --> H[Mark session active]
H --> I[Emit Started event]
I --> J[Capture media and health events]
References: apps/…/recording.rs• L1589-1839 apps/…/recording.rs• L2520-3035 apps/…/recording.rs• L3234-3430 apps/…/recording.rs• L118-181 apps/…/recording.rs• L530-587
Live recording controls
The recording controls are the user's live command surface. They reflect native events and send commands to the single session owner. They do not own the capture engine.
Control state
The controls show setup, countdown, recording, paused, and stopped states. They derive elapsed time from the active session and exclude paused time. A native stop event resets the controls because a stop can come from a window, tray action, shortcut, or capture actor.
Stop and restart work are tied to the current capture generation. When the controls window is reused, a new session resets its timer and mute state. This prevents an old response from reviving a stopped session or changing the timing of a new one.
All active modes support stop. Pause and resume depend on the mode and platform. Instant can mute the microphone during capture. Studio keeps the microphone as an editable track instead.
References: apps/…/in-progress-recording.tsx• L83-183 apps/…/in-progress-recording.tsx• L256-417 apps/…/in-progress-recording.tsx• L532-618 apps/…/recording.ts• L41-54 apps/…/recording.rs• L3450-3582
Device changes
A device can disappear after capture starts. Native code reports loss and restoration as events, so the controls can show a recoverable issue while the recording continues with silence or without the camera overlay.
The user can change an active microphone or camera only when that input was part of the session at start. The controls pause capture during the change, ask native code to apply the new input, and restore the earlier choice if the change fails. The camera window follows the same event stream and does not create a second recording state.
References: apps/…/in-progress-recording.tsx• L194-216 apps/…/in-progress-recording.tsx• L322-340 apps/…/in-progress-recording.tsx• L671-723 apps/…/camera.tsx• L156-165 apps/…/lib.rs• L1814-1957 apps/…/lib.rs• L1961-2499
Teleprompter synchronization
The teleprompter keeps script movement aligned with recording state. It keeps the user's play or pause choice separate from a recording pause, so a temporary recording pause can stop the script without losing the user's intent to continue.
Recording resume restores movement only when the user did not manually pause the script. Stop and failed start clear the automatic-resume intent. The window reads native pause state when it opens and ignores an older result when a newer recording event has already arrived.
References: apps/…/teleprompter.tsx• L99-203 apps/…/teleprompter.tsx• L301-383 apps/…/teleprompter-utils.ts• L1-77 apps/…/teleprompter-utils.test.ts• L91-134
Stop and media handoff
Stopping ends live capture before it delivers the result. Native code clears active session state and stops the capture actor, then completes the local project or waits for the Instant upload path to hand media to web processing.
Stop, restart, and delete
Stop runs a mode-specific completion path. If Instant stop fails, the app aborts the segment upload so the remote record does not remain active. Restart discards the old local recording, starts a fresh session with the same inputs, and cleans up the old remote Instant record without delaying the new start.
Delete is a discard path. It cancels capture, removes local files, deletes any remote Instant video, hides the controls, and returns the app according to its post-delete setting.
References: apps/…/recording.rs• L2646-2727 apps/…/recording.rs• L2736-2867 apps/…/in-progress-recording.tsx• L620-657 apps/…/recording.ts• L41-54
Studio project completion
Studio completion produces a local editable project. Native code saves recording metadata, creates a thumbnail, and writes project settings from the recorded tracks and target. If media needs remuxing, the app tracks that work separately from the editor's loading state.
The finished project can return to an editor re-record flow. Otherwise the app follows the configured post-recording behavior, such as opening the editor, showing recordings, or adding the project to the library. Cleanup restores the main window and related preview or editor focus.
References: apps/…/recording.rs• L3160-3265 apps/…/recording.rs• L3280-3348 apps/…/recording.rs• L3350-3646 apps/…/general_settings.rs• L17-39
Editor preparation handoff
The editor can open while Studio media is still being finalized. A preparation view shows the title, available tracks, playable duration, audio, and preview frames. Editing stays disabled until the prepared media can move to the normal editor.
The preparation view accepts only newer state for its current request and media job. It bounds playback to the confirmed range and keeps a visible frame while the source changes. The handoff adopts a rendered frame at the requested position before it closes preparation. If the source changes during transfer, the editor keeps the preparation surface and offers a retry.
Recordings that need unsupported camera or keyboard presentation, recorded clicks, multiple screen segments, or display-notch handling use normal editor loading instead. This keeps the early preview limited to projects it can represent safely.
This flow is summarized below.
sequenceDiagram
participant E as Editor window
participant N as Native preparation
participant F as Local finalization
participant P as Normal editor
E->>N: Request preparation frame
N->>F: Observe project readiness
F-->>N: Progress, range, frames, and audio
N-->>E: Snapshot and preview frame
E->>N: Seek or play within range
N-->>E: Matching rendered frame
E->>N: Commit frame and playback handoff
N-->>P: Release preparation and admit normal loading
P-->>E: Render ordinary editor frame
References: apps/…/index.tsx• L9-59 apps/…/preparing-editor-context.tsx• L25-251 apps/…/preparing-editor-model.ts• L86-245 apps/…/preparing-handoff.ts• L4-179 apps/…/editor_preparing.rs• L187-384 apps/…/editor_preparing.rs• L389-589 apps/…/editor_preparing.rs• L601-839
Instant upload completion
Instant screen and window recordings upload video segments during capture. After stop, the uploader sends a final manifest and stores the share data needed to open the result. The web service validates the upload, reads the manifest, grants media access, and starts a media-server job.
The media server creates the final MP4 and preview files in storage. It reports progress through the service, which polls until processing completes or records an error. This separates fast desktop capture from slower media assembly.
References: apps/…/upload.rs• L699-803 apps/…/upload.rs• L1060-1181 apps/…/upload.rs• L1438-1582 apps/…/recording.rs• L3473-3629 apps/…/finalize-desktop-recording.ts• L134-183 apps/…/finalize-desktop-recording.ts• L304-409 apps/…/finalize-desktop-recording.ts• L506-637
Segment finalization
Finalization starts only when the manifest has valid video content. The queue marks the upload as processing and starts the media workflow. Transcription can start from uploaded audio before MP4 muxing finishes, then a final transcription pass runs after media completion.
Recovery handles sessions interrupted during capture. It waits for a manifest to stop changing before queuing the same finalization flow. Repeatedly failed or dead candidates are retired so abandoned uploads do not block later recovery.
The end-to-end handoff is summarized below.
sequenceDiagram
participant D as Desktop app
participant S as Storage
participant W as Web finalizer
participant M as Media server
participant V as Video record
D->>S: Upload segments and manifest
D->>W: Queue finalization
W->>S: Read manifest and sign media access
W->>M: Start mux job
M->>S: Write MP4 and preview outputs
M-->>V: Report progress and completion
W->>V: Observe processing state
References: apps/…/desktop-segments-finalization.ts• L70-147 apps/…/desktop-segments-recovery.ts• L175-227 apps/…/desktop-segments-recovery.ts• L320-392 apps/…/finalize-desktop-recording.ts• L568-671
Cross-surface coordination
Recording orchestration depends on shared state and event order across windows. The main window shows start failures and refreshes recording results. Controls reset from stop events. The camera window and teleprompter follow input and recording events. The editor preparation view follows native progress until the normal editor takes ownership.
The active session also changes window behavior. The app opens controls and target occluders, protects capture surfaces, hides or restores the main window, and returns focus to the editor when needed. Global shortcuts and tray actions enter the same command path as visible controls, so they can start, stop, restart, pause where supported, open the picker, or take a screenshot.
References: apps/…/index.tsx• L2171-2183 apps/…/index.tsx• L2299-2323 apps/…/in-progress-recording.tsx• L256-417 apps/…/teleprompter.tsx• L137-203 apps/…/Editor.tsx• L459-487 apps/…/Player.tsx• L578-734 apps/…/hotkeys.rs• L278-453 apps/…/recording.rs• L1733-1776
Change checklist
When these files or sections are changed, remember to consider these:
- Keep native command results, recording events, generated bridge types, and all consuming windows aligned.
- Preserve pending, active, and cleared session order so setup and teardown cannot race with a second start.
- Keep device revisions, pending state, operation locks, and active ownership aligned. A late device response must not replace a newer choice.
- Keep persisted recording choices and picker state synchronized. New choices need a safe default and a load and save path.
- When changing Linux camera presentation, keep geometry, recording generation, input revision, processing mode, and accepted frame state aligned.
- When changing Instant upload or manifest fields, update the desktop uploader, storage data, finalization request, and media completion checks together.
- When changing Studio completion, check editor handoff, remux tracking, thumbnail creation, and window focus together.
- When changing editor preparation, keep request identity, media job identity, frame order, playable range, audio handoff, and the normal-editor barrier aligned.
- When changing teleprompter sync, keep event variants, query revisions, user playback intent, and stop or failure reset behavior aligned.
- When changing export, timeline, transcript, or screenshot-editor handoff, keep source time, output time, project revision, and native window ownership consistent.
- When changing recovery status, check the stable-manifest scan, queue guard, workflow polling, and user-visible upload state together.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A second start arrives while a session is pending or active | A new request could replace the live capture owner | Native state rejects the start and emits a start-failure event. |
| A selected device disappears during setup | Capture could start with the wrong input or without a required camera | Revisions, availability checks, readiness checks, and input locks reject stale setup. |
| A device disconnects during capture | Part of the result loses an input | Loss and restore events keep the session alive and make the gap visible. |
| A stale stop or restart response reaches reused controls | An old session can appear active or alter a new timer | Capture generations and request identity limit updates to the current session. |
| Linux camera presentation is stale | The camera image can use the wrong position or effect | Native validation checks the current window, generation, input, preview state, scale, and bounds. |
| The Instant manifest is missing, invalid, or still changing | Media processing can start with incomplete input | Finalization validates the manifest and recovery waits for a stable signature. |
| Media muxing fails or times out | The remote recording remains unfinished | The workflow retries allowed failures and records a processing error after its wait limit. |
| Preparation cleanup races with normal editor loading | Two consumers can compete for the same media | Normal loading waits for the preparation consumer to stop. |
| A preparation project needs unsupported media presentation | The preview can omit required content | The preparation path declines the case and uses normal editor loading. |
| Export resources are low or the worker fails | Export can stop late or leave the editor busy | Preflight checks resources, cancellation releases session guards, and safe worker fallbacks retry. |
| The shared graphics device is lost | Later preview work can fail or crash | Device health rejects more work and asks the user to restart. |
| Studio media needs remux after stop | The editor can read incomplete media | Finalization is tracked and editor reads wait for remux completion. |
Key files
| File | Why to read it |
|---|---|
| apps/…/recording.rs | Defines native recording setup, device handling, stop paths, and Studio or Instant completion. |
| apps/…/lib.rs | Defines shared recording state, input coordination, events, and native command registration. |
| apps/…/tauri.ts | Shows the command and event boundary used by desktop windows. |
| apps/…/target-select-overlay.tsx | Shows how target and mode choices enter start. |
| apps/…/in-progress-recording.tsx | Shows how live controls reflect events and issue commands. |
| apps/…/teleprompter.tsx | Shows how the script follows recording pause, resume, stop, and start failure. |
| apps/…/hotkeys.rs | Shows how shortcuts and external stop actions enter the same command path. |
| apps/…/linux_instant_camera.rs | Defines the Linux camera presentation boundary. |
| apps/…/preparing-editor-context.tsx | Coordinates preparation snapshots, frames, retry, and editor handoff. |
| apps/…/editor_preparing.rs | Owns native preparation, preview playback, audio handoff, and normal-editor admission. |
| apps/…/upload.rs | Shows progressive Instant upload and manifest ownership. |
| apps/…/desktop-segments-finalization.ts | Shows the queue boundary between uploaded segments and media processing. |
| apps/…/finalize-desktop-recording.ts | Shows manifest validation, media-server handoff, polling, and final transcription. |
| apps/…/desktop-segments-recovery.ts | Shows recovery for interrupted or dead segmented recordings. |
| apps/…/export.rs | Defines export resource checks, worker execution, progress, cancellation, and estimates. |