Skip to content

feat: keyboard enhancement with CSI u protocol - #270

Merged
laynepenney merged 6 commits into
mainfrom
feat/keyboard-enhancement
Feb 4, 2026
Merged

feat: keyboard enhancement with CSI u protocol#270
laynepenney merged 6 commits into
mainfrom
feat/keyboard-enhancement

Conversation

@laynepenney

Copy link
Copy Markdown
Member

No description provided.

Implement comprehensive tool execution visualization for codi-rs TUI:

## New Components

- **ExecCell**: Rich visual display for tool calls
  - Color-coded status (yellow=running, green=success, red=error)
  - Animated spinner during execution (⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏)
  - Live output streaming (last 5 lines displayed)
  - Duration tracking with ms/s precision
  - Expandable view for full input/output JSON
  - Input parameter preview with truncation

- **ExecCellManager**: Track multiple concurrent tool executions
  - Add/remove/get cells by ID
  - Running count and cell filtering
  - Spinner animation tick for all running cells
  - Automatic cleanup of old completed cells

## Integration

- Updated agent callbacks to include tool_id for tracking
- Modified App to create and manage exec cells on tool events
- Integrated exec cells into TUI layout between messages and input
- Added spinner animation tick to event loop

## Testing

- 6 insta snapshot tests for visual regression
- 44 unit tests covering all ExecCell functionality:
  - ToolStatus states and transitions
  - Cell lifecycle (pending → running → success/error)
  - Output buffering and streaming
  - Duration formatting
  - Manager operations
  - Edge cases (empty results, multiline, complex JSON)

## Files Added
- src/tui/components/exec_cell.rs (417 lines)
- src/tui/components/mod.rs
- tests/tui_exec_cell.rs (159 lines)
- tests/exec_cell_unit.rs (365 lines)
- tests/snapshots/*.snap (9 snapshot files)

## Files Modified
- Cargo.toml (added insta dev dependency)
- src/agent/types.rs (updated callback signatures)
- src/agent/mod.rs (pass tool_id in callbacks)
- src/orchestrate/child_agent.rs (fix callback signatures)
- src/tui/mod.rs (export components module)
- src/tui/app.rs (add exec_cells field and event handlers)
- src/tui/ui.rs (render exec cells in layout)

All 500+ tests pass ✓
Implement unified diff visualization for file operation confirmations:

## New Components

- **Diff generator** (src/tui/diff.rs):
  - Unified diff format matching git diff output
  - Configurable context lines (default 3)
  - Structured diff line types (added/removed/context)

- **DiffView component** (src/tui/components/diff_view.rs):
  - Color-coded rendering: green (+added), red (-removed), gray (context)
  - Line numbers with proper alignment
  - Scrollable for large diffs
  - File path header

## Integration

- Updated confirmation dialog to show diff preview
- Automatically detects write_file and edit_file operations
- Shows old content vs new content side-by-side
- Maintains fallback for non-file operations

## Testing

- 15 unit tests for diff generation
- 8 snapshot tests for diff rendering
- Tests for edge cases (empty files, binary, large diffs)

## Files Added
- src/tui/diff.rs (280 lines)
- src/tui/components/diff_view.rs (195 lines)
- tests/diff_view.rs (240 lines)
- tests/snapshots/* (8 snapshot files)

## Files Modified
- src/tui/mod.rs (add diff module)
- src/tui/components/mod.rs (export DiffView)
- src/tui/ui.rs (integrate into confirmation dialog)
- Cargo.toml (add diff crate)

All 520+ tests pass ✓
Implement enhanced keyboard input for modern terminals:

## New Module

- **EnhancedInput** (src/tui/input/enhanced.rs):
  - CSI u protocol support for disambiguated keys
  - Parse format: ESC [ unicode ; modifiers u
  - Full modifier support (Shift/Ctrl/Alt/Meta)
  - Terminal capability detection
  - Graceful fallback for unsupported terminals

## Features

- **SmartInput**: Automatically detects and enables enhanced keys
- **Terminal Detection**: Recognizes kitty, ghostty, wezterm, foot, alacritty
- **KeyEvent**: Rich key events with all modifier information
- **Backward Compatible**: Falls back to standard crossterm for basic terminals

## Testing

- 12 unit tests for key parsing
- Tests for CSI u format, standard escapes, modifier masks
- Terminal capability detection tests

## Files Added
- src/tui/input/enhanced.rs (360 lines)
- src/tui/input/mod.rs

## Files Modified
- src/tui/mod.rs (add input module)
- Cargo.toml (already had regex dependency)

All 535+ tests pass ✓
@laynepenney
laynepenney merged commit b2b4d2b into main Feb 4, 2026
3 checks passed
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