GPUI desktop client
The GPUI desktop client is Cap's native desktop app for screen recording, screenshots, media import, editing, and sharing. It draws its UI with Rust and GPUI, owns one shared recording session across several native windows, and keeps projects and settings available across app restarts.
Product role
Shipping role
The client is the only desktop app in the current repository and has shipped as Cap since version 0.6.1. It replaced the Tauri app from version 0.6.0 while keeping the live project, settings, app identity, and update contracts that existing users depend on. For the wider desktop product model, see Desktop application.
The app is a standalone native process. Its UI does not use a webview, but its recording, project, rendering, and export services are shared Cap services. This lets a recording move from capture to editing without crossing a separate front-end boundary.
References: apps/…/README.md• L1-11 apps/…/store.rs• L1-17
Application lifecycle
The client starts by establishing logging, crash handling, single-instance ownership, deep-link handling, localization, theme state, device services, and the shared recording session. It then creates the main window and registry before enabling menus, the status item, hotkeys, upload recovery, and update checks. Work that can take time runs away from the UI so the app can continue to accept input.
On first use, the app opens onboarding instead of the capture window. On later launches it restores the normal capture surface and can open a project, settings page, or capture flow from a deep link, tray action, hotkey, or second launch. The development relaunch path can also restore open windows and editor state.
The lifecycle connects startup, capture, and media work as follows:
flowchart TD
A[Start native client] --> B[Claim single app session]
B --> C[Load shared settings and language]
C --> D[Create window registry and recording session]
D --> E{First use or missing permission?}
E -- Yes --> F[Show onboarding]
E -- No --> G[Show capture window]
G --> H[Open capture, library, settings, or editor surfaces]
D --> I[Recover uploads and run background checks]
References: apps/…/main.rs• L332-405 apps/…/main.rs• L418-535 apps/…/app_windows.rs• L550-733
Application structure
Window registry
The window registry gives one process a set of coordinated native surfaces. It holds the main window, recording controls, camera bubble, target overlays, settings, onboarding, teleprompter, video editors, and screenshot editors. Each surface has a focused role, while the registry keeps them aligned with the same recording session and project state.
The registry also controls ownership during transitions. It hides the main window while a target picker is open, moves control to the recording bar during capture, reuses an editor for an already open project, and decides which surface receives the finished recording.
References: apps/…/app_windows.rs• L254-307 apps/…/app_windows.rs• L605-733
User surfaces
The client presents a compact capture window and supporting native windows. Together they cover the full path from choosing a source to producing a finished media result.
| Surface | Product purpose |
|---|---|
| Main window | Select Instant, Studio, or Screenshot mode. Choose inputs and targets. Browse recent media. |
| Recording controls | Monitor a live capture. Pause, resume, restart, stop, delete, or mute the microphone when supported. |
| Camera window | Show and adjust the camera bubble during capture. |
| Target overlays | Select a display, app window, screen area, or camera-only target. |
| Settings | Manage shared desktop choices, recordings, shortcuts, integrations, language, and diagnostics. |
| Video editor | Review and edit Studio projects. |
| Screenshot editor | Style, annotate, crop, and export screenshots. |
| Teleprompter | Show a script above other windows without placing it in the recording. |
| Status item and menus | Start capture, open media and settings, access recent items, and quit without opening the main window. |
References: apps/…/app_windows.rs• L254-274 apps/…/main_window.rs• L103-181 apps/…/controls_window.rs• L164-227
Session ownership
The recording session is the shared authority for capture state. It moves through Idle, Starting, Recording, and Stopping; pause is a state of an active recording. The main window, controls, tray, teleprompter, and editor recording flow observe this one session instead of starting separate lifecycles.
When the session stops, the app finalizes the project before it chooses the next surface. A Studio recording normally opens in the video editor. An Instant recording can stay local, open its share result, or leave Cap hidden according to the user's preference. A failed or uncertain stop keeps local files available.
References: apps/…/session.rs• L1-29 apps/…/app_windows.rs• L605-733
Capture experience
Modes and targets
The capture flow turns a mode, target, and set of device choices into one recording session. Instant is aimed at fast sharing. Studio preserves material for later editing. Screenshot produces a still-image project without starting video capture.
The client supports display, app-window, area, and camera-only targets. It discovers cameras, microphones, displays, and windows and gives the user live previews or level feedback where the platform allows it. Device identities match those used by the recording service, so a choice made in the picker remains the same input when capture starts.
References: apps/…/main_window.rs• L103-145 apps/…/main_window.rs• L496-531 apps/…/feeds.rs• L670-830 apps/…/target_overlay.rs• L48-98
Recording flow
The session primes the selected feeds, runs the optional countdown and start cue, then exposes live controls without taking focus from the captured app. Pause and resume preserve one Studio project with multiple segments when needed.
When the user stops, the client waits for capture cleanup and finalizes metadata, thumbnails, and library state. It opens the editor for a completed Studio project or preserves the local Instant result while cloud work continues. Local files remain the recovery point when storage, cleanup, authentication, or the capture pipeline is not fully reliable.
sequenceDiagram
participant User
participant Main as Capture window
participant Session as Recording session
participant Engine as Capture service
participant Library as Project library
participant Next as Editor or share result
User->>Main: Choose mode, target, and inputs
Main->>Session: Start capture
Session->>Engine: Prime feeds and record
User->>Session: Pause, resume, or stop
Session->>Engine: Stop and confirm cleanup
Engine-->>Library: Final project and metadata
Library-->>Next: Open editor or expose sharing result
References: apps/…/session.rs• L82-115 apps/…/recording.rs• L798-1285 apps/…/app_windows.rs• L614-733
Native capture behavior
The client keeps Cap-owned surfaces out of the captured output and protects them while a session runs. The camera bubble, controls, and teleprompter can remain visible to the user without becoming part of the recording. Camera presentation choices such as size, shape, mirror state, and background treatment remain part of the live capture experience and the rendered project.
Window arrangement is an optional part of window capture. When supported, the client can place and size the selected app window for a common recording shape, then restore its former placement. Unsupported desktop systems report that the action is unavailable instead of pretending that the arrangement succeeded.
References: apps/…/feeds.rs• L228-309 apps/…/recording.rs• L33-71 apps/…/foreign_window.rs• L8-97 apps/…/window_arrange.rs• L4-109 apps/…/platform.rs• L859-887
Media and editing experience
Project library and import
The library treats a Cap project as a filesystem-backed media bundle. It scans the known recording locations and the shared screenshot location, reads project metadata, and combines Studio recordings, Instant recordings, and screenshots into recent views used by the main window, status item, and settings.
Import brings an existing video or image into the same product path as native capture. A video becomes a Studio project and an image becomes a screenshot project. The background job reports its progress, then adds the finished project to the library and opens the matching editor.
References: apps/…/main_window.rs• L17-27 apps/…/app_windows.rs• L622-699 apps/…/import.rs• L1-12 apps/…/import.rs• L157-180
Video editing
The video editor is the workspace for Studio projects. It combines a rendered preview, playback and scrubbing, a timeline, and a configuration sidebar so the user can shape the recording before export.
Timeline changes edit the project configuration in place. The editor supports selecting, trimming, moving, splitting, creating, deleting, and undoing timeline work. The sidebar controls the visual and audio result, including layout, crop, camera, sound, cursor, keyboard, captions, and color choices. The project remains the source of truth while the preview and export output are derived from it.
The editor can prepare a project while recording finalization is still finishing. It accepts only the current project version, and it presents an unavailable state when the media cannot be opened instead of allowing damaged input to break the app.
flowchart LR
A[Studio project bundle] --> B[Load metadata and project settings]
B --> C[Preview and timeline]
C --> D[Edit project configuration]
D --> C
D --> E[Render export]
E --> F[File, clipboard, or share link]
References: apps/…/editor_window.rs• L319-508 apps/…/editor_window.rs• L1219-1243 apps/…/editor_export.rs• L58-186
Screenshot editing
The screenshot editor uses a still image as the source and the same project rendering model used by video media. It lets the user choose a background, padding, corners, shadow, and border, then add annotations, layers, crop, and zoom changes. Each edit updates the project preview and is saved in the screenshot bundle's project configuration.
The export path keeps the image, styled frame, and annotation space aligned. It expands the output when annotations extend beyond the source bounds and keeps transparency when the project has no visible background. This makes a screenshot project portable between editing and sharing without depending on an open editor window.
References: apps/…/screenshot_editor.rs• L55-82 apps/…/screenshot_editor.rs• L109-166 apps/…/screenshot_export.rs• L68-85 apps/…/screenshot_export.rs• L175-257
Export and sharing
Video export turns the current project into a local file, clipboard output, or share link. The editor previews the result and estimates its size before rendering, then reports render and transfer progress. Link sharing uses the signed-in account and can be limited by the user's plan.
Screenshot export chooses an image format that matches the result. Save uses PNG. Copy uses PNG and can flatten onto white. Share uses JPEG for opaque output and PNG when transparency is needed. A stable project fingerprint lets the service recognize an unchanged screenshot result and lets video re-uploads keep an existing share identity where supported.
References: apps/…/editor_export.rs• L58-186 apps/…/editor_export.rs• L247-260 apps/…/screenshot_export.rs• L263-349 apps/…/screenshot_export.rs• L382-397
Instant upload recovery
Instant capture can finish local saving before cloud transfer finishes. The upload state stays with the project and records the share identity, server, account context, transfer phase, and verification result. A background queue can resume eligible work after a network error, sign-in change, or process restart.
The client confirms the server result and checks that local media still matches before marking an upload complete. Until then it keeps the local project and exposes retry or sign-in actions. Local cleanup follows the user's retention choice only after verification.
References: apps/…/queue.rs• L11-21 apps/…/queue.rs• L40-140 apps/…/upload.rs• L232-378
Resources and integrations
Persistent state and project data
The client separates shared desktop settings from GPUI-only presentation state. The shared store file keeps settings that must remain compatible with the former Tauri release, including recording choices, authentication, paths, hotkeys, language, and post-recording behavior. GPUI-specific state keeps window presentation, editor placement, screenshot preferences, and export preferences.
Project edits live in the .cap bundle. This makes the recording, its configuration, captions, and sharing state travel together through the library, editor, import path, and export path. Shared-store writes preserve keys that the native client does not know so another Cap release can still use them.
References: apps/…/store.rs• L1-17 apps/…/store.rs• L95-155 apps/…/store.rs• L157-190 apps/…/store.rs• L287-335
Native platform services
The platform boundary supplies desktop behavior that GPUI does not define on its own. It covers native file dialogs, window levels, screen-aware placement, window focus, capture exclusion, clipboard access, application appearance, and platform-specific update or permission actions.
The client adapts these services by operating system. macOS supplies panel behavior, permission and System Settings integration, and native window materials. Linux uses desktop portals for file dialogs and handles X11 and Wayland differences. Windows supplies native window and packaging resources. Unsupported behavior stays explicit so a user can distinguish an unavailable platform feature from a failed recording.
References: apps/…/platform.rs• L1-16 apps/…/platform.rs• L105-242 apps/…/windows.rs• L1-120 apps/…/Cargo.toml• L1-20
Resources and visual language
The app embeds the assets needed for its native surfaces, including icons, fonts, onboarding art, recording cues, music, and editor background choices. The resource set is packaged with the native client so the capture and editing experience does not depend on a web page or a network request for its basic UI.
Glass surfaces provide a shared visual language for native panels and overlays. The same visual model supports light and dark appearance and gives the app a reference path for checking native output against the intended material.
References: apps/…/assets.rs• L1-120 apps/…/build.rs• L1-32 apps/…/model.rs• L1-90 apps/…/glass.rs• L1-131
Permissions and onboarding
Onboarding introduces the three capture modes and guides the user through the permissions needed for capture. Screen recording and accessibility are required for the core macOS flow. Camera and microphone access remain optional because the user can capture without those inputs.
The permission flow checks status without starting a capture, requests permissions when the system can show a prompt, and opens System Settings when a prompt is no longer available. A grant that needs a new process triggers a relaunch so the recording client starts with the new permission state. On macOS, the permission guide can also show a small drag helper while the user adds Cap to System Settings.
References: apps/…/onboarding_window.rs• L111-176 apps/…/onboarding_window.rs• L296-347 apps/…/onboarding_window.rs• L485-506 apps/…/permissions.rs• L221-267 apps/…/permission_guide.rs• L1-13
Localization and support
Localization controls text in the native windows, menus, and status item. The language preference can follow the system or select a bundled catalog. If the system language has no catalog, the client falls back to English. Changing the preference refreshes the native surfaces without a restart.
Diagnostics give the user a local report and an audio/video sync check through the bundled Cap command-line tool. Updates are downloaded and verified in the background, then wait for recording, export, upload, import, and transcription work to finish before restart.
References: apps/…/mod.rs• L10-16 apps/…/mod.rs• L36-64 apps/…/mod.rs• L90-150 apps/…/messages.rs• L1-7 apps/…/README.md• L127-147
Change checklist
When these files or sections are changed, remember to consider these:
- Keep mode names, stored mode values, target types, and deep-link actions aligned across the main window, tray, session, and shared settings.
- Keep the window registry's visibility rules aligned with session phases so pickers, controls, camera, teleprompter, and editors do not compete for capture ownership.
- When changing project metadata or configuration, check library discovery, import, video editing, screenshot editing, rendering, export, captions, and upload recovery together.
- Preserve the shared store's read-modify-write behavior and unknown keys when changing settings used by the former desktop release.
- When changing upload state, keep the original account and server context tied to verification and local cleanup.
- When changing a capture window, preserve its native level, placement, focus, and capture exclusion on every supported desktop system.
- Keep permission completion, System Settings guidance, startup flags, and the relaunch path aligned when changing onboarding.
- When changing bundled resources or localization keys, keep build registration, packaged paths, catalogs, menus, and rendered surfaces aligned.
- When changing export destinations or formats, keep transparency rules, disk checks, sign-in and plan checks, and persisted export choices aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Required macOS permissions are missing | Capture or target selection cannot start | Startup and onboarding check permissions and open the correct system guide. |
| A target window cannot be arranged on the current desktop system | Window capture starts without the requested arrangement or reports unavailable support | Platform capability checks keep the original placement and expose unsupported behavior. |
| A recording stop or cleanup is not confirmed | The project could be incomplete or unsafe to remove | Finalization preserves local files and keeps retry or recovery state visible. |
| A device refresh finishes after the user changed picker or device state | A stale device can replace the current choice | Picker generations reject results that no longer belong to the active selection. |
| A project has missing or damaged media | The editor cannot prepare a usable preview | Project preflight converts bad media into an editor error state and keeps the app running. |
| Local media changes during Instant upload | The app could claim that the cloud copy matches the wrong file | Verification checks the local artifact before completion and cleanup. |
| The shared settings store is malformed | A client could overwrite settings owned by another release | The store refuses malformed data and updates one known key at a time. |
| A screenshot annotation extends outside the source frame | The exported image could cut off user content | Export bounds include annotation extents before encoding. |
| A signed-in session or plan cannot use link sharing | The local export exists but no share link is created | Export keeps local output and offers sign-in or retry instead of discarding it. |
| An update starts while media work is active | Recording or unsaved edits could be interrupted | Restart waits for active recording, export, upload, import, and transcription work. |
Key files
| File | Why to read it |
|---|---|
| apps/…/README.md | Defines the client role, user-facing surfaces, packaging boundary, and current product status. |
| apps/…/main.rs | Shows startup, shared services, the main window, background work, and native app entry points. |
| apps/…/app_windows.rs | Shows how native surfaces share one session and how completion moves between them. |
| apps/…/session.rs | Defines the recording lifecycle shared by capture controls, tray, teleprompter, and editors. |
| apps/…/main_window.rs | Shows the capture modes, target choices, devices, library entry points, and import actions. |
| apps/…/recording.rs | Connects capture choices to final project creation and recording results. |
| apps/…/import.rs | Shows how external video and image files become Cap projects. |
| apps/…/editor_window.rs | Shows project loading, playback, timeline editing, and the video editor boundary. |
| apps/…/editor_export.rs | Shows preview, local export, clipboard output, and link sharing. |
| apps/…/screenshot_editor.rs | Shows the still-image editing experience and project configuration flow. |
| apps/…/screenshot_export.rs | Shows annotation composition, transparency, image encoding, and share identity. |
| apps/…/queue.rs | Shows durable Instant upload state, retry, verification, and local retention. |
| apps/…/store.rs | Defines the shared desktop settings boundary and GPUI-only state. |
| apps/…/platform.rs | Defines native dialogs, window behavior, placement, and platform capability boundaries. |
| apps/…/onboarding_window.rs | Shows the first-run mode tour, permission flow, and relaunch decision. |
| apps/…/mod.rs | Shows language selection, system fallback, and live language refresh. |
| apps/…/Cargo.toml | Shows the native workspace boundary and the Cap services used by the client. |
| docs/desktop-recording-orchestration.md | Explains the recording flow beyond the client window layer. |
| docs/desktop-application.md | Explains the broader desktop product model and client boundary. |