Commit e7a796f
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
- crates
- ppvm-cli
- src
- ppvm-tui
- src
- ppvm-vihaco
- src
- tests
- ppvm-python
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
0 commit comments