The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Leave the last terminal column free when clipping picker lines
shukieshahfd02be538ee3
diff --git a/cli/beacon/internal/onboarding/picker.go b/cli/beacon/internal/onboarding/picker.goindex 26dca911..d3a55142 100644--- a/cli/beacon/internal/onboarding/picker.go+++ b/cli/beacon/internal/onboarding/picker.go@@ -199,8 +199,9 @@ func decodeByte(c byte, total int) (keyEvent, bool) {}// render draws the option list plus its key hint, overwriting the previous draw. width is-// the terminal width in columns, or 0 when unknown; every line is clipped to it so the-// draw occupies exactly renderedLines rows.+// the terminal width in columns, or 0 when unknown; every line is clipped to one column+// less than that, so the draw occupies exactly renderedLines rows even on terminals that+// wrap eagerly at the last column.func render(out io.Writer, options []choice, selected int, color bool, first bool, width int) {if !first {fmt.Fprintf(out, ansiUp, renderedLines(options))@@ -212,13 +213,13 @@ func render(out io.Writer, options []choice, selected int, color bool, first boofor i, option := range options {fmt.Fprint(out, ansiClearLine)if i == selected {- fmt.Fprintf(out, " %s❯ %s%s\r\n", accent, clip(option.Label, width-4), clear)+ fmt.Fprintf(out, " %s❯ %s%s\r\n", accent, clip(option.Label, width-5), clear)} else {- fmt.Fprintf(out, " %s\r\n", clip(option.Label, width-4))+ fmt.Fprintf(out, " %s\r\n", clip(option.Label, width-5))}if option.Detail != "" {fmt.Fprint(out, ansiClearLine)- fmt.Fprintf(out, " %s%s%s\r\n", dimmed, clip(option.Detail, width-6), clear)+ fmt.Fprintf(out, " %s%s%s\r\n", dimmed, clip(option.Detail, width-7), clear)}}fmt.Fprint(out, ansiClearLine)diff --git a/cli/beacon/internal/onboarding/picker_test.go b/cli/beacon/internal/onboarding/picker_test.goindex 04390c2b..c8307c41 100644--- a/cli/beacon/internal/onboarding/picker_test.go+++ b/cli/beacon/internal/onboarding/picker_test.go@@ -217,8 +217,8 @@ func TestRenderClipsToTerminalWidth(t *testing.T) {render(&out, rows, 0, false, true, 40)for _, line := range strings.Split(strings.TrimSpace(out.String()), "\r\n") {visible := strings.NewReplacer(ansiClearLine, "").Replace(line)- if n := len([]rune(visible)); n > 40 {- t.Fatalf("line is %d columns wide on a 40-column terminal: %q", n, visible)+ if n := len([]rune(visible)); n >= 40 {+ t.Fatalf("line is %d columns wide on a 40-column terminal; must leave the last column free: %q", n, visible)}}if !strings.Contains(out.String(), "…") {diff --git a/cli/beacon/internal/onboarding/prompt_test.go b/cli/beacon/internal/onboarding/prompt_test.goindex 6aa97f5f..3995d88b 100644--- a/cli/beacon/internal/onboarding/prompt_test.go+++ b/cli/beacon/internal/onboarding/prompt_test.go@@ -262,14 +262,15 @@ func TestAskDestinationAlone(t *testing.T) {}}-// Every destination row must draw without wrapping on a standard 80-column terminal, or-// the picker's line count is off and it eats the lines above it on redraw.+// Every destination row must draw without wrapping on a standard 80-column terminal, with+// the last column left free for terminals that wrap eagerly, or the picker's line count+// is off and it eats the lines above it on redraw.func TestDestinationRowsFitEightyColumns(t *testing.T) {for _, item := range destinationChoices(true) {- if n := 4 + len([]rune(item.label)); n > 80 {+ if n := 4 + len([]rune(item.label)); n >= 80 {t.Fatalf("label %q draws %d columns", item.label, n)}- if n := 6 + len([]rune(item.detail)); n > 80 {+ if n := 6 + len([]rune(item.detail)); n >= 80 {t.Fatalf("detail %q draws %d columns", item.detail, n)}}