Skip to content

Commit 15edceb

Browse files
authored
chat: a bare number-and-period reply draws instead of vanishing (#1072) (#1746)
* chat: a bare number-and-period reply draws instead of vanishing (#1072) A model reply whose whole text was a number and a full stop (32., 1024.) parsed as a Markdown ordered list with one empty item. renderer.list drew the marker column, found no body, and popped the item as undrawn, taking the marker with it, so the reply rendered to zero rows and the deck skipped it. Draw the marker as literal text when the item body produced nothing, which is the only case a bare <number>. reaches. * address review: PR number in change entry, exact test assertions - Rename change entry to 1746-... and set pr: 1746 (was the issue number). - Assert the exact rendered output ('32.', '1024.', '1. one') instead of just non-empty.
1 parent c240e36 commit 15edceb

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
kind: fixed
3+
title: a reply that is only a number and a full stop draws instead of vanishing
4+
pr: 1746
5+
surface: [chat]
6+
invalidates:
7+
- "A model reply whose whole text was a number and a full stop (`32.`, `1024.`) parsed as a Markdown ordered list with one empty item, so the list renderer drew the marker column, found no body, and discarded the marker too. The reply rendered to zero rows and the deck skipped it: the fold showed only the thought row though the transcript held the text. An ordered-list item with no body now draws its marker as the literal text the reader sent, so `32.` stands under the chip; `1. one` and multi-item lists still draw as lists."
8+
---
9+
10+
Found while running the number-answer journey against `dev`: asking the chat for
11+
"only the number followed by a period" produced `32.`, which the surface dropped.
12+
`renderer.list` in `internal/tui2/prose` pushed the marker, rendered the empty
13+
item, and popped it as undrawn, taking the marker with it. The fix draws the
14+
marker when the item body produced nothing, which is the only case a bare
15+
`<number>.` reaches.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package prose
2+
3+
import (
4+
"strings"
5+
"testing"
6+
)
7+
8+
// TestABareNumberedReplyStillDraws guards #1072: a reply that is only a number
9+
// and a full stop (`32.`, `1024.`) is parsed by Markdown as an ordered list
10+
// with one empty item. The list renderer must draw the marker as the literal
11+
// text the reader sent, never discard it as an empty list and render nothing.
12+
func TestABareNumberedReplyStillDraws(t *testing.T) {
13+
for _, in := range []string{"32.", "1024."} {
14+
if got := strings.TrimSpace(strings.Join(Render(in, Options{Width: 80}), "\n")); got != in {
15+
t.Errorf("Render(%q) = %q, want %q", in, got, in)
16+
}
17+
}
18+
// A genuine ordered list with a body still draws as a list.
19+
if got := strings.TrimSpace(strings.Join(Render("1. one", Options{Width: 80}), "\n")); got != "1. one" {
20+
t.Errorf("Render(%q) = %q, want %q", "1. one", got, "1. one")
21+
}
22+
}

‎internal/tui2/prose/render.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,15 @@ func (r *renderer) list(n *ast.List) {
294294
saved := r.push(first, indent)
295295
before := len(r.out)
296296
r.container(c, !n.IsTight)
297-
r.pop(saved, len(r.out) > before)
297+
drew := len(r.out) > before
298+
r.pop(saved, drew)
299+
// An item with no body - a line that was only a marker, like the whole
300+
// reply `32.` - would otherwise render to nothing and the deck would
301+
// drop the reply. Draw the marker as the literal text the reader sent so
302+
// the answer still stands.
303+
if !drew {
304+
r.emit(first)
305+
}
298306
}
299307
}
300308

0 commit comments

Comments
 (0)