Skip to content

Commit 3041994

Browse files
committed
Collapse three identical system rows instead of leaking the third
1 parent 1364367 commit 3041994

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/tui/shell/chrome.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,10 @@ function paintAppendStreamRow(shell: AppShell, row: StreamRow): void {
11201120
clearLandingMark(shell);
11211121
const seq = (paintSequence.get(shell) ?? 0) + 1;
11221122
paintSequence.set(shell, seq);
1123-
if (isDuplicateSystemEcho(shell, row)) return;
1123+
if (isDuplicateSystemEcho(shell, row)) {
1124+
systemPushSequence.set(shell, seq);
1125+
return;
1126+
}
11241127
const gainedVoice = noteAgentVoice(shell, row);
11251128
shell.streamLog.push(row);
11261129
if (row.role === "system") systemPushSequence.set(shell, seq);

src/tui/startup-transcript.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ describe("startup transcript", () => {
4040
});
4141
});
4242

43+
test("three identical system rows in a row paint once", async () => {
44+
await withTestRenderer(async (h) => {
45+
const shell = createAppShell(h.renderer, OPTIONS);
46+
try {
47+
for (let i = 0; i < 3; i += 1) {
48+
appendStreamRow(shell, {
49+
role: "system",
50+
text: "Chose muse-spark.",
51+
meta: "model picker",
52+
});
53+
}
54+
expect(streamRowCount(shell)).toBe(1);
55+
expect(shell.streamLog.map((row) => row.text)).toEqual([
56+
"Chose muse-spark.",
57+
]);
58+
} finally {
59+
shell.dispose();
60+
}
61+
});
62+
});
63+
4364
test("separated repeats and other roles still paint", async () => {
4465
await withTestRenderer(async (h) => {
4566
const shell = createAppShell(h.renderer, OPTIONS);

0 commit comments

Comments
 (0)