Skip to content

Commit 87e2e4a

Browse files
authored
Merge pull request #21 from marcus/show-commits-in-wt-diff
show-commits-in-wt-diff
2 parents d7f9431 + 1746b39 commit 87e2e4a

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

internal/plugins/worktree/view.go

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,10 @@ func (p *Plugin) renderWorktreeItem(wt *Worktree, selected bool, width int) stri
360360
func (p *Plugin) renderPreviewContent(width, height int) string {
361361
var lines []string
362362

363-
// Hide tabs when no worktree is selected - show tmux guide instead
363+
// Hide tabs when no worktree is selected - show welcome guide instead
364364
wt := p.selectedWorktree()
365365
if wt == nil {
366-
return truncateAllLines(p.renderTmuxGuide(width, height), width)
366+
return truncateAllLines(p.renderWelcomeGuide(width, height), width)
367367
}
368368

369369
// Tab header
@@ -392,17 +392,31 @@ func (p *Plugin) renderPreviewContent(width, height int) string {
392392
return truncateAllLines(result, width)
393393
}
394394

395-
// renderTmuxGuide renders a helpful tmux guide when no worktree is selected.
396-
func (p *Plugin) renderTmuxGuide(width, height int) string {
395+
// renderWelcomeGuide renders a helpful guide when no worktree is selected.
396+
func (p *Plugin) renderWelcomeGuide(width, height int) string {
397397
var lines []string
398398

399+
// Section Style
400+
sectionStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("62"))
401+
402+
// Git Worktree Explanation
403+
lines = append(lines, sectionStyle.Render("Git Worktrees: A Better Workflow"))
404+
lines = append(lines, dimText(" • Parallel Development: Work on multiple branches simultaneously"))
405+
lines = append(lines, dimText(" in separate directories."))
406+
lines = append(lines, dimText(" • No Context Switching: Keep your editor/server running while"))
407+
lines = append(lines, dimText(" reviewing a PR or fixing a bug."))
408+
lines = append(lines, dimText(" • Isolated Environments: Each worktree has its own clean state,"))
409+
lines = append(lines, dimText(" unaffected by other changes."))
410+
lines = append(lines, "")
411+
lines = append(lines, strings.Repeat("─", min(width-4, 60)))
412+
lines = append(lines, "")
413+
399414
// Title
400415
title := lipgloss.NewStyle().Bold(true).Render("tmux Quick Reference")
401416
lines = append(lines, title)
402417
lines = append(lines, "")
403418

404419
// Section: Attaching to agent sessions
405-
sectionStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("62"))
406420
lines = append(lines, sectionStyle.Render("Agent Sessions"))
407421
lines = append(lines, dimText(" Enter Attach to selected worktree session"))
408422
lines = append(lines, dimText(" Ctrl-b d Detach from session (return here)"))
@@ -629,21 +643,29 @@ func (p *Plugin) renderCommitStatusHeader(width int) string {
629643

630644
// renderDiffContent renders git diff using the shared diff renderer.
631645
func (p *Plugin) renderDiffContent(width, height int) string {
632-
if p.diffRaw == "" {
633-
wt := p.selectedWorktree()
634-
if wt == nil {
635-
return dimText("No worktree selected")
636-
}
637-
return dimText("No changes")
646+
wt := p.selectedWorktree()
647+
if wt == nil {
648+
return dimText("No worktree selected")
649+
}
650+
651+
// Render commit status header if it belongs to current worktree
652+
header := ""
653+
if p.commitStatusWorktree == wt.Name {
654+
header = p.renderCommitStatusHeader(width)
638655
}
639656

640-
// Render commit status header
641-
header := p.renderCommitStatusHeader(width)
642657
headerHeight := 0
643658
if header != "" {
644659
headerHeight = lipgloss.Height(header) + 1 // +1 for blank line
645660
}
646661

662+
if p.diffRaw == "" {
663+
if header != "" {
664+
return header + "\n" + dimText("No uncommitted changes")
665+
}
666+
return dimText("No changes")
667+
}
668+
647669
// Adjust available height for diff content
648670
contentHeight := height - headerHeight
649671
if contentHeight < 5 {

0 commit comments

Comments
 (0)