pi-stereo-view 0.1.22 → 0.1.24

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,31 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.24 - 2026-11-22
6
+
7
+ ### Added
8
+
9
+ - **Turn colors**, **hover highlighting** and **Go to** make it easy to see what the agent did for each request. A turn is a message you or an extension sent plus all the work that followed it. They are on by default with clock colors, block stripes, separators and a gray hover; set **Turns** to `off` in Stereo View settings to hide them.
10
+ - Each turn gets its own color in both panels, shown in any combination of **Clock color**, **Stripe** (a colored `block` or a thin `line`), **Background** and **Separator**, a colored line where each turn begins. Strength settings for clocks, stripes, backgrounds and hover set how strongly each shows, and `←`/`→` step through settings values. Tool cards and messages keep their own backgrounds.
11
+ - **Highlight on hover** highlights the turn under the pointer in both panels, in the turn's own color or one **Hover color** for every turn, picked from presets or typed as `#rrggbb`. It is shown as unavailable inside tmux, zellij and screen, where Pi does not receive pointer movement.
12
+ - **Go to** opens the same moment in the other panel from a block's clock or a `[Go to]` / `[ ⇄ ]` button beside Copy.
13
+ Thanks to [@alejandro5042](https://github.com/alejandro5042) for the idea ([#104](https://github.com/alexshpunt/pi-stereo-view/issues/104)).
14
+
15
+ ## 0.1.23 - 2026-11-21
16
+
17
+ ### Fixed
18
+
19
+ - Pi-Bolt no longer closes with "Pi's assistant content layout is not supported" after a reply. Pi-Bolt 1.1.6 and later free the parts of finished replies they have drawn; split view now asks Pi-Bolt to restore them before showing the reply. Thanks to [@Unk-now](https://github.com/Unk-now) for the detailed report ([#99](https://github.com/alexshpunt/pi-stereo-view/issues/99)).
20
+ - An error in split view no longer closes Pi. Split view turns off, and Pi shows its own history until the next reload.
21
+
22
+ ### Added
23
+
24
+ - When split view turns off after an error, or cannot start in a Pi version it does not support, a panel above the editor names the problem. **Open issue** opens a GitHub issue form with the error, its stack and the versions filled in; nothing is sent until you submit it. **Copy report** copies the same text, and **Close** hides the panel.
25
+
26
+ ### Changed
27
+
28
+ - Combined history no longer reads the split's content index on every frame.
29
+
5
30
  ## 0.1.22 - 2026-11-21
6
31
 
7
32
  ### Fixed
package/README.md CHANGED
@@ -37,6 +37,7 @@ If the Activity surface cannot fit without clipping, the view temporarily return
37
37
 
38
38
  - Arrange Conversation and Activity in columns or rows, swap or resize the panels, and zoom either one while keeping the input full width.
39
39
  - Group consecutive Activity tools and expand individual calls inline while keeping thinking visible.
40
+ - Optionally see which work belongs to which request: each request and everything the agent did for it share a color in both panels, pointing at a block highlights all of it, and a block's clock jumps to the same moment in the other panel.
40
41
  - Copy an individual user message, assistant reply or thinking block with its own copy icon.
41
42
  - Copy a complete tool call with its arguments, saved result and linked late output, including collapsed and off-screen text.
42
43
  - Search panel history with literal text, Boolean expressions or regular expressions, then jump between matches.
@@ -85,6 +86,7 @@ Click the toolbar and the buttons in each panel's header. Buttons use text label
85
86
  | `[ ≡ ]` | `[Settings]` | Open display and Conversation height settings. |
86
87
  | `[ ⌕ ]` | `[Find]` | Search this panel. |
87
88
  | `[ ⊟ ]` / `[ ⊞ ]` | `[Compact tools]` / `[Full tools]` | Compact Activity tools / restore full tools. |
89
+ | `[ ⇄ ]` | `[Go to]` | Open the same moment in the other panel (when Go to includes the button). |
88
90
 
89
91
  **Resize:** drag the double line between the panels — `═` in rows, `║` in columns.
90
92
 
@@ -124,6 +126,35 @@ Compact rows and groups work in columns, rows and zoomed Activity. Settings save
124
126
 
125
127
  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.
126
128
 
129
+ ## Find your way between requests
130
+
131
+ A turn is one message you sent, or one message an extension gave the agent, together with everything the agent did and said until the next such message. Consecutive messages with no work in between form one turn.
132
+
133
+ Turn colors, hover highlighting and Go to are on by default. Set **Turns** to `off` in Stereo View settings to turn them all off; the settings indented under it choose what each does, and keep their values while Turns is off.
134
+
135
+ Every turn gets its own color in both panels, so the work for one request is easy to tell from the next. Turns are marked in four independent ways; use any combination:
136
+
137
+ | Setting | Values | What it marks |
138
+ | --- | --- | --- |
139
+ | **Clock color** | `on` (default), `off` | The background of each block's clock. |
140
+ | **Stripe** | `block` (default), `line`, `off` | Every block's left column: a colored cell or a thin colored line. |
141
+ | **Background** | `on`, `off` (default) | The background of every block. |
142
+ | **Separator** | `on` (default), `off` | A colored line across both panels where each new turn begins. |
143
+
144
+ Neighbouring turns get different hues. Colors stack in layers over your terminal's background: the turn background, then hover, then stripes, separators and clocks. Each layer adds its strength to the layers under it: **Background color strength** (8% by default), **Hover color strength** (10%), **Stripe color strength** (20%, also for separators) and **Clock color strength** (10%). With these strengths and hover in the turn's color, the clock of a hovered block with a turn background is 8 + 10 + 10 = 28% of the hue, so a clock always stays darker than the block it sits on. In settings, `←` and `→` step a strength down or up, wrapping around at either end.
145
+
146
+ **Hover color** sets the hover layer's color: `turn` highlights each turn in its own color, or one `#rrggbb` color highlights every turn the same way; the default is gray, `#808080`. `←` and `→` pick from presets; `Enter` opens a field to type any color. Clocks, stripes and separators keep their turn's own color on top of a one-color hover. Tool cards, your messages and extension messages keep their own backgrounds; turn backgrounds only fill the plain background around them.
147
+
148
+ **Highlight on hover** (on by default) highlights the turn under the pointer in both panels while the pointer stays there. It needs a terminal that reports pointer movement. Pi turns that off inside tmux, zellij and screen, so there the setting is shown as `unavailable`.
149
+
150
+ **Go to** opens the same moment of history in the other panel:
151
+
152
+ - From Activity, it shows the Conversation block just before: for a tool call, the reply that made it.
153
+ - From Conversation, it shows the first Activity block after: for your message, the work it started.
154
+ - A message with a part in both panels, such as a reply with thinking, opens its own other part.
155
+
156
+ Click a block's clock, including the clock of a compact tool row or group, or the `[ ⇄ ]` / `[Go to]` button beside Copy. The **Go to** setting chooses `clock`, `button`, `both` (default) or `off`. A zoomed panel returns to the split first. The other panel becomes the active one, so keyboard scrolling continues there.
157
+
127
158
  ## Search history
128
159
 
129
160
  Press **Ctrl+F** to search the last clicked or scrolled panel. The active panel's header is highlighted and, when space permits, marked with a dot; Conversation is active initially. The `[ ⌕ ]` / `[Find]` button always searches its own panel.
@@ -193,12 +224,13 @@ Keyboard scrolling (`PgUp`/`PgDn` and Pi's other scroll keys) moves the active p
193
224
 
194
225
  ## Settings and limits
195
226
 
196
- Your layout, panel order, sizes, compact Activity choice, timestamp and copy-button settings are saved automatically. Each new session opens both panels in that arrangement. Zooming one panel or turning split off is temporary and does not carry over to another session.
227
+ Your layout, panel order, sizes, compact Activity choice, turn marks, hover and Go to choices, timestamp and copy-button settings are saved automatically. Each new session opens both panels in that arrangement. Zooming one panel or turning split off is temporary and does not carry over to another session.
197
228
 
198
229
  - Tested with Pi 1.1.0. Requires Node.js 22.19 or newer.
199
230
  - Regular mode shows one combined history.
200
231
  - If the terminal is too small, history temporarily combines without forgetting your split.
201
- - If your Pi version cannot display the split, normal history stays visible and a warning explains the problem.
232
+ - If your Pi version cannot display the split, or the split hits an error, Pi keeps working with its normal history. A panel above the editor names the problem and offers a prefilled GitHub issue (**Open issue**) or the same report as text (**Copy report**). Nothing is sent until you submit the issue yourself.
233
+ - Also tested with [Pi-Bolt](https://github.com/opensec-git/Pi-Bolt) 1.1.7.
202
234
 
203
235
  ## License
204
236
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-stereo-view",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "description": "Keep Pi conversation separate from tool output and agent activity.",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
- import { stripTerminalSequences, truncateToWidth, visibleWidth, type Component, type TuiMouseEvent } from "@earendil-works/pi-tui";
2
+ import { stripTerminalSequences, truncateToWidth, visibleWidth, type Color, type Component, type TuiMouseEvent } from "@earendil-works/pi-tui";
3
3
  import type { ToolSummary } from "./content.ts";
4
4
 
5
5
  const singleLine = (text: string): string => stripTerminalSequences(text).replace(/[\x00-\x1f\x7f-\x9f]/g, " ").replace(/\s+/g, " ").trim();
@@ -29,20 +29,27 @@ interface CompactToolOptions {
29
29
  count?(): number;
30
30
  expanded?(): boolean;
31
31
  toggle?(): void;
32
+ /** Turn color behind the clock. */
33
+ clockBackground?(): Color | undefined;
34
+ /** When it returns an action, clicking the clock runs it instead of toggling the row. */
35
+ clockAction?(): (() => void) | undefined;
32
36
  }
33
37
 
34
38
  interface HeaderInputs {
35
39
  width: number; name: string; args: unknown; status: ToolSummary["status"]; images: number; count?: number; expanded?: boolean;
36
- label: string; theme: Theme;
40
+ label: string; background?: Color; theme: Theme;
37
41
  }
38
42
  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.images === b.images && a.count === b.count && a.expanded === b.expanded && a.label === b.label && a.theme === b.theme;
43
+ 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.background === b.background && a.theme === b.theme;
40
44
 
41
45
  /** A display-only call or group header; the original renderer owns the body. */
42
46
  export class CompactTool implements Component {
43
47
  // Headers are rebuilt every frame for the whole history. Completed calls keep their
44
48
  // argument object, so reuse the row until a displayed input changes.
45
49
  private cached?: { inputs: HeaderInputs; lines: string[] };
50
+ /** Columns of the clock in the last row, which a click may open in the other panel. */
51
+ private clockSpan?: { start: number; end: number };
52
+ private clockPressed = false;
46
53
 
47
54
  constructor(private readonly summary: () => ToolSummary, private readonly theme: () => Theme,
48
55
  private readonly options: CompactToolOptions = {}) {}
@@ -51,14 +58,15 @@ export class CompactTool implements Component {
51
58
  width = Math.max(0, width - (this.options.gutter?.() ?? 0));
52
59
  const { name, args, status, images = 0 } = this.summary();
53
60
  const inputs: HeaderInputs = { width, name, args, status, images, count: this.options.count?.(),
54
- expanded: this.options.toggle ? this.options.expanded?.() : undefined, label: this.options.clock?.() ?? "", theme: this.theme() };
61
+ expanded: this.options.toggle ? this.options.expanded?.() : undefined, label: this.options.clock?.() ?? "",
62
+ background: this.options.clockBackground?.(), theme: this.theme() };
55
63
  // Streamed arguments may be updated in place, so running calls always rebuild.
56
64
  if (this.cached && status !== "running" && sameInputs(this.cached.inputs, inputs)) return this.cached.lines;
57
65
  const lines = this.header(inputs);
58
66
  this.cached = { inputs, lines };
59
67
  return lines;
60
68
  }
61
- private header({ width, name, args, status, images, count, expanded, label, theme }: HeaderInputs): string[] {
69
+ private header({ width, name, args, status, images, count, expanded, label, background, theme }: HeaderInputs): string[] {
62
70
  const dot = theme.fg(status === "running" ? "warning" : status === "unknown" ? "dim" : status, "●");
63
71
  const description = count ? "" : toolDescription(args);
64
72
  const control = this.options.toggle ? theme.fg("muted", expanded ? "▾" : "▸") + " " : this.options.alignControl ? " " : "";
@@ -68,13 +76,29 @@ export class CompactTool implements Component {
68
76
  const clock = label && width >= visibleWidth(label) + 8 ? label : "";
69
77
  const available = Math.max(0, width - 1 - (clock ? visibleWidth(clock) + 1 : 0));
70
78
  const body = truncateToWidth(text, available, "…");
71
- return [(width > 0 ? " " : "") + (clock ? theme.fg("dim", clock) + " " : "") + body];
79
+ const gutter = width > 0 ? 1 : 0;
80
+ this.clockSpan = clock ? { start: gutter, end: gutter + visibleWidth(clock) } : undefined;
81
+ const shown = !clock ? "" : background ? theme.style(clock, { fg: "text", bg: background }) : theme.fg("dim", clock);
82
+ return [(gutter ? " " : "") + (clock ? shown + " " : "") + body];
72
83
  }
73
84
  handleMouse(event: TuiMouseEvent): ReturnType<NonNullable<Component["handleMouse"]>> {
74
- if (!this.options.toggle || event.button !== "left") return undefined;
75
- if (event.type === "press") return { capture: true };
76
- if (event.type === "click" && event.x >= 0 && event.x < event.width && event.y === 0) {
77
- this.options.toggle();
85
+ if (event.button !== "left") return undefined;
86
+ const span = this.clockSpan;
87
+ const action = span && event.y === 0 && event.x >= span.start && event.x < span.end ? this.options.clockAction?.() : undefined;
88
+ if (!this.options.toggle && !action && !this.clockPressed) return undefined;
89
+ if (event.type === "press") {
90
+ this.clockPressed = action !== undefined;
91
+ return { capture: true };
92
+ }
93
+ if (event.type === "click") {
94
+ const pressed = this.clockPressed;
95
+ this.clockPressed = false;
96
+ if (event.x < 0 || event.x >= event.width || event.y !== 0) return { handled: true };
97
+ if (pressed) {
98
+ if (action) action();
99
+ return { handled: true, render: true };
100
+ }
101
+ this.options.toggle?.();
78
102
  return { handled: true, render: true };
79
103
  }
80
104
  return { handled: true };
package/src/content.ts CHANGED
@@ -30,6 +30,8 @@ interface NativeAssistant extends Container {
30
30
  lastMessage?: { content: { type: string; text?: string; thinking?: string }[] };
31
31
  contentIsStale?: boolean;
32
32
  buildContent?(message: NonNullable<NativeAssistant["lastMessage"]>): void;
33
+ isCompacted?(): boolean;
34
+ thaw?(): void;
33
35
  setHideThinkingBlock(hidden: boolean): void;
34
36
  }
35
37
 
@@ -83,6 +85,12 @@ function assistant(component: Component): NativeAssistant | undefined {
83
85
  (native.lastMessage !== undefined && !Array.isArray(native.lastMessage.content))) {
84
86
  throw new Error("Pi's assistant content metadata is not supported");
85
87
  }
88
+ // Pi-Bolt releases the children of settled messages it drew itself and keeps only their lines.
89
+ // Restore them through the owner, as Pi-Bolt does before it draws such a message again.
90
+ if (typeof native.isCompacted === "function" && native.isCompacted()) {
91
+ if (typeof native.thaw !== "function") throw new Error("Pi's compacted assistant content is not supported");
92
+ native.thaw();
93
+ }
86
94
  // Pi-Bolt builds streamed children lazily. Synchronize the real owner before
87
95
  // indexing or cloning it, so a pane cannot rebuild both content kinds itself.
88
96
  if (native.contentIsStale === true) {
@@ -123,6 +131,9 @@ interface Classified {
123
131
  parent?: { id: string; owner?: NativeContent; parts?: Component[] };
124
132
  }
125
133
 
134
+ /** Native messages that start a turn: what the user or an extension gave the agent. */
135
+ const TURN_STARTS = new Set(["UserMessageComponent", "SkillInvocationMessageComponent", "CustomMessageComponent"]);
136
+
126
137
  const parentOf = (component: NativeContent): unknown => component.entry?.data?.parentToolCallId ?? component.message?.details?.parentToolCallId;
127
138
 
128
139
  /** The previous entry for the same native block, when every field that renders or searches it is equal. */
@@ -223,6 +234,61 @@ export class NativeContentIndex {
223
234
  return this.content.some(entry => entry.source === source && (pane === undefined || panes[entry.kind] === pane));
224
235
  }
225
236
 
237
+ /**
238
+ * The turn of a block: 1 for the first user, skill or custom message and the work that follows it, 2 for the next,
239
+ * and so on; 0 before the first one. Consecutive messages without work in between share one turn.
240
+ */
241
+ turn(source: Component): number {
242
+ return this.turns().turns.get(source) ?? 0;
243
+ }
244
+
245
+ /** Every block's turn, for reading many blocks in one frame; blocks before the first turn map to 0. */
246
+ turnMap(): ReadonlyMap<Component, number> {
247
+ return this.turns().turns;
248
+ }
249
+
250
+ /**
251
+ * The block of the other panel at the same point of history: the same native message when it has a part there;
252
+ * from Activity, the last Conversation block before it; from Conversation, the first Activity block after it.
253
+ * Without one in that direction, the nearest block in the other direction.
254
+ */
255
+ counterpart(source: Component, from: Pane): Component | undefined {
256
+ const content = this.entries();
257
+ const { positions } = this.turns();
258
+ const position = positions.get(source);
259
+ if (position === undefined) return undefined;
260
+ const other = (entry: ContentEntry): boolean => panes[entry.kind] !== from;
261
+ const same = content.find(entry => entry.source === source && other(entry));
262
+ if (same) return same.source;
263
+ const step = from === "activity" ? -1 : 1;
264
+ for (const direction of [step, -step]) {
265
+ for (let index = position + direction; index >= 0 && index < content.length; index += direction) {
266
+ if (other(content[index])) return content[index].source;
267
+ }
268
+ }
269
+ return undefined;
270
+ }
271
+
272
+ private turnIndex?: { content: ContentEntry[]; turns: Map<Component, number>; positions: Map<Component, number> };
273
+ /** Turns and history positions, rebuilt only when the classified history changes. */
274
+ private turns(): NonNullable<NativeContentIndex["turnIndex"]> {
275
+ const content = this.entries();
276
+ if (this.turnIndex?.content === content) return this.turnIndex;
277
+ const turns = new Map<Component, number>();
278
+ const positions = new Map<Component, number>();
279
+ let turn = 0;
280
+ let worked = false;
281
+ for (const [position, entry] of content.entries()) {
282
+ if (!positions.has(entry.source)) positions.set(entry.source, position);
283
+ if (entry.owner === entry.source && TURN_STARTS.has(nameOf(entry.source))) {
284
+ if (turn === 0 || worked) { turn++; worked = false; }
285
+ } else if (turn) worked = true;
286
+ if (!turns.has(entry.source)) turns.set(entry.source, turn);
287
+ }
288
+ this.turnIndex = { content, turns, positions };
289
+ return this.turnIndex;
290
+ }
291
+
226
292
  /** Build clipboard text only on demand, from this branch's current semantic block. */
227
293
  copy(entry: ContentEntry, width: number): string | undefined {
228
294
  this.refresh();
@@ -0,0 +1,51 @@
1
+ import { Input, type Component } from "@earendil-works/pi-tui";
2
+
3
+ /** Style hooks for the hex input, from the settings theme. */
4
+ export interface HexInputTheme {
5
+ title(text: string): string;
6
+ hint(text: string): string;
7
+ error(text: string): string;
8
+ }
9
+
10
+ /**
11
+ * A settings submenu that takes one `#rrggbb` color. Enter keeps a valid color, Escape leaves the setting as it was;
12
+ * an invalid entry stays open with a note instead of closing.
13
+ */
14
+ export class HexInput implements Component {
15
+ private readonly input = new Input();
16
+ private invalid = false;
17
+
18
+ constructor(current: string, private readonly theme: HexInputTheme, done: (value?: string) => void) {
19
+ this.input.focused = true;
20
+ // Typed in, so the cursor ends after the text; setValue leaves it at the start.
21
+ for (const key of /^#[0-9a-f]{6}$/i.test(current) ? current : "#") this.input.handleInput(key);
22
+ this.input.onSubmit = value => {
23
+ const color = HexInput.normalize(value);
24
+ if (color) done(color);
25
+ else this.invalid = true;
26
+ };
27
+ this.input.onEscape = () => done();
28
+ }
29
+
30
+ /** `#rrggbb` in lowercase, accepting the color with or without `#`; undefined for anything else. */
31
+ static normalize(value: string): string | undefined {
32
+ const match = /^#?([0-9a-f]{6})$/i.exec(value.trim());
33
+ return match ? "#" + match[1].toLowerCase() : undefined;
34
+ }
35
+
36
+ render(width: number): string[] {
37
+ return [
38
+ this.theme.title("Hover color"),
39
+ ...this.input.render(width),
40
+ "",
41
+ this.invalid ? this.theme.error(" Enter a color as #rrggbb, such as #3b82f6.") : this.theme.hint(" #rrggbb · Enter to keep · Esc to cancel"),
42
+ ];
43
+ }
44
+
45
+ handleInput(data: string): void {
46
+ this.invalid = false;
47
+ this.input.handleInput(data);
48
+ }
49
+
50
+ invalidate(): void { this.input.invalidate(); }
51
+ }
package/src/index.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import path from "node:path";
2
2
  import { copyToClipboard, getAgentDir, getSettingsListTheme, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
3
- import { Box, Container, isKeyRelease, matchesKey, SettingsList, Text, type OverlayHandle, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
3
+ import { backgroundAnsi, Box, Container, isKeyRelease, matchesKey, rgbColor, SettingsList, Text, type OverlayHandle, type SettingItem, type TUI, type TuiMouseEvent } from "@earendil-works/pi-tui";
4
+ import { SteadySettings } from "./steady-settings.ts";
5
+ import { HexInput } from "./hex-input.ts";
6
+ import { parseHex } from "./turns.ts";
4
7
  import { TranscriptLayout } from "./layout.ts";
5
8
  import { TOOL_START_ENTRY, TranscriptTimestamps } from "./timestamps.ts";
6
- import { defaults, loadPreferences, savePreferences, type Preferences } from "./preferences.ts";
9
+ import { HOVER_COLORS, TURN_MIXES, TURN_STRIPES, GO_TO, defaults, loadPreferences, savePreferences, type TurnStripe, type GoTo, type Preferences } from "./preferences.ts";
7
10
  import { beforeFirstFrame } from "./startup.ts";
8
11
  import { observeNativeEditor } from "./native-editor.ts";
9
12
  import { NestedCalls } from "./nested-calls.ts";
13
+ import { ProblemReporter } from "./report.ts";
10
14
 
11
15
  const DELAYS = [1, 2, 3, 5, 10, 30];
12
16
 
@@ -54,7 +58,19 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
54
58
  return result;
55
59
  };
56
60
  if (dismissOutside) viewport.dispatchMouseToOverlay = dismissOutside;
57
- const list = new SettingsList([{
61
+ const hoverAvailable = layout?.hoverAvailable() ?? false;
62
+ const HOVER_LABEL = " Highlight on hover";
63
+ const TURNS_HEADER = "Turns";
64
+ const SETTINGS_BACKGROUND = "customMessageBg";
65
+ const listTheme = getSettingsListTheme();
66
+ // A saved mix outside the offered steps stays selectable until another is chosen.
67
+ const mixSetting = (id: "turnClockMix" | "turnStripeMix" | "turnBackgroundMix" | "turnHoverMix", label: string, description: string) => ({
68
+ id, label, description, currentValue: `${preferences[id]}%`,
69
+ values: [...new Set([...TURN_MIXES, preferences[id]])].sort((a, b) => a - b).map(percent => `${percent}%`),
70
+ });
71
+ // A typed hover color joins the presets, so the arrows can step to and from it.
72
+ const hoverColors = (current: string): string[] => ["turn", ...new Set([...HOVER_COLORS, ...(current === "turn" ? [] : [current])])];
73
+ const items: SettingItem[] = [{
58
74
  id: "timestamps", label: "Show timestamps",
59
75
  description: "Hide clock rows without changing messages or recorded tool starts.",
60
76
  currentValue: preferences.showTimestamps ? "on" : "off", values: ["on", "off"],
@@ -90,8 +106,69 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
90
106
  id: "height", label: "Conversation height",
91
107
  description: "Auto grows to half the history area. Drag sets a manual maximum.",
92
108
  currentValue: preferences.chatHeight === null ? "auto" : "manual", values: ["auto", "manual"],
93
- }], 9, getSettingsListTheme(), (id, value) => {
94
- if (id === "timestamps") layout?.setTimestamps(value === "on");
109
+ }, {
110
+ // The Turns header switches the whole feature; its settings sit indented under it and keep their values while it is off.
111
+ id: "turns", label: TURNS_HEADER,
112
+ description: "A turn is one request, yours or an extension's, with all the work that answers it. On colors each turn alike in both panels, highlights it on hover and links the panels with Go to, as the settings below choose.",
113
+ currentValue: preferences.turns ? "on" : "off", values: ["on", "off"],
114
+ }, {
115
+ id: "turnClock", label: " Clock color",
116
+ description: "Color the background of every block's clock in its turn's color.",
117
+ currentValue: preferences.turnClock ? "on" : "off", values: ["on", "off"],
118
+ }, {
119
+ ...mixSetting("turnClockMix", " Clock color strength", "How strongly the turn's color shows behind the clock: the percent of the hue mixed into the terminal background."),
120
+ }, {
121
+ id: "turnStripe", label: " Stripe",
122
+ description: "Mark every block of a turn on the left: a colored cell (block), a thin colored line, or nothing.",
123
+ currentValue: preferences.turnStripe, values: [...TURN_STRIPES],
124
+ }, {
125
+ ...mixSetting("turnStripeMix", " Stripe color strength", "How strongly the turn's color shows in stripes, lines and separators: 100% is the full hue."),
126
+ }, {
127
+ id: "turnBackground", label: " Background",
128
+ description: "Tint the plain background of every block of a turn. Tool cards and messages keep their own backgrounds.",
129
+ currentValue: preferences.turnBackground ? "on" : "off", values: ["on", "off"],
130
+ }, {
131
+ ...mixSetting("turnBackgroundMix", " Background color strength", "How strongly the turn's color tints the background of its blocks."),
132
+ }, {
133
+ id: "turnSeparator", label: " Separator",
134
+ description: "Draw a line in the turn's color in both panels where each new turn begins.",
135
+ currentValue: preferences.turnSeparator ? "on" : "off", values: ["on", "off"],
136
+ }, {
137
+ id: "turnHover", label: HOVER_LABEL,
138
+ description: hoverAvailable ? "While the pointer is over any block, highlight its whole turn in both panels."
139
+ : "Unavailable: the terminal does not report pointer motion here, such as inside tmux, zellij or screen, or with Pi's mouse support off.",
140
+ currentValue: hoverAvailable ? (preferences.turnHover ? "on" : "off") : "unavailable",
141
+ values: hoverAvailable ? ["on", "off"] : ["unavailable"],
142
+ }, {
143
+ ...mixSetting("turnHoverMix", " Hover color strength", "How strongly the hover color tints every block of the turn under the pointer."),
144
+ }, {
145
+ id: "turnHoverColor", label: " Hover color",
146
+ description: "turn highlights each turn in its own color; a #rrggbb color highlights every turn in that one color. ←/→ pick a preset; Enter types any color.",
147
+ currentValue: preferences.turnHoverColor, values: hoverColors(preferences.turnHoverColor),
148
+ submenu: (current, done) => new HexInput(current, {
149
+ title: text => ui.theme.bold(ui.theme.fg("accent", text)),
150
+ hint: text => ui.theme.fg("dim", text),
151
+ error: text => ui.theme.fg("error", text),
152
+ }, done),
153
+ }, {
154
+ id: "goTo", label: " Go to",
155
+ description: "Open the same point of history in the other panel by clicking a block's clock, a Go to button beside Copy, both or neither.",
156
+ currentValue: preferences.goTo, values: [...GO_TO],
157
+ }];
158
+ const VISIBLE_SETTINGS = 21;
159
+ const apply = (id: string, value: string): void => {
160
+ if (id === "turns" || id === "turnClock" || id === "turnBackground" || id === "turnSeparator") layout?.setTurnMark(id, value === "on");
161
+ else if (id === "turnStripe") layout?.setTurnMark("turnStripe", value as TurnStripe);
162
+ else if (id === "turnClockMix" || id === "turnStripeMix" || id === "turnBackgroundMix" || id === "turnHoverMix") {
163
+ layout?.setTurnMark(id, Number.parseInt(value, 10));
164
+ } else if (id === "turnHoverColor") {
165
+ layout?.setTurnMark(id, value);
166
+ const item = items.find(entry => entry.id === id);
167
+ if (item) item.values = hoverColors(value);
168
+ }
169
+ else if (id === "turnHover") { if (value !== "unavailable") layout?.setTurnHover(value === "on"); }
170
+ else if (id === "goTo") layout?.setGoTo(value as GoTo);
171
+ else if (id === "timestamps") layout?.setTimestamps(value === "on");
95
172
  else if (id === "copyButtons") layout?.setCopyButtons(value === "on");
96
173
  else if (id === "buttonStyle") layout?.setButtonStyle(value === "text" ? "text" : "icons");
97
174
  else if (id === "compactTools") layout?.setCompactTools(value === "on");
@@ -101,14 +178,37 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
101
178
  else if (id === "streamDelay") layout?.setStreamDelay(Number.parseInt(value, 10));
102
179
  else if (id === "height") layout?.setAutomaticHeight(value === "auto");
103
180
  tui.requestRender();
104
- }, () => done());
181
+ };
182
+ const list = new SettingsList(items, VISIBLE_SETTINGS, {
183
+ ...listTheme,
184
+ label: (text, selected) => {
185
+ const label = text.trim();
186
+ if (label === TURNS_HEADER) return ui.theme.bold(ui.theme.fg("accent", text));
187
+ // Turn settings look disabled while turns are off, and so does an unavailable setting; both stay listed
188
+ // so their explanations can be read. Only turn settings are indented.
189
+ if (text.startsWith(" ") && !preferences.turns) return ui.theme.fg("dim", text);
190
+ if (!hoverAvailable && label === HOVER_LABEL.trim()) return ui.theme.fg("dim", text);
191
+ return listTheme.label(text, selected);
192
+ },
193
+ value: (text, selected) => {
194
+ if (text === "unavailable") return ui.theme.fg("dim", text);
195
+ // A hover color shows a swatch of itself.
196
+ const color = parseHex(text);
197
+ if (!color) return listTheme.value(text, selected);
198
+ // The swatch's own background ends at the swatch; the panel's background resumes after it, with no reset
199
+ // that would end the panel's background for the rest of the row.
200
+ return backgroundAnsi(rgbColor(color.r, color.g, color.b), ui.theme.getColorMode()) + " " +
201
+ ui.theme.getBgAnsi(SETTINGS_BACKGROUND) + " " + listTheme.value(text, selected);
202
+ },
203
+ }, apply, () => done());
204
+ const steady = new SteadySettings(list, items, VISIBLE_SETTINGS, apply);
105
205
  const content = new Container();
106
206
  content.addChild({
107
207
  render: () => [ui.theme.fg("accent", ui.theme.bold("pi-stereo-view settings")), ""],
108
208
  invalidate() {},
109
209
  });
110
- content.addChild(list);
111
- const box = new Box(1, 1, text => ui.theme.bg("customMessageBg", text));
210
+ content.addChild(steady);
211
+ const box = new Box(1, 1, text => ui.theme.bg(SETTINGS_BACKGROUND, text));
112
212
  box.addChild(content);
113
213
  return {
114
214
  render: (width: number) => box.render(width),
@@ -121,7 +221,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
121
221
  }
122
222
  },
123
223
  handleInput: (data: string) => {
124
- list.handleInput(data);
224
+ steady.handleInput(data);
125
225
  tui.requestRender();
126
226
  },
127
227
  };
@@ -146,6 +246,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
146
246
  host = tui;
147
247
  timestamps = new TranscriptTimestamps(session);
148
248
  nested.restore(session.getBranch());
249
+ const problems = new ProblemReporter(ui, copyToClipboard);
149
250
  layout = new TranscriptLayout(preferences, () => ui.theme,
150
251
  message => ui.notify(message, "warning"), () => persist(ui), timestamps,
151
252
  () => { void openSettings(ui).catch(error => ui.notify(String(error), "error")); }, text => {
@@ -159,7 +260,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
159
260
  }
160
261
  void copyToClipboard(text).then(() => ui.notify("Block sent to clipboard.", "info"),
161
262
  error => ui.notify("Could not copy block: " + String(error), "error"));
162
- }, () => pi.getAllTools(), nested, () => nativeEditor.get(tui));
263
+ }, () => pi.getAllTools(), nested, () => nativeEditor.get(tui), problem => problems.show(problem));
163
264
  try { ensureLayout(); }
164
265
  catch (error) {
165
266
  layout.dispose();
@@ -198,6 +299,8 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
198
299
  else createLayout(tui, ctx.ui, ctx.sessionManager);
199
300
  finish = done;
200
301
  ensureLayout();
302
+ // Pi starts its terminal before session_start, also after an early layout mount.
303
+ layout?.markTerminalStarted();
201
304
  return new Text("", 0, 0);
202
305
  }, {
203
306
  overlay: true,
@@ -285,7 +388,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
285
388
  const choice = await ctx.ui.select("Copy a block from the active panel", blocks.map(block => block.label));
286
389
  blocks.find(block => block.label === choice)?.copy();
287
390
  } else if (action === "help") {
288
- ctx.ui.notify("pi-stereo-view: choose icon or text buttons in /stereo-view settings. Buttons: ▣/Combine combines history, ◫/Split separates it, ▤/Rows and ▥/Columns change layout, ↕/↔/Swap exchanges panels, ↗/Maximize and ↙/Restore change panel size, ⌕/Find searches, ⊟/Compact tools and ⊞/Full tools toggle compact tools, ≡/Settings opens settings, ⧉/Copy copies a block. /stereo-view copy chooses a block with the keyboard. Ctrl+F searches and PgUp/PgDn scroll the active panel; Ctrl+Alt+Up/Down switches it. Drag the ═ or ║ divider to resize.", "info");
391
+ ctx.ui.notify("pi-stereo-view: choose icon or text buttons in /stereo-view settings. Buttons: ▣/Combine combines history, ◫/Split separates it, ▤/Rows and ▥/Columns change layout, ↕/↔/Swap exchanges panels, ↗/Maximize and ↙/Restore change panel size, ⌕/Find searches, ⊟/Compact tools and ⊞/Full tools toggle compact tools, ≡/Settings opens settings, ⧉/Copy copies a block, ⇄/Go to or a click on a block's clock opens the same point in the other panel. /stereo-view copy chooses a block with the keyboard. Ctrl+F searches and PgUp/PgDn scroll the active panel; Ctrl+Alt+Up/Down switches it. Drag the ═ or ║ divider to resize.", "info");
289
392
  } else if (action === "swap") layout.swap();
290
393
  else if (action === "width" && /^\d+$/.test(target ?? "")) layout.setWidth(Number(target));
291
394
  else if (action === "height" && target === "auto") layout.setHeight(null);