Scarab Navigation System
Overview
Enable keyboard-driven, Vimium/Vimium-C style navigation for TUI applications running within the Scarab terminal environment.
Documentation
Getting Started
- Quickstart Guide - Get up and running in 5 minutes
- Installation Guide - Detailed setup instructions
- Usage Guide - Integration examples and patterns
Reference
- Introduction - Overview and architecture
- API Reference - Complete API documentation
- Manifest Schema - Plugin manifest specification
- Changelog - Version history
For Plugin Developers
- Plugin Packaging - How to package and distribute
- Release Process - Publishing to crates.io
- Documentation Structure - Documentation organization
Problem
Current navigation plugins in scarab rely on screen-scraping (regex on character buffers). This fails to identify semantic UI elements like buttons, lists, or tabs that don’t look like URLs.
Proposed Architecture: “Semantic Navigation Overlay”
The solution involves a side-channel communication protocol where the TUI application reports its interactive layout to the host (scarab).
1. The Protocol (Scarab Navigation Protocol - SNP)
We define a lightweight IPC protocol (JSON or Protobuf over Unix Domain Socket) for apps to report their UI state.
Message Structure:
message UpdateLayout {
// Unique ID for the window/pane
string window_id = 1;
// List of interactive zones
repeated InteractiveElement elements = 2;
}
message InteractiveElement {
// Unique stable ID for the element (optional, for debugging)
string id = 1;
// Screen coordinates (relative to the terminal window)
uint32 x = 2;
uint32 y = 3;
uint32 width = 4;
uint32 height = 5;
// Type of element (helps with styling the hint)
ElementType type = 6;
// Optional: Description for screen readers / accessibility
string description = 7;
}
enum ElementType {
BUTTON = 0;
INPUT = 1;
LINK = 2;
LIST_ITEM = 3;
TAB = 4;
}2. The Host (Scarab)
- Role: Server / Display Manager.
- Action:
- Exposes a Unix Socket (e.g.,
/tmp/scarab-nav-<pid>.sock). - Sets environment variable
SCARAB_NAV_SOCKETfor child processes. - Listens for
UpdateLayoutmessages. - Maintains a
Map<WindowID, List<InteractiveElement>>. - On Nav Key (e.g.,
f):- Pauses input to child.
- Generates hints (e.g., “AA”, “AB”) for each stored element.
- Overlays these hints on the terminal grid.
- Waits for user input.
- On Hint Selection:
- Lookups coordinates
(x, y)of the selected element. - Synthesizes a Mouse Click Event at
(center_x, center_y)of the element. - Sends this mouse event to the child process’s PTY.
- Lookups coordinates
- Exposes a Unix Socket (e.g.,
3. The Client (Tolaria / Hibana Apps)
- Role: The TUI Application.
- Action:
- During its render loop (e.g., in
ratatui), it “records” the areas of interactive widgets. - Hook: A simple wrapper around
frame.render_widgetcan capture theRectand push it to a thread-local list. - Post-Render: Serialize the list of
Rects and send it toSCARAB_NAV_SOCKET. - Input Handling: Must support Mouse Events (standard in
ratatuiand most modern TUI libs).
- During its render loop (e.g., in
Integration Strategy
A. Shared Library (scarab-nav-client)
Create a small Rust crate scarab-nav-client that handles:
- Socket connection/reconnection (async/non-blocking).
- Buffering layout updates (debounce to avoid flooding).
- Helper traits for
ratatuiwidgets.
B. Tolaria Implementation
In tolaria-lens/src/app.rs:
- Initialize
NavClienton startup. - In
render():// Example pseudo-code let nav_recorder = NavRecorder::new(); // When rendering a widget let area = chunks[1]; nav_recorder.register(area, ElementType::Button, "Click Me"); frame.render_widget(my_widget, area); // End of frame nav_recorder.flush(&app.nav_client);
C. Hibana Implementation
Since Hibana has a “pluggable kernel”, we can add a NavigationService to the kernel that apps can optionally talk to, which then bridges to Scarab. However, direct socket communication from the UI process is simpler and lower latency.
Advantages
- Decoupled: Scarab doesn’t need to know what the app is doing, just where the buttons are.
- Clean: Uses standard Mouse Events for interaction. No complex RPC callbacks needed.
- Retroactive: Can be added to existing TUI apps with minimal changes (just instrument the render loop).
For Maintainers
- Release Process - Detailed release workflow and steps
- Branch Protection Setup - How to configure branch protection
- CODEOWNERS - Code ownership and review requirements
Next Steps
- Define the
UpdateLayoutprotobuf inhibana/proto(or a new sharedscarab-protocolcrate). ✅ Done - Implement the
scarab-nav-clientcrate. ✅ Done - Integrate into
tolaria-lensas a proof of concept.