feat: stabilize list output with fixed-height preview (5 lines, 300 chars)

Each session always occupies the same number of lines, preventing
visual jitter between watch refreshes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-23 20:50:28 +01:00
parent bdac6d07a9
commit bab681ca30
3 changed files with 19 additions and 14 deletions

View File

@@ -92,10 +92,12 @@ func DisplaySessionInfos(w io.Writer, sessions []SessionInfo, noColor bool, now
fmt.Fprintf(w, "[%s] %s%s%s%s%s\n", stateStr, s.Cwd, branch, workspace, label, waiting)
if s.Preview != "" {
lines := strings.Split(s.Preview, "\n")
for _, line := range lines {
fmt.Fprintf(w, " %s\n", line)
lines := strings.Split(s.Preview, "\n")
for i := 0; i < previewLines; i++ {
if i < len(lines) && lines[i] != "" {
fmt.Fprintf(w, " %s\n", lines[i])
} else {
fmt.Fprintln(w)
}
}
}