Skip to content

Commit a16e4d8

Browse files
Gustav-SimonssonTheGreatAxios
authored andcommitted
refactor(tui): compress verbose comments in the thinking reveal module
1 parent 10d581a commit a16e4d8

2 files changed

Lines changed: 16 additions & 27 deletions

File tree

‎src/tui/thinking-reveal.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/**
2-
* Live reasoning reveals text at a bounded rate into a short wrapped preview,
3-
* so a fast model still reads at human pace without sideways-scrolling one
4-
* line. Pure-function coverage lives here; `advanceOpenReveal`'s bridge wiring
5-
* is covered by the bridge/tick tests below.
2+
* Pure-function coverage of the bounded reveal lives here; the
3+
* `advanceOpenReveal` bridge wiring sits in the bridge/tick tests below.
64
*/
75

86
import { describe, expect, test } from "bun:test";

‎src/tui/thinking.ts‎

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
2-
* Reasoning chrome: a short wrapped preview while thought streams, and a
3-
* one-line opener once it settles (full text behind expand).
2+
* Reasoning chrome: a short wrapped preview while reasoning streams, one
3+
* line once it settles (full text behind expand).
44
*
5-
* Reasoning is not the answer, so it never owns the screen: the newest
6-
* revealed prose wraps into a bounded inset paragraph, then the row collapses
7-
* to its opening clause.
5+
* Reasoning is not the answer, so it never owns the screen.
86
*/
97

108
import { sliceToWidth, stringWidth, wrapLines } from "./view/height.js";
@@ -16,30 +14,26 @@ export interface Thought {
1614
}
1715

1816
/**
19-
* Whitespace-flattened reasoning text. Reveal position counts in these units
20-
* so paint and the reveal clock agree.
17+
* Flattens whitespace; reveal counts in these units so paint and the
18+
* reveal clock agree.
2119
*/
2220
export function flattenReasoningText(text: string): string {
2321
return text.replace(/\s+/g, " ").trimStart();
2422
}
2523

2624
/**
27-
* Characters per second the reveal position advances while reasoning streams.
28-
* Chosen by printing sample frames: below ~20 feels laggy, above ~40 is
29-
* unreadable; 28 is fast-but-legible.
25+
* Below ~20 feels laggy, above ~40 is unreadable; 28 is fast-but-legible.
3026
*/
3127
export const REVEAL_CHARS_PER_SEC = 28;
3228

3329
/**
34-
* How many wrapped lines a live reasoning preview may claim — never unbounded
35-
* CoT. Raised into the 8–12 band so mid-turn chain-of-thought is glanceable.
30+
* Bounded CoT — kept in the 8–12 band so mid-turn thought stays glanceable.
3631
*/
3732
export const LIVE_THINKING_MAX_LINES = 10;
3833

3934
/**
40-
* Advance a reveal position toward the text that has arrived, capped at a
41-
* bounded reading rate. Never exceeds `availableChars` and never regresses,
42-
* so a shrinking count cannot visibly rewind the row.
35+
* Advance the reveal toward arrived text at a bounded rate. Never exceeds
36+
* `availableChars` nor regresses, so a shrink cannot visibly rewind the row.
4337
*/
4438
export function advanceRevealChars(
4539
prevChars: number,
@@ -54,9 +48,8 @@ export function advanceRevealChars(
5448
}
5549

5650
/**
57-
* Live reasoning as a short wrapped paragraph of the newest *revealed* text.
58-
* `revealChars` is the bounded-rate reveal position from `advanceRevealChars`;
59-
* omitting it shows whatever has arrived so far (fixtures).
51+
* Short wrapped paragraph of the newest *revealed* text; omit `revealChars`
52+
* to show whatever arrived (fixtures).
6053
*/
6154
export function thinkingLivePreviewLines(
6255
text: string,
@@ -85,14 +78,12 @@ export function thinkingLivePreviewLines(
8578
return wrapped.slice(-linesCap);
8679
}
8780

88-
/** Marker that a settled reasoning line is holding back the rest of the text. */
81+
/** Marker that a settled reasoning line holds back the rest of the text. */
8982
const ELLIPSIS = "…";
9083

9184
/**
92-
* Settled reasoning as one line: the *opening* of the chain of thought, cut to
93-
* the row's columns. The opening reads as a whole clause; the tail is wherever
94-
* the model stopped, usually a mid-sentence fragment. The rest stays behind
95-
* the expand key.
85+
* The *opening* of the chain of thought reads as a whole clause; the tail
86+
* is wherever the model stopped, usually a mid-sentence fragment.
9687
*/
9788
export function thinkingSettledLine(text: string, width: number): string {
9889
const flat = flattenReasoningText(text).trimEnd();

0 commit comments

Comments
 (0)