pi-stereo-view 0.1.19 → 0.1.20

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 CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.20 - 2026-11-19
6
+
7
+ ### Added
8
+
9
+ - **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).
10
+
11
+ ### Changed
12
+
13
+ - Stream latest tools also works with grouping alone: a new call stays a full card for the collapse delay before it joins its group.
14
+ - Saved settings keep their look: grouping follows your saved Compact Activity tools choice until you change it.
15
+
5
16
  ## 0.1.19 - 2026-11-19
6
17
 
7
18
  ### 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
- Click `[ ⊟ ]` or `[Compact tools]` beside Find and Maximize in the Activity header to show compact tool calls. Adjacent calls to the same tool in the same state share a header with a count; every failed call stays separate, even beside another failure. Click that header to show the individual compact rows, then click a row to open its original full card and linked output. 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. Thinking, Conversation content and different tools end a group.
101
+ Three independent settings in `/stereo-view settings` control how Activity shows tool calls. All three are on by default and survive restart.
102
+
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.
102
114
 
103
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. 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. You can also click `[ ⊞ ]` or `[Full tools]` in the Activity header to restore full tools. Conversation and combined history keep their normal display.
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 tools work in columns, rows and zoomed Activity. The choice survives restart and defaults to on. For keyboard access, run `/stereo-view settings` and change **Compact Activity tools**.
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. With Compact Activity tools 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 and joins the adjacent identical collapsed calls (`read ×3`).
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-stereo-view",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "type": "module",
5
5
  "description": "Keep Pi conversation separate from tool output and agent activity.",
6
6
  "license": "MIT",
package/src/content.ts CHANGED
@@ -181,9 +181,13 @@ export class NativeContentIndex {
181
181
  private readonly views = new WeakMap<NativeAssistant, Partial<Record<Pane, Container>>>();
182
182
  private readonly diagnostics = new WeakMap<NativeAssistant, Component[]>();
183
183
 
184
- private pass?: { active: boolean; verified?: { children: Component[]; length: number; last?: Component; parts: number; revision: number } };
184
+ private pass?: { active: boolean; verified?: { children: Component[]; length: number; last?: Component; parts: number; revision: number; trees: boolean } };
185
185
 
186
- constructor(private readonly source: Container, readonly nested = new NestedCalls()) {}
186
+ /**
187
+ * With `nestedTrees` on, a parented output panel is split into the native parts of its nested calls, which Activity
188
+ * shows as the caller's tree. Off, the panel stays one original entry beside its owner.
189
+ */
190
+ constructor(private readonly source: Container, readonly nested = new NestedCalls(), readonly nestedTrees: () => boolean = () => true) {}
187
191
 
188
192
  /**
189
193
  * Native history cannot change while Pi lays out one frame, so the panes of a pass
@@ -228,9 +232,9 @@ export class NativeContentIndex {
228
232
  const children = history.children;
229
233
  const verified = pass?.verified;
230
234
  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;
235
+ verified.parts === this.source.children.length && verified.revision === this.nested.revision && verified.trees === this.nestedTrees()) return;
232
236
  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 };
237
+ 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
238
  }
235
239
 
236
240
  /** Whether a classified block still has the native inputs its entries were built from. */
@@ -245,7 +249,7 @@ export class NativeContentIndex {
245
249
  if (block.parent) {
246
250
  const owner = this.owners.get(block.parent.id);
247
251
  if (owner !== block.parent.owner) return false;
248
- const parts = owner?.toolCallId && this.nested.entries(owner.toolCallId).length ? nativePanelParts(component) : undefined;
252
+ const parts = owner?.toolCallId ? this.panelParts(component, owner.toolCallId) : undefined;
249
253
  if (parts ? !sameValues(block.parent.parts, parts) : block.parent.parts) return false;
250
254
  }
251
255
  return true;
@@ -315,6 +319,11 @@ export class NativeContentIndex {
315
319
  this.panes = {};
316
320
  }
317
321
 
322
+ /** The parts a nested-call tree shows for an owner's linked panel, or none to keep the panel whole. */
323
+ private panelParts(panel: NativeContent, owner: string): Component[] | undefined {
324
+ return this.nestedTrees() && this.nested.entries(owner).length ? nativePanelParts(panel) : undefined;
325
+ }
326
+
318
327
  /** Build the entries of one native history block, keeping previous entry objects that did not change. */
319
328
  private classify(component: Component, spacing: Component[], old: Classified | undefined): Classified {
320
329
  const native = component as NativeContent;
@@ -335,7 +344,7 @@ export class NativeContentIndex {
335
344
  content.setExpanded?.(true);
336
345
  this.expandedPanels.set(component, owner);
337
346
  } else if (!owner) this.expandedPanels.delete(component);
338
- const parts = owner && this.nested.entries(owner.toolCallId!).length ? nativePanelParts(content) : undefined;
347
+ const parts = owner ? this.panelParts(content, owner.toolCallId!) : undefined;
339
348
  if (kind === "system" && typeof parentId === "string") block.parent = { id: parentId, owner, parts };
340
349
  if (parts) for (const part of parts) {
341
350
  const adapter = nativeKinds[nameOf(part)];
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: "Group adjacent tools and expand individual calls inline. Full text stays searchable and copyable.",
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: "In compact Activity, show new tool calls in full and collapse them after the delay.",
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
- }], 7, getSettingsListTheme(), (id, value) => {
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, () => this.preferences.compactTools, this.getTools,
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
- /** Show the latest compact tool calls in full until they have been finished for the delay. */
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 compactTools: () => boolean = () => false,
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 Compact Activity still shows as full native cards. */
171
- private live(source: Component): boolean { return this.compactActive && this.streamer?.isLive(source) === true; }
172
- private compactActive = false;
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.compactTools() && entry.kind === "tool" && !this.live(entry.owner)),
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(compactTools: boolean): void {
443
+ private updateGroups(group: boolean): void {
435
444
  const all = this.index.entries();
436
- const inputs = [compactTools, all, this.present, this.compactActive, this.streamer?.revision];
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 = compactTools ? toolGroups(all, this.present, source => this.live(source)) : new Map<Component, ToolGroup>();
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
- if (compactTools) for (const [source, previous] of this.groups) {
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 or nested calls change. */
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 inputs = [entries, this.index.nested.revision];
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 (this.pane === "activity") for (const entry of entries) {
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.compactTools() && !this.live(entry.source), () => {
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.compactTools() ? this.timestamps.label(entry.source) : "";
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 compactTools = this.pane === "activity" && this.compactTools();
509
- this.updatePresentations(compactTools ? this.getTools() : []);
510
- this.compactActive = compactTools && this.streaming?.enabled() === true;
511
- if (this.compactActive) this.streamer!.observe(this.index.entries());
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(compactTools);
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(), compactTools, this.compactActive, this.showTimestamps(), this.showCopy(), this.buttonStyle(),
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, compactTool: boolean, tree: NestedTree | undefined): Segment => {
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
- if (compactTool) {
554
- const group = this.groups.get(entry.owner);
555
- const grouped = group !== undefined && group.calls.length > 1;
556
- bodyDepth = grouped ? 2 : 1;
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
- if (visibleBlock && !toolRun) result.push(new Spacer(1));
560
- if (grouped && group.calls[0].source === component) result.push(this.groupRow(group));
561
- if (members) result.push(this.indent(this.compactRow(entry), grouped ? 1 : 0));
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 (!compactTool) toolRun = false;
601
+ if (!rowed) toolRun = false;
579
602
  const stamped = this.nativeBlock(entry);
580
- visibleBlock = stamped.prepare(bodyWidth, compactTool ? false : visibleBlock) || visibleBlock;
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, compactTool, tree, print);
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 compactTool = compactTools && entry.kind === "tool" && !this.live(entry.owner);
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, compactTool, tree, this.print);
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, compactTool, tree);
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, compactTool: boolean, tree: NestedTree | undefined, out: unknown[]): void {
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 = compactTool ? this.groups.get(entry.owner) : undefined;
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, compactTool, this.toolOpen(entry.owner),
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
  }
@@ -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
- /** Show the latest tool calls in full inside compact Activity, then collapse them. */
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 {