detached 7f38ec6

fix(tui): retain phase progress in narrow bars

commit
7f38ec6b7919d732158d9676374a4d5c2bca616e
author
brice · · 2026-08-06 06:43 UTC
parent
d3cdac6
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +12 -2
M packages/tui/rightbar.go +4 -1
@@ -224,7 +224,10 @@ func truncateRightBarPhaseLine(text string, width int) string {
224224 prefix := text[:nameStart]
225225 suffix := text[nameEnd:]
226226 nameWidth := width - visibleWidth(prefix) - visibleWidth(suffix)
227- if nameWidth <= 0 {
227+ if nameWidth == 0 {
228+ return prefix + suffix
229+ }
230+ if nameWidth < 0 {
228231 return truncateRightBarLine(text, width)
229232 }
230233 return prefix + truncateRightBarLine(text[nameStart:nameEnd], nameWidth) + suffix
@@ -224,7 +224,10 @@ func truncateRightBarPhaseLine(text string, width int) string {
224 prefix := text[:nameStart]224 prefix := text[:nameStart]
225 suffix := text[nameEnd:]225 suffix := text[nameEnd:]
226 nameWidth := width - visibleWidth(prefix) - visibleWidth(suffix)226 nameWidth := width - visibleWidth(prefix) - visibleWidth(suffix)
227- if nameWidth <= 0 {227+ if nameWidth == 0 {
228+ return prefix + suffix
229+ }
230+ if nameWidth < 0 {
228 return truncateRightBarLine(text, width)231 return truncateRightBarLine(text, width)
229 }232 }
230 return prefix + truncateRightBarLine(text[nameStart:nameEnd], nameWidth) + suffix233 return prefix + truncateRightBarLine(text[nameStart:nameEnd], nameWidth) + suffix
M packages/tui/rightbar_test.go +8 -1
@@ -106,6 +106,13 @@ func TestRenderRightBarPreservesPhaseProgressWhenTitleIsClipped(t *testing.T) {
106106 }
107107 }
108108
109+func TestTruncateRightBarPhaseLinePreservesProgressWithoutRoomForName(t *testing.T) {
110+ got := truncateRightBarPhaseLine("[>] Current phase 0/1", 9)
111+ if want := "[>] 0/1"; got != want {
112+ t.Fatalf("truncated phase = %q, want %q", got, want)
113+ }
114+}
115+
109116 func TestRenderRightBarUsesChecklistIndentEllipsisAndBoldPhases(t *testing.T) {
110117 lines := RenderRightBar(Dark, []RightBarWidget{{
111118 Extension: "tasked-phases",
@@ -123,7 +130,7 @@ func TestRenderRightBarUsesChecklistIndentEllipsisAndBoldPhases(t *testing.T) {
123130 if len(plainLines) < 4 {
124131 t.Fatalf("checklist rows are missing: %q", plain)
125132 }
126- expectedTask := truncateRightBarLine(" [ ] Sort the leftover star stickers", 35)
133+ const expectedTask = " [ ] Sort the leftover star sti..."
127134 if got := strings.TrimRight(plainLines[3], " "); got != expectedTask {
128135 t.Fatalf("task row = %q, want clipped row %q", got, expectedTask)
129136 }
@@ -106,6 +106,13 @@ func TestRenderRightBarPreservesPhaseProgressWhenTitleIsClipped(t *testing.T) {
106 }106 }
107 }107 }
108 108
109+func TestTruncateRightBarPhaseLinePreservesProgressWithoutRoomForName(t *testing.T) {
110+ got := truncateRightBarPhaseLine("[>] Current phase 0/1", 9)
111+ if want := "[>] 0/1"; got != want {
112+ t.Fatalf("truncated phase = %q, want %q", got, want)
113+ }
114+}
115+
109 func TestRenderRightBarUsesChecklistIndentEllipsisAndBoldPhases(t *testing.T) {116 func TestRenderRightBarUsesChecklistIndentEllipsisAndBoldPhases(t *testing.T) {
110 lines := RenderRightBar(Dark, []RightBarWidget{{117 lines := RenderRightBar(Dark, []RightBarWidget{{
111 Extension: "tasked-phases",118 Extension: "tasked-phases",
@@ -123,7 +130,7 @@ func TestRenderRightBarUsesChecklistIndentEllipsisAndBoldPhases(t *testing.T) {
123 if len(plainLines) < 4 {130 if len(plainLines) < 4 {
124 t.Fatalf("checklist rows are missing: %q", plain)131 t.Fatalf("checklist rows are missing: %q", plain)
125 }132 }
126- expectedTask := truncateRightBarLine(" [ ] Sort the leftover star stickers", 35)133+ const expectedTask = " [ ] Sort the leftover star sti..."
127 if got := strings.TrimRight(plainLines[3], " "); got != expectedTask {134 if got := strings.TrimRight(plainLines[3], " "); got != expectedTask {
128 t.Fatalf("task row = %q, want clipped row %q", got, expectedTask)135 t.Fatalf("task row = %q, want clipped row %q", got, expectedTask)
129 }136 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close