feat: diff preview in confirmation dialogs - #269
Merged
Conversation
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 ✓
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.
No description provided.