-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add TUI diff mode with mouse scroll and self-detection #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive diff viewing capabilities to the CWT TUI: ## Diff Mode Features - Press 'v' on sessions with changes to view unified diff - Syntax highlighting for additions, deletions, and context - Line numbers for easy reference - Scroll with ββ/jk, PgUp/PgDn, or mouse wheel - Toggle between working tree and staged changes with 'c' - Refresh diff with 'r', exit with Esc/q ## Mouse Support - Enable mouse wheel scrolling in diff mode - Mouse wheel navigation in main session list - Natural scrolling experience for reviewing long diffs ## Self-Detection for Commands - Auto-detect whether running from source or built binary - Switch/merge/publish commands work with both: - go run cmd/cwt/main.go (development) - ./cwt or cwt (built binary) - Created shared utils.ExecuteCWTCommand() for consistency ## Technical Implementation - New DiffMode state with scroll management - Git diff parsing with structured DiffLine types - Lipgloss styling for syntax highlighting - Mouse event handling in Bubble Tea - Robust executable detection logic Fixes the issue where TUI commands failed when running locally with 'go run' instead of built binary. π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @jlaneve's task ββ View job π Code Review: TUI Diff Mode & Self-DetectionI've thoroughly analyzed the implementation and have several observations across code quality, potential issues, performance, security, and testing: β StrengthsCode Quality & Design
Self-Detection Implementation
|
- Fix code formatting issues identified by CI - Add missing newline at end of command.go - All files now pass gofmt and go vet checks π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix final gofmt formatting issue - Ensure proper file ending without extra blank lines π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
β¦andling - Fix cross-platform temp directory detection in utils/command.go - Add git repository validation before changing directories - Change diff target from 'main' to 'origin/main' for remote comparison - Add ScrollAmount constant to replace magic numbers - Improve error messages by capturing stderr in ExecuteCWTCommand π€ Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
π― Overview
This PR adds a comprehensive diff viewing mode to the CWT TUI, along with mouse scroll support and automatic binary detection for command execution.
β¨ Key Features
π Diff Mode
von any session with changesββ/jk,PgUp/PgDn, or mouse wheelc), refresh (r), exit (Esc/q)π±οΈ Mouse Support
π§ Self-Detection
go run cmd/cwt/main.govs built binaryπ οΈ Technical Implementation
Core Components
ExecuteCWTCommand()with detection logicFiles Changed
internal/tui/model.go: Diff mode state and event handlinginternal/tui/view.go: Diff rendering with lipgloss stylinginternal/tui/commands.go: Git diff parsing and data loadinginternal/utils/command.go: Self-detection utility (new)π§ͺ Testing
Tested with both execution methods:
go run cmd/cwt/main.go(development)./cwt(built binary)πΈ Demo
The diff mode provides:
π Related Issues
Fixes the issue where TUI commands (switch/merge/publish) failed when running with
go runinstead of a built binary.Ready for review! The diff mode makes it much easier to review changes before deciding to merge or publish sessions. π