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:
@@ -151,13 +151,13 @@ func TestExtractPreview(t *testing.T) {
|
||||
Type: "assistant",
|
||||
Message: &MessagePayload{
|
||||
Role: "assistant",
|
||||
Content: []ContentBlock{{Type: "text", Text: "Voici le resultat\nLigne 2\nLigne 3\nLigne 4\nLigne 5"}},
|
||||
Content: []ContentBlock{{Type: "text", Text: "Voici le resultat\nLigne 2\nLigne 3\nLigne 4\nLigne 5\nLigne 6\nLigne 7"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
preview := ExtractPreview(msgs)
|
||||
want := "Voici le resultat\nLigne 2\nLigne 3"
|
||||
want := "Voici le resultat\nLigne 2\nLigne 3\nLigne 4\nLigne 5"
|
||||
if preview != want {
|
||||
t.Errorf("ExtractPreview = %q, want %q", preview, want)
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestExtractPreview_NoAssistant(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExtractPreview_LongText(t *testing.T) {
|
||||
// Text longer than 200 chars should be truncated
|
||||
// Text longer than 300 chars should be truncated
|
||||
longText := ""
|
||||
for i := 0; i < 100; i++ {
|
||||
longText += "abcde "
|
||||
@@ -194,7 +194,7 @@ func TestExtractPreview_LongText(t *testing.T) {
|
||||
}}
|
||||
|
||||
preview := ExtractPreview(msgs)
|
||||
if len(preview) > 203 { // 200 + "..."
|
||||
if len(preview) > 303 { // 300 + "..."
|
||||
t.Errorf("preview too long: %d chars", len(preview))
|
||||
}
|
||||
if preview[len(preview)-3:] != "..." {
|
||||
|
||||
Reference in New Issue
Block a user