Skip to content

Commit 606b352

Browse files
Gustav-SimonssonTheGreatAxios
authored andcommitted
refactor(tui): compress verbose comments in the ramp module
1 parent b5ee08f commit 606b352

2 files changed

Lines changed: 30 additions & 39 deletions

File tree

‎src/tui/ramp-paint.test.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
2-
* The density ramp is the activity primitive. Every assertion reads the
3-
* rendered frame pinned to the prompt box's bottom border — the row the
4-
* status slot rides. Shell fields are not evidence: the bug this indicator
5-
* fixes was a slot whose state was correct but whose painted row never
6-
* changed.
2+
* Every assertion reads the rendered frame pinned to the prompt box's
3+
* bottom border — the row the status slot rides. Shell fields are not
4+
* evidence: the bug this indicator fixes was a slot whose state was
5+
* correct but whose painted row never changed.
76
*/
87

98
import { describe, expect, test } from "bun:test";
@@ -63,8 +62,8 @@ function statusRow(frame: string): string {
6362

6463
/**
6564
* The slot's single state cell: the first glyph after the border's opening
66-
* corner and rule. Pinning to it keeps these assertions honest — a bang or
67-
* a block elsewhere in the frame must not satisfy them.
65+
* corner and rule, so a bang or a block elsewhere in the frame must not
66+
* satisfy these assertions.
6867
*/
6968
function slotGlyph(frame: string): string {
7069
const match = /╰─ (\S)/.exec(statusRow(frame));

‎src/tui/ramp.ts‎

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
/**
2-
* Density ramp — the activity primitive. Two surfaces draw from it.
3-
*
4-
* The wide fill (`rampFor`) is the provider-setup status line; the single
5-
* cell (`rampPulse`) is the session shell's status slot, where one column
6-
* is all the border row can spare:
7-
*
8-
* working █ ▓ ▒ ░ … cycling density — visibly moving
9-
* done █ still
10-
* blocked ▌ static half block — stillness is the signal
11-
* stalled ! / █ bang/block alternation, then static !
12-
*
13-
* `blocked` and `stalled` share a color (both wait on outside action) but
14-
* differ by glyph and motion, so all states read without color.
15-
*
16-
* Pure and clock-injected: `nowMs` is the only time source.
2+
* Density ramp — the activity primitive. The wide fill (`rampFor`) is the
3+
* provider-setup status line; the single cell (`rampPulse`) is the session
4+
* shell's status slot, where one column is all the border row can spare.
5+
* `blocked` and `stalled` share a color (both wait on outside action), but
6+
* every phase differs by glyph and motion — working cycles density, done
7+
* and blocked hold still, stalled blinks then sits on `!` — so states read
8+
* without color. Pure and clock-injected: `nowMs` is the only time source.
179
*/
1810

1911
import { UI } from "./theme.js";
@@ -30,8 +22,8 @@ const EMPTY = " ";
3022
const COMET_LENGTH = FEATHER.length;
3123

3224
/**
33-
* One full comet traversal; slow enough to read as motion, not a strobe at
34-
* the 250 ms status tick.
25+
* One full comet traversal, slow enough to read as motion at the 250 ms
26+
* status tick, not a strobe.
3527
*/
3628
export const RAMP_CYCLE_MS = 1200;
3729

@@ -48,16 +40,16 @@ const BLOCKED_GLYPH = "▌";
4840
export const STALL_BLINK_CYCLE_MS = 900;
4941

5042
/**
51-
* How long the stall blink runs before settling to a static bang. A stall
52-
* can last minutes; an unbounded blink would strobe until it means
53-
* nothing. The burst spends attention up front; the static bang still
54-
* reads as a problem.
43+
* How long the stall blink runs before settling to a static bang: a
44+
* minutes-long stall would strobe an unbounded blink into noise, so the
45+
* burst spends attention up front and the static bang still reads as a
46+
* problem.
5547
*/
5648
export const STALL_BLINK_BURST_MS = STALL_BLINK_CYCLE_MS * 9;
5749

5850
/**
5951
* Whether `nowMs` is in the solid half of the stall blink; exported so every
60-
* stalled surface blinks on the same clock.
52+
* stalled surface blinks in sync.
6153
*/
6254
export function stallBlinkOn(nowMs: number): boolean {
6355
const phase =
@@ -81,7 +73,7 @@ function clamp01(value: number): number {
8173
/**
8274
* Determinate fill: solid cells up to `progress`, then a short dither
8375
* feather at the leading edge so the boundary reads as texture, not a hard
84-
* stop. A full ramp is entirely solid.
76+
* stop.
8577
*/
8678
export function renderRamp(progress: number, width = RAMP_WIDTH): string {
8779
if (width <= 0) return "";
@@ -95,8 +87,8 @@ export function renderRamp(progress: number, width = RAMP_WIDTH): string {
9587
}
9688

9789
/**
98-
* Indeterminate fill: a comet traveling left to right and wrapping. Most
99-
* work has no denominator, so it animates rather than faking a percentage.
90+
* Indeterminate fill: a left-to-right wrapping comet. Most work has no
91+
* denominator, so it animates rather than faking a percentage.
10092
*/
10193
export function renderIndeterminateRamp(
10294
nowMs: number,
@@ -117,14 +109,14 @@ export function renderIndeterminateRamp(
117109
export type RampPhase = "working" | "done" | "blocked" | "stalled";
118110

119111
/**
120-
* Wide-fill phases. Only a live session reports a stall, and it paints the
121-
* single cell, so a wide stall would produce glyphs nothing renders.
112+
* Only a live session reports a stall, and it paints the single cell, so
113+
* a wide stall would produce glyphs nothing renders.
122114
*/
123115
export type RampFillPhase = Exclude<RampPhase, "stalled">;
124116

125117
/**
126-
* Stalled duration, or null when not stalled. Required: it decides whether
127-
* the blink still runs; forgetting it paints a permanent strobe.
118+
* Stalled duration, or null when not stalled. It decides whether the blink
119+
* still runs; forgetting it paints a permanent strobe.
128120
*/
129121
export type StallAge = number | null;
130122

@@ -156,9 +148,9 @@ export function rampFg(phase: RampPhase): string {
156148
}
157149

158150
/**
159-
* Whether the phase still has frames to draw. False for terminal and waiting
160-
* states and for a settled stall, so the caller's tick can fall back to its
161-
* slow cadence.
151+
* Whether the phase still has frames to draw. False for terminal, waiting,
152+
* and settled-stall states, so the caller's tick can fall back to its slow
153+
* cadence.
162154
*/
163155
export function rampAnimating(
164156
phase: RampPhase,

0 commit comments

Comments
 (0)