pi-stereo-view 0.1.13 → 0.1.14
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 +6 -0
- package/package.json +1 -1
- package/src/compact-tools.ts +22 -5
- package/src/content.ts +74 -22
- package/src/layout.ts +9 -1
- package/src/native.ts +7 -2
- package/src/timestamps.ts +56 -21
- package/src/tool-indent.ts +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.1.14 - 2026-11-07
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Keep split view responsive while an agent streams in long sessions. Frames no longer rebuild call headers, timestamps and every earlier answer for the whole history.
|
|
10
|
+
|
|
5
11
|
## 0.1.13 - 2026-11-06
|
|
6
12
|
|
|
7
13
|
### Changed
|
package/package.json
CHANGED
package/src/compact-tools.ts
CHANGED
|
@@ -31,21 +31,38 @@ interface CompactToolOptions {
|
|
|
31
31
|
toggle?(): void;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
interface HeaderInputs {
|
|
35
|
+
width: number; name: string; args: unknown; status: ToolSummary["status"]; count?: number; expanded?: boolean;
|
|
36
|
+
label: string; theme: Theme;
|
|
37
|
+
}
|
|
38
|
+
const sameInputs = (a: HeaderInputs, b: HeaderInputs): boolean => a.width === b.width && a.name === b.name &&
|
|
39
|
+
a.args === b.args && a.status === b.status && a.count === b.count && a.expanded === b.expanded && a.label === b.label && a.theme === b.theme;
|
|
40
|
+
|
|
34
41
|
/** A display-only call or group header; the original renderer owns the body. */
|
|
35
42
|
export class CompactTool implements Component {
|
|
43
|
+
// Headers are rebuilt every frame for the whole history. Completed calls keep their
|
|
44
|
+
// argument object, so reuse the row until a displayed input changes.
|
|
45
|
+
private cached?: { inputs: HeaderInputs; lines: string[] };
|
|
46
|
+
|
|
36
47
|
constructor(private readonly summary: () => ToolSummary, private readonly theme: () => Theme,
|
|
37
48
|
private readonly options: CompactToolOptions = {}) {}
|
|
38
49
|
|
|
39
50
|
render(width: number): string[] {
|
|
40
51
|
width = Math.max(0, width - (this.options.gutter?.() ?? 0));
|
|
41
52
|
const { name, args, status } = this.summary();
|
|
42
|
-
const
|
|
53
|
+
const inputs: HeaderInputs = { width, name, args, status, count: this.options.count?.(),
|
|
54
|
+
expanded: this.options.toggle ? this.options.expanded?.() : undefined, label: this.options.clock?.() ?? "", theme: this.theme() };
|
|
55
|
+
// Streamed arguments may be updated in place, so running calls always rebuild.
|
|
56
|
+
if (this.cached && status !== "running" && sameInputs(this.cached.inputs, inputs)) return this.cached.lines;
|
|
57
|
+
const lines = this.header(inputs);
|
|
58
|
+
this.cached = { inputs, lines };
|
|
59
|
+
return lines;
|
|
60
|
+
}
|
|
61
|
+
private header({ width, name, args, status, count, expanded, label, theme }: HeaderInputs): string[] {
|
|
43
62
|
const dot = theme.fg(status === "running" ? "warning" : status === "unknown" ? "dim" : status, "●");
|
|
44
|
-
const count = this.options.count?.();
|
|
45
63
|
const description = count ? "" : toolDescription(args);
|
|
46
|
-
const control = this.options.toggle ? theme.fg("muted",
|
|
64
|
+
const control = this.options.toggle ? theme.fg("muted", expanded ? "▾" : "▸") + " " : this.options.alignControl ? " " : "";
|
|
47
65
|
const text = `${dot} ${control}${singleLine(name)}${count ? ` ×${count}` : ""}${description ? " " + theme.fg("muted", description) : ""}`;
|
|
48
|
-
const label = this.options.clock?.() ?? "";
|
|
49
66
|
const clock = label && width >= visibleWidth(label) + 8 ? label : "";
|
|
50
67
|
const available = Math.max(0, width - 1 - (clock ? visibleWidth(clock) + 1 : 0));
|
|
51
68
|
const body = truncateToWidth(text, available, "…");
|
|
@@ -60,5 +77,5 @@ export class CompactTool implements Component {
|
|
|
60
77
|
}
|
|
61
78
|
return { handled: true };
|
|
62
79
|
}
|
|
63
|
-
invalidate(): void {}
|
|
80
|
+
invalidate(): void { this.cached = undefined; }
|
|
64
81
|
}
|
package/src/content.ts
CHANGED
|
@@ -79,6 +79,20 @@ function assistant(component: Component): NativeAssistant | undefined {
|
|
|
79
79
|
return native;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** Native rendering creates one child per visible text block or consecutive thinking run. */
|
|
83
|
+
function forEachRun(source: NativeAssistant, visit: (kind: ContentKind) => void): void {
|
|
84
|
+
let thinking = false;
|
|
85
|
+
for (const block of source.lastMessage?.content ?? []) {
|
|
86
|
+
if (block.type === "thinking") {
|
|
87
|
+
if (!thinking && block.thinking?.trim()) { visit("thinking"); thinking = true; }
|
|
88
|
+
} else {
|
|
89
|
+
thinking = false;
|
|
90
|
+
if (block.type === "text" && block.text?.trim()) visit("dialogue");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const runsEnd = Symbol("runs");
|
|
95
|
+
|
|
82
96
|
/** Read supported native execution identities; unrecognized content is system information. */
|
|
83
97
|
const nativeKinds: Record<string, { kind: ContentKind; accepts(content: NativeContent): boolean }> = {
|
|
84
98
|
UserMessageComponent: { kind: "dialogue", accepts: content => typeof content.text === "string" },
|
|
@@ -127,15 +141,31 @@ function nativePanelParts(source: NativeContent): Component[] | undefined {
|
|
|
127
141
|
export class NativeContentIndex {
|
|
128
142
|
private signature: unknown[] = [];
|
|
129
143
|
private content: ContentEntry[] = [];
|
|
144
|
+
private panes: Partial<Record<Pane, ContentEntry[]>> = {};
|
|
130
145
|
private readonly expandedPanels = new WeakMap<Component, Component>();
|
|
131
146
|
private readonly views = new WeakMap<NativeAssistant, Partial<Record<Pane, Container>>>();
|
|
132
147
|
|
|
148
|
+
private pass?: { active: boolean; verified?: { children: Component[]; length: number; last?: Component; parts: number; revision: number } };
|
|
149
|
+
|
|
133
150
|
constructor(private readonly source: Container, readonly nested = new NestedCalls()) {}
|
|
134
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Native history cannot change while Pi lays out one frame, so the panes of a pass
|
|
154
|
+
* share one verification. The pass ends in the next microtask; structural changes
|
|
155
|
+
* and nested-call updates inside it still verify again.
|
|
156
|
+
*/
|
|
157
|
+
beginFrame(): void {
|
|
158
|
+
if (this.pass?.active) { this.pass.verified = undefined; return; }
|
|
159
|
+
const pass: NonNullable<typeof this.pass> = { active: true };
|
|
160
|
+
this.pass = pass;
|
|
161
|
+
queueMicrotask(() => { pass.active = false; if (this.pass === pass) this.pass = undefined; });
|
|
162
|
+
}
|
|
163
|
+
|
|
135
164
|
/** Return the same classification until native ownership or assistant content changes. */
|
|
136
165
|
entries(pane?: Pane): ContentEntry[] {
|
|
137
166
|
this.refresh();
|
|
138
|
-
|
|
167
|
+
if (pane === undefined) return this.content;
|
|
168
|
+
return this.panes[pane] ??= this.content.filter(entry => panes[entry.kind] === pane);
|
|
139
169
|
}
|
|
140
170
|
|
|
141
171
|
/** A rebuilt history cannot retain search hits belonging to removed native owners. */
|
|
@@ -155,23 +185,51 @@ export class NativeContentIndex {
|
|
|
155
185
|
return group.map(candidate => stripTerminalSequences(candidate.search(width).text)).filter(Boolean).join("\n\n");
|
|
156
186
|
}
|
|
157
187
|
|
|
188
|
+
/** Visit every native identity that classification depends on, in a fixed order. */
|
|
189
|
+
private visitSignature(history: Container, visit: (value: unknown) => boolean): boolean {
|
|
190
|
+
if (!visit(this.nested.revision)) return false;
|
|
191
|
+
for (const component of this.source.children) if (!visit(component)) return false;
|
|
192
|
+
for (const component of history.children) if (!visit(component)) return false;
|
|
193
|
+
for (const component of history.children) {
|
|
194
|
+
const metadata = component as NativeContent;
|
|
195
|
+
if (!visit(metadata.toolCallId) || !visit(metadata.entry?.data?.parentToolCallId) ||
|
|
196
|
+
!visit(metadata.message?.details?.parentToolCallId) || !visit(metadata.customComponent)) return false;
|
|
197
|
+
if (metadata.entry?.data?.parentToolCallId || metadata.message?.details?.parentToolCallId)
|
|
198
|
+
for (const part of nativePanelParts(metadata) ?? []) if (!visit(part)) return false;
|
|
199
|
+
const native = assistant(component);
|
|
200
|
+
if (native) {
|
|
201
|
+
// Streaming replaces the message on every delta; only its block layout affects routing.
|
|
202
|
+
let changed = false;
|
|
203
|
+
forEachRun(native, kind => { if (!changed && !visit(kind)) changed = true; });
|
|
204
|
+
if (changed || !visit(runsEnd)) return false;
|
|
205
|
+
for (const child of native.contentContainer.children) if (!visit(child)) return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
|
|
158
211
|
private refresh(): void {
|
|
159
212
|
const history = this.source.children[2] as Container;
|
|
160
213
|
if (!Array.isArray(history?.children)) throw new Error("Pi's history document is not supported");
|
|
214
|
+
const pass = this.pass?.active ? this.pass : undefined;
|
|
215
|
+
const children = history.children;
|
|
216
|
+
const verified = pass?.verified;
|
|
217
|
+
if (verified && verified.children === children && verified.length === children.length && verified.last === children.at(-1) &&
|
|
218
|
+
verified.parts === this.source.children.length && verified.revision === this.nested.revision) return;
|
|
219
|
+
this.verify(history);
|
|
220
|
+
if (pass) pass.verified = { children, length: children.length, last: children.at(-1), parts: this.source.children.length, revision: this.nested.revision };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private verify(history: Container): void {
|
|
161
224
|
const makeSignature = (): unknown[] => {
|
|
162
|
-
const values: unknown[] = [
|
|
163
|
-
|
|
164
|
-
const metadata = component as NativeContent;
|
|
165
|
-
values.push(metadata.toolCallId, metadata.entry?.data?.parentToolCallId, metadata.message?.details?.parentToolCallId, metadata.customComponent);
|
|
166
|
-
if (metadata.entry?.data?.parentToolCallId || metadata.message?.details?.parentToolCallId)
|
|
167
|
-
values.push(...(nativePanelParts(metadata) ?? []));
|
|
168
|
-
const native = assistant(component);
|
|
169
|
-
if (native) values.push(native.lastMessage, ...native.contentContainer.children);
|
|
170
|
-
}
|
|
225
|
+
const values: unknown[] = [];
|
|
226
|
+
this.visitSignature(history, value => { values.push(value); return true; });
|
|
171
227
|
return values;
|
|
172
228
|
};
|
|
173
|
-
|
|
174
|
-
|
|
229
|
+
// Compare in place: this runs several times per frame over the whole history.
|
|
230
|
+
let position = 0;
|
|
231
|
+
const previous = this.signature;
|
|
232
|
+
if (this.visitSignature(history, value => value === previous[position++]) && position === previous.length) return;
|
|
175
233
|
const owners = new Map<string, NativeContent>();
|
|
176
234
|
for (const component of history.children) {
|
|
177
235
|
const adapter = nativeKinds[nameOf(component)];
|
|
@@ -219,6 +277,7 @@ export class NativeContentIndex {
|
|
|
219
277
|
this.content = entries.flatMap(entry => entry.owner === entry.source
|
|
220
278
|
? [entry, ...(linked.get(entry.source) ?? [])] : []);
|
|
221
279
|
this.signature = makeSignature();
|
|
280
|
+
this.panes = {};
|
|
222
281
|
}
|
|
223
282
|
|
|
224
283
|
private entry(source: Component, kind: ContentKind, spacing: Component[], compact: boolean, owner?: NativeContent): ContentEntry {
|
|
@@ -268,15 +327,7 @@ export class NativeContentIndex {
|
|
|
268
327
|
// Native rendering creates one child per visible text block or consecutive thinking run.
|
|
269
328
|
// Match those children to semantic content before projecting; a Text diagnostic is not thinking.
|
|
270
329
|
const runs: ContentKind[] = [];
|
|
271
|
-
|
|
272
|
-
for (const block of source.lastMessage?.content ?? []) {
|
|
273
|
-
if (block.type === "thinking") {
|
|
274
|
-
if (block.thinking?.trim() && !thinking) { runs.push("thinking"); thinking = true; }
|
|
275
|
-
} else {
|
|
276
|
-
thinking = false;
|
|
277
|
-
if (block.type === "text" && block.text?.trim()) runs.push("dialogue");
|
|
278
|
-
}
|
|
279
|
-
}
|
|
330
|
+
forEachRun(source, kind => runs.push(kind));
|
|
280
331
|
const groups: Record<Pane, Component[]> = { chat: [], activity: [] };
|
|
281
332
|
const diagnostics: Component[] = [];
|
|
282
333
|
let slot = 0;
|
|
@@ -310,7 +361,8 @@ export class NativeContentIndex {
|
|
|
310
361
|
views[pane] = view;
|
|
311
362
|
}
|
|
312
363
|
const content = view.children[0] as Container;
|
|
313
|
-
|
|
364
|
+
// Keep the array of unchanged views: their native render caches compare child identity.
|
|
365
|
+
if (content.children.length !== parts.length || content.children.some((child, index) => child !== parts[index])) content.children = parts;
|
|
314
366
|
result.push({
|
|
315
367
|
source, owner: source, component: view, kind: pane === "activity" ? "thinking" : runs.includes("dialogue") ? "dialogue" : "system", spacing, compact: true,
|
|
316
368
|
search: width => {
|
package/src/layout.ts
CHANGED
|
@@ -270,7 +270,14 @@ export class TranscriptLayout {
|
|
|
270
270
|
this.chat = new PanelScrollView(chatDocument, scrollOptions, () => this.activate("chat"), () => this.searchPane() === "chat");
|
|
271
271
|
let historyHeight = 0;
|
|
272
272
|
let projectSurface = false;
|
|
273
|
-
|
|
273
|
+
// Every root entry asks in turn during one visibility pass; evaluate the projection once.
|
|
274
|
+
let pass: { width: number; height: number; shown: boolean } | undefined;
|
|
275
|
+
const shown = (viewport: { width: number; height: number }): boolean => {
|
|
276
|
+
if (pass?.width === viewport.width && pass.height === viewport.height) return pass.shown;
|
|
277
|
+
pass = { ...viewport, shown: evaluate(viewport) };
|
|
278
|
+
return pass.shown;
|
|
279
|
+
};
|
|
280
|
+
const evaluate = ({ width, height }: { width: number; height: number }): boolean => {
|
|
274
281
|
const previousHeight = historyHeight;
|
|
275
282
|
const candidate = !!projectedDock && (widgetsPresent() || dialogPresent()) && dockUnchanged() && !this.failed &&
|
|
276
283
|
this.preferences.mode === "split" && this.preferences.zoom !== "chat";
|
|
@@ -467,6 +474,7 @@ export class TranscriptLayout {
|
|
|
467
474
|
const mounted = new TranscriptRoot([
|
|
468
475
|
{ component: toolbar, basis: 1, shrink: 0, visible: () => {
|
|
469
476
|
// Root visibility is evaluated once at the start of each native layout pass.
|
|
477
|
+
pass = undefined;
|
|
470
478
|
this.timestamps.beginFrame();
|
|
471
479
|
activityDocument.beginFrame();
|
|
472
480
|
chatDocument.beginFrame();
|
package/src/native.ts
CHANGED
|
@@ -73,6 +73,7 @@ export class NativeDocument extends Container {
|
|
|
73
73
|
private frameWidth?: number;
|
|
74
74
|
private frameLines?: string[];
|
|
75
75
|
private checked = false;
|
|
76
|
+
private releasedFor?: readonly ContentEntry[];
|
|
76
77
|
private disposed = false;
|
|
77
78
|
|
|
78
79
|
constructor(
|
|
@@ -98,8 +99,12 @@ export class NativeDocument extends Container {
|
|
|
98
99
|
beginFrame(): void {
|
|
99
100
|
this.frameActive = true;
|
|
100
101
|
this.frameWidth = undefined;
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
this.index.beginFrame();
|
|
103
|
+
// Blocks are only added from the current entries, so an unchanged index has nothing to release.
|
|
104
|
+
const entries = this.index.entries(this.pane);
|
|
105
|
+
if (this.compactBlocks.size && entries !== this.releasedFor) {
|
|
106
|
+
this.releasedFor = entries;
|
|
107
|
+
const present = new Set(entries.map(entry => entry.source));
|
|
103
108
|
for (const [component, block] of this.compactBlocks) if (!present.has(component)) {
|
|
104
109
|
block.dispose();
|
|
105
110
|
this.compactBlocks.delete(component);
|
package/src/timestamps.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { NativeRenderCache } from "./render-cache.js";
|
|
|
8
8
|
type Message = ReturnType<typeof sessionEntryToContextMessages>[number];
|
|
9
9
|
type TimedSource = { message: Message; time: unknown };
|
|
10
10
|
type UserSlot = { kind: string; text?: string; time: unknown };
|
|
11
|
+
interface BranchTimes {
|
|
12
|
+
messageTimes: WeakMap<object, unknown>; users: TimedSource[]; slots: UserSlot[]; bash: TimedSource[];
|
|
13
|
+
starts: Map<string, number>; owners: Map<string, unknown>;
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
// Identical native padding is common across cold blocks. Keep only a few short blank rows.
|
|
13
17
|
const blankRows = new Set<string>();
|
|
@@ -33,10 +37,17 @@ const validTime = (value: unknown): number | undefined => {
|
|
|
33
37
|
export function timestampLabel(value: unknown): string {
|
|
34
38
|
const time = validTime(value);
|
|
35
39
|
if (time === undefined) return "";
|
|
40
|
+
// Every visible block asks for its clock on every frame.
|
|
41
|
+
let label = labels.get(time);
|
|
42
|
+
if (label !== undefined) return label;
|
|
36
43
|
const date = new Date(time);
|
|
37
|
-
|
|
44
|
+
label = [date.getHours(), date.getMinutes(), date.getSeconds()]
|
|
38
45
|
.map(part => String(part).padStart(2, "0")).join(":");
|
|
46
|
+
if (labels.size >= 8192) labels.clear();
|
|
47
|
+
labels.set(time, label);
|
|
48
|
+
return label;
|
|
39
49
|
}
|
|
50
|
+
const labels = new Map<number, string>();
|
|
40
51
|
|
|
41
52
|
const userSlots = ({ message, time }: TimedSource): UserSlot[] => {
|
|
42
53
|
if (message.role !== "user") return [];
|
|
@@ -64,11 +75,46 @@ export class TranscriptTimestamps {
|
|
|
64
75
|
|
|
65
76
|
constructor(private readonly session: ExtensionContext["sessionManager"]) {}
|
|
66
77
|
|
|
78
|
+
private branch?: { leaf: object; sources: TimedSource[]; derived?: BranchTimes };
|
|
79
|
+
|
|
80
|
+
/** Session entries are append-only, so one leaf entry identifies the whole active branch. */
|
|
81
|
+
private leaf(): object | undefined {
|
|
82
|
+
const leaf = typeof this.session.getLeafEntry === "function" ? this.session.getLeafEntry() : undefined;
|
|
83
|
+
return leaf && typeof leaf === "object" ? leaf : undefined;
|
|
84
|
+
}
|
|
67
85
|
private sources(): TimedSource[] {
|
|
68
|
-
|
|
86
|
+
const leaf = this.leaf();
|
|
87
|
+
if (leaf && this.branch?.leaf === leaf) return this.branch.sources;
|
|
88
|
+
const sources = this.session.buildContextEntries().flatMap(entry =>
|
|
69
89
|
sessionEntryToContextMessages(entry).map(message => ({
|
|
70
90
|
message, time: validTime("timestamp" in message ? message.timestamp : undefined) ?? entry.timestamp,
|
|
71
91
|
})));
|
|
92
|
+
this.branch = leaf ? { leaf, sources } : undefined;
|
|
93
|
+
return sources;
|
|
94
|
+
}
|
|
95
|
+
/** Branch-derived lookups are rebuilt only when the active branch changes. */
|
|
96
|
+
private times(): BranchTimes {
|
|
97
|
+
const sources = this.sources();
|
|
98
|
+
if (this.branch?.sources === sources && this.branch.derived) return this.branch.derived;
|
|
99
|
+
const users = sources.filter(source => source.message.role === "user");
|
|
100
|
+
const starts = new Map<string, number>();
|
|
101
|
+
for (const entry of this.session.getBranch()) {
|
|
102
|
+
if (entry.type !== "custom" || entry.customType !== TOOL_START_ENTRY || !entry.data || typeof entry.data !== "object") continue;
|
|
103
|
+
const data = entry.data as { toolCallId?: unknown; time?: unknown };
|
|
104
|
+
const time = validTime(data.time);
|
|
105
|
+
if (typeof data.toolCallId === "string" && time !== undefined) starts.set(data.toolCallId, time);
|
|
106
|
+
}
|
|
107
|
+
const owners = new Map<string, unknown>();
|
|
108
|
+
for (const { message, time } of sources) {
|
|
109
|
+
if (message.role !== "assistant") continue;
|
|
110
|
+
for (const block of message.content) if (block.type === "toolCall") owners.set(block.id, time);
|
|
111
|
+
}
|
|
112
|
+
const derived = {
|
|
113
|
+
messageTimes: new WeakMap(sources.map(source => [source.message, source.time])), users, slots: users.flatMap(userSlots),
|
|
114
|
+
bash: sources.filter(source => source.message.role === "bashExecution"), starts, owners,
|
|
115
|
+
};
|
|
116
|
+
if (this.branch?.sources === sources) this.branch.derived = derived;
|
|
117
|
+
return derived;
|
|
72
118
|
}
|
|
73
119
|
|
|
74
120
|
/** Include the current unpersisted user and streamed tool IDs before UI delivery. */
|
|
@@ -99,8 +145,9 @@ export class TranscriptTimestamps {
|
|
|
99
145
|
this.liveCalls.clear();
|
|
100
146
|
this.orderedLabels = new WeakMap();
|
|
101
147
|
this.messageTimes = new WeakMap();
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
148
|
+
this.branch = undefined;
|
|
149
|
+
this.starts = new Map();
|
|
150
|
+
this.owners = new Map();
|
|
104
151
|
}
|
|
105
152
|
|
|
106
153
|
/** Share one history correlation across the panels measured in a native frame. */
|
|
@@ -112,11 +159,10 @@ export class TranscriptTimestamps {
|
|
|
112
159
|
prepare(components: Component[]): void {
|
|
113
160
|
if (this.frameActive && this.preparedComponents === components) return;
|
|
114
161
|
this.preparedComponents = components;
|
|
115
|
-
const
|
|
116
|
-
this.messageTimes =
|
|
117
|
-
const users = sources.filter(source => source.message.role === "user");
|
|
162
|
+
const { messageTimes, users, slots: saved, bash, starts, owners } = this.times();
|
|
163
|
+
this.messageTimes = messageTimes;
|
|
118
164
|
if (this.pendingUser?.ended && users.length > this.pendingUser.before) this.pendingUser = undefined;
|
|
119
|
-
const slots =
|
|
165
|
+
const slots = saved.slice();
|
|
120
166
|
const nativeUsers = components.filter(component =>
|
|
121
167
|
component.constructor.name === "UserMessageComponent" || component.constructor.name === "SkillInvocationMessageComponent");
|
|
122
168
|
if (nativeUsers.length !== slots.length && this.pendingUser) slots.push(...userSlots(this.pendingUser.source));
|
|
@@ -130,24 +176,13 @@ export class TranscriptTimestamps {
|
|
|
130
176
|
});
|
|
131
177
|
if (matches) nativeUsers.forEach((component, index) => this.orderedLabels.set(component, timestampLabel(slots[index].time)));
|
|
132
178
|
}
|
|
133
|
-
const bash = sources.filter(source => source.message.role === "bashExecution");
|
|
134
179
|
const nativeBash = components.filter(component => component.constructor.name === "BashExecutionComponent");
|
|
135
180
|
if (nativeBash.length === bash.length && nativeBash.every((component, index) =>
|
|
136
181
|
(component as Component & { command?: unknown }).command === (bash[index].message as { command: string }).command)) {
|
|
137
182
|
nativeBash.forEach((component, index) => this.orderedLabels.set(component, timestampLabel(bash[index].time)));
|
|
138
183
|
}
|
|
139
|
-
this.starts
|
|
140
|
-
|
|
141
|
-
if (entry.type !== "custom" || entry.customType !== TOOL_START_ENTRY || !entry.data || typeof entry.data !== "object") continue;
|
|
142
|
-
const data = entry.data as { toolCallId?: unknown; time?: unknown };
|
|
143
|
-
const time = validTime(data.time);
|
|
144
|
-
if (typeof data.toolCallId === "string" && time !== undefined) this.starts.set(data.toolCallId, time);
|
|
145
|
-
}
|
|
146
|
-
this.owners.clear();
|
|
147
|
-
for (const { message, time } of sources) {
|
|
148
|
-
if (message.role !== "assistant") continue;
|
|
149
|
-
for (const block of message.content) if (block.type === "toolCall") this.owners.set(block.id, time);
|
|
150
|
-
}
|
|
184
|
+
this.starts = starts;
|
|
185
|
+
this.owners = owners;
|
|
151
186
|
}
|
|
152
187
|
|
|
153
188
|
/** Reject changed private metadata before relying on it for a label. */
|
package/src/tool-indent.ts
CHANGED
|
@@ -8,10 +8,22 @@ export class ToolIndent extends Container {
|
|
|
8
8
|
super(); this.addChild(component);
|
|
9
9
|
this.prefix = " ".repeat(gutter) + " │".repeat(depth) + (body ? " " : "");
|
|
10
10
|
}
|
|
11
|
+
// Expanded runs are re-indented on every frame; reuse rows while the native rows are unchanged.
|
|
12
|
+
private cached?: { width: number; prefix: string; source: string[]; lines: string[] };
|
|
11
13
|
override render(width: number): string[] {
|
|
12
14
|
const inset = Math.min(width, this.prefix.length);
|
|
13
15
|
const prefix = this.theme().fg("dim", this.prefix.slice(0, inset));
|
|
14
|
-
|
|
16
|
+
const source = super.render(Math.max(0, width - inset));
|
|
17
|
+
const cached = this.cached;
|
|
18
|
+
if (cached && cached.width === width && cached.prefix === prefix && cached.source.length === source.length &&
|
|
19
|
+
cached.source.every((line, index) => line === source[index])) return cached.lines;
|
|
20
|
+
const lines = source.map(line => truncateToWidth(prefix + line, width, ""));
|
|
21
|
+
this.cached = { width, prefix, source, lines };
|
|
22
|
+
return lines;
|
|
23
|
+
}
|
|
24
|
+
override invalidate(): void {
|
|
25
|
+
this.cached = undefined;
|
|
26
|
+
super.invalidate();
|
|
15
27
|
}
|
|
16
28
|
override handleMouse(event: TuiMouseEvent): ReturnType<Container["handleMouse"]> {
|
|
17
29
|
const inset = Math.min(event.width, this.prefix.length);
|