pi-stereo-view 0.1.19 → 0.1.21
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 +17 -0
- package/README.md +18 -6
- package/package.json +1 -1
- package/src/compact-tools.ts +8 -6
- package/src/content.ts +25 -7
- package/src/index.ts +13 -3
- package/src/layout.ts +17 -3
- package/src/native.ts +64 -41
- package/src/preferences.ts +14 -5
- package/src/tool-groups.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.1.21 - 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Compact tool rows show how many images a call returned, such as `read (1 image)`, so a collapsed screenshot or image read is not missed. Groups show the total for their calls (#103).
|
|
10
|
+
|
|
11
|
+
## 0.1.20 - 2026-11-19
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Group Activity tools** and **Nested call tree** settings. Compact rows, `read ×3` groups and the nested call tree of tools such as Codemode now turn on and off independently. With only grouping on, a group opens into full cards; with only compact on, every call keeps its own row; with the tree off, a tool keeps its own output panel. Thanks to Oula Kuuva for the idea and the first implementation (#100).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Stream latest tools also works with grouping alone: a new call stays a full card for the collapse delay before it joins its group.
|
|
20
|
+
- Saved settings keep their look: grouping follows your saved Compact Activity tools choice until you change it.
|
|
21
|
+
|
|
5
22
|
## 0.1.19 - 2026-11-19
|
|
6
23
|
|
|
7
24
|
### Changed
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Unrecognized content stays in Conversation unless its metadata links it to a kno
|
|
|
27
27
|
|
|
28
28
|
Late output linked to a tool call appears directly below that call in Activity, even if other work has happened since. Combined history keeps its original order.
|
|
29
29
|
|
|
30
|
-
Expand a parent tool such as Codemode to browse its nested call tree. Adjacent calls of the same tool form a group with individual call headers. Each independent native result opens under its call. A combined result covering several calls stays whole inside their group. Panels without child execution identities remain available inside the parent's output disclosure. Session restoration uses Pi's saved nested-call metadata and the original saved panels.
|
|
30
|
+
Expand a parent tool such as Codemode to browse its nested call tree. To keep the parent's own output panel instead, turn off **Nested call tree** in Settings. Adjacent calls of the same tool form a group with individual call headers. Each independent native result opens under its call. A combined result covering several calls stays whole inside their group. Panels without child execution identities remain available inside the parent's output disclosure. Session restoration uses Pi's saved nested-call metadata and the original saved panels.
|
|
31
31
|
|
|
32
32
|
Messages and tools keep their familiar appearance. Extension widgets and inline dialogs appear at the bottom of Activity, below its independently scrolling history. Standard select, confirm, input and editor dialogs and non-overlay custom components keep Pi's native input, focus and completion behavior. The message editor, including extension-provided replacements, stays full width whenever Pi displays it. Explicit overlays keep their native placement.
|
|
33
33
|
|
|
@@ -98,17 +98,29 @@ Swap the panels whenever you want. Zoom a panel to give it the whole history are
|
|
|
98
98
|
|
|
99
99
|
## Compact Activity
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Three independent settings in `/stereo-view settings` control how Activity shows tool calls. All three are on by default and survive restart.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
| Setting | On | Off |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| **Compact Activity tools** | Each call is a one-line row; click it to open its full card and linked output. | Calls show their full cards. |
|
|
106
|
+
| **Group Activity tools** | Adjacent calls to the same tool in the same state share one header with a count, such as `read ×3`. | Every call stands alone. |
|
|
107
|
+
| **Nested call tree** | Calls made by a tool such as Codemode appear as a tree under it. | The tool keeps its own output panel. |
|
|
108
|
+
|
|
109
|
+
Compact and Group combine freely. With both on, a group opens into compact rows, and each row opens its card. With only Group on, a group opens straight into the members' full cards. With only Compact on, every call keeps its own row. With both off, Activity shows the original cards; this suits other extensions that draw their own tool cards.
|
|
110
|
+
|
|
111
|
+
Click `[ ⊟ ]` or `[Compact tools]` beside Find and Maximize in the Activity header to turn compact rows on, and `[ ⊞ ]` or `[Full tools]` to turn them off. The button changes only **Compact Activity tools**.
|
|
112
|
+
|
|
113
|
+
Every failed call stays separate, even beside another failure. Left guides mark each level: members sit inside their group, and an open card and its linked output sit inside their call. Collapse a call or its group independently; reopening the group keeps your expanded calls, and so does turning grouping off and on again. Thinking, Conversation content and different tools end a group.
|
|
114
|
+
|
|
115
|
+
Group and call headers show `▸` when collapsed and `▾` when expanded. Each call row has a one-cell left gutter, a colored status dot, its tool name and a short argument description. A group shows its shared running or successful state. Failed calls expose their own status and argument preview without opening a group. A call whose result holds images shows their count, such as `(1 image)`, before its description; a group shows the total for its calls. Open the call to see the images, if your terminal can display them. Long descriptions are truncated, not the saved calls. Verified local MCP forwarding aliases use their native tool's name; foreign, ambiguous and unknown tools keep their original identity.
|
|
104
116
|
|
|
105
|
-
Search and `/stereo-view copy` still include full saved results and linked output. A search match opens its group and call temporarily; clearing the search restores your previous expansion.
|
|
117
|
+
Search and `/stereo-view copy` still include full saved results and linked output. A search match opens its group and call temporarily; clearing the search restores your previous expansion. Conversation and combined history keep their normal display.
|
|
106
118
|
|
|
107
|
-
Compact
|
|
119
|
+
Compact rows and groups work in columns, rows and zoomed Activity. Settings saved before grouping was a separate setting keep their look: grouping follows the saved compact choice.
|
|
108
120
|
|
|
109
121
|
### Stream latest tools
|
|
110
122
|
|
|
111
|
-
**Stream latest tools** (on by default, in Settings) lets you watch the current work while keeping history short.
|
|
123
|
+
**Stream latest tools** (on by default, in Settings) lets you watch the current work while keeping history short. While Compact or Group is on, a new tool call appears as its full card and updates live. When it finishes, it stays fully visible for the **Collapse delay** (1, 2, 3, 5, 10 or 30 seconds; default 5), then collapses in place: into a compact row with Compact on, and into the adjacent identical calls' group (`read ×3`) with Group on. With both off, every call already shows in full, so streaming changes nothing.
|
|
112
124
|
|
|
113
125
|
Calls that are still running or waiting to collapse are never grouped. Thinking, answers and other content between calls appear as usual and end a group. Several calls running together collapse separately, each after its own delay. A call you opened yourself stays open. Scroll position is not changed when a call collapses; if you are at the end of Activity, you stay there. A reopened session shows all its calls collapsed. Both options survive restart; streaming defaults to on.
|
|
114
126
|
|
package/package.json
CHANGED
package/src/compact-tools.ts
CHANGED
|
@@ -32,11 +32,11 @@ interface CompactToolOptions {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
interface HeaderInputs {
|
|
35
|
-
width: number; name: string; args: unknown; status: ToolSummary["status"]; count?: number; expanded?: boolean;
|
|
35
|
+
width: number; name: string; args: unknown; status: ToolSummary["status"]; images: number; count?: number; expanded?: boolean;
|
|
36
36
|
label: string; theme: Theme;
|
|
37
37
|
}
|
|
38
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;
|
|
39
|
+
a.args === b.args && a.status === b.status && a.images === b.images && a.count === b.count && a.expanded === b.expanded && a.label === b.label && a.theme === b.theme;
|
|
40
40
|
|
|
41
41
|
/** A display-only call or group header; the original renderer owns the body. */
|
|
42
42
|
export class CompactTool implements Component {
|
|
@@ -49,8 +49,8 @@ export class CompactTool implements Component {
|
|
|
49
49
|
|
|
50
50
|
render(width: number): string[] {
|
|
51
51
|
width = Math.max(0, width - (this.options.gutter?.() ?? 0));
|
|
52
|
-
const { name, args, status } = this.summary();
|
|
53
|
-
const inputs: HeaderInputs = { width, name, args, status, count: this.options.count?.(),
|
|
52
|
+
const { name, args, status, images = 0 } = this.summary();
|
|
53
|
+
const inputs: HeaderInputs = { width, name, args, status, images, count: this.options.count?.(),
|
|
54
54
|
expanded: this.options.toggle ? this.options.expanded?.() : undefined, label: this.options.clock?.() ?? "", theme: this.theme() };
|
|
55
55
|
// Streamed arguments may be updated in place, so running calls always rebuild.
|
|
56
56
|
if (this.cached && status !== "running" && sameInputs(this.cached.inputs, inputs)) return this.cached.lines;
|
|
@@ -58,11 +58,13 @@ export class CompactTool implements Component {
|
|
|
58
58
|
this.cached = { inputs, lines };
|
|
59
59
|
return lines;
|
|
60
60
|
}
|
|
61
|
-
private header({ width, name, args, status, count, expanded, label, theme }: HeaderInputs): string[] {
|
|
61
|
+
private header({ width, name, args, status, images, count, expanded, label, theme }: HeaderInputs): string[] {
|
|
62
62
|
const dot = theme.fg(status === "running" ? "warning" : status === "unknown" ? "dim" : status, "●");
|
|
63
63
|
const description = count ? "" : toolDescription(args);
|
|
64
64
|
const control = this.options.toggle ? theme.fg("muted", expanded ? "▾" : "▸") + " " : this.options.alignControl ? " " : "";
|
|
65
|
-
|
|
65
|
+
// Before the description, so truncation keeps it: the collapsed row is the only sign of a hidden image.
|
|
66
|
+
const attachment = images ? " " + theme.fg("accent", `(${images} ${images === 1 ? "image" : "images"})`) : "";
|
|
67
|
+
const text = `${dot} ${control}${singleLine(name)}${count ? ` ×${count}` : ""}${attachment}${description ? " " + theme.fg("muted", description) : ""}`;
|
|
66
68
|
const clock = label && width >= visibleWidth(label) + 8 ? label : "";
|
|
67
69
|
const available = Math.max(0, width - 1 - (clock ? visibleWidth(clock) + 1 : 0));
|
|
68
70
|
const body = truncateToWidth(text, available, "…");
|
package/src/content.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface ToolSummary {
|
|
|
37
37
|
name: string;
|
|
38
38
|
args: unknown;
|
|
39
39
|
status: "running" | "success" | "error" | "unknown";
|
|
40
|
+
/** Image blocks in the call's result, shown on compact rows that hide the native card. */
|
|
41
|
+
images?: number;
|
|
40
42
|
}
|
|
41
43
|
/** One native owner and its pane projection; spacing and search retain that same owner. */
|
|
42
44
|
export interface ContentEntry {
|
|
@@ -55,6 +57,13 @@ export function callStatus(call: Component): ToolSummary["status"] {
|
|
|
55
57
|
const { result, isPartial } = call as NativeContent;
|
|
56
58
|
return !result || isPartial !== false ? "running" : result.isError ? "error" : "success";
|
|
57
59
|
}
|
|
60
|
+
/** Number of image blocks in a tool result's content. */
|
|
61
|
+
export function imageCount(content: unknown): number {
|
|
62
|
+
if (!Array.isArray(content)) return 0;
|
|
63
|
+
let count = 0;
|
|
64
|
+
for (const block of content) if (block?.type === "image") count++;
|
|
65
|
+
return count;
|
|
66
|
+
}
|
|
58
67
|
|
|
59
68
|
const nameOf = (component: Component): string => component.constructor.name;
|
|
60
69
|
const contentText = (content: unknown): string => typeof content === "string" ? content :
|
|
@@ -181,9 +190,13 @@ export class NativeContentIndex {
|
|
|
181
190
|
private readonly views = new WeakMap<NativeAssistant, Partial<Record<Pane, Container>>>();
|
|
182
191
|
private readonly diagnostics = new WeakMap<NativeAssistant, Component[]>();
|
|
183
192
|
|
|
184
|
-
private pass?: { active: boolean; verified?: { children: Component[]; length: number; last?: Component; parts: number; revision: number } };
|
|
193
|
+
private pass?: { active: boolean; verified?: { children: Component[]; length: number; last?: Component; parts: number; revision: number; trees: boolean } };
|
|
185
194
|
|
|
186
|
-
|
|
195
|
+
/**
|
|
196
|
+
* With `nestedTrees` on, a parented output panel is split into the native parts of its nested calls, which Activity
|
|
197
|
+
* shows as the caller's tree. Off, the panel stays one original entry beside its owner.
|
|
198
|
+
*/
|
|
199
|
+
constructor(private readonly source: Container, readonly nested = new NestedCalls(), readonly nestedTrees: () => boolean = () => true) {}
|
|
187
200
|
|
|
188
201
|
/**
|
|
189
202
|
* Native history cannot change while Pi lays out one frame, so the panes of a pass
|
|
@@ -228,9 +241,9 @@ export class NativeContentIndex {
|
|
|
228
241
|
const children = history.children;
|
|
229
242
|
const verified = pass?.verified;
|
|
230
243
|
if (verified && verified.children === children && verified.length === children.length && verified.last === children.at(-1) &&
|
|
231
|
-
verified.parts === this.source.children.length && verified.revision === this.nested.revision) return;
|
|
244
|
+
verified.parts === this.source.children.length && verified.revision === this.nested.revision && verified.trees === this.nestedTrees()) return;
|
|
232
245
|
this.verify(history);
|
|
233
|
-
if (pass) pass.verified = { children, length: children.length, last: children.at(-1), parts: this.source.children.length, revision: this.nested.revision };
|
|
246
|
+
if (pass) pass.verified = { children, length: children.length, last: children.at(-1), parts: this.source.children.length, revision: this.nested.revision, trees: this.nestedTrees() };
|
|
234
247
|
}
|
|
235
248
|
|
|
236
249
|
/** Whether a classified block still has the native inputs its entries were built from. */
|
|
@@ -245,7 +258,7 @@ export class NativeContentIndex {
|
|
|
245
258
|
if (block.parent) {
|
|
246
259
|
const owner = this.owners.get(block.parent.id);
|
|
247
260
|
if (owner !== block.parent.owner) return false;
|
|
248
|
-
const parts = owner?.toolCallId
|
|
261
|
+
const parts = owner?.toolCallId ? this.panelParts(component, owner.toolCallId) : undefined;
|
|
249
262
|
if (parts ? !sameValues(block.parent.parts, parts) : block.parent.parts) return false;
|
|
250
263
|
}
|
|
251
264
|
return true;
|
|
@@ -315,6 +328,11 @@ export class NativeContentIndex {
|
|
|
315
328
|
this.panes = {};
|
|
316
329
|
}
|
|
317
330
|
|
|
331
|
+
/** The parts a nested-call tree shows for an owner's linked panel, or none to keep the panel whole. */
|
|
332
|
+
private panelParts(panel: NativeContent, owner: string): Component[] | undefined {
|
|
333
|
+
return this.nestedTrees() && this.nested.entries(owner).length ? nativePanelParts(panel) : undefined;
|
|
334
|
+
}
|
|
335
|
+
|
|
318
336
|
/** Build the entries of one native history block, keeping previous entry objects that did not change. */
|
|
319
337
|
private classify(component: Component, spacing: Component[], old: Classified | undefined): Classified {
|
|
320
338
|
const native = component as NativeContent;
|
|
@@ -335,7 +353,7 @@ export class NativeContentIndex {
|
|
|
335
353
|
content.setExpanded?.(true);
|
|
336
354
|
this.expandedPanels.set(component, owner);
|
|
337
355
|
} else if (!owner) this.expandedPanels.delete(component);
|
|
338
|
-
const parts = owner
|
|
356
|
+
const parts = owner ? this.panelParts(content, owner.toolCallId!) : undefined;
|
|
339
357
|
if (kind === "system" && typeof parentId === "string") block.parent = { id: parentId, owner, parts };
|
|
340
358
|
if (parts) for (const part of parts) {
|
|
341
359
|
const adapter = nativeKinds[nameOf(part)];
|
|
@@ -352,7 +370,7 @@ export class NativeContentIndex {
|
|
|
352
370
|
const native = source as NativeContent;
|
|
353
371
|
return {
|
|
354
372
|
name: native.toolName!, args: native.args,
|
|
355
|
-
status: callStatus(native),
|
|
373
|
+
status: callStatus(native), images: imageCount(native.result?.content),
|
|
356
374
|
};
|
|
357
375
|
} : undefined;
|
|
358
376
|
return { source, owner: owner ?? source, component: source, kind: owner ? "tool" : kind, spacing, compact, tool, search: width => {
|
package/src/index.ts
CHANGED
|
@@ -68,11 +68,19 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
68
68
|
currentValue: preferences.buttonStyle, values: ["icons", "text"],
|
|
69
69
|
}, {
|
|
70
70
|
id: "compactTools", label: "Compact Activity tools",
|
|
71
|
-
description: "
|
|
71
|
+
description: "Show each finished call as one row that opens its full card. Full text stays searchable and copyable.",
|
|
72
72
|
currentValue: preferences.compactTools ? "on" : "off", values: ["on", "off"],
|
|
73
|
+
}, {
|
|
74
|
+
id: "groupTools", label: "Group Activity tools",
|
|
75
|
+
description: "Merge adjacent calls of the same tool and state under one counted header.",
|
|
76
|
+
currentValue: preferences.groupTools ? "on" : "off", values: ["on", "off"],
|
|
77
|
+
}, {
|
|
78
|
+
id: "nestedTree", label: "Nested call tree",
|
|
79
|
+
description: "Show the calls a tool makes, such as Codemode's, as a tree. Off keeps the tool's own output panel.",
|
|
80
|
+
currentValue: preferences.nestedTree ? "on" : "off", values: ["on", "off"],
|
|
73
81
|
}, {
|
|
74
82
|
id: "streamTools", label: "Stream latest tools",
|
|
75
|
-
description: "
|
|
83
|
+
description: "While compact or grouped, show new tool calls in full and collapse them after the delay.",
|
|
76
84
|
currentValue: preferences.streamTools ? "on" : "off", values: ["on", "off"],
|
|
77
85
|
}, {
|
|
78
86
|
id: "streamDelay", label: "Collapse delay",
|
|
@@ -82,11 +90,13 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
82
90
|
id: "height", label: "Conversation height",
|
|
83
91
|
description: "Auto grows to half the history area. Drag sets a manual maximum.",
|
|
84
92
|
currentValue: preferences.chatHeight === null ? "auto" : "manual", values: ["auto", "manual"],
|
|
85
|
-
}],
|
|
93
|
+
}], 9, getSettingsListTheme(), (id, value) => {
|
|
86
94
|
if (id === "timestamps") layout?.setTimestamps(value === "on");
|
|
87
95
|
else if (id === "copyButtons") layout?.setCopyButtons(value === "on");
|
|
88
96
|
else if (id === "buttonStyle") layout?.setButtonStyle(value === "text" ? "text" : "icons");
|
|
89
97
|
else if (id === "compactTools") layout?.setCompactTools(value === "on");
|
|
98
|
+
else if (id === "groupTools") layout?.setGroupTools(value === "on");
|
|
99
|
+
else if (id === "nestedTree") layout?.setNestedTree(value === "on");
|
|
90
100
|
else if (id === "streamTools") layout?.setStreamTools(value === "on");
|
|
91
101
|
else if (id === "streamDelay") layout?.setStreamDelay(Number.parseInt(value, 10));
|
|
92
102
|
else if (id === "height") layout?.setAutomaticHeight(value === "auto");
|
package/src/layout.ts
CHANGED
|
@@ -343,9 +343,10 @@ export class TranscriptLayout {
|
|
|
343
343
|
const timestampGutter = (): number => scroll.scrollbar === "auto" ? 1 : 0;
|
|
344
344
|
const showTimestamps = (): boolean => this.preferences.showTimestamps;
|
|
345
345
|
const showCopyButtons = (): boolean => this.preferences.showCopyButtons;
|
|
346
|
-
const index = new NativeContentIndex(document, this.nested);
|
|
346
|
+
const index = new NativeContentIndex(document, this.nested, () => this.preferences.nestedTree);
|
|
347
347
|
const activityDocument = new NativeDocument(document, "activity", this.timestamps, this.theme, timestampGutter, showTimestamps,
|
|
348
|
-
() => this.activate("activity"), false, index, this.copy, showCopyButtons,
|
|
348
|
+
() => this.activate("activity"), false, index, this.copy, showCopyButtons,
|
|
349
|
+
() => ({ compact: this.preferences.compactTools, group: this.preferences.groupTools }), this.getTools,
|
|
349
350
|
() => { if (this.activity) this.activity.scrollTo(this.activity.scrollTop, { disableFollow: true }); }, () => this.preferences.buttonStyle, {
|
|
350
351
|
enabled: () => this.preferences.streamTools, delay: () => this.preferences.streamDelay * 1000,
|
|
351
352
|
changed: () => this.host?.requestRender(),
|
|
@@ -786,7 +787,20 @@ export class TranscriptLayout {
|
|
|
786
787
|
this.preferences.compactTools = compact;
|
|
787
788
|
this.changed();
|
|
788
789
|
}
|
|
789
|
-
|
|
790
|
+
|
|
791
|
+
/** Merge adjacent calls of one tool in one state under a counted header, with or without compact rows. */
|
|
792
|
+
setGroupTools(group: boolean): void {
|
|
793
|
+
this.preferences.groupTools = group;
|
|
794
|
+
this.changed();
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Show nested calls as a tree, or keep the parent's native output panel. */
|
|
798
|
+
setNestedTree(tree: boolean): void {
|
|
799
|
+
this.preferences.nestedTree = tree;
|
|
800
|
+
this.changed();
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** Show the latest tool calls in full while Compact or Group would hide them, until they have been finished for the delay. */
|
|
790
804
|
setStreamTools(stream: boolean): void {
|
|
791
805
|
this.preferences.streamTools = stream;
|
|
792
806
|
this.changed();
|
package/src/native.ts
CHANGED
|
@@ -48,6 +48,15 @@ class SearchHighlight implements Component {
|
|
|
48
48
|
/** Scroll state of the panel showing a document, read before the panel's layout in a frame. */
|
|
49
49
|
export interface DocumentViewport { top: number; height: number; following: boolean }
|
|
50
50
|
|
|
51
|
+
/** How Activity presents finished tool calls; the two choices are independent. */
|
|
52
|
+
export interface ToolDisplay {
|
|
53
|
+
/** Each call is a one-line row that opens its original card and linked output. */
|
|
54
|
+
compact: boolean;
|
|
55
|
+
/** Adjacent calls of one tool in one state share a counted header. */
|
|
56
|
+
group: boolean;
|
|
57
|
+
}
|
|
58
|
+
const FULL_TOOLS: ToolDisplay = { compact: false, group: false };
|
|
59
|
+
|
|
51
60
|
/** Time per frame for measuring offscreen entries that are new, changed or stale. */
|
|
52
61
|
const LAZY_BUDGET_MS = 4;
|
|
53
62
|
/** Offscreen entries checked for native changes per frame, in rotation. */
|
|
@@ -157,7 +166,7 @@ export class NativeDocument extends Container {
|
|
|
157
166
|
private readonly index = new NativeContentIndex(source),
|
|
158
167
|
private readonly copy?: (text: string | undefined) => void,
|
|
159
168
|
private readonly showCopy: () => boolean = () => true,
|
|
160
|
-
private readonly
|
|
169
|
+
private readonly toolDisplay: () => ToolDisplay = () => FULL_TOOLS,
|
|
161
170
|
private readonly getTools: () => readonly ToolInfo[] = () => [],
|
|
162
171
|
private readonly beforeExpand: () => void = () => {},
|
|
163
172
|
private readonly buttonStyle: () => "icons" | "text" = () => "text",
|
|
@@ -167,9 +176,9 @@ export class NativeDocument extends Container {
|
|
|
167
176
|
if (streaming) this.streamer = new ToolStreaming(() => streaming.delay(), () => streaming.changed());
|
|
168
177
|
}
|
|
169
178
|
private readonly streamer?: ToolStreaming;
|
|
170
|
-
/** Calls
|
|
171
|
-
private live(source: Component): boolean { return this.
|
|
172
|
-
private
|
|
179
|
+
/** Calls still shown as separate full cards, although Compact or Group would hide them. */
|
|
180
|
+
private live(source: Component): boolean { return this.streamActive && this.streamer?.isLive(source) === true; }
|
|
181
|
+
private streamActive = false;
|
|
173
182
|
|
|
174
183
|
/**
|
|
175
184
|
* Start a native frame; only repeated measurements within that frame may reuse routing.
|
|
@@ -399,7 +408,7 @@ export class NativeDocument extends Container {
|
|
|
399
408
|
let stamped = this.stamped.get(routed);
|
|
400
409
|
if (!stamped) {
|
|
401
410
|
stamped = new CompactMessage(routed, () => this.timestamps.label(this.clockOwners.get(component) ?? component),
|
|
402
|
-
this.theme, this.timestampGutter, () => this.showTimestamps() && !(this.pane === "activity" && this.
|
|
411
|
+
this.theme, this.timestampGutter, () => this.showTimestamps() && !(this.pane === "activity" && this.toolDisplay().compact && entry.kind === "tool" && !this.live(entry.owner)),
|
|
403
412
|
this.copy ? () => this.copyBlock(component) : undefined, this.showCopy, this.buttonStyle, () => {
|
|
404
413
|
// Nested panels render inside their owner's segment.
|
|
405
414
|
this.dirty.add(component).add(entry.owner);
|
|
@@ -431,14 +440,14 @@ export class NativeDocument extends Container {
|
|
|
431
440
|
* Regroup calls only when the entries, presentation, live calls or a call's status change. Pi updates a call's
|
|
432
441
|
* result without invalidating it, so the status is read from its native fields on every frame.
|
|
433
442
|
*/
|
|
434
|
-
private updateGroups(
|
|
443
|
+
private updateGroups(group: boolean): void {
|
|
435
444
|
const all = this.index.entries();
|
|
436
|
-
const inputs = [
|
|
445
|
+
const inputs = [group, all, this.present, this.streamActive, this.streamer?.revision];
|
|
437
446
|
if (sameValues(this.groupInputs, inputs) && this.callStatesUnchanged(all)) return;
|
|
438
447
|
this.groupInputs = inputs;
|
|
439
448
|
this.callStates.length = 0;
|
|
440
449
|
pushCallStates(all, this.callStates);
|
|
441
|
-
const groups =
|
|
450
|
+
const groups = group ? toolGroups(all, this.present, source => this.live(source)) : new Map<Component, ToolGroup>();
|
|
442
451
|
// Carry visible expansion through state-driven splits and merges, without
|
|
443
452
|
// reopening explicitly collapsed runs. Read the old state before adding heads.
|
|
444
453
|
const opening: Component[] = [];
|
|
@@ -449,7 +458,8 @@ export class NativeDocument extends Container {
|
|
|
449
458
|
return previous && (previous.calls.length > 1 ? this.openGroups.has(previous.calls[0].source) : this.openTools.has(call.source));
|
|
450
459
|
})) opening.push(source);
|
|
451
460
|
}
|
|
452
|
-
|
|
461
|
+
// While grouping is off, keep the open groups for when it is turned on again.
|
|
462
|
+
if (group) for (const [source, previous] of this.groups) {
|
|
453
463
|
const current = groups.get(source);
|
|
454
464
|
if (previous.calls[0].source === source && previous.calls.length > 1 &&
|
|
455
465
|
(!current || current.calls.length < 2 || current.calls[0].source !== source)) this.openGroups.delete(source);
|
|
@@ -468,21 +478,22 @@ export class NativeDocument extends Container {
|
|
|
468
478
|
return position === states.length;
|
|
469
479
|
}
|
|
470
480
|
|
|
471
|
-
/** Nested call trees of Activity calls, rebuilt only when the entries
|
|
481
|
+
/** Nested call trees of Activity calls, rebuilt only when the entries, nested calls or the tree setting change. */
|
|
472
482
|
private treesFor(entries: readonly ContentEntry[]): Map<Component, NestedTree> {
|
|
473
|
-
const
|
|
483
|
+
const enabled = this.pane === "activity" && this.index.nestedTrees();
|
|
484
|
+
const inputs = [entries, this.index.nested.revision, enabled];
|
|
474
485
|
if (this.trees && sameValues(this.trees.inputs, inputs)) return this.trees.map;
|
|
475
486
|
const trees = new Map<Component, NestedTree>();
|
|
476
|
-
if (
|
|
487
|
+
if (enabled) for (const entry of entries) {
|
|
477
488
|
if (!entry.tool) continue;
|
|
478
489
|
const id = Reflect.get(entry.source, "toolCallId") as string | undefined;
|
|
479
490
|
if (!id || (!this.index.nested.entries(id).length && !this.index.nested.isIncomplete(id))) continue;
|
|
480
491
|
let tree = this.nestedTrees.get(entry.source);
|
|
481
492
|
if (!tree) {
|
|
482
|
-
tree = new NestedTree(id, this.index.nested, this.theme, name => this.present(name), () => this.
|
|
493
|
+
tree = new NestedTree(id, this.index.nested, this.theme, name => this.present(name), () => this.toolDisplay().compact && !this.live(entry.source), () => {
|
|
483
494
|
this.beforeExpand(); if (this.searchAnchor) this.clearSearch(); this.frameWidth = undefined;
|
|
484
495
|
}, () => {
|
|
485
|
-
const clock = this.showTimestamps() && this.
|
|
496
|
+
const clock = this.showTimestamps() && this.toolDisplay().compact ? this.timestamps.label(entry.source) : "";
|
|
486
497
|
return clock ? clock.length + 1 : 0;
|
|
487
498
|
});
|
|
488
499
|
this.nestedTrees.set(entry.source, tree);
|
|
@@ -505,12 +516,14 @@ export class NativeDocument extends Container {
|
|
|
505
516
|
let row = 0;
|
|
506
517
|
let visibleBlock = false;
|
|
507
518
|
let toolRun = false;
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
519
|
+
const display = this.pane === "activity" ? this.toolDisplay() : FULL_TOOLS;
|
|
520
|
+
// Streaming shows new calls in full only while a row or a group would hide them.
|
|
521
|
+
const hiding = display.compact || display.group;
|
|
522
|
+
this.updatePresentations(hiding ? this.getTools() : []);
|
|
523
|
+
this.streamActive = hiding && this.streaming?.enabled() === true;
|
|
524
|
+
if (this.streamActive) this.streamer!.observe(this.index.entries());
|
|
512
525
|
else this.streamer?.clear();
|
|
513
|
-
this.updateGroups(
|
|
526
|
+
this.updateGroups(display.group);
|
|
514
527
|
const searched = this.searchAnchor ? this.index.entries(this.pane).find(entry => entry.source === this.searchAnchor!.entry.source) : undefined;
|
|
515
528
|
this.searchTool = searched?.owner;
|
|
516
529
|
const entries = this.index.entries(this.pane);
|
|
@@ -518,8 +531,8 @@ export class NativeDocument extends Container {
|
|
|
518
531
|
const view = locateMatch ? undefined : this.viewport?.();
|
|
519
532
|
// The first frame and search measure every entry; later frames reuse offscreen rows.
|
|
520
533
|
const virtual = view !== undefined && view.height > 0 && this.built !== undefined;
|
|
521
|
-
const presentation = [this.theme(),
|
|
522
|
-
this.timestampGutter(), this.invalidations];
|
|
534
|
+
const presentation = [this.theme(), display.compact, display.group, this.index.nestedTrees(), this.streamActive, this.showTimestamps(),
|
|
535
|
+
this.showCopy(), this.buttonStyle(), this.timestampGutter(), this.invalidations];
|
|
523
536
|
if (!sameValues(presentation, this.presentation)) {
|
|
524
537
|
this.presentation = presentation;
|
|
525
538
|
this.epoch++;
|
|
@@ -541,7 +554,7 @@ export class NativeDocument extends Container {
|
|
|
541
554
|
let shift = 0;
|
|
542
555
|
let pending = false;
|
|
543
556
|
const order: Segment[] = [];
|
|
544
|
-
const renderEntry = (entry: ContentEntry,
|
|
557
|
+
const renderEntry = (entry: ContentEntry, rowed: boolean, tree: NestedTree | undefined): Segment => {
|
|
545
558
|
const component = entry.source;
|
|
546
559
|
const routed = entry.component;
|
|
547
560
|
const result: Component[] = [];
|
|
@@ -550,34 +563,44 @@ export class NativeDocument extends Container {
|
|
|
550
563
|
let clock: SearchClock | undefined;
|
|
551
564
|
let nativeBody = true;
|
|
552
565
|
let bodyDepth = 0;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
566
|
+
let separate = visibleBlock;
|
|
567
|
+
const group = this.groups.get(entry.owner);
|
|
568
|
+
const grouped = group !== undefined && group.calls.length > 1;
|
|
569
|
+
if (rowed || grouped) {
|
|
570
|
+
bodyDepth = (grouped ? 1 : 0) + (rowed ? 1 : 0);
|
|
557
571
|
const members = !grouped || this.groupOpen(group);
|
|
572
|
+
const head = grouped && group.calls[0].source === component;
|
|
558
573
|
if (entry.tool) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (
|
|
574
|
+
const row = members && rowed;
|
|
575
|
+
// Only header rows need this separator; a member's full card brings its own.
|
|
576
|
+
if (visibleBlock && !toolRun && (head || row)) result.push(new Spacer(1));
|
|
577
|
+
if (head) result.push(this.groupRow(group));
|
|
578
|
+
if (row) result.push(this.indent(this.compactRow(entry), grouped ? 1 : 0));
|
|
562
579
|
toolRun = true;
|
|
563
580
|
visibleBlock = true;
|
|
564
581
|
}
|
|
565
|
-
nativeBody = members && this.toolOpen(entry.owner);
|
|
582
|
+
nativeBody = members && (!rowed || this.toolOpen(entry.owner));
|
|
583
|
+
// A body directly under its call's row or its group's header needs no separator.
|
|
584
|
+
separate = !rowed && !head && visibleBlock;
|
|
566
585
|
}
|
|
567
586
|
const contentStart = result.length;
|
|
568
587
|
const bodyWidth = Math.max(0, width - (bodyDepth ? bodyDepth * 2 + 1 : 0));
|
|
588
|
+
let treeOffset = 0;
|
|
569
589
|
if (nativeBody && tree) {
|
|
590
|
+
// Native blocks bring their own separator; a tree needs one to stand apart from the block above.
|
|
591
|
+
if (separate) { result.push(new Spacer(1)); treeOffset = 1; }
|
|
570
592
|
const panels = entries.filter(panel => panel.owner === component && panel.source !== component);
|
|
571
593
|
tree.setBodies(this.treeBody(entry), panels.map(panel => this.treeBody(panel)), this.searchAnchor?.entry.source);
|
|
572
594
|
result.push(tree);
|
|
595
|
+
if (!rowed) toolRun = false;
|
|
573
596
|
visibleBlock = true;
|
|
574
597
|
} else if (nativeBody && !entry.compact) {
|
|
575
598
|
toolRun = false;
|
|
576
599
|
result.push(...entry.spacing, routed);
|
|
577
600
|
} else if (nativeBody) {
|
|
578
|
-
if (!
|
|
601
|
+
if (!rowed) toolRun = false;
|
|
579
602
|
const stamped = this.nativeBlock(entry);
|
|
580
|
-
visibleBlock = stamped.prepare(bodyWidth,
|
|
603
|
+
visibleBlock = stamped.prepare(bodyWidth, separate) || visibleBlock;
|
|
581
604
|
result.push(stamped);
|
|
582
605
|
clock = stamped.searchClock();
|
|
583
606
|
}
|
|
@@ -604,8 +627,8 @@ export class NativeDocument extends Container {
|
|
|
604
627
|
const prefixRows = prefix.length;
|
|
605
628
|
if (tree && nativeBody) {
|
|
606
629
|
for (const [source, position] of tree.positions) this.positions.set(source, {
|
|
607
|
-
...position, row: row + prefixRows + position.row,
|
|
608
|
-
excerptRow: position.excerptRow === undefined ? undefined : row + prefixRows + position.excerptRow,
|
|
630
|
+
...position, row: row + prefixRows + treeOffset + position.row,
|
|
631
|
+
excerptRow: position.excerptRow === undefined ? undefined : row + prefixRows + treeOffset + position.excerptRow,
|
|
609
632
|
});
|
|
610
633
|
if (excerptRow !== undefined) this.positions.set(component, { row, lines: [], excerptRow });
|
|
611
634
|
} else this.positions.set(component, { row: row + prefixRows, lines: lines.slice(prefixRows), clock, excerptRow });
|
|
@@ -620,7 +643,7 @@ export class NativeDocument extends Container {
|
|
|
620
643
|
for (const line of childLines) lines.push(line);
|
|
621
644
|
}
|
|
622
645
|
const print: unknown[] = [];
|
|
623
|
-
this.fingerprint(entry,
|
|
646
|
+
this.fingerprint(entry, rowed, tree, print);
|
|
624
647
|
let segment = this.segments.get(component);
|
|
625
648
|
if (!segment) {
|
|
626
649
|
segment = { components: result, heights, lines, width, epoch: this.epoch, estimate: false, visibleIn, toolRunIn,
|
|
@@ -639,7 +662,7 @@ export class NativeDocument extends Container {
|
|
|
639
662
|
const entry = entries[index];
|
|
640
663
|
if (entry.owner !== entry.source && trees.has(entry.owner)) continue;
|
|
641
664
|
const component = entry.source;
|
|
642
|
-
const
|
|
665
|
+
const rowed = display.compact && entry.kind === "tool" && !this.live(entry.owner);
|
|
643
666
|
const tree = trees.get(component);
|
|
644
667
|
let segment = this.segments.get(component);
|
|
645
668
|
const previous = segment?.build === build - 1 ? { start: segment.start, height: segment.lines.length } : undefined;
|
|
@@ -657,7 +680,7 @@ export class NativeDocument extends Container {
|
|
|
657
680
|
// Check a rotating slice per frame so heights converge without reading every entry each frame.
|
|
658
681
|
const swept = this.dirty.delete(component) ||
|
|
659
682
|
(index >= sweep && index < sweep + SWEEP_ENTRIES) || index + entries.length < sweep + SWEEP_ENTRIES;
|
|
660
|
-
if (measured && swept) this.fingerprint(entry,
|
|
683
|
+
if (measured && swept) this.fingerprint(entry, rowed, tree, this.print);
|
|
661
684
|
if (!measured || (swept && !sameValues(segment!.print, this.print))) {
|
|
662
685
|
if (performance.now() < started + LAZY_BUDGET_MS) render = true;
|
|
663
686
|
// Native changes request their own frames; only unmeasured layout needs follow-up frames.
|
|
@@ -669,7 +692,7 @@ export class NativeDocument extends Container {
|
|
|
669
692
|
}
|
|
670
693
|
if (render) {
|
|
671
694
|
this.dirty.delete(component);
|
|
672
|
-
segment = renderEntry(entry,
|
|
695
|
+
segment = renderEntry(entry, rowed, tree);
|
|
673
696
|
}
|
|
674
697
|
else {
|
|
675
698
|
if (!segment) {
|
|
@@ -742,14 +765,14 @@ export class NativeDocument extends Container {
|
|
|
742
765
|
}
|
|
743
766
|
|
|
744
767
|
/** Native state an offscreen entry's rows depend on, read without rendering it. */
|
|
745
|
-
private fingerprint(entry: ContentEntry,
|
|
768
|
+
private fingerprint(entry: ContentEntry, rowed: boolean, tree: NestedTree | undefined, out: unknown[]): void {
|
|
746
769
|
out.length = 0;
|
|
747
770
|
const routed = entry.component;
|
|
748
771
|
pushShellInputs(routed, out);
|
|
749
772
|
const children = (routed as Partial<Container>).children;
|
|
750
|
-
const group =
|
|
773
|
+
const group = this.groups.get(entry.owner);
|
|
751
774
|
out.push(children, (children?.[0] as Partial<Container> | undefined)?.children, entry.spacing.length,
|
|
752
|
-
this.stamped.get(routed)?.revision,
|
|
775
|
+
this.stamped.get(routed)?.revision, rowed, this.toolOpen(entry.owner),
|
|
753
776
|
group?.calls[0].source, group?.calls.length, group && group.calls.length > 1 ? this.groupOpen(group) : undefined,
|
|
754
777
|
tree ? this.index.nested.revision : undefined);
|
|
755
778
|
}
|
package/src/preferences.ts
CHANGED
|
@@ -15,8 +15,13 @@ export interface Preferences {
|
|
|
15
15
|
zoom: "activity" | "chat" | null;
|
|
16
16
|
showTimestamps: boolean;
|
|
17
17
|
showCopyButtons: boolean;
|
|
18
|
+
/** Show each finished Activity call as a one-line row that opens its full card. */
|
|
18
19
|
compactTools: boolean;
|
|
19
|
-
/**
|
|
20
|
+
/** Merge adjacent Activity calls of one tool in one state under a counted header. */
|
|
21
|
+
groupTools: boolean;
|
|
22
|
+
/** Show the calls a tool made, such as Codemode's, as a tree instead of the parent's native output panel. */
|
|
23
|
+
nestedTree: boolean;
|
|
24
|
+
/** Show the latest tool calls in full while Compact or Group would hide them, then collapse them. */
|
|
20
25
|
streamTools: boolean;
|
|
21
26
|
/** Seconds a finished streamed call stays in full before it collapses. */
|
|
22
27
|
streamDelay: number;
|
|
@@ -24,7 +29,7 @@ export interface Preferences {
|
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export const defaults: Preferences = {
|
|
27
|
-
mode: "split", side: "left", chatWidth: null, layout: "columns", chatHeight: null, zoom: null, showTimestamps: true, showCopyButtons: true, compactTools: true, streamTools: true, streamDelay: 5, buttonStyle: "text",
|
|
32
|
+
mode: "split", side: "left", chatWidth: null, layout: "columns", chatHeight: null, zoom: null, showTimestamps: true, showCopyButtons: true, compactTools: true, groupTools: true, nestedTree: true, streamTools: true, streamDelay: 5, buttonStyle: "text",
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
/** Read display preferences, retaining the first version's saved arrangement. */
|
|
@@ -44,6 +49,9 @@ export async function loadPreferences(file: string): Promise<Preferences> {
|
|
|
44
49
|
const showTimestamps = record.showTimestamps === undefined ? defaults.showTimestamps : record.showTimestamps;
|
|
45
50
|
const showCopyButtons = record.showCopyButtons === undefined ? defaults.showCopyButtons : record.showCopyButtons;
|
|
46
51
|
const compactTools = record.compactTools === undefined ? defaults.compactTools : record.compactTools;
|
|
52
|
+
// Grouping used to be part of Compact; files saved before the split keep that combination.
|
|
53
|
+
const groupTools = record.groupTools === undefined ? compactTools : record.groupTools;
|
|
54
|
+
const nestedTree = record.nestedTree === undefined ? defaults.nestedTree : record.nestedTree;
|
|
47
55
|
const streamTools = record.streamTools === undefined ? defaults.streamTools : record.streamTools;
|
|
48
56
|
const streamDelay = record.streamDelay === undefined ? defaults.streamDelay : record.streamDelay;
|
|
49
57
|
const buttonStyle = record.buttonStyle === undefined ? defaults.buttonStyle : record.buttonStyle;
|
|
@@ -53,12 +61,13 @@ export async function loadPreferences(file: string): Promise<Preferences> {
|
|
|
53
61
|
(layout !== "columns" && layout !== "rows") ||
|
|
54
62
|
(chatHeight !== null && (typeof chatHeight !== "number" || !Number.isInteger(chatHeight) || chatHeight < 4 || chatHeight > 240)) ||
|
|
55
63
|
typeof showTimestamps !== "boolean" || typeof showCopyButtons !== "boolean" || typeof compactTools !== "boolean" ||
|
|
64
|
+
typeof groupTools !== "boolean" || typeof nestedTree !== "boolean" ||
|
|
56
65
|
typeof streamTools !== "boolean" || typeof streamDelay !== "number" || !Number.isInteger(streamDelay) || streamDelay < 1 || streamDelay > 300 ||
|
|
57
66
|
(buttonStyle !== "icons" && buttonStyle !== "text")) {
|
|
58
67
|
throw new Error("Invalid pi-stereo-view preferences");
|
|
59
68
|
}
|
|
60
69
|
// Legacy files may contain mode/zoom. Every session starts with both panels visible.
|
|
61
|
-
return { mode: "split", side: record.side, chatWidth: record.chatWidth, layout, chatHeight, zoom: null, showTimestamps, showCopyButtons, compactTools, streamTools, streamDelay, buttonStyle };
|
|
70
|
+
return { mode: "split", side: record.side, chatWidth: record.chatWidth, layout, chatHeight, zoom: null, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle };
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
/** Atomically save only the display settings, never session messages. */
|
|
@@ -66,8 +75,8 @@ export async function savePreferences(file: string, preferences: Preferences): P
|
|
|
66
75
|
await mkdir(path.dirname(file), { recursive: true });
|
|
67
76
|
const temporary = file + "." + randomUUID() + ".tmp";
|
|
68
77
|
try {
|
|
69
|
-
const { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, streamTools, streamDelay, buttonStyle } = preferences;
|
|
70
|
-
const saved = { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, streamTools, streamDelay, buttonStyle };
|
|
78
|
+
const { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle } = preferences;
|
|
79
|
+
const saved = { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle };
|
|
71
80
|
await writeFile(temporary, JSON.stringify(saved, null, 2) + "\n", { mode: 0o600 });
|
|
72
81
|
await rename(temporary, file);
|
|
73
82
|
} finally {
|
package/src/tool-groups.ts
CHANGED
|
@@ -21,7 +21,9 @@ export function toolGroups(entries: readonly ContentEntry[], present: (name: str
|
|
|
21
21
|
return groups;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/** Every group has one state; failed calls always remain individual rows. */
|
|
24
|
+
/** Every group has one state; failed calls always remain individual rows. Images are counted across members. */
|
|
25
25
|
export function groupSummary(group: ToolGroup): ToolSummary {
|
|
26
|
-
|
|
26
|
+
let images = 0;
|
|
27
|
+
for (const call of group.calls) images += call.tool?.().images ?? 0;
|
|
28
|
+
return { name: group.name, args: undefined, status: group.status, images };
|
|
27
29
|
}
|