Desktop application and recording experience
Cap is a native Rust desktop application built with GPUI. It gives users one local flow for choosing a capture target, recording screen or camera input, saving a .cap project, and then editing, sharing, exporting, or recovering that work. GPUI is now the shipping desktop client; the former webview-based desktop app is no longer the product boundary.
Native application boundary
The application draws its user interface in Rust through GPUI and uses native windows for capture controls, target selection, settings, teleprompter, screenshots, and editing. Shared Cap crates provide capture, media, project, rendering, and upload services behind that interface. The boundary keeps operating-system work native while giving every window the same application state.
GPUI application shell
apps/…/main.rs is the process entry point. It establishes logging, crash tracking, single-instance behavior, platform hooks, the GPUI application, shared entities, and the main window before it enables menus, tray actions, hotkeys, updates, and uploads. The application runs as a native binary rather than a webview host.
References: apps/…/README.md• L1-8 apps/…/main.rs• L288-405 apps/…/Cargo.toml• L10-20
Window roles
The window registry gives each product surface a clear role. The main window starts work, target overlays select what to capture, the controls window manages an active recording, and editor or screenshot windows manage completed projects. Settings, camera, teleprompter, onboarding, tray, and mode-selection surfaces support the same session without becoming separate recording systems.
The registry also controls ownership and visibility. The main window hides while a target is selected or a recording runs, the controls window stays available above the captured desktop, and the editor is reused for the project it owns. These rules prevent a helper surface from being captured or from acting on the wrong project.
References: apps/…/app_windows.rs• L254-299 apps/…/app_windows.rs• L1-8 apps/…/controls_window.rs• L1-9
Shared session state
RecordingSession is the application-wide source of truth for recording state. It moves through Idle, Starting, Recording, and Stopping, and both the main window and controls window observe it. This keeps countdowns, pause state, elapsed time, errors, storage warnings, and completion actions consistent across windows.
The session also owns the handoff between capture and project management. It records which editor should receive a new clip, which recording just finished, and whether a project is ready for early editor presentation. Recording generations and operation ownership keep late work from changing a newer session.
References: apps/…/session.rs• L21-29 apps/…/session.rs• L416-486 apps/…/session.rs• L620-671
Recording lifecycle
The recording flow turns a user’s saved choices into a native capture session and then into a durable local project. The same session supports fast sharing, later editing, and a new clip recorded from inside an editor.
The main lifecycle is:
flowchart LR
A[Open Cap] --> B[Choose mode and target]
B --> C[Choose camera microphone and system audio]
C --> D[Check permissions and storage]
D --> E[Prepare native capture]
E --> F[Countdown and record]
F --> G[Pause resume or stop]
G --> H[Finalize local project]
H --> I[Recents editor share export or recovery]
Recording setup
The main window lets the user choose Instant, Studio, or Screenshot mode and select a display, window, area, or camera target. Device choices are taken from the same capture systems that the recording engine uses, so the selected camera, microphone, display, and window remain meaningful when capture starts.
Target overlays move selection onto the desktop. They show the display or window under the pointer and let the user draw an area. The overlay is a native capture surface and is excluded from the recording when the session begins.
References: apps/…/main_window.rs• L103-145 apps/…/target_overlay.rs• L1-18 apps/…/target_overlay.rs• L121-129
Capture modes
Each mode chooses a different product outcome while using the same setup and session boundary.
| Mode | Main goal | Result |
|---|---|---|
| Instant | Share quickly | A local project with upload and share state |
| Studio | Edit after capture | A local project with editable recording clips |
| Screenshot | Save a still capture | A screenshot project that can be annotated and exported |
An editor-created recording always uses Studio behavior because the new capture must become a clip in an existing project. Normal user preference is restored after that editor flow ends.
References: apps/…/main_window.rs• L103-145 apps/…/session.rs• L620-637 apps/…/recording.rs• L27-31
Active capture
Starting a recording prepares the native pipeline before the start cue opens the recording gate. This makes the visible cue match the point at which capture is live. A countdown can give the pipeline time to become ready without exposing an unrecorded start.
The controls window provides the active session’s stop, pause, resume, restart, delete, timer, and microphone actions. It does not own capture state; it reflects RecordingSession and sends commands back to it. A microphone level and recording-scoped mute state give immediate feedback without changing the session’s overall mode.
The session treats pause and resume as confirmed actions. If the capture engine cannot confirm the requested state, the product keeps the control uncertain and avoids claiming that the recording is safely paused.
References: apps/…/session.rs• L673-805 apps/…/controls_window.rs• L196-243 apps/…/controls_window.rs• L261-318
Project completion
Stopping first ends capture and then prepares the project for later use. Studio work is made playable and receives its project metadata and preview assets. Instant work is turned into a local output project while preserving its share and upload status.
The application exposes a project only after the stop and finalization path has enough evidence to do so. If capture shutdown or finalization is not confirmed, it keeps local files and keeps the user-facing stop or recovery path available instead of reporting a false success.
References: apps/…/recording.rs• L428-514 apps/…/recording.rs• L821-845 apps/…/session.rs• L1109-1275
Recording management
After capture, Cap manages recordings as local projects rather than as temporary files. The library, editor, upload flow, and recovery flow all use the project’s media and metadata so a recording remains useful across app restarts.
Project library
Recents is a filesystem view of .cap bundles. It scans the active recording location and known earlier locations, reads project metadata, finds thumbnails, and orders items by their filesystem creation or modification time. This avoids a separate library index that could become out of sync with the user’s files.
The library distinguishes Studio, Instant, and Screenshot items. Completed Studio projects open in the editor. Instant items can open their share link, while incomplete or failed items remain available for local management.
References: apps/…/library.rs• L1-17 apps/…/library.rs• L90-140 apps/…/library.rs• L236-279
Editing and clip intake
The editor loads a completed project into a native timeline and preview. Users can change clip order and timing, adjust the visual and audio result, and save the project as they work. The editor treats the project configuration as durable state rather than as a view-only copy.
When an editor asks for a new clip, the application hides that editor while the recording runs. The finished Studio project is handed back to the same editor target, which keeps the capture flow connected to the project the user was editing.
References: apps/…/editor_window.rs• L1347-1492 apps/…/editor_window.rs• L2205-2218 apps/…/session.rs• L443-452
Project saves
Editor changes are saved to the project with a short delay so normal edits do not block the interface. A close or other boundary flushes pending changes. Save revisions prevent an older background write from replacing a newer edit.
This makes project-config.json the durable record of the current composition while recording metadata remains separate. The distinction lets editing state and project identity change without overwriting each other.
References: apps/…/project_save.rs• L8-99 apps/…/editor_window.rs• L1424-1432 apps/…/editor_window.rs• L1490-1499
Sharing and recovery
Instant sharing keeps enough upload state with the local project to support retry after a restart. Updates do not install while recording, export, upload, import, or transcription work is active, so application maintenance does not interrupt active user work.
An unclean exit leaves the project and its status available for recovery. The product favors retaining local media when stop, finalization, or upload work is uncertain. This gives the next launch a recoverable project instead of silently discarding the recording.
References: apps/…/README.md• L127-147 apps/…/recording.rs• L1131-1155 apps/…/library.rs• L207-279
Related recording systems
The page Desktop recording orchestration explains the capture commands, state changes, and media handoff in more detail. The page GPUI desktop client explains the native client structure, window surfaces, platform behavior, and packaging boundary.
References: apps/…/README.md• L1-8 apps/…/main.rs• L6-107
Change checklist
When these files or sections are changed, remember to consider these:
- Keep
RecordingSessionphases, active project ownership, andAppWindowsvisibility rules aligned so each surface acts on the current recording. - Keep mode names and saved recording choices compatible with the shared project and settings data used by existing installs.
- Keep target identity, selected devices, permission checks, and excluded native windows aligned across the main window, target overlays, and recording start.
- Keep the start cue, capture gate, stop acknowledgement, and finalization result in the same order so the user-facing state matches the media state.
- Keep editor recording targets tied to the current project and clear them on every completion, cancellation, and failure path.
- Keep library scanning compatible with recording-folder changes, prior folders,
.capmetadata, and thumbnail locations. - Keep project-save revisions and close-time flush behavior aligned so delayed saves cannot replace newer edits.
- Keep package identity, updater artifacts, permissions, and user data paths compatible when changing the native GPUI packaging boundary.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A start request arrives while the session is not idle | A second request could take over capture resources | RecordingSession accepts a start only from Idle |
| Target or device permission is missing | Capture cannot begin with the requested source | Setup and native start checks validate the selected target and inputs |
| The start cue runs before capture is ready | The user hears a start signal for media that is not yet recording | The start gate waits for the pipeline to become ready |
| Pause or resume is not confirmed by capture | The controls can show a state that does not match the media | The session marks the control uncertain and blocks unsafe follow-up actions |
| Capture shutdown is not confirmed | Media may still be active or incomplete | The app retains local files and keeps the stop or recovery path available |
| Finalization fails after capture stops | The library could treat an unusable project as complete | Finalization reports failure and preserves the project for recovery |
| A late stop or editor result belongs to an older session | A newer recording or editor could be changed by stale work | Session generations and project/window ownership reject stale results |
| A delayed editor save finishes after a newer edit | The newer project configuration could be overwritten | Revision tracking retires older queued saves |
| The app exits during recording or upload | The user could lose the visible path to local work | Session markers, project status, and retained local media support recovery |
Key files
| File | Why to read it |
|---|---|
| apps/…/README.md | States the product boundary, shipping model, project compatibility, and update behavior. |
| apps/…/Cargo.toml | Shows that GPUI is a standalone native desktop workspace and identifies the shared capture, project, editor, and media layers. |
| apps/…/main.rs | Shows application startup and the creation of the shared native application state. |
| apps/…/app_windows.rs | Shows window roles, project ownership, and visibility handoffs. |
| apps/…/main_window.rs | Shows the main recording entry point, modes, and saved device choices. |
| apps/…/target_overlay.rs | Shows native display, window, and area target selection. |
| apps/…/session.rs | Shows the recording state machine and the handoff from capture to project actions. |
| apps/…/recording.rs | Shows capture start, stop, finalization, local retention, and share-aware project completion. |
| apps/…/controls_window.rs | Shows the active recording controls and their relationship to shared session state. |
| apps/…/library.rs | Shows how local projects become Recents and remain visible across storage-folder changes. |
| apps/…/editor_window.rs | Shows project loading, editing, clip intake, playback, and save boundaries. |
| apps/…/project_save.rs | Shows how delayed editor saves avoid stale writes. |