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