GPUI Native Client (Experimental)
Relevant source files
The following files were used as context for generating this wiki page:
The GPUI Native Client is an experimental Rust-based desktop application for the Rebase project. It uses the GPUI framework to provide a GPU-accelerated user interface. This client operates as a performance-oriented alternative to the production React/Tauri application while sharing the same underlying data structures and databases.
Sources: README.md:121-124, crates/rebase-gpui/src/main.rs:252-255
Architecture and Framework
The client is built using GPUI, a hybrid immediate and retained mode UI framework for Rust. GPUI leverages GPU acceleration to render application windows and supports macOS (Metal), Windows (DirectWrite), and Linux (Wayland/X11).
Sources: vendor/gpui-pre/README.md:1-5, crates/rebase-gpui/Cargo.toml:13-16
Core Components
The application architecture consists of three primary layers of abstraction provided by the GPUI framework:
- Entities: Manage application state and communication. They are owned by GPUI and accessed via smart pointers similar to
Rc. - Views: Entities that implement the
Rendertrait. They build a tree of elements to be turned into pixels. - Elements: The low-level building blocks of the UI. They provide imperative control over layout and rendering.
Sources: vendor/gpui-pre/README.md:68-81
Application Flow
The application initializes by determining the appropriate data directory and database path before starting the GPUI event loop.
Data Persistence and Shared Contracts
The Native Client shares a unified data layer with the Tauri production app to ensure compatibility across both implementations.
Shared Database
Both applications access rebase.db located in the com.rebase.desktop application support folder. This database contains session history, transcripts, and pilot data.
Sources: crates/rebase-core/tests/shared_contracts.rs:48-52, src/test/sharedContracts.test.ts:31-35
Contract Synchronization
To prevent data loss when switching between clients, specific JSON field names are pinned across both TypeScript and Rust implementations.
| Field | Description |
|---|---|
agentId | Identifier for the agent assigned to a session |
resumeOf | Reference to a previous session being continued |
activity | Current status or action of the agent |
continuation | Data required to resume an interrupted turn |
sentAt | Timestamp of message delivery |
Sources: crates/rebase-core/tests/shared_contracts.rs:170-185, src/test/sharedContracts.test.ts:98-112
File Editor and Syntax Analysis
The client includes a native FileEditor that handles file previews, drafts, and syntax highlighting.
Editor Features
The editor performs disk operations and syntax parsing off the UI thread to maintain responsiveness. It utilizes Tree-sitter for incremental parsing and syntax highlighting.
Sources: crates/rebase-gpui/src/file_editor.rs:1-12, crates/rebase-gpui/Cargo.toml:34-40
Syntax Highlighting Logic
Command Line Interface
The native binary supports several flags for development and data management.
| Flag | Function |
|---|---|
--dev-data | Opens an isolated development database |
--rebase-data | Opens the production rebase.db directly |
--check-data | Validates and lists the selected store, then exits |
--cwd PATH | Sets the initial project directory |
--fixture | Seeds the database with a 10,000-message stress test |
Sources: crates/rebase-gpui/src/main.rs:205-220, crates/rebase-gpui/src/main.rs:245-260
Experimental Limitations
As an experimental preview, the GPUI Native Client has specific operational constraints:
- Shared Database Access: It is recommended not to open the same conversation in both the Tauri and Native apps simultaneously, as Rebase saves whole conversations and may overwrite turns.
- Platform Requirements: On macOS, it requires Xcode and Node.js 22+.
- Feature Parity: While it supports core features like the file editor and terminal, it remains a preview of the eventual native port.
Sources: README.md:129-138
Summary
The GPUI Native Client provides a high-performance, GPU-accelerated interface for the Rebase agent system. By sharing a database and strictly defined data contracts with the production Tauri app, it allows for seamless transitions between environments while testing new Rust-native UI capabilities.
Sources: crates/rebase-gpui/src/main.rs:188-195, src/test/sharedContracts.test.ts:27-30