Skip to main content

Crate diffler

Crate diffler 

Source
Expand description

diffler binary internals, exposed as a library so the integration tests can drive the full app (event pump + MCP server) headlessly. The public surface is the binary’s: nothing here is a stable API.

Modules§

app
Application state and event handling. App::handle is a pure-ish state transition (no terminal IO) so the whole shell is unit-testable; rendering reads the state in ui::draw. Per-screen state and handlers live in the status, log, and diff submodules.
clipboard
OSC52 clipboard sequences. The escape string is produced here and written to the terminal stream by the main loop after a draw — never from inside rendering, so the alternate screen stays intact. OSC52 is the only clipboard mechanism (works over ssh/tmux, no native deps).
config
Layered TOML configuration: defaults → global file → project file → CLI.
editor
$EDITOR integration. The TUI loop owns the terminal, so opening an editor is a request: App queues an EditorRequest, the main loop suspends the terminal, runs the subprocess, restores the screen, and hands the outcome back to App::editor_finished.
event
Terminal event pump: crossterm’s async stream plus a periodic tick, multiplexed onto one channel. Kept thin — all decisions live in App::handle, which is what the tests drive.
keymap
Key bindings: neogit-style defaults per screen, overridable from [keys.*] config sections, with multi-key sequence resolution.
mcp
Embedded MCP server: agents read review comments, answer them in place, and long-poll for the human’s feedback. Tool handlers never touch the review directly — every call is sent through the app event channel as an McpRequest and answered by App::handle_mcp on the main loop, so the app stays the single owner of all state (no locks).
theme
Color theme. GitHub-dark is the only built-in theme; the ui.theme config key exists so more can land without a config break.
transient
Magit/neogit-style transient menus: a top-level prefix key opens a transient whose own keys are pure leaves (immediate actions). The model is data, not closures, so resolution and the which-key panel layout stay pure and unit-testable; the app owns the live transient state and timer.
tree
Pure directory-trie flattening shared by the diff sidebar and the status sections. A file list (repo-relative paths, in input order) becomes a list of visible rows honoring fold state — directories before files at each level, input order preserved within a kind, folded directories hiding their subtree. No rendering and no app state, so the navigation math is fully unit-testable.
ui
Rendering. draw never computes review state; it reads App (the diff view additionally fills its lazy highlight cache and follows the cursor with its scroll offset, which is why it takes &mut App).
watch
Filesystem watcher: debounced notify events on the repo become AppEvent::RepoChanged. Noise sources (the session store, lockfiles, git’s object database) are filtered out so staging or saving a comment does not echo back as a repo change.