Skip to content

Commit e7a796f

Browse files
david-plclaudeCopilot
authored
Add a composable ratatui TUI to ppvm-cli (#166)
## Summary Adds a composable [ratatui](https://ratatui.rs) TUI to `ppvm-cli`. Bare `ppvm` launches a unified single-screen REPL + step-debugger; `ppvm <file>` opens a program paused at the first instruction. The existing `run`/`dump`/`parse`/`debug` subcommands are unchanged. - **New library crate `crates/ppvm-tui`** holds the terminal-agnostic pieces: an `AppState` owning a `ppvm_vihaco::composite::PPVM`, the command grammar, and four ratatui `Widget` view components (Program/State/Measurement-record/Command line). - **`ppvm-cli` (bin)** owns only terminal setup (RAII restore on panic) and the blocking event loop. - **Composability:** view components own no terminal and run no loop (`impl Widget for &…View`-style; `handle_key(KeyEvent) -> bool`), and deps are pinned to `ratatui`/`crossterm` `0.29.0` to match `stellarscope` so panels can dock together later. ### Features - **REPL:** `device N` then gate ops (`h 0`, `cnot 0 1`, `rx 0 0.5`, `measure 0`, …); outcomes echo as `=> bits`. - **Debugger:** `:load`, Enter = step, `:c` = continue to next breakpoint/end, `:reset`; authored `breakpoint`s pause. - **Breakpoint gate injection:** at a breakpoint you can apply ad-hoc gates and resume — backed by making `apply_circuit_instruction` preserve the program counter (`ppvm-vihaco`). - **Line editing + history:** movable cursor (←/→, Home/End, insert/Backspace/Delete) drawn via the terminal cursor; ↑/↓ command history with a draft stash. - **`:help`** toggles a command-reference overlay (works in both modes). ## Base branch Targets **`david/42-circuit-component`** (not `main`) — this branch was cut from it and depends on its `vihaco-circuit-isa` work. The merge commit here also pulls in that branch's `Add back eyre` fix (a pre-existing derive-macro build breakage), so the branch compiles. ## Design docs - Spec: `docs/superpowers/specs/2026-07-01-cli-tui-design.md` - Plan: `docs/superpowers/plans/2026-07-01-cli-tui.md` ## Testing - `cargo test --workspace` — green (0 failures). - `ppvm-tui`: 36 tests (command grammar, REPL/debug state transitions, breakpoint injection resume, cursor/history editing, help toggle, `TestBackend` render checks). - `clippy --all-targets` clean. Built TDD, task-by-task, with per-task + whole-branch review. **Draft:** opened for review before it's ready to merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a24a69f commit e7a796f

17 files changed

Lines changed: 2134 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ jobs:
7070
run: cargo test -p ppvm-stim --features rayon
7171

7272
# Cross-compile the whole workspace for browser wasm so a wasm regression
73-
# surfaces in CI. `ppvm-python-native` (a CPython extension) and `ppvm-cli`
74-
# (a terminal binary using clap and forcing the rayon feature) are never
75-
# browser-wasm targets and are excluded; the reusable engine lives in the
76-
# library crates, which stay covered. Native-only acceleration deps (gxhash,
77-
# dashmap → rayon, ahash) are pruned automatically by the `cfg(not(target_arch =
73+
# surfaces in CI. Three crates are never browser-wasm targets and are
74+
# excluded: `ppvm-python-native` (a CPython extension), `ppvm-cli` (a terminal
75+
# binary), and `ppvm-tui` (its ratatui/crossterm terminal UI). The reusable
76+
# engine lives in the library crates, which stay covered. Native-only
77+
# acceleration deps (gxhash, dashmap →
78+
# rayon, ahash) are pruned automatically by the `cfg(not(target_arch =
7879
# "wasm32"))` dependency tables, and `rand`'s entropy uses the getrandom
7980
# `wasm_js` backend wired in `.cargo/config.toml` — so no extra flags here.
8081
wasm-build:
@@ -91,7 +92,7 @@ jobs:
9192
- uses: Swatinem/rust-cache@v2
9293

9394
- name: Build workspace for wasm32-unknown-unknown
94-
run: cargo build --target wasm32-unknown-unknown --workspace --exclude ppvm-python-native --exclude ppvm-cli
95+
run: cargo build --target wasm32-unknown-unknown --workspace --exclude ppvm-python-native --exclude ppvm-cli --exclude ppvm-tui
9596

9697
python-tests:
9798
name: Python tests

0 commit comments

Comments
 (0)