Skip to content

Architecture

sivtr is a Cargo workspace with two main layers:

  • sivtr, the binary crate in src/;
  • sivtr-core, the library crate in crates/sivtr-core/.

The binary owns user interaction: CLI parsing, command dispatch, TUI state, and platform-specific hotkey behavior. The core crate owns reusable logic: capture, parsing, buffers, selection, search, history, export, config, and Codex session parsing.

sivtr/
|- Cargo.toml
|- src/
| |- cli.rs
| |- main.rs
| |- app.rs
| |- commands/
| `- tui/
`- crates/
`- sivtr-core/
`- src/
|- buffer/
|- capture/
|- config/
|- export/
|- history/
|- parse/
|- search/
|- selection/
|- session/
`- codex.rs

The binary crate contains:

AreaResponsibility
cli.rsclap command definitions and help text
commands/command handlers for run, pipe, copy, history, config, hotkey, diff, and import
app.rsTUI state machine
tui/terminal setup, event handling, and rendering
command_blocks.rsparsed command-block spans for session browsing and copying

This layer can depend on terminal UI libraries, platform APIs, and process spawning behavior.

The core crate contains reusable domain logic:

ModuleResponsibility
capturestdin, subprocess, and scrollback/session capture helpers
parseANSI stripping, Unicode display width, and line parsing
bufferline, cursor, and viewport models
selectionvisual, line, and block selection extraction
searchmatching and navigation state
historySQLite storage, schema, and search
exportclipboard, file, and editor export helpers
configTOML config model, defaults, and path resolution
sessionstructured session entries and rendering
codexCodex session discovery, parsing, and formatting

This split keeps computation and data handling in Rust modules that can be tested independently from the TUI.

Pipe mode:

stdin -> capture::pipe -> parse::parse_lines -> Buffer -> App -> TUI/editor

Run mode:

subprocess -> combined output -> parse::parse_lines -> Buffer -> App -> TUI/editor

Session import:

session log -> render entries -> parse::parse_lines -> Buffer -> command block spans -> TUI/editor

Copy mode:

session log -> SessionEntry list -> command blocks -> selector -> filters -> clipboard

Codex copy:

~/.codex/sessions -> current cwd match -> parsed blocks -> selector -> filters -> clipboard

The frontend layer is presentation and interaction. The Rust core performs the computation: parsing, capture, selection extraction, search, storage, and formatting. This keeps UI changes from leaking into the data model and makes command behavior easier to test.