@linxiraos/pi-tui 1.4.11 → 1.4.13
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.
- package/CHANGELOG.md +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/hotkeys-markdown.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +9 -2
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +22 -4
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type Component, Container, type HistoryBatch } from "../tui";
|
|
1
|
+
import { type Component, Container, type HistoryBatch, ownDescription } from "../tui";
|
|
2
2
|
import * as logger from "@linxiraos/pi-utils/logger";
|
|
3
3
|
import { popLoopPhase, pushLoopPhase } from "@linxiraos/pi-utils";
|
|
4
4
|
import { measureRender, renderForScrollback } from "../components/image";
|
|
5
5
|
import { col } from "../native/describe";
|
|
6
|
-
import type { NativeNode } from "../native/node";
|
|
6
|
+
import type { DescribeContext, NativeNode } from "../native/node";
|
|
7
|
+
import { sameItems } from "../native/memo";
|
|
7
8
|
import { isNativeSettled, settleNative } from "../native/settle";
|
|
8
9
|
import { isUsageRowBlock } from "../overlays/usage-row";
|
|
9
10
|
import { isToolActivityComponent } from "./tool-activity";
|
|
@@ -68,6 +69,18 @@ interface FinalizableBlock {
|
|
|
68
69
|
renderTranscriptBlockEmergencyRow?(width: number): string | undefined;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Lets a block pack against its neighbors. Two consecutive compact blocks
|
|
74
|
+
* (blocks that draw nothing between them don't count) have no blank separator
|
|
75
|
+
* row between them in the terminal, and a native (TSP) surface groups each
|
|
76
|
+
* such run into one gapless entry. The hook is read every frame, so a block
|
|
77
|
+
* may change its answer at any time (expanded, collapsed, re-presented).
|
|
78
|
+
*/
|
|
79
|
+
export interface CompactTranscriptBlock {
|
|
80
|
+
/** Whether the block's current presentation is compact rows. */
|
|
81
|
+
isTranscriptBlockCompact?(): boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
/**
|
|
72
85
|
* Block lifecycle:
|
|
73
86
|
* - `active`: still mutating; renders live and counts against tool admission.
|
|
@@ -133,10 +146,20 @@ interface RowSplit {
|
|
|
133
146
|
|
|
134
147
|
type RetirementPolicy = "pressure" | "flush";
|
|
135
148
|
type Offered =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
/** `lead`: the rows start with the blank history owed the head (see {@link RowsAbove}). */
|
|
150
|
+
| { batch: HistoryBatch; kind: "append"; entry: number; emittedEnd: number; lead: boolean }
|
|
151
|
+
/**
|
|
152
|
+
* Whole blocks `[frontier, end)`, then optionally the head rows of block
|
|
153
|
+
* `end`; `historyEnd` is what history ends with once it is acknowledged.
|
|
154
|
+
*/
|
|
155
|
+
| { batch: HistoryBatch; kind: "commit"; end: number; split?: RowSplit; historyEnd: RowsAbove }
|
|
156
|
+
| { batch: HistoryBatch; kind: "replay"; historyEnd: RowsAbove };
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Compactness of the last non-empty block above when its separator is still
|
|
160
|
+
* owed; `undefined` when none is (nothing above, or rows ending in a blank).
|
|
161
|
+
*/
|
|
162
|
+
type RowsAbove = boolean | undefined;
|
|
140
163
|
|
|
141
164
|
/** Rows a progressive-append retirement offers, and the stable count they bring the head to. */
|
|
142
165
|
interface AppendBatch {
|
|
@@ -175,6 +198,31 @@ function isFinalized(component: Component): boolean {
|
|
|
175
198
|
return (block.isTranscriptBlockFinalized?.() ?? true) && block.isTranscriptBlockPending?.() !== true;
|
|
176
199
|
}
|
|
177
200
|
|
|
201
|
+
function isCompact(component: Component): boolean {
|
|
202
|
+
return (component as Component & CompactTranscriptBlock).isTranscriptBlockCompact?.() === true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Blank rows before a non-empty block: one, unless none is owed or both blocks are compact. */
|
|
206
|
+
function separatorRows(above: RowsAbove, compact: boolean): number {
|
|
207
|
+
return above === undefined || (above && compact) ? 0 : 1;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Whether a native surface lays out nothing of `component` (a hidden node, or a `col`/`row` of such nodes). */
|
|
211
|
+
function describesNothing(component: Component, cx: DescribeContext, depth = 0): boolean {
|
|
212
|
+
// `null`: the reconciler draws it as rows.
|
|
213
|
+
const described = ownDescription(component, cx);
|
|
214
|
+
return described !== null && isVoidNode(described, cx, depth);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function isVoidNode(described: NativeNode, cx: DescribeContext, depth: number): boolean {
|
|
218
|
+
if ((described.p as { hidden?: boolean } | undefined)?.hidden === true) return true;
|
|
219
|
+
if ((described.k !== "col" && described.k !== "row") || depth > 16) return false;
|
|
220
|
+
for (const child of described.c ?? []) {
|
|
221
|
+
if ("k" in child ? !isVoidNode(child, cx, depth + 1) : !describesNothing(child, cx, depth + 1)) return false;
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
|
|
178
226
|
function blockMode(component: Component): TranscriptBlockMode {
|
|
179
227
|
return (component as Component & Partial<AppendOnlyTranscriptBlock>).transcriptBlockMode === "appendOnly"
|
|
180
228
|
? "appendOnly"
|
|
@@ -262,6 +310,39 @@ export interface TranscriptViewportSpan {
|
|
|
262
310
|
end: number;
|
|
263
311
|
}
|
|
264
312
|
|
|
313
|
+
/**
|
|
314
|
+
* One native entry for a run of consecutive compact transcript blocks: a
|
|
315
|
+
* gapless column whose members stay component children, so each describes
|
|
316
|
+
* itself, keeps its wire id and receives its own native events.
|
|
317
|
+
*/
|
|
318
|
+
class CompactRun implements Component {
|
|
319
|
+
#members: readonly Component[] = [];
|
|
320
|
+
#node: NativeNode | undefined;
|
|
321
|
+
|
|
322
|
+
/** Adopt `children[start, end)` as the members; the description holds while they are unchanged. */
|
|
323
|
+
setMembers(children: readonly Component[], start: number, end: number): void {
|
|
324
|
+
const members = this.#members;
|
|
325
|
+
let same = members.length === end - start;
|
|
326
|
+
for (let index = 0; same && index < members.length; index++) same = members[index] === children[start + index];
|
|
327
|
+
if (same) return;
|
|
328
|
+
this.#members = children.slice(start, end);
|
|
329
|
+
this.#node = undefined;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** Rows for a surface that cannot describe the run: the members' rows, packed. */
|
|
333
|
+
render(width: number): readonly string[] {
|
|
334
|
+
return this.#members.flatMap(member => member.render(width));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
describe(): NativeNode {
|
|
338
|
+
this.#node ??= col(this.#members, { role: "omp.compact", gap: "none" });
|
|
339
|
+
return this.#node;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** {@link TranscriptContainer.nativeBlocks}' run wrappers while no run has formed. */
|
|
344
|
+
const NO_RUNS: ReadonlyMap<Component, CompactRun> = new Map();
|
|
345
|
+
|
|
265
346
|
/** Owns transcript order, live capacity, and ordered immutable retirement. */
|
|
266
347
|
export class TranscriptContainer extends Container {
|
|
267
348
|
#entries: TranscriptEntry[] = [];
|
|
@@ -303,6 +384,10 @@ export class TranscriptContainer extends Container {
|
|
|
303
384
|
/** Block list handed to the native frame provider, reused while the children are unchanged. */
|
|
304
385
|
#nativeBlocks: readonly Component[] = [];
|
|
305
386
|
#nativeNode: NativeNode | undefined;
|
|
387
|
+
/** `true` when history ends with a compact block whose separator was withheld; history rows never change. */
|
|
388
|
+
#historyEnd: RowsAbove;
|
|
389
|
+
/** Native wrappers of compact runs keyed by their first member; see {@link nativeBlocks}. */
|
|
390
|
+
#nativeRuns: ReadonlyMap<Component, CompactRun> = NO_RUNS;
|
|
306
391
|
override addChild(component: Component): void {
|
|
307
392
|
if (isToolActivityComponent(component)) component.setToolActivityVisible(this.#toolActivityVisible);
|
|
308
393
|
super.addChild(component);
|
|
@@ -365,6 +450,7 @@ export class TranscriptContainer extends Container {
|
|
|
365
450
|
this.#replayPending = false;
|
|
366
451
|
this.#replayRequested = false;
|
|
367
452
|
this.#lastViewportSpans = [];
|
|
453
|
+
this.#historyEnd = undefined;
|
|
368
454
|
}
|
|
369
455
|
|
|
370
456
|
setToolActivityVisible(visible: boolean): void {
|
|
@@ -393,6 +479,7 @@ export class TranscriptContainer extends Container {
|
|
|
393
479
|
if (this.#offered?.kind === "append" || (this.#offered?.kind === "commit" && this.#offered.split)) {
|
|
394
480
|
this.#offered = undefined;
|
|
395
481
|
}
|
|
482
|
+
this.#historyEnd = undefined;
|
|
396
483
|
for (const entry of this.#entries) {
|
|
397
484
|
entry.emitted = 0;
|
|
398
485
|
entry.stableRows = EMPTY_STABLE_ROWS;
|
|
@@ -520,9 +607,13 @@ export class TranscriptContainer extends Container {
|
|
|
520
607
|
this.#syncEntries();
|
|
521
608
|
this.#settleFinalized();
|
|
522
609
|
let total = 0;
|
|
610
|
+
let above = this.#projectedHistoryEnd();
|
|
523
611
|
for (const { entry, index } of this.#liveEntries()) {
|
|
524
612
|
const block = this.#liveBlock(entry, index, width).rows;
|
|
525
|
-
if (block.length
|
|
613
|
+
if (block.length === 0) continue;
|
|
614
|
+
const compact = isCompact(entry.component);
|
|
615
|
+
total += separatorRows(above, compact) + block.length;
|
|
616
|
+
above = compact;
|
|
526
617
|
if (total > limit) break;
|
|
527
618
|
}
|
|
528
619
|
return total;
|
|
@@ -542,6 +633,25 @@ export class TranscriptContainer extends Container {
|
|
|
542
633
|
};
|
|
543
634
|
}
|
|
544
635
|
|
|
636
|
+
/** What native history ends with once the unacknowledged offer, if any, lands. */
|
|
637
|
+
#projectedHistoryEnd(): RowsAbove {
|
|
638
|
+
const offered = this.#offered;
|
|
639
|
+
if (offered === undefined) return this.#historyEnd;
|
|
640
|
+
return offered.kind === "append" ? undefined : offered.historyEnd;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/** Index into `live` of the first non-empty block when history owes it a separator, else -1. */
|
|
644
|
+
#owedLead(live: readonly { entry: TranscriptEntry; index: number }[], width: number): number {
|
|
645
|
+
const historyEnd = this.#projectedHistoryEnd();
|
|
646
|
+
if (historyEnd === undefined) return -1;
|
|
647
|
+
for (let cursor = 0; cursor < live.length; cursor++) {
|
|
648
|
+
const { entry, index } = live[cursor]!;
|
|
649
|
+
if (this.#liveBlock(entry, index, width).rows.length === 0) continue;
|
|
650
|
+
return separatorRows(historyEnd, isCompact(entry.component)) > 0 ? cursor : -1;
|
|
651
|
+
}
|
|
652
|
+
return -1;
|
|
653
|
+
}
|
|
654
|
+
|
|
545
655
|
/**
|
|
546
656
|
* One block's blank-trimmed render at its full-height allocation. Inside an
|
|
547
657
|
* open frame the first measurement of each block is replayed to later ones,
|
|
@@ -667,13 +777,22 @@ export class TranscriptContainer extends Container {
|
|
|
667
777
|
this.#projectedEmittedRowCount(entry, index, width),
|
|
668
778
|
);
|
|
669
779
|
}
|
|
780
|
+
// Separator rows above each block; the first one's is owed by history.
|
|
781
|
+
const gaps: number[] = [];
|
|
782
|
+
let above = this.#projectedHistoryEnd();
|
|
670
783
|
let total = 0;
|
|
671
|
-
for (
|
|
784
|
+
for (let blockIndex = 0; blockIndex < shown.length; blockIndex++) {
|
|
785
|
+
const compact = isCompact(shown[blockIndex]!.entry.component);
|
|
786
|
+
const gap = separatorRows(above, compact);
|
|
787
|
+
gaps.push(gap);
|
|
788
|
+
total += gap + blocks[blockIndex]!.length;
|
|
789
|
+
above = compact;
|
|
790
|
+
}
|
|
672
791
|
if (total <= capacity) {
|
|
673
792
|
const output: string[] = [];
|
|
674
793
|
const owners: (Component | undefined)[] = [];
|
|
675
794
|
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
676
|
-
if (
|
|
795
|
+
if (gaps[blockIndex]! > 0) {
|
|
677
796
|
output.push("");
|
|
678
797
|
owners.push(undefined);
|
|
679
798
|
}
|
|
@@ -746,19 +865,21 @@ export class TranscriptContainer extends Container {
|
|
|
746
865
|
// The one path that must compose the whole ledger in a single frame; the
|
|
747
866
|
// phase label attributes any watchdog block here instead of "unknown".
|
|
748
867
|
pushLoopPhase("ui.transcript-replay");
|
|
749
|
-
let rows: readonly string[];
|
|
868
|
+
let replay: { rows: readonly string[]; historyEnd: RowsAbove };
|
|
750
869
|
try {
|
|
751
|
-
|
|
870
|
+
replay = this.#renderReplay(width);
|
|
752
871
|
} finally {
|
|
753
872
|
popLoopPhase();
|
|
754
873
|
}
|
|
755
874
|
this.#replayPending = false;
|
|
756
|
-
if (rows.length === 0) {
|
|
875
|
+
if (replay.rows.length === 0) {
|
|
876
|
+
// The cleared history holds no transcript rows.
|
|
877
|
+
this.#historyEnd = undefined;
|
|
757
878
|
this.#releaseCommittedRenderCaches();
|
|
758
879
|
return undefined;
|
|
759
880
|
}
|
|
760
|
-
const batch: HistoryBatch = { id: this.#nextBatchId++, rows, kind: "replay" };
|
|
761
|
-
this.#offered = { batch, kind: "replay" };
|
|
881
|
+
const batch: HistoryBatch = { id: this.#nextBatchId++, rows: replay.rows, kind: "replay" };
|
|
882
|
+
this.#offered = { batch, kind: "replay", historyEnd: replay.historyEnd };
|
|
762
883
|
return batch;
|
|
763
884
|
}
|
|
764
885
|
|
|
@@ -777,9 +898,11 @@ export class TranscriptContainer extends Container {
|
|
|
777
898
|
if (entry === undefined) return undefined;
|
|
778
899
|
const before = this.#renderStablePrefix(entry, entry.emitted, width);
|
|
779
900
|
const after = this.#renderStablePrefix(entry, offered.emittedEnd, width);
|
|
780
|
-
|
|
901
|
+
const added = after.slice(before.length);
|
|
902
|
+
rows = offered.lead ? ["", ...added] : added;
|
|
781
903
|
} else if (offered.kind === "commit") {
|
|
782
|
-
|
|
904
|
+
const retirement = this.#renderRange(this.#frontier, offered.end, width, this.#historyEnd);
|
|
905
|
+
rows = retirement.rows;
|
|
783
906
|
const head = offered.split ? this.#entries[offered.end] : undefined;
|
|
784
907
|
if (head !== undefined && offered.split !== undefined) {
|
|
785
908
|
// The offer's fingerprint covers bytes of a discarded frame history
|
|
@@ -792,10 +915,15 @@ export class TranscriptContainer extends Container {
|
|
|
792
915
|
width === offered.split.width ? offered.split.rows : this.#splitRowCount(head, offered.split, width);
|
|
793
916
|
const end = Math.min(cut, scrollback.length);
|
|
794
917
|
offered.split = rowSplit(scrollback, end, width);
|
|
795
|
-
|
|
918
|
+
if (separatorRows(retirement.above, isCompact(head.component)) > 0) retirement.rows.push("");
|
|
919
|
+
retirement.rows.push(...scrollback.slice(start, end));
|
|
920
|
+
} else {
|
|
921
|
+
offered.historyEnd = this.#closeRange(retirement.rows, retirement.above, offered.end, width);
|
|
796
922
|
}
|
|
797
923
|
} else {
|
|
798
|
-
|
|
924
|
+
const replay = this.#renderReplay(width);
|
|
925
|
+
offered.historyEnd = replay.historyEnd;
|
|
926
|
+
rows = replay.rows;
|
|
799
927
|
}
|
|
800
928
|
offered.batch = { id: offered.batch.id, rows, kind: offered.batch.kind };
|
|
801
929
|
return offered.batch;
|
|
@@ -833,23 +961,38 @@ export class TranscriptContainer extends Container {
|
|
|
833
961
|
// region costs one full render per block, which on a resumed session's
|
|
834
962
|
// first paint is every message it ever had (#12933). The progressive
|
|
835
963
|
// append path below needs the exact live height to size its emission,
|
|
836
|
-
// and only runs while a streaming head pins retirement.
|
|
964
|
+
// and only runs while a streaming head pins retirement. Heights include
|
|
965
|
+
// the separator below each block, and above the first one if history owes it.
|
|
966
|
+
const lead = this.#owedLead(live, width);
|
|
837
967
|
let tailRows = 0;
|
|
838
968
|
let liveRows = 0;
|
|
839
969
|
let keep = 0;
|
|
840
970
|
let fits = true;
|
|
971
|
+
// Compactness of the nearest non-empty block below the cursor.
|
|
972
|
+
let below: boolean | undefined;
|
|
973
|
+
// Separator rows between the first block that does not fit and the tail.
|
|
974
|
+
let boundaryGap = 0;
|
|
975
|
+
// The first live block fits; only the blank history owes it does not.
|
|
976
|
+
let leadOnly = false;
|
|
841
977
|
for (let cursor = live.length - 1; cursor >= 0; cursor--) {
|
|
842
978
|
const candidate = live[cursor]!;
|
|
843
|
-
const
|
|
844
|
-
if (
|
|
845
|
-
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
979
|
+
const rows = this.#liveBlock(candidate.entry, candidate.index, width).rows.length;
|
|
980
|
+
if (rows > 0) {
|
|
981
|
+
const compact = isCompact(candidate.entry.component);
|
|
982
|
+
const gap = below === undefined ? 0 : separatorRows(compact, below);
|
|
983
|
+
const height = rows + gap + (cursor === lead ? 1 : 0);
|
|
984
|
+
liveRows += height;
|
|
985
|
+
if (fits) {
|
|
986
|
+
if (tailRows + height > room) {
|
|
987
|
+
fits = false;
|
|
988
|
+
keep = cursor + 1;
|
|
989
|
+
boundaryGap = gap;
|
|
990
|
+
leadOnly = cursor === lead && tailRows + height - 1 <= room;
|
|
991
|
+
} else {
|
|
992
|
+
tailRows += height;
|
|
993
|
+
}
|
|
852
994
|
}
|
|
995
|
+
below = compact;
|
|
853
996
|
}
|
|
854
997
|
if (!fits && appendHead === undefined) break;
|
|
855
998
|
}
|
|
@@ -869,6 +1012,13 @@ export class TranscriptContainer extends Container {
|
|
|
869
1012
|
return undefined;
|
|
870
1013
|
}
|
|
871
1014
|
}
|
|
1015
|
+
if (leadOnly && policy === "pressure" && this.#liveCount() < MAX_LIVE_BLOCKS) {
|
|
1016
|
+
// Retire just that blank: every block's rows are still on screen.
|
|
1017
|
+
const batch: HistoryBatch = { id: this.#nextBatchId++, rows: [""], kind: "append" };
|
|
1018
|
+
this.#offered = { batch, kind: "commit", end: this.#frontier, historyEnd: undefined };
|
|
1019
|
+
this.#pinnedFrontier = undefined;
|
|
1020
|
+
return batch;
|
|
1021
|
+
}
|
|
872
1022
|
|
|
873
1023
|
if (appendHead !== undefined && keep > 0) {
|
|
874
1024
|
// Emit as many finished rows as the overflow needs, in one batch. A
|
|
@@ -876,17 +1026,19 @@ export class TranscriptContainer extends Container {
|
|
|
876
1026
|
// and the live region has to fall back under `room` to stay readable:
|
|
877
1027
|
// rows left behind here are rows dropped from the top of the viewport.
|
|
878
1028
|
// `liveRows` is exact here: the append path measured every live block.
|
|
879
|
-
|
|
1029
|
+
// A blank history owes the head goes out first, within the overflow.
|
|
1030
|
+
const leadRows = lead === 0 ? 1 : 0;
|
|
1031
|
+
const overflow = liveRows - room - leadRows;
|
|
880
1032
|
const { rows, emittedEnd } =
|
|
881
1033
|
this.#measuredAppendBatch(appendHead, width, overflow) ??
|
|
882
1034
|
this.#renderedAppendBatch(appendHead, width, overflow);
|
|
883
1035
|
if (emittedEnd > appendHead.emitted) {
|
|
884
1036
|
const batch: HistoryBatch = {
|
|
885
1037
|
id: this.#nextBatchId++,
|
|
886
|
-
rows,
|
|
1038
|
+
rows: leadRows > 0 ? ["", ...rows] : rows,
|
|
887
1039
|
kind: "append",
|
|
888
1040
|
};
|
|
889
|
-
this.#offered = { batch, kind: "append", entry: this.#frontier, emittedEnd };
|
|
1041
|
+
this.#offered = { batch, kind: "append", entry: this.#frontier, emittedEnd, lead: leadRows > 0 };
|
|
890
1042
|
this.#pinnedFrontier = undefined;
|
|
891
1043
|
return batch;
|
|
892
1044
|
}
|
|
@@ -913,7 +1065,7 @@ export class TranscriptContainer extends Container {
|
|
|
913
1065
|
let split: { index: number; rows: readonly string[]; split: RowSplit } | undefined;
|
|
914
1066
|
if (policy === "pressure" && keep > 0 && limit === this.#frontier + keep) {
|
|
915
1067
|
const boundary = live[keep - 1]!;
|
|
916
|
-
const visible = room - tailRows -
|
|
1068
|
+
const visible = room - tailRows - boundaryGap;
|
|
917
1069
|
if (boundary.entry.state === "settled" && visible > 0) {
|
|
918
1070
|
const offer = this.#splitOffer(boundary.entry, width, visible);
|
|
919
1071
|
if (offer === "whole") {
|
|
@@ -933,27 +1085,33 @@ export class TranscriptContainer extends Container {
|
|
|
933
1085
|
}
|
|
934
1086
|
this.#pinnedFrontier = undefined;
|
|
935
1087
|
pushLoopPhase("ui.transcript-retire");
|
|
936
|
-
let
|
|
1088
|
+
let rows: string[];
|
|
1089
|
+
let historyEnd: RowsAbove;
|
|
1090
|
+
let reached: number;
|
|
937
1091
|
try {
|
|
938
1092
|
// Shutdown must hand over the full prefix; a live frame stops at the
|
|
939
1093
|
// budget and offers the rest on the next frames.
|
|
940
|
-
retirement = this.#renderRange(
|
|
1094
|
+
const retirement = this.#renderRange(
|
|
941
1095
|
this.#frontier,
|
|
942
1096
|
end,
|
|
943
1097
|
width,
|
|
944
|
-
|
|
1098
|
+
this.#historyEnd,
|
|
945
1099
|
policy === "flush" ? undefined : RETIREMENT_BUDGET_MS,
|
|
946
1100
|
);
|
|
1101
|
+
rows = retirement.rows;
|
|
1102
|
+
reached = retirement.end;
|
|
1103
|
+
if (split !== undefined && reached !== split.index) split = undefined;
|
|
1104
|
+
if (split === undefined) {
|
|
1105
|
+
historyEnd = this.#closeRange(rows, retirement.above, reached, width);
|
|
1106
|
+
} else {
|
|
1107
|
+
if (separatorRows(retirement.above, isCompact(this.#entries[split.index]!.component)) > 0) rows.push("");
|
|
1108
|
+
rows.push(...split.rows);
|
|
1109
|
+
}
|
|
947
1110
|
} finally {
|
|
948
1111
|
popLoopPhase();
|
|
949
1112
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
id: this.#nextBatchId++,
|
|
953
|
-
rows: split === undefined ? retirement.rows : [...retirement.rows, ...split.rows],
|
|
954
|
-
kind: "append",
|
|
955
|
-
};
|
|
956
|
-
this.#offered = { batch, end: retirement.end, kind: "commit", split: split?.split };
|
|
1113
|
+
const batch: HistoryBatch = { id: this.#nextBatchId++, rows, kind: "append" };
|
|
1114
|
+
this.#offered = { batch, end: reached, kind: "commit", split: split?.split, historyEnd };
|
|
957
1115
|
return batch;
|
|
958
1116
|
}
|
|
959
1117
|
|
|
@@ -994,6 +1152,7 @@ export class TranscriptContainer extends Container {
|
|
|
994
1152
|
// zero with the offer still live) must not move it backwards.
|
|
995
1153
|
if (entry === undefined || offered.entry !== this.#frontier || offered.emittedEnd <= entry.emitted) return;
|
|
996
1154
|
entry.emitted = offered.emittedEnd;
|
|
1155
|
+
this.#historyEnd = undefined;
|
|
997
1156
|
} else if (offered.kind === "commit") {
|
|
998
1157
|
for (let index = this.#frontier; index < offered.end; index++) {
|
|
999
1158
|
this.#retireEntry(this.#entries[index]!);
|
|
@@ -1001,8 +1160,10 @@ export class TranscriptContainer extends Container {
|
|
|
1001
1160
|
this.#frontier = offered.end;
|
|
1002
1161
|
const head = offered.split ? this.#entries[offered.end] : undefined;
|
|
1003
1162
|
if (head !== undefined) head.split = offered.split;
|
|
1163
|
+
this.#historyEnd = offered.historyEnd;
|
|
1004
1164
|
} else {
|
|
1005
1165
|
this.#releaseCommittedRenderCaches();
|
|
1166
|
+
this.#historyEnd = offered.historyEnd;
|
|
1006
1167
|
}
|
|
1007
1168
|
this.#offered = undefined;
|
|
1008
1169
|
if (this.#replayRequested) this.#startReplay();
|
|
@@ -1018,46 +1179,100 @@ export class TranscriptContainer extends Container {
|
|
|
1018
1179
|
const cap = Math.max(0, Math.trunc(maxRows));
|
|
1019
1180
|
if (cap === 0) return EMPTY_ROWS;
|
|
1020
1181
|
const rows: string[] = [];
|
|
1182
|
+
let below: boolean | undefined;
|
|
1021
1183
|
for (let index = this.#entries.length - 1; index >= 0; index--) {
|
|
1022
1184
|
const entry = this.#entries[index]!;
|
|
1023
1185
|
this.#setAllocation(entry.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
1024
1186
|
const block = trimBlankEdges(entry.component.render(width));
|
|
1025
1187
|
if (entry.state === "committed") this.#releaseRenderCaches(entry);
|
|
1026
1188
|
if (block.length === 0) continue;
|
|
1027
|
-
|
|
1189
|
+
const compact = isCompact(entry.component);
|
|
1190
|
+
if (below !== undefined && separatorRows(compact, below) > 0) rows.unshift("");
|
|
1028
1191
|
rows.unshift(...block);
|
|
1192
|
+
below = compact;
|
|
1029
1193
|
if (rows.length >= cap) break;
|
|
1030
1194
|
}
|
|
1031
1195
|
return rows.length > cap ? rows.slice(rows.length - cap) : rows;
|
|
1032
1196
|
}
|
|
1033
1197
|
|
|
1034
1198
|
/**
|
|
1035
|
-
* The transcript's blocks for a native (TSP) surface, one
|
|
1036
|
-
*
|
|
1199
|
+
* The transcript's blocks for a native (TSP) surface, one `main` child
|
|
1200
|
+
* per block in transcript order; ids follow component identity, so
|
|
1037
1201
|
* inserts, removals (rewind, displacement) and reorders become targeted ops.
|
|
1038
1202
|
* Finalized blocks are settled as a hint; they stay editable, so a later
|
|
1039
1203
|
* expansion, late result or reaction still reaches them wherever they sit.
|
|
1204
|
+
* A block's {@link Component.nativeTrailers} follow it as blocks of their own.
|
|
1040
1205
|
* No retirement happens on this path: the whole transcript is one document.
|
|
1041
|
-
*
|
|
1206
|
+
*
|
|
1207
|
+
* Each run of two or more consecutive compact blocks
|
|
1208
|
+
* ({@link CompactTranscriptBlock}), with any blocks between them that
|
|
1209
|
+
* describe nothing at `cx`, is one gapless entry whose members stay
|
|
1210
|
+
* component children, keeping their own description, wire id and native
|
|
1211
|
+
* events. A compact block's trailers are members of its run; a trailer of
|
|
1212
|
+
* any other block is not. The entry is the same object while the same block
|
|
1213
|
+
* leads the run, and it never settles: a member joining later may still be live.
|
|
1214
|
+
*
|
|
1215
|
+
* Returns the same array while the entries are unchanged.
|
|
1042
1216
|
*/
|
|
1043
|
-
nativeBlocks(): readonly Component[] {
|
|
1217
|
+
nativeBlocks(cx: DescribeContext): readonly Component[] {
|
|
1044
1218
|
this.#syncEntries();
|
|
1045
1219
|
const children = this.children;
|
|
1046
|
-
|
|
1220
|
+
// Copies only once some block has trailers; `owners[i]` is the block whose compactness `flat[i]` takes.
|
|
1221
|
+
let flat: Component[] | undefined;
|
|
1222
|
+
let owners: Component[] | undefined;
|
|
1223
|
+
for (let i = 0; i < children.length; i++) {
|
|
1224
|
+
const child = children[i]!;
|
|
1047
1225
|
if (!isNativeSettled(child) && isFinalized(child)) settleNative(child);
|
|
1226
|
+
flat?.push(child);
|
|
1227
|
+
owners?.push(child);
|
|
1228
|
+
const trailers = child.nativeTrailers?.();
|
|
1229
|
+
if (!trailers?.length) continue;
|
|
1230
|
+
flat ??= children.slice(0, i + 1);
|
|
1231
|
+
owners ??= children.slice(0, i + 1);
|
|
1232
|
+
for (const trailer of trailers) {
|
|
1233
|
+
flat.push(trailer);
|
|
1234
|
+
owners.push(child);
|
|
1235
|
+
}
|
|
1048
1236
|
}
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
|
|
1237
|
+
const units: readonly Component[] = flat ?? children;
|
|
1238
|
+
const compactAt = (at: number): boolean => isCompact((owners ?? units)[at]!);
|
|
1239
|
+
// Copies only once a run forms.
|
|
1240
|
+
let blocks: Component[] | undefined;
|
|
1241
|
+
let runs: Map<Component, CompactRun> | undefined;
|
|
1242
|
+
let index = 0;
|
|
1243
|
+
while (index < units.length) {
|
|
1244
|
+
const first = units[index]!;
|
|
1245
|
+
let last = index;
|
|
1246
|
+
if (compactAt(index)) {
|
|
1247
|
+
// The run reaches over blocks that describe nothing and ends at its last compact member.
|
|
1248
|
+
for (let probe = index + 1; probe < units.length; probe++) {
|
|
1249
|
+
if (compactAt(probe)) last = probe;
|
|
1250
|
+
else if (!describesNothing(units[probe]!, cx)) break;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (last === index) {
|
|
1254
|
+
blocks?.push(first);
|
|
1255
|
+
index++;
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
const run = this.#nativeRuns.get(first) ?? new CompactRun();
|
|
1259
|
+
run.setMembers(units, index, last + 1);
|
|
1260
|
+
(runs ??= new Map()).set(first, run);
|
|
1261
|
+
(blocks ??= units.slice(0, index)).push(run);
|
|
1262
|
+
index = last + 1;
|
|
1052
1263
|
}
|
|
1053
|
-
this.#
|
|
1264
|
+
this.#nativeRuns = runs ?? NO_RUNS;
|
|
1265
|
+
const next = blocks ?? units;
|
|
1266
|
+
if (sameItems(this.#nativeBlocks, next)) return this.#nativeBlocks;
|
|
1267
|
+
// `children` mutates in place: keep a snapshot.
|
|
1268
|
+
this.#nativeBlocks = next === children ? children.slice() : next;
|
|
1054
1269
|
this.#nativeNode = undefined;
|
|
1055
1270
|
return this.#nativeBlocks;
|
|
1056
1271
|
}
|
|
1057
1272
|
|
|
1058
1273
|
/** Embedded as a child (transcript viewers): a stack of the {@link nativeBlocks}. */
|
|
1059
|
-
override describe(): NativeNode {
|
|
1060
|
-
const blocks = this.nativeBlocks();
|
|
1274
|
+
override describe(cx: DescribeContext): NativeNode {
|
|
1275
|
+
const blocks = this.nativeBlocks(cx);
|
|
1061
1276
|
this.#nativeNode ??= col(blocks, { role: "zeta.transcript" });
|
|
1062
1277
|
return this.#nativeNode;
|
|
1063
1278
|
}
|
|
@@ -1067,14 +1282,17 @@ export class TranscriptContainer extends Container {
|
|
|
1067
1282
|
this.#syncEntries();
|
|
1068
1283
|
this.#childStartRows.clear();
|
|
1069
1284
|
const rows: string[] = [];
|
|
1285
|
+
let above: RowsAbove;
|
|
1070
1286
|
for (const entry of this.#entries) {
|
|
1071
1287
|
this.#setAllocation(entry.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
1072
1288
|
const block = this.#renderEntry(entry, width);
|
|
1073
1289
|
if (entry.state === "committed") this.#releaseRenderCaches(entry);
|
|
1074
1290
|
if (block.length === 0) continue;
|
|
1075
|
-
|
|
1291
|
+
const compact = isCompact(entry.component);
|
|
1292
|
+
if (separatorRows(above, compact) > 0) rows.push("");
|
|
1076
1293
|
this.#childStartRows.set(entry.component, rows.length);
|
|
1077
1294
|
rows.push(...block);
|
|
1295
|
+
above = compact;
|
|
1078
1296
|
}
|
|
1079
1297
|
return rows;
|
|
1080
1298
|
}
|
|
@@ -1325,7 +1543,9 @@ export class TranscriptContainer extends Container {
|
|
|
1325
1543
|
}
|
|
1326
1544
|
|
|
1327
1545
|
/**
|
|
1328
|
-
* Compose entries `[start, end)` as one ordered retirement payload
|
|
1546
|
+
* Compose entries `[start, end)` as one ordered retirement payload below
|
|
1547
|
+
* rows ending as `above` says, without the separator the last block owes
|
|
1548
|
+
* what follows (see {@link #closeRange}).
|
|
1329
1549
|
*
|
|
1330
1550
|
* `budgetMs` stops the walk after the first block that crosses it — always
|
|
1331
1551
|
* at least one block — and reports the index actually reached, so a single
|
|
@@ -1337,9 +1557,9 @@ export class TranscriptContainer extends Container {
|
|
|
1337
1557
|
start: number,
|
|
1338
1558
|
end: number,
|
|
1339
1559
|
width: number,
|
|
1340
|
-
|
|
1560
|
+
above: RowsAbove,
|
|
1341
1561
|
budgetMs?: number,
|
|
1342
|
-
): { rows:
|
|
1562
|
+
): { rows: string[]; end: number; above: RowsAbove } {
|
|
1343
1563
|
const rows: string[] = [];
|
|
1344
1564
|
const startedAt = budgetMs === undefined ? 0 : performance.now();
|
|
1345
1565
|
let reached = start;
|
|
@@ -1358,28 +1578,59 @@ export class TranscriptContainer extends Container {
|
|
|
1358
1578
|
const block = rendered.slice(emittedRows);
|
|
1359
1579
|
reached = index + 1;
|
|
1360
1580
|
if (block.length > 0) {
|
|
1361
|
-
|
|
1581
|
+
const compact = isCompact(entry.component);
|
|
1582
|
+
if (separatorRows(above, compact) > 0) rows.push("");
|
|
1362
1583
|
rows.push(...block);
|
|
1584
|
+
above = compact;
|
|
1363
1585
|
}
|
|
1364
1586
|
if (budgetMs !== undefined && performance.now() - startedAt >= budgetMs) break;
|
|
1365
1587
|
}
|
|
1366
|
-
|
|
1367
|
-
return { rows, end: reached };
|
|
1588
|
+
return { rows, end: reached, above };
|
|
1368
1589
|
}
|
|
1369
1590
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1591
|
+
/**
|
|
1592
|
+
* End retired `rows` with the separator their last block owes the first
|
|
1593
|
+
* non-empty live block from `next`, withheld when both are compact, and
|
|
1594
|
+
* return what history then ends with. After a compact block with no
|
|
1595
|
+
* non-empty live block yet, the separator stays owed: the next block's
|
|
1596
|
+
* lead row (see {@link #owedLead}) draws it unless that block packs.
|
|
1597
|
+
*/
|
|
1598
|
+
#closeRange(rows: string[], above: RowsAbove, next: number, width: number): RowsAbove {
|
|
1599
|
+
if (above === undefined) return undefined;
|
|
1600
|
+
if (above) {
|
|
1601
|
+
for (let index = next; index < this.#entries.length; index++) {
|
|
1602
|
+
const entry = this.#entries[index]!;
|
|
1603
|
+
if (this.#liveBlock(entry, index, width).rows.length === 0) continue;
|
|
1604
|
+
if (isCompact(entry.component)) return above;
|
|
1605
|
+
rows.push("");
|
|
1606
|
+
return undefined;
|
|
1607
|
+
}
|
|
1608
|
+
return above;
|
|
1609
|
+
}
|
|
1610
|
+
rows.push("");
|
|
1611
|
+
return undefined;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
/** The committed ledger and the head rows already in history, and what that history ends with. */
|
|
1615
|
+
#renderReplay(width: number): { rows: readonly string[]; historyEnd: RowsAbove } {
|
|
1616
|
+
const range = this.#renderRange(0, this.#frontier, width, undefined);
|
|
1372
1617
|
const head = this.#entries[this.#frontier];
|
|
1618
|
+
let headRows: readonly string[] = EMPTY_ROWS;
|
|
1373
1619
|
if (head?.split !== undefined) {
|
|
1374
1620
|
this.#setAllocation(head.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
1375
1621
|
const committed = this.#splitRowCount(head, head.split, width);
|
|
1376
|
-
|
|
1622
|
+
headRows = renderForScrollback(() => this.#renderEntry(head, width)).slice(0, committed);
|
|
1377
1623
|
} else if (head?.mode === "appendOnly" && head.emitted > 0) {
|
|
1378
1624
|
this.#setAllocation(head.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
1379
1625
|
this.#renderEntry(head, width);
|
|
1380
|
-
|
|
1626
|
+
headRows = this.#renderStablePrefix(head, head.emitted, width);
|
|
1381
1627
|
}
|
|
1382
|
-
|
|
1628
|
+
if (head === undefined || headRows.length === 0) {
|
|
1629
|
+
return { rows: range.rows, historyEnd: this.#closeRange(range.rows, range.above, this.#frontier, width) };
|
|
1630
|
+
}
|
|
1631
|
+
if (separatorRows(range.above, isCompact(head.component)) > 0) range.rows.push("");
|
|
1632
|
+
range.rows.push(...headRows);
|
|
1633
|
+
return { rows: range.rows, historyEnd: undefined };
|
|
1383
1634
|
}
|
|
1384
1635
|
|
|
1385
1636
|
#completeFullyEmittedHeads(width: number): void {
|