Skip to content

feat(tui): Batch 1 — event bus, AppState, two-panel layout, -T flag - #57

Merged
NikolaRHristov merged 2 commits into
Currentfrom
tui
Jul 22, 2026
Merged

feat(tui): Batch 1 — event bus, AppState, two-panel layout, -T flag#57
NikolaRHristov merged 2 commits into
Currentfrom
tui

Conversation

@NikolaRHristov

Copy link
Copy Markdown
Member

Batch 1 — Minimal TUI scaffold

This PR is the first incremental batch toward Run -T. Everything compiles against the existing codebase with zero behaviour change to the plain CLI path.

What changed

File Change
Source/Struct/Event.rs New — typed event enum (JobStarted, Line, JobProgress, JobFinished, IndexLockTimeout, AllDone)
Source/Struct/Tui.rs NewAppState, DirState, Status enum, SPINNER frames, all nav/scroll helpers
Source/Fn/Tui/mod.rs New — terminal init/restore RAII guard + main 100 ms tick loop
Source/Fn/Tui/Render.rs New — two-panel ratatui layout (30 % dir list / 70 % log) + bottom status bar
Source/Fn/Tui/Input.rs New — keyboard (↑↓ jk, PgUp/Dn, s, q, Ctrl-C) + mouse click dispatch
Source/Fn/Binary/Command/Sequential.rs Modified — accepts Sender<Event>, removes all println!/eprintln!
Source/Fn/Binary/Command/Parallel.rs Modified — same
Source/Fn/Binary/Command.rs Modified — adds -T / --Tui clap flag
Source/Struct/Binary/Command/Option.rs Modified — adds Tui: bool field
Source/Struct/Binary/Command.rs Modified — creates mpsc channel, dispatches to Tui::Fn or plain printer
Source/Fn/mod.rs Modifiedpub mod Tui
Source/Struct/mod.rs Modifiedpub mod Event; pub mod Tui
Cargo.toml Modified — adds ratatui = "0.29", crossterm = "0.28"

How to test locally

# CLI mode — identical behaviour to before
cargo run -- Cargo.toml -C "echo hello"

# TUI mode
cargo run -- -T Cargo.toml -C "cargo check"

# Parallel + TUI
cargo run -- -T -P Cargo.toml -C "cargo check"

Key design decisions

  • Execution engines are now 100 % I/O-free — all output flows through mpsc::unbounded_channel::<Event>.
  • The CLI printer is a zero-overhead tokio::spawn that calls println!/eprintln! — exact same observable output as before.
  • ratatui/crossterm are unconditional dependencies (not feature-gated) to keep the PR minimal; feature-gating can be a follow-up.
  • RAII TerminalGuard ensures the terminal is always restored even on panic.
  • Spinner uses 10-frame Braille animation cycling on the 100 ms tick.

Next batches

  • Batch 2 — re-run a directory on r keypress (daemon-like re-queue), exact click coordinates via area threading
  • Batch 3 — command selector overlay (which commands to run per dir), filter/search in dir list
  • Batch 4 — persist log to file, copy selected line to clipboard

Adds the full scaffold for `Run -T`:
- Source/Struct/Event.rs          — typed event enum (JobStarted, Line, JobFinished, AllDone)
- Source/Struct/Tui.rs            — AppState: panel list, log buffers, status, selection, tick
- Source/Fn/Tui/mod.rs            — terminal init/restore guard + main app loop (crossterm + ratatui)
- Source/Fn/Tui/Render.rs         — two-panel layout: dir list (left) + log viewer (right)
- Source/Fn/Tui/Input.rs          — keyboard + mouse click dispatch
- Source/Fn/Binary/Command/Sequential.rs — inject Sender<Event>, remove direct println/eprintln
- Source/Fn/Binary/Command/Parallel.rs  — inject Sender<Event>, remove direct println/eprintln
- Source/Fn/Binary/Command.rs     — add -T / --Tui flag
- Source/Struct/Binary/Command.rs — wire Tui flag through Option and dispatch to Tui::Fn
- Source/Struct/Binary/Command/Option.rs — add Tui: bool field
- Source/Fn/mod.rs                — pub mod Tui
- Source/Struct/mod.rs            — pub mod Event + Tui
- Cargo.toml                      — add ratatui, crossterm, unicode-width under [tui] feature
@NikolaRHristov
NikolaRHristov merged commit 314c25e into Current Jul 22, 2026
7 of 11 checks passed
@NikolaRHristov
NikolaRHristov deleted the tui branch July 22, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant