Desktop Build & Deployment
Relevant source files
The following files were used as context for generating this wiki page:
The Opcode desktop application is built using the Tauri 2 framework, which facilitates the creation of cross-platform desktop applications using a Rust-based backend and a web-based frontend. The build system integrates Vite for frontend asset orchestration and Cargo for Rust compilation, producing highly optimized binaries and native installers for Windows, macOS, and Linux.
Deployment strategies focus on distributing native executables and installers while maintaining a lean footprint. The project also supports a specialized "Web Server" mode for remote browser-based access, though the primary deployment target remains the desktop environment.
Sources: README.md:27-31, src-tauri/Cargo.toml:13-17
Build Architecture
The build process is orchestrated as a dual-pipeline system where the frontend is compiled into static assets before being embedded into the Rust executable.
Core Build Flow
The following diagram illustrates the sequence of operations during a production build:
This flow ensures that the frontend assets are finalized and available in the ../dist directory before the Rust compiler wraps them into the final executable.
Sources: src-tauri/tauri.conf.json:7-11, package.json:7-9
Build Configurations by Environment
| Component | Development Mode | Production Mode |
|---|---|---|
| Frontend | Vite HMR (Port 1420) | Static Minification |
| Backend | cargo debug build | cargo release (LTO + Strip) |
| Protocol | Dev Server Proxy | tauri:// Custom Protocol |
| Binary | Unstripped | Stripped, Opt-level "z" |
Sources: vite.config.ts:21-25, src-tauri/Cargo.toml:84-88, src-tauri/tauri.conf.json:74-75
Dependency Management
The project relies on a multi-language dependency stack managed by Bun and Cargo.
Frontend Dependencies
The frontend uses Bun as the primary package manager and runtime. Key dependencies include React 18, Tailwind CSS v4, and the Tauri API core.
Sources: package.json:20-63
Backend Dependencies (Rust)
The Rust backend leverages several specialized crates for desktop functionality:
- tauri: Core framework with features like
tray-iconandprotocol-asset. - rusqlite: Local SQLite database storage.
- tokio: Asynchronous runtime for process management.
- axum: Utilized specifically for the optional web server mode.
Sources: src-tauri/Cargo.toml:23-56
Frontend Orchestration with Vite
Vite is configured to handle the React/TypeScript environment specifically for Tauri's requirements.
Optimization & Code Splitting
To improve load times and manage binary size, the build uses manual chunking in vite.config.ts:
- react-vendor: React core libraries.
- ui-vendor: Radix UI and layout components.
- tauri-vendor:
@tauri-apps/apiand associated plugins. - editor-vendor: Markdown and syntax highlighting tools.
Sources: vite.config.ts:50-64
Environment Integration
The development environment uses a fixed port (1420) and strict port checking to ensure reliable communication between the webview and the Rust sidecar.
Sources: vite.config.ts:22-24, src/lib/apiAdapter.ts:24-33
Cross-Platform Deployment
Opcode targets Windows, macOS, and Linux using Tauri's bundling system.
Deployment Artifacts
The build process generates several platform-specific installers located in src-tauri/target/release/:
- Windows:
.msiand.exe(WebView2 based). - macOS:
.dmgand.app(Universal binaries supported). - Linux:
.deband.AppImage(WebKitGTK based).
Sources: README.md:195-204, src-tauri/tauri.conf.json:49-55
Security and Permissions
Deployment builds enforce strict Content Security Policy (CSP) and file system scopes.
- FS Scope: Restricted to
$HOME/**by default. - CSP: Restricts connections to
self,ipc:, and approved telemetry endpoints (PostHog). - External Binaries: The app requires a system-installed
claudeCLI binary to function.
Sources: src-tauri/tauri.conf.json:24-34, src-tauri/tauri.conf.json:37-45, README.md:144-145
Summary
The Desktop Build & Deployment system for Opcode is a sophisticated pipeline that combines the speed of modern web development (Vite/Bun) with the safety and performance of Rust. By utilizing Tauri 2, the project provides native desktop experiences across all major operating systems while maintaining a unified codebase for both local application execution and optional remote web server deployment.