Workspace layout
app/. The UI framework lives in ui/ and is published separately under the MIT license (the rest of the code is AGPL v3).
WarpUI framework
WarpUI is a custom retained-mode UI framework inspired by Flutter’s element model and GPUI’s entity system. It consists of two crates:warpui_core— platform-agnostic primitives: layout elements, the entity/handle system, the action dispatch system, and the rendering model.warpui— the full framework, including native platform integration, windowing, and the component library (ui_components).
Key WarpUI concepts
Elements
Elements
Elements describe visual layout and are Flutter-inspired: they are immutable
descriptions of what to render, not the rendered output itself. Common
elements include
Flex, Align, Shrinkable, Hoverable, SavePosition,
and ParentElement. Elements are composed into a tree during the render
method of a view.Actions
Actions
The actions system is the event-handling mechanism. Views declare the actions
they handle, and the framework dispatches user input (keyboard, mouse,
window events) to the correct handler through a
StateEvent dispatch chain.
The TypedActionView trait marks views that handle a specific action type.AppContext
AppContext
AppContext provides temporary access to the global application state and all
entity handles during render and event handling. It is passed as the last
parameter to any function that needs access to other views or models — by
convention, the parameter is always named ctx. Never store AppContext
beyond the scope of a single function call.Entity-Component-Handle pattern
The central architectural pattern in WarpUI is the Entity-Handle system.- A View (or Model) is an entity owned by the global
Appobject. - Views reference other views via
ViewHandle<T>— a lightweight reference-counted handle, not a direct ownership transfer. - During render and event handling,
AppContextis used to dereference handles and access entity state. WeakViewHandle<T>avoids retain cycles in cases where a child needs to reference its parent.
Key application modules
Terminal emulation (app/src/terminal/)
The terminal emulator is built on top of Alacritty’s grid and VTE parser. Warp adds its own block model on top, turning runs of output into structured, individually addressable blocks.
Locking discipline: The TerminalModel uses an explicit mutex. Acquiring multiple locks on the same model from different call sites causes deadlocks. Always verify that no caller in the current call stack already holds the lock before adding a new model.lock() call.
AI integration (app/src/ai/)
Agent Mode and the AI assistant live here. Key sub-modules include the conversation model, the codebase indexing pipeline, the AI fact store, and the agent dispatch layer. The agent can call tools (grep, file retrieval, MCP servers) and produces structured diffs that feed into the code review panel.
Warp Drive (app/src/drive/)
Drive handles cloud synchronization of terminal objects. The DrivePanel component manages the sidebar UI and its interactions with the rest of the workspace. The DriveIndex view manages the internal tree, filtering, and item rendering. The sharing/ sub-module implements the ACL model and session sharing protocol.
Authentication (app/src/auth/)
Handles Firebase authentication, token refresh, and the server-side account and team model. Authentication state is used to gate Drive sync and team object visibility.
Settings (app/src/settings/)
Stores user preferences using a typed preferences model. When the SettingsFile feature flag is enabled, preferences can also be loaded from a settings.toml file with hot reload.
Persistence: Diesel and SQLite
Warp persists local state (Drive object cache, terminal history, settings) using Diesel ORM with a SQLite backend. The database schema is defined inapp/src/persistence/schema.rs and migrations live in migrations/. Each Drive object carries a SyncId (local) and a ServerId (server-assigned) to reconcile offline changes with the server.
GraphQL client
Server communication is done over GraphQL. The schema lives ingraphql/api/schema.graphql, and Rust client code is generated from it. WebSocket subscriptions (WS_SERVER_URL) are used for real-time updates such as session sharing events and Drive sync notifications.
Cross-platform strategy
Warp runs on macOS, Linux, Windows, and a WASM target. The strategy is:Conditional compilation
Platform-specific code is gated with
#[cfg(target_os = "...")]. Imports
inside cfg-guarded branches may use absolute paths instead of top-level
use statements to avoid polluting other platforms.Runtime feature flags
Behavioral differences that do not require separate compilation paths
(e.g., MSYS2 shell support on Windows) are gated with
FeatureFlag
variants so they can be toggled without recompilation.crates/integration/ run on all supported platforms in CI to catch cross-platform regressions.
Coding style highlights
A few rules that differ from default Rust style:- No unnecessary type annotations in closure parameters.
- Imports over path qualifiers: prefer
use foo::Barand thenBaroverfoo::Barat each call site. Exception: inside#[cfg(...)]branches. ctxgoes last: any function taking anAppContext,ViewContext, orModelContextnames itctxand puts it last. Exception: when a closure is the last parameter.- Remove unused parameters entirely — do not prefix with
_. Update the signature and all call sites. - Inline format arguments: write
eprintln!("{message}")noteprintln!("{}", message). - Exhaustive match: avoid
_wildcards inmatchstatements wherever possible.