Workspace Structure
The project is organized as a Cargo workspace with the maintermy binary and 15 supporting crates:
Core Components
Main Application (src/)
The root package integrates GPUI (the UI framework from Zed) with Termy’s terminal functionality:
- main.rs: Application entry point, window setup, lifecycle management
- terminal_view/: GPUI-based terminal view rendering
- commands.rs: Application command handlers
- menus.rs: Platform menus (File, Edit, View, etc.)
- settings_view/: Settings UI
- config/: Configuration loading and parsing
- keybindings/: Keybind registration and handling
Terminal UI (termy_terminal_ui)
Core terminal emulation and rendering logic, UI-framework agnostic:
- runtime.rs: Terminal process management, PTY handling
- grid.rs: Cell-based grid rendering with paint cache optimization
- pane_terminal.rs: Pane abstraction for terminal instances
- tmux/: tmux integration (session/window/pane management)
- links.rs: URL/path detection and classification
- render_metrics.rs: Debug-only performance metrics
Terminal, PaneTerminal, TmuxClient, TerminalGrid
Command Core (termy_command_core)
Pure domain crate for command and keybind behavior:
- Command ID definitions and normalization
- Default keybind configuration
- Keybind directive parsing (
clear, bind, unbind) - Deterministic keybind resolution
gpui or termy_config_core. See Command Boundary below.
Config Core (termy_config_core)
Configuration data structures and parsing logic:
- Configuration schema definitions
- Theme integration (depends on
termy_theme_core) - Config validation and defaults
termy_theme_core only
Theme System
termy_theme_core: Pure theme data structures (no dependencies) termy_themes: Built-in theme collection (depends ontermy_theme_core)
Themes define terminal colors, UI colors, and visual appearance. The separation allows theme definitions to be used across both the main app and CLI tools.
CLI Tools
termy_cli: Standalonetermy-cli binary for:
- Configuration validation and migration
- Keybind inspection
- Theme preview (TUI-based)
- Font listing
- Installation management
Auto-Update System
termy_auto_update: Background update checking and binary download termy_auto_update_ui: GPUI-based update notification UI termy_release_core: Release metadata types and version comparisonAI Integration
termy_openai: OpenAI API client for AI features termy_gemini: Google Gemini API client These crates provide clean API abstractions with minimal dependencies.Utilities
termy_search: Terminal buffer search with regex support termy_toast: Toast notification SDK for GPUI termy_native_sdk: Platform-specific native APIs (macOS, Windows, Linux) xtask: Build automation (doc generation, validation)Dependency Architecture
Layered Design
Command Boundary
The command system enforces strict ownership boundaries:termy_command_core owns:
- Command IDs and config-facing names
- Command parsing and normalization
- Default keybinds
- Keybind directive parsing
- Deterministic resolution order
- UI labels and command palette presentation
- Platform-specific visibility
- Trigger canonicalization (e.g., GPUI keystroke parsing)
- Adapters convert config keybinds to
KeybindLineRef - Adapters call
parse_keybind_directives_from_iter - Adapters call
resolve_keybindsoverdefault_resolved_keybinds
termy_command_core→gpuitermy_command_core→termy_config_coretermy_config_core→termy_themestermy_cli*→gpui
/home/daytona/workspace/source/scripts/check-boundaries.sh and /home/daytona/workspace/source/docs/architecture/command-boundary.md for details.
GPUI Integration
Termy uses GPUI, the UI framework from Zed, for:- Window management and platform integration
- Reactive UI rendering
- Event handling and actions
- Menu and command palette
- GPU-accelerated text rendering
src/ bridges GPUI’s component model with termy_terminal_ui’s terminal abstraction.
Terminal Emulation
Termy uses alacritty_terminal for VT100/xterm emulation:termy_terminal_ui crate wraps alacritty_terminal and provides:
- PTY process spawning (Unix: rustix-openpty)
- Grid-based rendering with dirty-span tracking
- Cell-level paint cache optimization
- Shell integration (tab titles, working directory)
Render Optimization
The terminal renderer uses a multi-tiered caching strategy:- Full rebuild: Complete cell cache regeneration (avoided during cursor blink)
- Partial update: Dirty-span patching for changed regions
- Reuse: No cache update when terminal reports no damage
termy_terminal_ui::render_metrics for debug metrics.
Tmux Integration
Termy has first-class tmux support viatermy_terminal_ui::tmux:
- Session/window/pane discovery
- Split pane navigation
- Tmux control mode protocol
- Integration tests (requires tmux >= 3.3)
Build System
Cargo Workspace
The workspace uses Cargo’s 2021 edition resolver:Build Scripts
build.rs handles platform-specific setup:- macOS: Detects SDK version >= 26 for feature flags
- Windows: Embeds icon resource via
winresource
Justfile Automation
Thejustfile provides task runners:
Testing Strategy
Unit Tests
Each crate has its own test suite:Integration Tests
Tmux integration: End-to-end tmux split testingTERMY_TEST_TMUX_BIN to override binary).
Architecture Checks
CI enforces dependency boundaries:- Forbidden dependencies
- Generated documentation freshness (keybindings, config)
Documentation Generation
Thextask crate auto-generates docs from code:
Platform-Specific Code
macOS
- Core-text pinned to 21.0.0 (avoids core-graphics conflict)
- DMG packaging with Finder layout
- Code signing and notarization support
Windows
- Icon embedding via winresource
- Inno Setup-based installer
- Windows subsystem for GUI app (
#![windows_subsystem = "windows"])
Linux
- Unix PTY via rustix-openpty
- Standard desktop integration
Next Steps
- Building from Source - Build Termy locally
- Contributing - Contribute to Termy
- Configuration - Customize Termy’s behavior