Expand description
FrankenTUI (ftui) application model for cass TUI.
Defines the Elm-architecture types: CassApp (Model), CassMsg (Message),
and service trait boundaries. This module is the foundational type definition
that all subsequent ftui feature work builds on (bead 2noh9.2.2).
§Architecture
Event (key/mouse/resize/tick)
│
▼
CassMsg (from Event)
│
▼
CassApp::update(&mut self, msg) -> Cmd<CassMsg>
│
├── Pure state transition → Cmd::none()
├── Async search → Cmd::task(SearchService::execute)
├── Spawn editor → Cmd::task(EditorService::open)
├── Export → Cmd::task(ExportService::export)
└── Persist state → Cmd::save_state()
CassApp::view(&self, frame)
│
▼
Renders current state to ftui Frame§FrankenTUI UX Overhaul (1mfw3)
This module underwent a comprehensive UX overhaul migrating from ratatui to ftui (a custom Elm-architecture framework). Key subsystems introduced:
§Command Palette
Keyboard-first action dispatch via Ctrl+P / Alt+P. The palette provides fuzzy
search over ~28 action variants grouped into 7 categories (Chrome, Filter, View,
Analytics, Export, Recording, Sources). Filtering uses Bayesian-scored matching
with six modes (All/Exact/Prefix/WordStart/Substring/Fuzzy) cycled via F9.
See PaletteState in components/palette.rs for state, and
PaletteLatencyStats for query performance instrumentation.
Design tradeoff: Bayesian scoring adds ~50μs per keystroke but produces significantly better ranking than simple substring matching. The latency budget indicator (OK <200μs, WARN <1000μs, SLOW ≥1000μs) keeps this measurable. Alt+B toggles a micro-bench overlay showing queries/second throughput.
§Responsive Layout
Terminal width drives LayoutBreakpoint (Narrow <80, MediumNarrow 80-119,
Medium 120-159, Wide ≥160). Each breakpoint maps to concrete topology contracts:
SearchTopology: pane widths, split handle, dual-pane toggleAnalyticsTopology: tab bar, filter summary, header rows, footer hintsVisibilityPolicy: theme label, hint slots/budget, saved-view path length
Ultra-narrow terminals (<30 cols or <6 rows) get a “terminal too small” fallback rather than a broken layout.
§Analytics Explorer
Seven views under AnalyticsView: Dashboard, Explorer, Heatmap, Breakdowns,
Tools, Plans, Coverage. The Explorer view supports interactive cycling of:
ExplorerMetric(m/M): ApiTokens, ContentTokens, Messages, ToolCalls, etc.ExplorerOverlay(o): None, ByAgent, ByWorkspace, BySourceExplorerZoom(z/Z): All, 24h, 7d, 30d, 90d- GroupBy (g/G): Hour, Day, Week, Month
Chart data is pre-computed via load_chart_data() in analytics_charts.rs.
§Inspector & Diagnostics
Ctrl+Shift+I opens the inspector overlay with 7 tabs (InspectorTab):
Timing, Layout, HitRegions, Resize, Diff, Budget, Timeline. Each tab renders
from EvidenceSnapshots, which are updated per-tick from ftui’s evidence
telemetry rather than re-parsing log files at render time.
FrameTimingStats maintains a rolling ring buffer of frame durations for
FPS calculation and jitter detection.
§Theme Cycling
F2 cycles forward through 18 preset themes; Shift+F2 cycles backward.
Theme selection persists to theme.json in the data directory.
§Key Bindings
Modal interceptors form a priority stack: inspector > palette >
normal key handling. When a modal is open, it captures all input except its own
dismiss/close messages, which must be explicitly passed through (not swallowed
by _ => Cmd::none() wildcards).
§Test Coverage
- 532 unit tests in this module (palette, latency, responsive, inspector, etc.)
- 59 unit tests in
components/palette.rs - 74 cross-workstream integration tests in
tests/cross_workstream_integration.rs - Key regression suites: palette lifecycle, dispatch coverage for all 28 action variants, responsive SIZE_MATRIX (16 entries), perf envelope checks
Re-exports§
pub use super::analytics_charts::AnalyticsChartData;
Modules§
- anim_
config - Spring-based animation durations / presets.
- focus_
ids - Well-known focus node IDs for the cass TUI layout.
Structs§
- Agent
Pane - One column of results, grouped by a key.
- Analytics
Filter State - Analytics-specific filter state (persisted within the analytics surface).
- Analytics
Topology - Per-breakpoint layout parameters for the analytics surface.
- Animation
State - Centralized animation state for all spring-based animations in the TUI.
- CassApp
- Top-level application state for the cass TUI.
- Cockpit
Topology - Per-breakpoint sizing and truncation policy for the cockpit overlay.
- Detail
Find State - Inline find state within the detail pane.
- Doctor
HudSummary - Drilldown
Context - Context passed when drilling down from an analytics selection into search.
- Evidence
Snapshots - Cached evidence telemetry snapshots, polled from global singletons on
each tick. Inspector/cockpit panels read these during
view()instead of parsing the JSONL evidence file at render time. - Export
Result - Result returned by
ExportService::export_html. - Frame
Timing Stats - Rolling frame timing statistics for the inspector overlay.
- Hovered
Result - Inline
TuiConfig - Configuration for inline TUI mode.
- Macro
Config - Configuration for macro recording/playback.
- Palette
Latency Stats - Palette query latency instrumentation (1mfw3.1.7).
- Pane
Split Drag State - Persisted
State - Subset of CassApp state that persists across sessions.
- Resize
Decision Entry - A single resize decision entry for the ring buffer history.
- Resize
Evidence Summary - Result
Item - A search result item prepared for rendering in a VirtualizedList.
- RowMini
Analytics - Saved
View - Persisted filters+ranking for a saved-view slot.
- Saved
View Drag State - Search
Params - Parameters for a search query.
- Search
Result - Result returned by
SearchService::execute. - Search
Topology - Per-breakpoint layout parameters for the search surface.
- Selected
HitKey - Stable identity for a selected search hit.
- Sources
View Item - Display-ready row for a configured source in the Sources view.
- Sources
View State - State for the Sources management surface.
- Swarm
Cockpit Snapshot - Swarm
Cockpit State - Swarm
Stale State Counts - Terminal
Event Payload - Wrapper for terminal events that will be converted to specific messages.
- Timeline
Buffer - Ring buffer of recent adaptive decision events.
- Timeline
Event - A single timeline event for the explainability cockpit.
- Undo
Entry - Snapshot of undoable state for undo/redo (Ctrl+Z / Ctrl+Y).
- Undo
History - Fixed-capacity undo/redo history.
- Visibility
Policy - Per-breakpoint visibility policy for optional UI elements.
Enums§
- Analytics
View - Analytics subview within the Analytics surface.
- AppSurface
- Top-level application surface.
- Breakdown
Tab - Active tab within the Breakdowns view.
- CassMsg
- Messages that drive the cass TUI state machine.
- Context
Window - How much surrounding context to show per result.
- Density
Mode - Visual density of the result list.
- Detail
Tab - Which tab is active in the detail pane.
- Explorer
Metric - Metric to display in the Explorer view.
- Explorer
Overlay - Overlay mode for the Explorer view.
- Explorer
Zoom - Zoom presets for the Explorer time range.
- Focus
Direction - Direction for focus movement.
- Focus
Region - Which pane currently holds keyboard focus.
- Heatmap
Metric - Metric to display in the Heatmap view.
- Inspector
Tab - Active tab in the inspector overlay (Ctrl+Shift+I).
- Layout
Breakpoint - Responsive layout breakpoint based on terminal width.
- Match
Mode - Text matching strategy for search queries.
- Mouse
Event Kind - Mouse event kinds (simplified from crossterm/ftui).
- Ranking
Mode - How search results are ranked and ordered.
- Results
Grouping - How results are grouped into panes (G to cycle).
- Screenshot
Format - Output format for TUI screenshot export.
- Search
Pass - Time
Preset - Quick time filter presets for Shift+F5 cycling.
- Timeline
Event Kind - Type of adaptive decision captured in the timeline.
Constants§
- BULK_
ACTIONS - Labels for the bulk-actions modal menu (order matters — matches action_index).
- OPEN_
CONFIRM_ THRESHOLD - Number of selected items before requiring double-press confirmation.
- RESIZE_
HISTORY_ CAPACITY - Rendering-ready resize evidence summary for inspector/cockpit panels.
- SAVED_
VIEWS_ MODAL_ TITLE - Title used by the saved-views manager modal.
- ULTRA_
NARROW_ MIN_ HEIGHT - ULTRA_
NARROW_ MIN_ WIDTH - Ultra-narrow fallback policy constants.
Traits§
- Editor
Service - Open files in external editors.
- Export
Service - HTML/markdown export.
- Index
Service - Background indexing with progress reporting.
- Persistence
Service - Save/load TUI state to disk.
- Search
Service - Async search execution.
Functions§
- build_
resize_ config - Build the BOCPD-based resize coalescer configuration.
- run_
tui_ ftui - Run the cass TUI using the ftui Program runtime.