feat: multi-line display format for wt recent#13
Conversation
- Multi-line format is now the default (better for small terminals) - Add --compact/-c flag to use the previous single-line format - Each branch entry shows: - Line 1: index, worktree indicator (*), full branch name - Line 2: commit subject (indented) - Line 3: author and date (indented) - No more truncation of long branch names - Update help documentation to reflect new defaults - Add comprehensive tests for both display formats
Based on benchmarks showing Go code performance is excellent (< 0.2ms for 10k branches), caching would not improve the actual bottleneck which is git command execution time.
|
Claude finished @tobiase's task —— View job PR Review CompleteReview Checklist:
Code Quality Assessment ⭐⭐⭐⭐⭐This PR demonstrates excellent code quality with thoughtful implementation, comprehensive testing, and attention to detail. The changes are well-architected and follow Go best practices consistently. Strengths🏗️ Architecture & Design
📝 Code Quality
🧪 Test Coverage
📚 Documentation
Technical Reviewmain.go:247-299 (handleRecentCommand)The refactored
main.go:1615-1647 (displayBranches)The new multi-line display function is excellent:
main.go:1649-1720 (displayBranchesCompact)The compact format shows sophisticated formatting:
Minor Suggestions1. Consider Terminal Width Detection (Enhancement)The compact format uses fixed maximum widths. Consider detecting terminal width for better responsiveness: // Could add terminal width detection for better adaptive display
termWidth := getTerminalWidth() // hypothetical function
maxBranchLen = min(maxBranchLen, termWidth/4)2. Extract Magic Numbers (Code Quality)In const (
DefaultBranchWidth = 15
DefaultDateWidth = 10
DefaultSubjectWidth = 30
MaxBranchWidth = 40
MaxSubjectWidth = 50
MaxDateWidth = 20
)3. Consider Flag Validation (Robustness)While not necessary for this change, // Already handled well, but could be more explicit
if flags.showOthers && flags.showAll {
return recentFlags{}, fmt.Errorf("cannot use --others and --all together")
}Performance ConsiderationsThe implementation is performance-conscious:
Performance tests confirm filtering remains fast even with 1000+ branches. Security ConsiderationsNo security concerns identified. The code:
VerdictThis PR represents high-quality software development:
The multi-line format effectively addresses the issue with long branch names in small terminal windows, while the Recommendation: ✅ APPROVE This PR is ready for merge. The implementation is solid, well-tested, and provides clear value to users. |
- Star now directly attached to branch name: '0: *branch-name' - Second and third lines properly aligned with branch name - Blank lines between all entries for better readability - Much easier to scan, especially with long branch names Implements task-25
The shell wrapper was filtering out empty lines with [ -n "$line" ] check, which removed the blank lines between entries in multi-line output. Now all lines, including empty ones, are preserved.
Summary
This PR changes the default display format for
wt recentto a multi-line format that shows full branch names without truncation, which is much better for small terminal windows.Changes
Multi-line format is now the default - Each branch entry displays across 3 lines:
Added
--compact/-cflag - Use this to get the previous single-line formatNo more truncation - Branch names are shown in full, solving the issue with long branch names
Updated help documentation - Reflects the new default behavior
Why this change?
As mentioned in the discussion, when working with small terminal displays (like tmux panes), the truncated branch names were problematic. With naming schemes like
<username>/<issue-id>/<description>, branch names get very long and important information was being cut off.The multi-line format solves this by:
Example Output
Default (multi-line):
With --compact flag:
Also included
Test Plan