Skip to content

feat(chisel): TUI support#14748

Open
mablr wants to merge 2 commits into
masterfrom
mablr/chisel-tui
Open

feat(chisel): TUI support#14748
mablr wants to merge 2 commits into
masterfrom
mablr/chisel-tui

Conversation

@mablr
Copy link
Copy Markdown
Collaborator

@mablr mablr commented May 13, 2026

Description

Adds an interactive ratatui-based TUI to the chisel REPL when running in a TTY, with a 3-region layout (output history, live variable state pane, syntax-highlighted input). Falls back to the existing plain rustyline loop in non-TTY / CI / TERM=dumb environments.

Key changes:

  • Unified output buffer: introduces ReplMessage { kind, text } and push_out/push_err helpers on ChiselDispatcher converts every sh_println!/sh_err! in REPL paths (all ! commands, traces, logs) to push into the buffer so the TUI can render them in its output pane.

  • Plain REPL drains the buffer through sh_println!/sh_err! so existing behavior (and rexpect tests) stays intact.

  • show_traces -> render_traces returning Option<String> inspect()'s error path bundles traces/logs into the returned error.

  • foundry-tui: adds with_suspended_terminal + thread-local TUI marker; TerminalGuard now also enables/disables bracketed paste. !edit and !exec wrap their child-process calls so the editor/shell command gets direct access to the terminal.

  • Live state pane via batched abi.encode(v1, v2, ...) -> 2 compiles per refresh instead of N+1.

  • Input widget: persistent multi-line history (escapes embedded \n in ~/.foundry/.chisel_history), bracketed-paste support, horizontal scrolling so the cursor is always visible, Backspace at column 0 pops a pending continuation, Esc/Ctrl+D only quit when both buf and pending are empty, blank Enter does not pollute history.

  • Adds DumbTerminal fallback reason

Adds an interactive ratatui-based TUI to the chisel REPL when running in
a TTY, with a 3-region layout (output history, live variable state pane,
syntax-highlighted input). Falls back to the existing plain rustyline
loop in non-TTY / CI / TERM=dumb environments.

Key changes:

* Unified output buffer: introduces ReplMessage { kind, text } and
  push_out/push_err helpers on ChiselDispatcher; converts every
  sh_println!/sh_err! in REPL paths (all ! commands, traces, logs) to
  push into the buffer so the TUI can render them in its output pane.
* Plain REPL drains the buffer through sh_println!/sh_err! so existing
  behavior (and rexpect tests) stays intact.
* show_traces -> render_traces returning Option<String>; inspect()'s
  error path bundles traces/logs into the returned error.

* foundry-tui: adds with_suspended_terminal + thread-local TUI marker;
  TerminalGuard now also enables/disables bracketed paste. !edit and
  !exec wrap their child-process calls so the editor/shell command gets
  direct access to the terminal.

* Live state pane via batched abi.encode(v1, v2, ...) snapshot
  (snapshot_session_variables) + tuple decode -> 2 compiles per refresh
  instead of N+1.

* Input widget: persistent multi-line history (escapes embedded \n in
  ~/.foundry/.chisel_history), bracketed-paste support, horizontal
  scrolling so the cursor is always visible, Backspace at column 0 pops
  a pending continuation, Esc/Ctrl+D only quit when both buf and
  pending are empty, blank Enter does not pollute history.

* Adds DumbTerminal fallback reason; cargo test -p chisel and
  -p foundry-tui all green; clippy clean.

Amp-Thread-ID:
https://ampcode.com/threads/T-019e2231-66cc-7558-a0ec-279836f8a6dd
Co-authored-by: Amp <amp@ampcode.com>
@mablr mablr marked this pull request as ready for review May 13, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant