revdiff is a Terminal User Interface (TUI) designed for reviewing diffs, files, and documents with inline annotations. It is built using the bubbletea framework. The system is organized into several functional layers:
- Composition Root (
app/): Handles the main entry point, configuration parsing, stdin validation, VCS detection, and theme wiring. - TUI Layer (
app/ui/): Manages the user interface using a single Model struct, including popups (overlay), navigation (sidepane), styling, and an intra-line diff engine (worddiff). - Core Logic Packages:
app/diff/: Handles VCS detection and diff parsing.app/highlight/: Provides syntax coloring via chroma.app/annotation/: Manages the in-memory store for annotations.app/editor/: Handles invoking the user's $EDITOR.app/theme/: Implements a catalog-centric theme system.app/history/: Manages auto-saving review sessions.
┌─────────────────────────────────────────────────────┐
│ app/ — composition root (package main) │
│ main.go — main(), early-exit flow │
│ config.go — options, parseArgs, config IO │
│ stdin.go — stdin validation, /dev/tty │
│ renderer_setup.go — VCS detection, renderer pick │
│ themes.go — theme CLI commands, wiring │
│ history_save.go — history-save policy │
├─────────────────────────────────────────────────────┤
│ app/ui/ — bubbletea TUI (single Model struct) │
│ ├── overlay/ — popup layers (help, annots, │
│ │ theme selector) │
│ ├── sidepane/ — file tree + markdown TOC │
│ ├── style/ — color/ANSI resolution │
│ └── worddiff/ — intra-line diff engine │
├─────────────────────────────────────────────────────┤
│ app/diff/ — VCS detection + diff parsing │
│ app/highlight/ — chroma syntax coloring │
│ app/annotation/ — in-memory annotation store │
│ app/editor/ — external $EDITOR invocation │
│ app/handoff/ — post-flush command preparation │
│ app/keymap/ — configurable keybindings │
│ app/theme/ — Catalog-centric theme system │
│ app/history/ — review session auto-save │
│ app/fsutil/ — filesystem utilities │
└─────────────────────────────────────────────────────┘