feat(tui): restructure to component-based architecture with usability improvements#3
Merged
feat(tui): restructure to component-based architecture with usability improvements#3
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete TUI restructure from flat module layout to component-based architecture with usability improvements:
models/(state, scroll, ui_block) andwidgets/(chat_log, status_bar, spinner, input_bar, approval_banner). Added unifiedTuiEventevent pump,FocusTargetwith Tab cycling,Themecentralizing all colors, andScrollStatewith offset-from-bottom auto-follow semantics./clear,/help,/model,/approve,/sessions,/state),InputHistoryring buffer with draft preservation, andInputBarStatewith cursor tracking, word movement (Ctrl+Left/Right), Home/End, Delete.submit_message/submit_approvalhelpers, 3-tier error surfacing (status bar flash, inline SystemAlert, approval banner)./sessionsand/statecommands, side panel layout (70/30 split), extended focus targets with Shift+Tab panel cycling.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 warningspassescargo test -p arcan-tui— 79 tests passcargo check --workspace— full workspace compiles cleanarcan chat, verify scroll, focus cycling, command input,/sessions,/state🤖 Generated with Claude Code