koneck 2.128.18 → 2.128.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,6 +39,38 @@ export declare function synchronizedFrame(chunk: string): string;
39
39
  * `write` is read from — and every method bound to — the real stream, so `on('resize')` registers
40
40
  * on the stream the terminal actually resizes rather than on a copy that never hears about it.
41
41
  */
42
+ /** True when a chunk only moves the cursor and erases: it paints nothing at all. */
43
+ export declare function isErasureOnly(chunk: string): boolean;
44
+ /**
45
+ * The same stream, with each frame presented atomically.
46
+ *
47
+ * A Proxy rather than a subclass or a prototype clone because Ink both writes to this object and
48
+ * listens on it, and an EventEmitter keeps its listeners on the instance. Every member other than
49
+ * `write` is read from — and every method bound to — the real stream, so `on('resize')` registers
50
+ * on the stream the terminal actually resizes rather than on a copy that never hears about it.
51
+ *
52
+ * ── Why a render is sometimes more than one write ──
53
+ *
54
+ * Ink usually paints in a single write: `eraseLines(n) + output`. Bracketing that is enough, and
55
+ * it stays synchronous here.
56
+ *
57
+ * But when <Static> has new rows to commit — which is every time a reply or a tool result is
58
+ * finished, so constantly while the agent works — it takes a different path:
59
+ *
60
+ * this.log.clear(); // write #1: erase the live region, print nothing
61
+ * this.options.stdout.write(staticOutput); // write #2: the newly finished rows
62
+ * this.log(output); // write #3: the live region again
63
+ *
64
+ * Bracketing those separately is worse than not bracketing at all: write #1 contains no printable
65
+ * output, so it instructs the terminal to present, as a completed frame, the state in which the
66
+ * composer and the status bar have been erased and nothing has replaced them. A guaranteed blank
67
+ * flash, once per committed row. Reported as blinking "when the model is working".
68
+ *
69
+ * So a write that only erases starts a batch instead of being sent. Everything written for the
70
+ * rest of the tick joins it, and the whole render leaves as one frame — erase, new rows and live
71
+ * region together, which is the picture that was wanted in the first place. A render that is a
72
+ * single write never enters the batch and is sent immediately, so ordinary typing is unchanged.
73
+ */
42
74
  export declare function withSynchronizedFrames<T extends NodeJS.WriteStream>(stream: T): T;
43
75
  /**
44
76
  * Whether this terminal really implements synchronized output, asked rather than assumed.
@@ -1 +1 @@
1
- {"version":3,"file":"frame-sync.d.ts","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,4EAA4E;AAC5E,wBAAgB,uBAAuB,CACrC,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAmB,EAC5C,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAMT;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAmBjF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAAmB,EAC5E,KAAK,GAAE,MAAM,CAAC,UAA0B,EACxC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,SAAS,SAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAmClB"}
1
+ {"version":3,"file":"frame-sync.d.ts","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,4EAA4E;AAC5E,wBAAgB,uBAAuB,CACrC,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAmB,EAC5C,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAMT;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;;;;;;GAOG;AACH,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAkDjF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAAmB,EAC5E,KAAK,GAAE,MAAM,CAAC,UAA0B,EACxC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,SAAS,SAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAmClB"}
@@ -56,20 +56,88 @@ export function synchronizedFrame(chunk) {
56
56
  * `write` is read from — and every method bound to — the real stream, so `on('resize')` registers
57
57
  * on the stream the terminal actually resizes rather than on a copy that never hears about it.
58
58
  */
59
+ /** True when a chunk only moves the cursor and erases: it paints nothing at all. */
60
+ export function isErasureOnly(chunk) {
61
+ if (chunk === '')
62
+ return false;
63
+ return chunk.replace(/\u001b\[[0-9;]*[A-Za-z]/g, '') === '';
64
+ }
65
+ /**
66
+ * The same stream, with each frame presented atomically.
67
+ *
68
+ * A Proxy rather than a subclass or a prototype clone because Ink both writes to this object and
69
+ * listens on it, and an EventEmitter keeps its listeners on the instance. Every member other than
70
+ * `write` is read from — and every method bound to — the real stream, so `on('resize')` registers
71
+ * on the stream the terminal actually resizes rather than on a copy that never hears about it.
72
+ *
73
+ * ── Why a render is sometimes more than one write ──
74
+ *
75
+ * Ink usually paints in a single write: `eraseLines(n) + output`. Bracketing that is enough, and
76
+ * it stays synchronous here.
77
+ *
78
+ * But when <Static> has new rows to commit — which is every time a reply or a tool result is
79
+ * finished, so constantly while the agent works — it takes a different path:
80
+ *
81
+ * this.log.clear(); // write #1: erase the live region, print nothing
82
+ * this.options.stdout.write(staticOutput); // write #2: the newly finished rows
83
+ * this.log(output); // write #3: the live region again
84
+ *
85
+ * Bracketing those separately is worse than not bracketing at all: write #1 contains no printable
86
+ * output, so it instructs the terminal to present, as a completed frame, the state in which the
87
+ * composer and the status bar have been erased and nothing has replaced them. A guaranteed blank
88
+ * flash, once per committed row. Reported as blinking "when the model is working".
89
+ *
90
+ * So a write that only erases starts a batch instead of being sent. Everything written for the
91
+ * rest of the tick joins it, and the whole render leaves as one frame — erase, new rows and live
92
+ * region together, which is the picture that was wanted in the first place. A render that is a
93
+ * single write never enters the batch and is sent immediately, so ordinary typing is unchanged.
94
+ */
59
95
  export function withSynchronizedFrames(stream) {
60
96
  if (!wantsSynchronizedFrames(stream))
61
97
  return stream;
98
+ // Called on `target`, not lifted off it: a stream's write reaches into `this._writableState`,
99
+ // so a detached reference throws "Cannot read properties of undefined". Found by running the
100
+ // real binary on a pty, which a fake stream in a unit test had not needed to expose.
101
+ const raw = (chunk, ...rest) => {
102
+ const write = stream.write;
103
+ return write.call(stream, chunk, ...rest);
104
+ };
105
+ let batch = '';
106
+ let batching = false;
107
+ const flush = () => {
108
+ batching = false;
109
+ if (batch === '')
110
+ return;
111
+ const frame = batch;
112
+ batch = '';
113
+ raw(synchronizedFrame(frame));
114
+ };
115
+ // A batch lives for one tick, so an ordinary exit drains it first. This is for the abrupt ones.
116
+ process.once('exit', flush);
62
117
  return new Proxy(stream, {
63
118
  get(target, prop) {
64
119
  if (prop === 'write') {
65
- // Called on `target`, not lifted off it: a stream's write reaches into `this._writableState`,
66
- // so a detached reference throws "Cannot read properties of undefined". Found by running
67
- // the real binary on a pty, which a fake stream in a unit test had not needed to expose.
68
120
  return (chunk, ...rest) => {
69
- const write = target.write;
70
- return typeof chunk === 'string'
71
- ? write.call(target, synchronizedFrame(chunk), ...rest)
72
- : write.call(target, chunk, ...rest);
121
+ // Anything that is not a plain string — a Buffer, or a write with a callback that must
122
+ // actually be called — is sent as it is, after whatever is queued, so nothing is
123
+ // reordered around it.
124
+ if (typeof chunk !== 'string' || rest.some(a => typeof a === 'function')) {
125
+ flush();
126
+ return raw(chunk, ...rest);
127
+ }
128
+ if (batching) {
129
+ batch += chunk;
130
+ return true;
131
+ }
132
+ if (isErasureOnly(chunk)) {
133
+ batch = chunk;
134
+ batching = true;
135
+ // A microtask, so it runs the moment Ink's synchronous render returns and never
136
+ // leaves a frame waiting on I/O.
137
+ queueMicrotask(flush);
138
+ return true;
139
+ }
140
+ return raw(synchronizedFrame(chunk));
73
141
  };
74
142
  }
75
143
  const value = Reflect.get(target, prop, target);
@@ -1 +1 @@
1
- {"version":3,"file":"frame-sync.js","sourceRoot":"","sources":["../src/frame-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,sFAAsF;AACtF,MAAM,KAAK,GAAG,aAAa,CAAC;AAC5B,2DAA2D;AAC3D,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B,4EAA4E;AAC5E,MAAM,UAAU,uBAAuB,CACrC,SAA8B,OAAO,CAAC,MAAM,EAC5C,MAA0C,OAAO,CAAC,GAAG;IAErD,IAAI,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,GAAG,CAAC,qBAAqB,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACpD,qFAAqF;IACrF,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACnD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,0FAA0F;IAC1F,kBAAkB;IAClB,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KA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,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACzB,MAAM,CAAC,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -67,6 +67,27 @@ export declare function pasteForDisplay(text: string, maxRows?: number): string;
67
67
  * only ever holds the fragment of the current block that has not been committed yet — the text a
68
68
  * reader is watching appear, rather than the whole reply waiting for the turn to end.
69
69
  */
70
+ /** At most this many files are previewed while a tool is still running. */
71
+ export declare const LIVE_DIFF_FILES = 2;
72
+ /**
73
+ * How many lines of each file's diff may be drawn while the tool that is writing it still runs.
74
+ *
75
+ * There has to be a ceiling, and it has to come from the window. Ink paints by erasing the lines
76
+ * it last wrote, but it cannot erase lines that have scrolled off — so when the live region is at
77
+ * least as tall as the terminal it gives up and writes `clearTerminal + everything` instead, on
78
+ * every render. That wipes the screen and the scrollback and repaints the entire session, per
79
+ * keystroke, getting heavier as the session grows.
80
+ *
81
+ * A running tool's diff was the only part of the live region with no natural ceiling: a large
82
+ * edit is a large diff, and off the alternate screen it is drawn inline rather than in the side
83
+ * panel. So a big write guaranteed the wipe-and-repaint path for as long as it took.
84
+ *
85
+ * The subtraction leaves room for everything else sharing the region — the reply tail, the step
86
+ * heading, the queued list, the composer and the status bar — and the floor keeps a preview
87
+ * worth looking at on a very short terminal, where a couple of scrolled lines are a far smaller
88
+ * problem than clearing the screen sixty times a minute.
89
+ */
90
+ export declare function liveDiffLineBudget(termRows: number | undefined, files?: number): number;
70
91
  export declare function liveReplyLines(termRows: number | undefined): number;
71
92
  /**
72
93
  * How long one animation frame lasts.
@@ -1 +1 @@
1
- {"version":3,"file":"ink-chat.d.ts","sourceRoot":"","sources":["../src/ink-chat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA2B3D,OAAO,EAAyB,KAAK,QAAQ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nB;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,kBAA0B,EAAE,EACxE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7C,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAg5KhE;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCvE"}
package/dist/ink-chat.js CHANGED
@@ -383,6 +383,30 @@ function tailLines(text, maxLines, width) {
383
383
  * only ever holds the fragment of the current block that has not been committed yet — the text a
384
384
  * reader is watching appear, rather than the whole reply waiting for the turn to end.
385
385
  */
386
+ /** At most this many files are previewed while a tool is still running. */
387
+ export const LIVE_DIFF_FILES = 2;
388
+ /**
389
+ * How many lines of each file's diff may be drawn while the tool that is writing it still runs.
390
+ *
391
+ * There has to be a ceiling, and it has to come from the window. Ink paints by erasing the lines
392
+ * it last wrote, but it cannot erase lines that have scrolled off — so when the live region is at
393
+ * least as tall as the terminal it gives up and writes `clearTerminal + everything` instead, on
394
+ * every render. That wipes the screen and the scrollback and repaints the entire session, per
395
+ * keystroke, getting heavier as the session grows.
396
+ *
397
+ * A running tool's diff was the only part of the live region with no natural ceiling: a large
398
+ * edit is a large diff, and off the alternate screen it is drawn inline rather than in the side
399
+ * panel. So a big write guaranteed the wipe-and-repaint path for as long as it took.
400
+ *
401
+ * The subtraction leaves room for everything else sharing the region — the reply tail, the step
402
+ * heading, the queued list, the composer and the status bar — and the floor keeps a preview
403
+ * worth looking at on a very short terminal, where a couple of scrolled lines are a far smaller
404
+ * problem than clearing the screen sixty times a minute.
405
+ */
406
+ export function liveDiffLineBudget(termRows, files = LIVE_DIFF_FILES) {
407
+ const rows = termRows && termRows > 0 ? termRows : 24;
408
+ return Math.max(3, Math.floor((rows - 14) / Math.max(1, files)));
409
+ }
386
410
  export function liveReplyLines(termRows) {
387
411
  const rows = termRows && termRows > 0 ? termRows : 24;
388
412
  return rows < 12 ? 1 : 2;
@@ -5787,23 +5811,61 @@ export function App({ config: initialConfig, clearFrame, synchronizedFrames = fa
5787
5811
  * itself on a tinted band. Every rendered line is padded to the same width so the tint forms a
5788
5812
  * solid block rather than a ragged edge, which is what makes an added run legible at a glance.
5789
5813
  */
5790
- const renderDiff = (d, key) => {
5814
+ const liveDiffBudget = liveDiffLineBudget(termRows);
5815
+ /**
5816
+ * One file's diff, with a ceiling on how many lines it may draw.
5817
+ *
5818
+ * The ceiling exists because of how Ink puts a frame on screen. It normally erases the lines it
5819
+ * last wrote and prints the new ones, but when the live region is at least as tall as the
5820
+ * terminal it cannot do that — lines that scrolled off cannot be erased — so it falls back to
5821
+ *
5822
+ * stdout.write(ansiEscapes.clearTerminal + fullStaticOutput + output) // ink/build/ink.js
5823
+ *
5824
+ * `clearTerminal` is ESC[2J ESC[3J ESC[H: wipe the screen, wipe the scrollback, home the cursor.
5825
+ * Then the entire session is written again. That happens on *every* render — so once the live
5826
+ * region outgrows the window, every keystroke wipes and repaints the whole terminal, and it gets
5827
+ * heavier as the session grows because the static output it rewrites only ever accumulates.
5828
+ * Measured with a recording stdout: a six-line live region gave three 466-byte frames for three
5829
+ * keystrokes; a forty-five-line one in a forty-row terminal gave three full clear-and-rewrites.
5830
+ *
5831
+ * That is the blinking. Not the animation, not the terminal, not the machine.
5832
+ *
5833
+ * A running tool's diff was the thing that made the region that tall: it is drawn in full, and
5834
+ * with the side panel shut — which it always is off the alternate screen — it is drawn inline.
5835
+ * A two-hundred-line edit therefore guaranteed the clear-and-rewrite path for as long as the
5836
+ * write took. Nothing is lost by capping it: this is the live preview of a diff that is written
5837
+ * to scrollback in full the moment the step finishes.
5838
+ */
5839
+ const renderDiff = (d, key, maxLines = Infinity) => {
5791
5840
  const numbers = d.hunks.flatMap(h => h.lines.map(l => l.after ?? l.before ?? 0));
5792
5841
  const gutter = Math.max(2, String(Math.max(0, ...numbers)).length);
5793
5842
  const width = Math.max(24, barWidth - gutter - 8);
5794
5843
  const header = d.created ? 'new file' : d.deleted ? 'deleted' : diffSummary(d);
5844
+ const all = [];
5845
+ for (const [hi, hunk] of d.hunks.entries()) {
5846
+ if (hi > 0)
5847
+ all.push({ key: `g${hi}`, gap: true });
5848
+ for (const [li, l] of hunk.lines.entries()) {
5849
+ all.push({ key: `${hi}-${li}`, gap: false, kind: l.kind,
5850
+ shown: (l.kind === 'del' ? l.before : l.after) ?? undefined,
5851
+ sign: l.kind === 'add' ? '+' : l.kind === 'del' ? '-' : ' ',
5852
+ text: l.text });
5853
+ }
5854
+ }
5855
+ const shownLines = all.slice(0, Math.max(1, maxLines));
5856
+ const clipped = all.length - shownLines.length;
5795
5857
  return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: DIM, children: "\u2514" }), _jsx(Text, { color: CYAN, children: d.path }), _jsx(Text, { color: d.created ? DIFF_ADD : d.deleted ? DIFF_DEL : MUTED, children: header })] }), d.binary
5796
5858
  ? _jsx(Text, { color: DIM, children: ' binary file - not shown' })
5797
- : d.hunks.map((hunk, hi) => (_jsxs(Box, { flexDirection: "column", children: [hi > 0 && _jsxs(Text, { color: DIM, children: [' '.repeat(gutter), " ..."] }), hunk.lines.map((l, li) => {
5798
- const shown = l.kind === 'del' ? l.before : l.after;
5799
- const sign = l.kind === 'add' ? '+' : l.kind === 'del' ? '-' : ' ';
5800
- const fg = l.kind === 'add' ? DIFF_ADD : l.kind === 'del' ? DIFF_DEL : MUTED;
5801
- const bg = l.kind === 'add' ? DIFF_ADD_BG : l.kind === 'del' ? DIFF_DEL_BG : undefined;
5802
- // Tabs would make the tinted block a ragged width, so they are expanded.
5803
- const body = `${sign} ${l.text}`.replace(/\t/g, ' ');
5804
- const cell = fitCells(body, width, true);
5805
- return (_jsxs(Box, { children: [_jsxs(Text, { color: DIM, children: [String(shown ?? '').padStart(gutter), " "] }), _jsx(Text, { color: fg, ...(bg ? { backgroundColor: bg } : {}), children: cell })] }, li));
5806
- })] }, hi))), d.hiddenLines > 0 && (_jsxs(Text, { color: DIM, children: [' '.repeat(gutter), " ... ", d.hiddenLines, " more changed lines"] }))] }, key));
5859
+ : shownLines.map(l => l.gap
5860
+ // A gap between hunks stands for the untouched lines that were skipped.
5861
+ ? _jsxs(Text, { color: DIM, children: [' '.repeat(gutter), " ..."] }, l.key)
5862
+ : (() => {
5863
+ const fg = l.kind === 'add' ? DIFF_ADD : l.kind === 'del' ? DIFF_DEL : MUTED;
5864
+ const bg = l.kind === 'add' ? DIFF_ADD_BG : l.kind === 'del' ? DIFF_DEL_BG : undefined;
5865
+ // Tabs would make the tinted block a ragged width, so they are expanded.
5866
+ const body = `${l.sign} ${l.text}`.replace(/\t/g, ' ');
5867
+ return (_jsxs(Box, { children: [_jsxs(Text, { color: DIM, children: [String(l.shown ?? '').padStart(gutter), " "] }), _jsx(Text, { color: fg, ...(bg ? { backgroundColor: bg } : {}), children: fitCells(body, width, true) })] }, l.key));
5868
+ })()), clipped > 0 && (_jsxs(Text, { color: DIM, children: [' '.repeat(gutter), " ... ", clipped, " more lines, shown in full when this finishes"] })), d.hiddenLines > 0 && (_jsxs(Text, { color: DIM, children: [' '.repeat(gutter), " ... ", d.hiddenLines, " more changed lines"] }))] }, key));
5807
5869
  };
5808
5870
  const renderStep = (step, key) => {
5809
5871
  if (step.kind === 'say') {
@@ -5813,7 +5875,20 @@ export function App({ config: initialConfig, clearFrame, synchronizedFrames = fa
5813
5875
  const ms = (step.endedAt ?? Date.now()) - step.startedAt;
5814
5876
  const glyph = running ? SPINNER[spinFrame] : step.ok === false ? G.fail : G.ok;
5815
5877
  const color = running ? AMBER : step.ok === false ? CRIMSON : GREEN;
5816
- return (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: color, children: glyph }), _jsx(Text, { color: AMBER, bold: true, children: step.name }), _jsx(Text, { color: DIM, children: "\u00B7" }), _jsx(Text, { color: MUTED, children: fmtElapsed(ms) })] }), step.detail !== '' && (step.diffs ?? []).length === 0 && (_jsxs(Box, { paddingLeft: 2, gap: 1, children: [_jsx(Text, { color: DIM, children: "\u2514" }), _jsx(Text, { color: MUTED, children: step.detail })] })), step.ok === false && step.error && (_jsxs(Box, { paddingLeft: 2, gap: 1, children: [_jsx(Text, { color: DIM, children: "\u2514" }), _jsx(Text, { color: CRIMSON, children: fitCells(step.error, Math.max(20, barWidth - 6)) })] })), running && step.output && (_jsx(Box, { paddingLeft: 4, children: _jsx(Text, { color: DIM, children: fitCells(step.output, Math.max(20, barWidth - 6)) }) })), !diffPanelOpenRef.current && (step.diffs ?? []).map((d, i) => renderDiff(d, i))] }, key));
5878
+ return (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Box, { gap: 1, children: [_jsx(Text, { color: color, children: glyph }), _jsx(Text, { color: AMBER, bold: true, children: step.name }), _jsx(Text, { color: DIM, children: "\u00B7" }), _jsx(Text, { color: MUTED, children: fmtElapsed(ms) })] }), step.detail !== '' && (step.diffs ?? []).length === 0 && (_jsxs(Box, { paddingLeft: 2, gap: 1, children: [_jsx(Text, { color: DIM, children: "\u2514" }), _jsx(Text, { color: MUTED, children: step.detail })] })), step.ok === false && step.error && (_jsxs(Box, { paddingLeft: 2, gap: 1, children: [_jsx(Text, { color: DIM, children: "\u2514" }), _jsx(Text, { color: CRIMSON, children: fitCells(step.error, Math.max(20, barWidth - 6)) })] })), running && step.output && (_jsx(Box, { paddingLeft: 4, children: _jsx(Text, { color: DIM, children: fitCells(step.output, Math.max(20, barWidth - 6)) }) })), !diffPanelOpenRef.current && (running
5879
+ /*
5880
+ * While the tool is still working this is a preview, and it has to stay small.
5881
+ *
5882
+ * It is the one part of the live region with no natural ceiling — a large edit is a
5883
+ * large diff — and the live region going past the window height is what makes Ink wipe
5884
+ * and repaint the whole terminal on every render. See renderDiff for the mechanism.
5885
+ *
5886
+ * Nothing is hidden by this. The step is committed to scrollback the moment it
5887
+ * finishes, and the branch below draws it there in full.
5888
+ */
5889
+ ? (step.diffs ?? []).slice(0, LIVE_DIFF_FILES)
5890
+ .map((d, i) => renderDiff(d, i, liveDiffBudget))
5891
+ : (step.diffs ?? []).map((d, i) => renderDiff(d, i)))] }, key));
5817
5892
  };
5818
5893
  /**
5819
5894
  * One transcript row.