Skip to content

Commit 13ef1e6

Browse files
javoireclaude
andauthored
feat: use dots-style tree display for stack visualization (#55)
Replace ASCII pipe characters with Unicode circles for cleaner tree display: - ● (filled, bold green) marks the current branch - ○ (hollow, dim) marks other branches - │ (vertical line) connects branches Also removes redundant "Processing N branch(es)..." message from sync since the progress indicator already shows this info. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 058a527 commit 13ef1e6

3 files changed

Lines changed: 31 additions & 18 deletions

File tree

cmd/status.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ func printTree(gitClient git.GitClient, node *stack.TreeNode, prefix string, isL
284284
printTreeVertical(gitClient, node, currentBranch, prCache, false)
285285
}
286286

287-
func printTreeVertical(gitClient git.GitClient, node *stack.TreeNode, currentBranch string, prCache map[string]*github.PRInfo, isPipe bool) {
287+
func printTreeVertical(gitClient git.GitClient, node *stack.TreeNode, currentBranch string, prCache map[string]*github.PRInfo, isChild bool) {
288288
if node == nil {
289289
return
290290
}
291291

292-
// Determine the current branch marker
293-
marker := ""
292+
// Determine the node marker (filled for current branch, hollow for others)
293+
nodeMarker := ui.TreeNode()
294294
if node.Name == currentBranch {
295-
marker = ui.CurrentBranchMarker()
295+
nodeMarker = ui.TreeNodeCurrent()
296296
}
297297

298298
// Get PR info from cache
@@ -303,13 +303,13 @@ func printTreeVertical(gitClient git.GitClient, node *stack.TreeNode, currentBra
303303
}
304304
}
305305

306-
// Print pipe if needed
307-
if isPipe {
308-
fmt.Printf(" %s\n", ui.Pipe())
306+
// Print connecting line if this is a child node
307+
if isChild {
308+
fmt.Printf("%s\n", ui.TreeLine())
309309
}
310310

311311
// Print current node
312-
fmt.Printf(" %s%s%s\n", ui.Branch(node.Name), prInfo, marker)
312+
fmt.Printf("%s %s%s\n", nodeMarker, ui.Branch(node.Name), prInfo)
313313

314314
// Print children vertically
315315
for _, child := range node.Children {

cmd/sync.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ func runSync(gitClient git.GitClient, githubClient github.GitHubClient) error {
459459
// Get all remote branches in one call (more efficient than checking each branch individually)
460460
remoteBranches := gitClient.GetRemoteBranchesSet()
461461

462-
fmt.Printf("Processing %d branch(es)...\n\n", len(sorted))
463-
464462
// Build a set of stack branch names for quick lookup
465463
stackBranchSet := make(map[string]bool)
466464
for _, sb := range stackBranches {
@@ -965,15 +963,15 @@ func printTreeForSync(gitClient git.GitClient, node *stack.TreeNode, currentBran
965963
printTreeVerticalForSync(gitClient, node, currentBranch, prCache, false)
966964
}
967965

968-
func printTreeVerticalForSync(gitClient git.GitClient, node *stack.TreeNode, currentBranch string, prCache map[string]*github.PRInfo, isPipe bool) {
966+
func printTreeVerticalForSync(gitClient git.GitClient, node *stack.TreeNode, currentBranch string, prCache map[string]*github.PRInfo, isChild bool) {
969967
if node == nil {
970968
return
971969
}
972970

973-
// Determine the current branch marker
974-
marker := ""
971+
// Determine the node marker (filled for current branch, hollow for others)
972+
nodeMarker := ui.TreeNode()
975973
if node.Name == currentBranch {
976-
marker = ui.CurrentBranchMarker()
974+
nodeMarker = ui.TreeNodeCurrent()
977975
}
978976

979977
// Get PR info from cache
@@ -984,13 +982,13 @@ func printTreeVerticalForSync(gitClient git.GitClient, node *stack.TreeNode, cur
984982
}
985983
}
986984

987-
// Print pipe if needed
988-
if isPipe {
989-
fmt.Printf(" %s\n", ui.Pipe())
985+
// Print connecting line if this is a child node
986+
if isChild {
987+
fmt.Printf("%s\n", ui.TreeLine())
990988
}
991989

992990
// Print current node
993-
fmt.Printf(" %s%s%s\n", ui.Branch(node.Name), prInfo, marker)
991+
fmt.Printf("%s %s%s\n", nodeMarker, ui.Branch(node.Name), prInfo)
994992

995993
// Print children vertically
996994
for _, child := range node.Children {

internal/ui/color.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ func Pipe() string {
8282
return dim.Sprint("|")
8383
}
8484

85+
// TreeNodeCurrent returns the filled circle for current branch (bold green)
86+
func TreeNodeCurrent() string {
87+
return boldGreen.Sprint("●")
88+
}
89+
90+
// TreeNode returns the hollow circle for non-current branches (dim)
91+
func TreeNode() string {
92+
return dim.Sprint("○")
93+
}
94+
95+
// TreeLine returns the vertical line for connecting branches (dim)
96+
func TreeLine() string {
97+
return dim.Sprint("│")
98+
}
99+
85100
// SuccessIcon returns just the green checkmark
86101
func SuccessIcon() string {
87102
return green.Sprint("✓")

0 commit comments

Comments
 (0)