Skip to content

feat(tui): restructure to component-based architecture with usability improvements#3

Merged
broomva merged 5 commits intomainfrom
feat/tui-restructure
Mar 2, 2026
Merged

feat(tui): restructure to component-based architecture with usability improvements#3
broomva merged 5 commits intomainfrom
feat/tui-restructure

Conversation

@broomva
Copy link
Owner

@broomva broomva commented Mar 2, 2026

Summary

Complete TUI restructure from flat module layout to component-based architecture with usability improvements:

  • Phase 1 — Foundation: Restructured into models/ (state, scroll, ui_block) and widgets/ (chat_log, status_bar, spinner, input_bar, approval_banner). Added unified TuiEvent event pump, FocusTarget with Tab cycling, Theme centralizing all colors, and ScrollState with offset-from-bottom auto-follow semantics.
  • Phase 2 — Rich Input: Unified command parser (/clear, /help, /model, /approve, /sessions, /state), InputHistory ring buffer with draft preservation, and InputBarState with cursor tracking, word movement (Ctrl+Left/Right), Home/End, Delete.
  • Phase 4 — Polish: Risk-colored approval banner widget with dynamic layout, connection status tracking, submit_message/submit_approval helpers, 3-tier error surfacing (status bar flash, inline SystemAlert, approval banner).
  • Phase 5 — Advanced Features: Session browser (lists sessions from daemon, keyboard nav), state inspector (agent state vector, budget, mode, progress bars), /sessions and /state commands, side panel layout (70/30 split), extended focus targets with Shift+Tab panel cycling.
  • Test coverage audit: Word boundary navigation, error flash TTL, HTTP client methods (wiremock), UTF-8 cursor counting, Delete key behavior.

Stats: 20 files changed, +2,900 / -525 lines | 79 tests passing (up from 14) | Clippy clean | Full workspace builds

Test plan

  • cargo fmt && cargo clippy -p arcan-tui -- -D warnings passes
  • cargo test -p arcan-tui — 79 tests pass
    • command: 16, history: 8, focus: 4, scroll: 8, state: 7, network: 12
    • input_bar: 10, approval_banner: 3, session_browser: 4, state_inspector: 6, spinner: 1, theme: 1
  • cargo check --workspace — full workspace compiles clean
  • Manual: launch arcan chat, verify scroll, focus cycling, command input, /sessions, /state

🤖 Generated with Claude Code

broomva and others added 5 commits March 1, 2026 20:17
… bar

Restructure arcan-tui from flat module layout to component-based
architecture with models/, widgets/, and shared infrastructure modules.

New modules:
- event.rs: Unified TuiEvent enum + event_pump merging terminal/network/tick
- focus.rs: FocusTarget enum with Tab cycling between ChatLog and InputBar
- theme.rs: Centralized Theme struct replacing hardcoded colors
- models/scroll.rs: ScrollState with offset-from-bottom, auto-follow, page navigation
- models/state.rs: Migrated AppState with scroll, focus, connection_status, error flash
- models/ui_block.rs: Extracted UiBlock, ToolStatus, ApprovalRequest
- widgets/chat_log.rs: Scrollable chat log with timestamps
- widgets/status_bar.rs: Session, branch, mode, connection dot, error flash
- widgets/spinner.rs: Animated Unicode spinner

Modified:
- app.rs: Uses event_pump, split key handling by focus, /help command
- lib.rs: Registers new modules
- models.rs: Re-export hub for backward compatibility
- ui.rs: Thin coordinator with 3-chunk layout (chat + status + input)

Tests: 26 (up from 14, all original tests migrated)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unified command parser, ring-buffer input history with Up/Down
navigation, and cursor-aware input bar with word movement.

New modules:
- command.rs: Unified parser for /clear, /help, /model, /approve + plain messages
  (14 tests covering all command variants and error cases)
- history.rs: InputHistory ring buffer (capacity 100) with draft preservation
  and dedup (8 tests)
- widgets/input_bar.rs: InputBarState with cursor tracking, Home/End,
  Ctrl+Left/Right word movement, Delete key support (5 tests)

Modified:
- app.rs: Uses command::parse() instead of inline parsing, delegates to
  InputBarState for all text input. Removed 6 old parse_model_command tests
  (now covered by command.rs tests with better coverage)
- ui.rs: Accepts InputBarState, delegates rendering to input_bar widget
- lib.rs/widgets.rs: Register new modules

Tests: 47 (up from 26, +27 new, -6 migrated to command.rs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add risk-colored approval banner widget with dynamic layout (conditionally
shown between chat log and status bar). Extract submit_message and
submit_approval helpers. Update connection status on network events.
3-tier error surfacing: status bar flash, inline SystemAlert, approval banner.

50 tests passing, clippy clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add session browser widget (list sessions from daemon, keyboard navigation,
selection) and state inspector widget (agent state vector, budget, mode,
progress bars). New /sessions and /state commands toggle side panels.
Extend FocusTarget with SessionBrowser and StateInspector variants.
Add network client methods for list_sessions and get_session_state.
Dynamic horizontal split layout: 70% main chat, 30% panels.

64 tests passing (up from 50), clippy clean, full workspace builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 15 new tests covering previously untested pure logic:
- InputBarState: Ctrl+Left/Right word boundaries (3 tests), Delete key,
  cursor_col UTF-8 char counting
- AppState: flash_error, clear_expired_errors TTL expiry/retention,
  default state assertions
- NetworkClient: wiremock HTTP tests for list_sessions (success/error),
  get_session_state (default/custom branch), submit_run, submit_approval

79 tests passing (up from 64), clippy clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@broomva broomva merged commit 6309d94 into main Mar 2, 2026
8 checks passed
@broomva broomva deleted the feat/tui-restructure branch March 2, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant