|
7 | 7 |
|
8 | 8 | import { describe, expect, test } from "bun:test"; |
9 | 9 |
|
10 | | -import { advanceRevealChars, thinkingLivePreviewLines } from "./thinking"; |
| 10 | +import { advanceRevealChars, LIVE_THINKING_MAX_LINES, thinkingLivePreviewLines } from "./thinking"; |
11 | 11 | import { withTestRenderer } from "./harness"; |
12 | 12 | import { attachSessionBridge, createRecordingPort } from "./runtime-bridge"; |
13 | 13 | import { createAppShell } from "./shell"; |
@@ -83,12 +83,23 @@ describe("thinkingLivePreviewLines with a reveal position", () => { |
83 | 83 |
|
84 | 84 | test("omitting revealChars wraps whatever has arrived, capped to max lines", () => { |
85 | 85 | const lines = thinkingLivePreviewLines(text, 10); |
86 | | - expect(lines.length).toBeLessThanOrEqual(3); |
| 86 | + expect(lines.length).toBeLessThanOrEqual(LIVE_THINKING_MAX_LINES); |
87 | 87 | expect(lines.length).toBeGreaterThan(0); |
88 | 88 | expect(lines.every((line) => line.length <= 10)).toBe(true); |
89 | 89 | expect(lines.join(" ")).toContain("running"); |
90 | 90 | }); |
91 | 91 |
|
| 92 | + test("a long burst fills more than three lines and still respects the hard cap", () => { |
| 93 | + const long = Array.from({ length: 40 }, (_, i) => `clause-${i}`).join(" "); |
| 94 | + const lines = thinkingLivePreviewLines(long, 20); |
| 95 | + expect(lines.length).toBeGreaterThan(3); |
| 96 | + expect(lines.length).toBeLessThanOrEqual(LIVE_THINKING_MAX_LINES); |
| 97 | + expect(lines.every((line) => line.length <= 20)).toBe(true); |
| 98 | + // Newest prose wins when the wrap exceeds the cap. |
| 99 | + expect(lines.join(" ")).toContain("clause-39"); |
| 100 | + expect(lines.join(" ")).not.toContain("clause-0"); |
| 101 | + }); |
| 102 | + |
92 | 103 | test("sample frames across a few rates, printed for eyeballing", () => { |
93 | 104 | const sample = "we need to check whether the cache key already accounts for the locale"; |
94 | 105 | for (const rate of [15, 20, 28, 40, 60]) { |
|
0 commit comments