pi-stereo-view 0.1.26 → 0.1.27
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 +11 -0
- package/README.md +29 -27
- package/package.json +4 -4
- package/src/index.ts +73 -42
- package/src/layout.ts +43 -18
- package/src/native.ts +3 -3
- package/src/nested-tree.ts +3 -3
- package/src/pi-windows.ts +46 -0
- package/src/preferences.ts +14 -5
- package/src/render-cache.ts +3 -3
- package/src/search-highlight.ts +3 -3
- package/src/steady-settings.ts +53 -5
- package/src/surface.ts +4 -4
- package/src/tool-indent.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.27 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Pi's own pickers, such as the session tree (`/tree` or double Escape), `/resume` and `/model`, now open at full width while the panels are side by side: the view temporarily shows combined history and restores the split when the picker closes. The **Pi pickers in split** setting can instead maximize Activity or keep them inside Activity. Extension dialogs and agent questions stay inside Activity. Thanks to [@okuuva](https://github.com/okuuva) for the idea ([#101](https://github.com/alexshpunt/pi-stereo-view/pull/101)).
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Settings say what you see: each name describes what it changes and each value what it shows, such as **Finished tool calls**: `one line` / `full`, **Block clocks**: `shown` / `hidden` and **Color each turn**. Settings are grouped under Blocks, Activity tools, Layout and Turns titles. Saved settings keep working.
|
|
12
|
+
- Development and tests run against Pi 1.6.0.
|
|
13
|
+
|
|
3
14
|
## 0.1.26 - 2026-11-23
|
|
4
15
|
|
|
5
16
|
### Changed
|
package/README.md
CHANGED
|
@@ -27,12 +27,14 @@ 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. To keep the parent's own output panel instead,
|
|
30
|
+
Expand a parent tool such as Codemode to browse its nested call tree. To keep the parent's own output panel instead, set **Codemode calls** to `raw output` 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
|
|
|
34
34
|
If the Activity surface cannot fit without clipping, the view temporarily returns to combined history and Pi's normal placement. Combined history, zoomed Conversation and unsupported native layouts also leave dialogs and widgets in Pi's dock. Open forms stay live as layouts change and disappear when their producer closes them; they are not added to history.
|
|
35
35
|
|
|
36
|
+
Pi's own menus, such as the session tree (`/tree` or double Escape), `/fork`, `/resume`, `/model`, `/login` and Pi's settings, are wide lists that only you open. While one is open with the panels side by side, the view temporarily returns to combined history so the menu gets the full width, then restores the split when it closes. Pi's follow-up questions, such as **Summarize branch?** after you pick another point in the tree, keep that placement. The **Pi pickers in split** setting chooses `full screen` (default), `maximize Activity`, which temporarily hides Conversation instead, or `inside Activity`, which keeps them in the half-width Activity panel like extension dialogs. Rows and a maximized panel already give the menu the full width and keep it there. Extension dialogs, including questions the agent asks, stay under Activity so Conversation remains visible.
|
|
37
|
+
|
|
36
38
|
## Features
|
|
37
39
|
|
|
38
40
|
- Arrange Conversation and Activity in columns or rows, swap or resize the panels, and zoom either one while keeping the input full width.
|
|
@@ -75,7 +77,7 @@ pi --tui-mode fullscreen
|
|
|
75
77
|
|
|
76
78
|
## Use it
|
|
77
79
|
|
|
78
|
-
Click the toolbar and the buttons in each panel's header. Buttons use text labels by default. To use icons instead, open **Stereo View settings** with `[Settings]` or `/stereo-view settings`, then set **Button
|
|
80
|
+
Click the toolbar and the buttons in each panel's header. Buttons use text labels by default. To use icons instead, open **Stereo View settings** with `[Settings]` or `/stereo-view settings`, then set **Button labels** to `icons`. The choice survives restart. Settings are grouped under **Blocks**, **Activity tools**, **Layout** and **Turns**.
|
|
79
81
|
|
|
80
82
|
| Icons | Text | Action |
|
|
81
83
|
| --- | --- | --- |
|
|
@@ -85,14 +87,14 @@ Click the toolbar and the buttons in each panel's header. Buttons use text label
|
|
|
85
87
|
| `[ ↗ ]` / `[ ↙ ]` | `[Maximize]` / `[Restore]` | Zoom a panel / restore the split. |
|
|
86
88
|
| `[ ≡ ]` | `[Settings]` | Open display and Conversation height settings. |
|
|
87
89
|
| `[ ⌕ ]` | `[Find]` | Search this panel. |
|
|
88
|
-
| `[ ⊟ ]` / `[ ⊞ ]` | `[Compact tools]` / `[Full tools]` |
|
|
89
|
-
| `[ ⇄ ]` | `[Go to]` | Open the same moment in the other panel (when
|
|
90
|
+
| `[ ⊟ ]` / `[ ⊞ ]` | `[Compact tools]` / `[Full tools]` | Show finished tool calls as one line / in full. |
|
|
91
|
+
| `[ ⇄ ]` | `[Go to]` | Open the same moment in the other panel (when **Jump to other panel** includes the button). |
|
|
90
92
|
|
|
91
93
|
**Resize:** drag the double line between the panels — `═` in rows, `║` in columns.
|
|
92
94
|
|
|
93
95
|
New installs start in Columns: Conversation gets 20% of the width on the left, and Activity gets 80% on the right. Drag the divider or use the size shortcuts to change this.
|
|
94
96
|
|
|
95
|
-
In Rows, Conversation grows with its messages up to half the available history area, then scrolls. Dragging the divider or setting a height changes that limit.
|
|
97
|
+
In Rows, Conversation grows with its messages up to half the available history area, then scrolls. Dragging the divider or setting a height changes that limit. Set **Conversation height in rows** to `grow with messages` in settings, or run `/stereo-view height auto`, to restore automatic sizing.
|
|
96
98
|
|
|
97
99
|
Panels fit short content and scroll when history fills up. Each panel has its own scrolling, text selection and copy.
|
|
98
100
|
|
|
@@ -100,17 +102,17 @@ Swap the panels whenever you want. Zoom a panel to give it the whole history are
|
|
|
100
102
|
|
|
101
103
|
## Compact Activity
|
|
102
104
|
|
|
103
|
-
Three independent settings in `/stereo-view settings` control how Activity shows tool calls.
|
|
105
|
+
Three independent settings in `/stereo-view settings` control how Activity shows tool calls. Each survives restart; the first value is the default.
|
|
104
106
|
|
|
105
|
-
| Setting |
|
|
107
|
+
| Setting | Values | What it shows |
|
|
106
108
|
| --- | --- | --- |
|
|
107
|
-
| **
|
|
108
|
-
| **
|
|
109
|
-
| **
|
|
109
|
+
| **Finished tool calls** | `one line`, `full` | One line per call that you click to open its full card and linked output, or the full card. |
|
|
110
|
+
| **Repeated tool calls** | `merge`, `separate` | Adjacent calls to the same tool in the same state share one header with a count, such as `read ×3`, or each stands alone. |
|
|
111
|
+
| **Codemode calls** | `tree`, `raw output` | Calls made by a tool such as Codemode appear as a tree under it, or the tool keeps its own output panel. |
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
One-line and merged calls combine freely. With both, a group opens into one-line rows, and each row opens its card. With merged full calls, a group opens straight into the members' full cards. With one-line separate calls, every call keeps its own row. With full separate calls, Activity shows the original cards; this suits other extensions that draw their own tool cards.
|
|
112
114
|
|
|
113
|
-
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 **
|
|
115
|
+
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 **Finished tool calls**.
|
|
114
116
|
|
|
115
117
|
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.
|
|
116
118
|
|
|
@@ -120,32 +122,32 @@ Search and `/stereo-view copy` still include full saved results and linked outpu
|
|
|
120
122
|
|
|
121
123
|
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.
|
|
122
124
|
|
|
123
|
-
###
|
|
125
|
+
### Running tool calls
|
|
124
126
|
|
|
125
|
-
**
|
|
127
|
+
**Running tool calls** (`full` by default) lets you watch the current work while keeping history short. While finished calls show as one line or merged, a new tool call appears as its full card and updates live. When it finishes, it stays full for **Fold finished calls after** (1, 2, 3, 5, 10 or 30 seconds; default 5), then folds in place: into one line, and into the adjacent identical calls' group (`read ×3`) when merged. With `one line`, a running call shows as one line right away. When finished calls show full and separate, every call already shows in full, so this setting changes nothing.
|
|
126
128
|
|
|
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
|
|
129
|
+
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 settings survive restart.
|
|
128
130
|
|
|
129
131
|
## Find your way between requests
|
|
130
132
|
|
|
131
133
|
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
134
|
|
|
133
|
-
Turn colors, hover highlighting and Go to are on by default. Set **
|
|
135
|
+
Turn colors, hover highlighting and Go to are on by default. Set **Color each turn** 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 it is off.
|
|
134
136
|
|
|
135
137
|
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
138
|
|
|
137
139
|
| Setting | Values | What it marks |
|
|
138
140
|
| --- | --- | --- |
|
|
139
|
-
| **
|
|
140
|
-
| **
|
|
141
|
-
| **
|
|
142
|
-
| **
|
|
141
|
+
| **Tint clocks** | `on` (default), `off` | The background of each block's clock. |
|
|
142
|
+
| **Left stripe** | `block` (default), `line`, `off` | Every block's left column: a colored cell or a thin colored line. |
|
|
143
|
+
| **Tint blocks** | `on`, `off` (default) | The background of every block. |
|
|
144
|
+
| **Line between turns** | `on` (default), `off` | A colored line across both panels where each new turn begins. |
|
|
143
145
|
|
|
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: **
|
|
146
|
+
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: **Block tint strength** (8% by default), **Hover strength** (10%), **Stripe strength** (20%, also for lines between turns) and **Clock tint 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
147
|
|
|
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 other cells with their own background shift by the same amount as the plain background around them, so they stay as distinct from it as without the layers. The terminal's basic 16 colors stay as they are.
|
|
148
|
+
**Hover color** sets the hover layer's color: `turn color` 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 other cells with their own background shift by the same amount as the plain background around them, so they stay as distinct from it as without the layers. The terminal's basic 16 colors stay as they are.
|
|
147
149
|
|
|
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`.
|
|
150
|
+
**Highlight turn 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
151
|
|
|
150
152
|
**Go to** opens the same moment of history in the other panel:
|
|
151
153
|
|
|
@@ -153,7 +155,7 @@ Neighbouring turns get different hues. Colors stack in layers over your terminal
|
|
|
153
155
|
- From Conversation, it shows the first Activity block after: for your message, the work it started.
|
|
154
156
|
- A message with a part in both panels, such as a reply with thinking, opens its own other part.
|
|
155
157
|
|
|
156
|
-
Click a block's clock, including the clock of a compact tool row or group, or the `[ ⇄ ]` / `[Go to]` button beside Copy. The **
|
|
158
|
+
Click a block's clock, including the clock of a compact tool row or group, or the `[ ⇄ ]` / `[Go to]` button beside Copy. The **Jump to other panel** setting chooses `click 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
159
|
|
|
158
160
|
## Search history
|
|
159
161
|
|
|
@@ -188,7 +190,7 @@ During streaming, each click copies the content available at that moment. Copy u
|
|
|
188
190
|
|
|
189
191
|
For keyboard access, run `/stereo-view copy` and choose a numbered block from the active panel. It copies the same text as that block's button.
|
|
190
192
|
|
|
191
|
-
|
|
193
|
+
Set **Copy buttons** to `hidden` in Stereo View settings to hide the buttons and their rows. This choice survives restart. Keyboard copying stays available when the buttons are hidden.
|
|
192
194
|
|
|
193
195
|
## Timestamps
|
|
194
196
|
|
|
@@ -224,9 +226,9 @@ Keyboard scrolling (`PgUp`/`PgDn` and Pi's other scroll keys) moves the active p
|
|
|
224
226
|
|
|
225
227
|
## Settings and limits
|
|
226
228
|
|
|
227
|
-
Your layout, panel order, sizes, compact Activity choice, turn marks, hover
|
|
229
|
+
Your layout, panel order, sizes, compact Activity choice, turn marks, hover, Go to and Pi menu 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.
|
|
228
230
|
|
|
229
|
-
- Tested with Pi 1.
|
|
231
|
+
- Tested with Pi 1.6.0. Requires Node.js 22.19 or newer.
|
|
230
232
|
- Regular mode shows one combined history.
|
|
231
233
|
- If the terminal is too small, history temporarily combines without forgetting your split.
|
|
232
234
|
- 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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-stereo-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Keep Pi conversation separate from tool output and agent activity.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@earendil-works/pi-tui": "*"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@earendil-works/pi-ai": "1.
|
|
56
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
57
|
-
"@earendil-works/pi-tui": "1.
|
|
55
|
+
"@earendil-works/pi-ai": "1.6.0",
|
|
56
|
+
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
57
|
+
"@earendil-works/pi-tui": "1.6.0",
|
|
58
58
|
"@types/node": "^24.0.4",
|
|
59
59
|
"pi-coding-agent-test": "0.1.3",
|
|
60
60
|
"typebox": "1.3.27",
|
package/src/index.ts
CHANGED
|
@@ -6,13 +6,33 @@ import { HexInput } from "./hex-input.ts";
|
|
|
6
6
|
import { parseHex } from "./turns.ts";
|
|
7
7
|
import { TranscriptLayout } from "./layout.ts";
|
|
8
8
|
import { TOOL_START_ENTRY, TranscriptTimestamps } from "./timestamps.ts";
|
|
9
|
-
import { HOVER_COLORS, TURN_MIXES, TURN_STRIPES, GO_TO, defaults, loadPreferences, savePreferences, type TurnStripe, type GoTo, type Preferences } from "./preferences.ts";
|
|
9
|
+
import { HOVER_COLORS, TURN_MIXES, TURN_STRIPES, GO_TO, PI_WINDOWS, defaults, loadPreferences, savePreferences, type TurnStripe, type GoTo, type PiWindows, type Preferences } from "./preferences.ts";
|
|
10
10
|
import { beforeFirstFrame } from "./startup.ts";
|
|
11
11
|
import { observeNativeEditor } from "./native-editor.ts";
|
|
12
12
|
import { NestedCalls } from "./nested-calls.ts";
|
|
13
13
|
import { ProblemReporter } from "./report.ts";
|
|
14
14
|
|
|
15
15
|
const DELAYS = [1, 2, 3, 5, 10, 30];
|
|
16
|
+
/**
|
|
17
|
+
* What a setting's values read as in the settings list, by setting id: what the user sees once it is chosen. The saved
|
|
18
|
+
* file and the code keep the short values. Values without an entry, such as delays, percents and colors, show as they are.
|
|
19
|
+
*/
|
|
20
|
+
const SHOWN_VALUES: Record<string, Record<string, string>> = {
|
|
21
|
+
timestamps: { on: "shown", off: "hidden" },
|
|
22
|
+
copyButtons: { on: "shown", off: "hidden" },
|
|
23
|
+
buttonStyle: { text: "words" },
|
|
24
|
+
compactTools: { on: "one line", off: "full" },
|
|
25
|
+
groupTools: { on: "merge", off: "separate" },
|
|
26
|
+
nestedTree: { on: "tree", off: "raw output" },
|
|
27
|
+
streamTools: { on: "full", off: "one line" },
|
|
28
|
+
height: { auto: "grow with messages", manual: "fixed by drag" },
|
|
29
|
+
piWindows: { combined: "full screen", maximize: "maximize Activity", inline: "inside Activity" },
|
|
30
|
+
turnHoverColor: { turn: "turn color" },
|
|
31
|
+
goTo: { clock: "click clock", button: "button" },
|
|
32
|
+
};
|
|
33
|
+
const shownValue = (id: string, value: string): string => SHOWN_VALUES[id]?.[value] ?? value;
|
|
34
|
+
const savedValue = (id: string, shown: string): string =>
|
|
35
|
+
Object.entries(SHOWN_VALUES[id] ?? {}).find(([, label]) => label === shown)?.[0] ?? shown;
|
|
16
36
|
|
|
17
37
|
/** Split native fullscreen history without changing message content or the input dock. */
|
|
18
38
|
export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
@@ -59,8 +79,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
59
79
|
};
|
|
60
80
|
if (dismissOutside) viewport.dispatchMouseToOverlay = dismissOutside;
|
|
61
81
|
const hoverAvailable = layout?.hoverAvailable() ?? false;
|
|
62
|
-
const HOVER_LABEL = " Highlight on hover";
|
|
63
|
-
const TURNS_HEADER = "Turns";
|
|
82
|
+
const HOVER_LABEL = " Highlight turn on hover";
|
|
64
83
|
const SETTINGS_BACKGROUND = "customMessageBg";
|
|
65
84
|
const listTheme = getSettingsListTheme();
|
|
66
85
|
// A saved mix outside the offered steps stays selectable until another is chosen.
|
|
@@ -71,79 +90,83 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
71
90
|
// A typed hover color joins the presets, so the arrows can step to and from it.
|
|
72
91
|
const hoverColors = (current: string): string[] => ["turn", ...new Set([...HOVER_COLORS, ...(current === "turn" ? [] : [current])])];
|
|
73
92
|
const items: SettingItem[] = [{
|
|
74
|
-
id: "timestamps", label: "
|
|
75
|
-
description: "
|
|
93
|
+
id: "timestamps", label: "Block clocks",
|
|
94
|
+
description: "The clock row above every block. Hiding it keeps the recorded times.",
|
|
76
95
|
currentValue: preferences.showTimestamps ? "on" : "off", values: ["on", "off"],
|
|
77
96
|
}, {
|
|
78
|
-
id: "copyButtons", label: "
|
|
79
|
-
description: "
|
|
97
|
+
id: "copyButtons", label: "Copy buttons",
|
|
98
|
+
description: "The Copy button on every block. Keyboard copying works either way.",
|
|
80
99
|
currentValue: preferences.showCopyButtons ? "on" : "off", values: ["on", "off"],
|
|
81
100
|
}, {
|
|
82
|
-
id: "buttonStyle", label: "Button
|
|
83
|
-
description: "
|
|
101
|
+
id: "buttonStyle", label: "Button labels",
|
|
102
|
+
description: "Toolbar, panel and copy buttons as icons, such as [ ⌕ ], or as words, such as [Find].",
|
|
84
103
|
currentValue: preferences.buttonStyle, values: ["icons", "text"],
|
|
85
104
|
}, {
|
|
86
|
-
id: "compactTools", label: "
|
|
87
|
-
description: "
|
|
105
|
+
id: "compactTools", label: "Finished tool calls",
|
|
106
|
+
description: "One line that opens the full card when clicked, or the full card. Search and copy always use the full text.",
|
|
88
107
|
currentValue: preferences.compactTools ? "on" : "off", values: ["on", "off"],
|
|
89
108
|
}, {
|
|
90
|
-
id: "groupTools", label: "
|
|
91
|
-
description: "
|
|
109
|
+
id: "groupTools", label: "Repeated tool calls",
|
|
110
|
+
description: "Adjacent calls of the same tool merged under one counted line, such as read ×3, or each on its own.",
|
|
92
111
|
currentValue: preferences.groupTools ? "on" : "off", values: ["on", "off"],
|
|
93
112
|
}, {
|
|
94
|
-
id: "nestedTree", label: "
|
|
95
|
-
description: "
|
|
113
|
+
id: "nestedTree", label: "Codemode calls",
|
|
114
|
+
description: "The calls a tool such as Codemode makes: a tree under the tool, or the tool's own raw output.",
|
|
96
115
|
currentValue: preferences.nestedTree ? "on" : "off", values: ["on", "off"],
|
|
97
116
|
}, {
|
|
98
|
-
id: "streamTools", label: "
|
|
99
|
-
description: "
|
|
117
|
+
id: "streamTools", label: "Running tool calls",
|
|
118
|
+
description: "A running call shows its full card and folds after the delay below, or shows as one line right away.",
|
|
100
119
|
currentValue: preferences.streamTools ? "on" : "off", values: ["on", "off"],
|
|
101
120
|
}, {
|
|
102
|
-
id: "streamDelay", label: "
|
|
103
|
-
description: "How long a finished
|
|
121
|
+
id: "streamDelay", label: "Fold finished calls after",
|
|
122
|
+
description: "How long a finished call stays full before it folds into one line or its merged group.",
|
|
104
123
|
currentValue: `${preferences.streamDelay}s`, values: [...new Set([...DELAYS, preferences.streamDelay])].sort((a, b) => a - b).map(seconds => `${seconds}s`),
|
|
105
124
|
}, {
|
|
106
|
-
id: "height", label: "Conversation height",
|
|
107
|
-
description: "
|
|
125
|
+
id: "height", label: "Conversation height in rows",
|
|
126
|
+
description: "In the Rows layout, Conversation grows with its messages up to half the history, or keeps the height you dragged.",
|
|
108
127
|
currentValue: preferences.chatHeight === null ? "auto" : "manual", values: ["auto", "manual"],
|
|
109
128
|
}, {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
id: "piWindows", label: "Pi pickers in split",
|
|
130
|
+
description: "Pi's own pickers, such as the session tree or the model list, open full screen, in maximized Activity, or inside Activity.",
|
|
131
|
+
currentValue: preferences.piWindows, values: [...PI_WINDOWS],
|
|
132
|
+
}, {
|
|
133
|
+
// Switches the whole group; the settings indented under it keep their values while it is off.
|
|
134
|
+
id: "turns", label: "Color each turn",
|
|
135
|
+
description: "A turn is a message you or an extension send, with all the work that answers it. Off turns off everything below.",
|
|
113
136
|
currentValue: preferences.turns ? "on" : "off", values: ["on", "off"],
|
|
114
137
|
}, {
|
|
115
|
-
id: "turnClock", label: "
|
|
116
|
-
description: "Color the background of every block's clock
|
|
138
|
+
id: "turnClock", label: " Tint clocks",
|
|
139
|
+
description: "Color the background of every block's clock with its turn's color.",
|
|
117
140
|
currentValue: preferences.turnClock ? "on" : "off", values: ["on", "off"],
|
|
118
141
|
}, {
|
|
119
|
-
...mixSetting("turnClockMix", " Clock
|
|
142
|
+
...mixSetting("turnClockMix", " Clock tint strength", "How strongly the turn's color shows behind the clock: the percent of the color mixed into the background."),
|
|
120
143
|
}, {
|
|
121
|
-
id: "turnStripe", label: "
|
|
144
|
+
id: "turnStripe", label: " Left stripe",
|
|
122
145
|
description: "Mark every block of a turn on the left: a colored cell (block), a thin colored line, or nothing.",
|
|
123
146
|
currentValue: preferences.turnStripe, values: [...TURN_STRIPES],
|
|
124
147
|
}, {
|
|
125
|
-
...mixSetting("turnStripeMix", " Stripe
|
|
148
|
+
...mixSetting("turnStripeMix", " Stripe strength", "How strongly the turn's color shows in stripes and in lines between turns: 100% is the full color."),
|
|
126
149
|
}, {
|
|
127
|
-
id: "turnBackground", label: "
|
|
150
|
+
id: "turnBackground", label: " Tint blocks",
|
|
128
151
|
description: "Tint the background of every block of a turn. Tool cards and messages shift by the same amount.",
|
|
129
152
|
currentValue: preferences.turnBackground ? "on" : "off", values: ["on", "off"],
|
|
130
153
|
}, {
|
|
131
|
-
...mixSetting("turnBackgroundMix", "
|
|
154
|
+
...mixSetting("turnBackgroundMix", " Block tint strength", "How strongly the turn's color tints the background of its blocks."),
|
|
132
155
|
}, {
|
|
133
|
-
id: "turnSeparator", label: "
|
|
156
|
+
id: "turnSeparator", label: " Line between turns",
|
|
134
157
|
description: "Draw a line in the turn's color in both panels where each new turn begins.",
|
|
135
158
|
currentValue: preferences.turnSeparator ? "on" : "off", values: ["on", "off"],
|
|
136
159
|
}, {
|
|
137
160
|
id: "turnHover", label: HOVER_LABEL,
|
|
138
161
|
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
|
|
162
|
+
: "Unavailable: the terminal does not report pointer motion, such as inside tmux, zellij or screen.",
|
|
140
163
|
currentValue: hoverAvailable ? (preferences.turnHover ? "on" : "off") : "unavailable",
|
|
141
164
|
values: hoverAvailable ? ["on", "off"] : ["unavailable"],
|
|
142
165
|
}, {
|
|
143
|
-
...mixSetting("turnHoverMix", " Hover
|
|
166
|
+
...mixSetting("turnHoverMix", " Hover strength", "How strongly the hover color tints every block of the turn under the pointer."),
|
|
144
167
|
}, {
|
|
145
168
|
id: "turnHoverColor", label: " Hover color",
|
|
146
|
-
description: "
|
|
169
|
+
description: "Each turn in its own color, or every turn in one #rrggbb color. ←/→ pick a preset; Enter types any color.",
|
|
147
170
|
currentValue: preferences.turnHoverColor, values: hoverColors(preferences.turnHoverColor),
|
|
148
171
|
submenu: (current, done) => new HexInput(current, {
|
|
149
172
|
title: text => ui.theme.bold(ui.theme.fg("accent", text)),
|
|
@@ -151,12 +174,19 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
151
174
|
error: text => ui.theme.fg("error", text),
|
|
152
175
|
}, done),
|
|
153
176
|
}, {
|
|
154
|
-
id: "goTo", label: "
|
|
155
|
-
description: "Open the same point of history in the other panel by clicking a block's clock, a Go to button
|
|
177
|
+
id: "goTo", label: " Jump to other panel",
|
|
178
|
+
description: "Open the same point of history in the other panel by clicking a block's clock, a Go to button, both or neither.",
|
|
156
179
|
currentValue: preferences.goTo, values: [...GO_TO],
|
|
157
180
|
}];
|
|
158
|
-
const
|
|
159
|
-
|
|
181
|
+
for (const item of items) {
|
|
182
|
+
item.currentValue = shownValue(item.id, item.currentValue);
|
|
183
|
+
item.values = item.values?.map(value => shownValue(item.id, value));
|
|
184
|
+
}
|
|
185
|
+
// Each group's title shows above its first setting.
|
|
186
|
+
const groups = new Map([["timestamps", "Blocks"], ["compactTools", "Activity tools"], ["height", "Layout"], ["turns", "Turns"]]);
|
|
187
|
+
const VISIBLE_SETTINGS = 22;
|
|
188
|
+
const apply = (id: string, shown: string): void => {
|
|
189
|
+
const value = savedValue(id, shown);
|
|
160
190
|
if (id === "turns" || id === "turnClock" || id === "turnBackground" || id === "turnSeparator") layout?.setTurnMark(id, value === "on");
|
|
161
191
|
else if (id === "turnStripe") layout?.setTurnMark("turnStripe", value as TurnStripe);
|
|
162
192
|
else if (id === "turnClockMix" || id === "turnStripeMix" || id === "turnBackgroundMix" || id === "turnHoverMix") {
|
|
@@ -164,10 +194,11 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
164
194
|
} else if (id === "turnHoverColor") {
|
|
165
195
|
layout?.setTurnMark(id, value);
|
|
166
196
|
const item = items.find(entry => entry.id === id);
|
|
167
|
-
if (item) item.values = hoverColors(value);
|
|
197
|
+
if (item) item.values = hoverColors(value).map(entry => shownValue(id, entry));
|
|
168
198
|
}
|
|
169
199
|
else if (id === "turnHover") { if (value !== "unavailable") layout?.setTurnHover(value === "on"); }
|
|
170
200
|
else if (id === "goTo") layout?.setGoTo(value as GoTo);
|
|
201
|
+
else if (id === "piWindows") layout?.setPiWindows(value as PiWindows);
|
|
171
202
|
else if (id === "timestamps") layout?.setTimestamps(value === "on");
|
|
172
203
|
else if (id === "copyButtons") layout?.setCopyButtons(value === "on");
|
|
173
204
|
else if (id === "buttonStyle") layout?.setButtonStyle(value === "text" ? "text" : "icons");
|
|
@@ -183,7 +214,6 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
183
214
|
...listTheme,
|
|
184
215
|
label: (text, selected) => {
|
|
185
216
|
const label = text.trim();
|
|
186
|
-
if (label === TURNS_HEADER) return ui.theme.bold(ui.theme.fg("accent", text));
|
|
187
217
|
// Turn settings look disabled while turns are off, and so does an unavailable setting; both stay listed
|
|
188
218
|
// so their explanations can be read. Only turn settings are indented.
|
|
189
219
|
if (text.startsWith(" ") && !preferences.turns) return ui.theme.fg("dim", text);
|
|
@@ -201,7 +231,8 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
|
|
|
201
231
|
ui.theme.getBgAnsi(SETTINGS_BACKGROUND) + " " + listTheme.value(text, selected);
|
|
202
232
|
},
|
|
203
233
|
}, apply, () => done());
|
|
204
|
-
const steady = new SteadySettings(list, items, VISIBLE_SETTINGS, apply
|
|
234
|
+
const steady = new SteadySettings(list, items, VISIBLE_SETTINGS, apply,
|
|
235
|
+
{ titles: groups, style: text => ui.theme.bold(ui.theme.fg("accent", text)) });
|
|
205
236
|
const content = new Container();
|
|
206
237
|
content.addChild({
|
|
207
238
|
render: () => [ui.theme.fg("accent", ui.theme.bold("pi-stereo-view settings")), ""],
|
package/src/layout.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { TurnMarkSetting, Preferences } from "./preferences.ts";
|
|
|
12
12
|
import type { TranscriptTimestamps } from "./timestamps.ts";
|
|
13
13
|
import { PANEL_SEARCH_ROWS, PanelSearch, PanelSearchShortcut, type SearchHit } from "./search.ts";
|
|
14
14
|
import { SplitSurface } from "./surface.ts";
|
|
15
|
+
import { showsPiWindow } from "./pi-windows.ts";
|
|
15
16
|
import { sameValues } from "./render-cache.ts";
|
|
16
17
|
import type { Problem } from "./report.ts";
|
|
17
18
|
|
|
@@ -29,8 +30,8 @@ const TOOLBAR_BUTTON_WIDTH = 6;
|
|
|
29
30
|
* A control that renders again only when one of its inputs changes. Every spinner frame lays out
|
|
30
31
|
* all toolbar and panel controls; restyling unchanged labels would cost more than the panels themselves.
|
|
31
32
|
*/
|
|
32
|
-
function memoized(inputs: (width: number) => unknown[], render: (width: number) => string[]): Component {
|
|
33
|
-
let last: { inputs: unknown[]; lines: string[] } | undefined;
|
|
33
|
+
function memoized(inputs: (width: number) => unknown[], render: (width: number) => readonly string[]): Component {
|
|
34
|
+
let last: { inputs: unknown[]; lines: readonly string[] } | undefined;
|
|
34
35
|
return {
|
|
35
36
|
render: width => {
|
|
36
37
|
const current = inputs(width);
|
|
@@ -237,6 +238,8 @@ export class TranscriptLayout {
|
|
|
237
238
|
private drag?: { position: number; size: number };
|
|
238
239
|
private failed = false;
|
|
239
240
|
private fallback = false;
|
|
241
|
+
/** How an open Pi window temporarily changes the side-by-side split; the saved layout and zoom stay unchanged. */
|
|
242
|
+
private piWindow?: "combined" | "maximize";
|
|
240
243
|
private automaticHeight = MIN_ROWS;
|
|
241
244
|
private readonly rejectedRoots = new WeakSet<Component>();
|
|
242
245
|
private rebuild = (): void => {};
|
|
@@ -265,6 +268,11 @@ export class TranscriptLayout {
|
|
|
265
268
|
(problem.error === undefined ? "" : ": " + (problem.error instanceof Error ? problem.error.message : String(problem.error)))),
|
|
266
269
|
) {}
|
|
267
270
|
|
|
271
|
+
/** The zoom the split shows: the user's, or Activity while a Pi window maximizes it. */
|
|
272
|
+
private get zoom(): Preferences["zoom"] {
|
|
273
|
+
return this.piWindow === "maximize" ? "activity" : this.preferences.zoom;
|
|
274
|
+
}
|
|
275
|
+
|
|
268
276
|
/** Refuse a Pi layout the split cannot use; Pi keeps its own history view. */
|
|
269
277
|
private refuse(reason: string): void {
|
|
270
278
|
this.report({ summary: "split is unavailable: " + reason });
|
|
@@ -357,6 +365,8 @@ export class TranscriptLayout {
|
|
|
357
365
|
const editor = this.getEditor();
|
|
358
366
|
return !!editor && !!editorSlot && editorSlot.children.length === 1 && editorSlot.children[0] !== editor;
|
|
359
367
|
};
|
|
368
|
+
// Updated once per frame, whatever the setting, so a chain of Pi's windows is followed through every swap.
|
|
369
|
+
let piWindowOpen = false;
|
|
360
370
|
const projectedDock = supportedDock ? new VStack(entries.filter((_, i) => i !== 2 && i !== 4).map(entry =>
|
|
361
371
|
entry.component === editorSlot ? { ...entry, visible: () => !projectDialog } : entry)) : undefined;
|
|
362
372
|
// Preserve the original containers and Pi's above/editor/below order. Pi still owns their lifecycle.
|
|
@@ -441,8 +451,13 @@ export class TranscriptLayout {
|
|
|
441
451
|
// Width-only stack rendering during external-editor handoff has no viewport height bound.
|
|
442
452
|
height = Math.min(height, Math.max(1, host.terminal.rows));
|
|
443
453
|
const previousHeight = historyHeight;
|
|
454
|
+
piWindowOpen = showsPiWindow(editorSlot?.children.length === 1 ? editorSlot.children[0] : undefined, piWindowOpen);
|
|
455
|
+
// A Pi window under half-width Activity would cut its wide lists; give it the full width until it closes.
|
|
456
|
+
this.piWindow = this.preferences.mode === "split" && this.preferences.layout === "columns" && !this.preferences.zoom &&
|
|
457
|
+
this.preferences.piWindows !== "inline" && piWindowOpen ? this.preferences.piWindows : undefined;
|
|
458
|
+
const combinedWindow = this.piWindow === "combined";
|
|
444
459
|
const candidate = !!projectedDock && (widgetsPresent() || dialogPresent()) && dockUnchanged() && !this.failed &&
|
|
445
|
-
this.preferences.mode === "split" && this.
|
|
460
|
+
this.preferences.mode === "split" && this.zoom !== "chat" && !combinedWindow;
|
|
446
461
|
projectDialog = candidate && dialogPresent();
|
|
447
462
|
historyHeight = Math.max(0, height - (candidate ? projectedDock : dock).render(width).length - toolbar.render(width).length);
|
|
448
463
|
const search = this.search;
|
|
@@ -450,20 +465,21 @@ export class TranscriptLayout {
|
|
|
450
465
|
if (this.search === search) search.bar.reposition();
|
|
451
466
|
});
|
|
452
467
|
this.automaticHeight = Math.max(MIN_ROWS, Math.floor(historyHeight / 2));
|
|
453
|
-
const chatWidth = this.
|
|
468
|
+
const chatWidth = this.zoom || this.preferences.layout === "rows" ? width : Math.min(width - MIN_ACTIVITY - 1,
|
|
454
469
|
Math.max(MIN_CHAT, this.preferences.chatWidth ?? this.defaultWidth(width)));
|
|
455
|
-
const activityWidth = this.
|
|
470
|
+
const activityWidth = this.zoom || this.preferences.layout === "rows" ? width : width - chatWidth - 1;
|
|
456
471
|
const chatSearch = this.search?.pane === "chat" ? PANEL_SEARCH_ROWS : 0;
|
|
457
472
|
const activitySearch = this.search?.pane === "activity" ? PANEL_SEARCH_ROWS : 0;
|
|
458
473
|
const chatMin = Math.max(MIN_ROWS + chatSearch, chatHeader.render(Math.max(1, chatWidth)).length + 1);
|
|
459
474
|
const activityMin = Math.max(MIN_ROWS + activitySearch, activityHeader.render(Math.max(1, activityWidth)).length + 1);
|
|
460
|
-
|
|
475
|
+
// A Pi window shown in combined history counts as not fitting: Pi's own history and dock take the screen.
|
|
476
|
+
const fits = !combinedWindow && (this.zoom ? width >= MIN_CHAT && historyHeight >= (this.zoom === "chat" ? chatMin : activityMin) :
|
|
461
477
|
this.preferences.layout === "columns" ? width >= MIN_CHAT + MIN_ACTIVITY + 1 && historyHeight >= Math.max(chatMin, activityMin) :
|
|
462
|
-
width >= MIN_CHAT && historyHeight >= chatMin + activityMin + 1;
|
|
478
|
+
width >= MIN_CHAT && historyHeight >= chatMin + activityMin + 1);
|
|
463
479
|
this.fallback = this.preferences.mode === "split" && !fits;
|
|
464
480
|
projectSurface = candidate && fits;
|
|
465
481
|
if (this.search && (this.fallback || this.failed || this.preferences.mode !== "split" ||
|
|
466
|
-
(this.
|
|
482
|
+
(this.zoom && this.zoom !== this.search.pane))) this.closeSearch(false);
|
|
467
483
|
this.searchShortcut.sync(!this.failed && this.preferences.mode === "split" && fits);
|
|
468
484
|
if (this.failed) return false;
|
|
469
485
|
try {
|
|
@@ -474,7 +490,7 @@ export class TranscriptLayout {
|
|
|
474
490
|
const widgetWidth = activityWidth;
|
|
475
491
|
const chatLimit = Math.max(chatMin, Math.min((this.preferences.chatHeight ?? this.automaticHeight) + chatSearch,
|
|
476
492
|
historyHeight - activityMin - 1));
|
|
477
|
-
const activityHeight = this.
|
|
493
|
+
const activityHeight = this.zoom || this.preferences.layout === "columns" ? historyHeight :
|
|
478
494
|
historyHeight - 1 - Math.min(chatLimit, Math.max(chatMin, chatPane.render(width).length));
|
|
479
495
|
// Do not clip opaque interactive surfaces: their own wheel handlers may consume scrolling.
|
|
480
496
|
// If the entire surface cannot fit, leave Pi's original dock available instead.
|
|
@@ -511,7 +527,7 @@ export class TranscriptLayout {
|
|
|
511
527
|
), basis: TOOLBAR_BUTTON_WIDTH + 1, minSize: TOOLBAR_BUTTON_WIDTH, shrink: 1 },
|
|
512
528
|
{ component: this.button(
|
|
513
529
|
() => this.preferences.buttonStyle === "icons" ? (this.preferences.layout === "columns" ? "↔" : "↕") : "Swap", () => this.swap(),
|
|
514
|
-
() => this.preferences.mode === "split" && !this.
|
|
530
|
+
() => this.preferences.mode === "split" && !this.zoom && !this.fallback && !this.failed,
|
|
515
531
|
), basis: TOOLBAR_BUTTON_WIDTH + 1, minSize: TOOLBAR_BUTTON_WIDTH, shrink: 1 },
|
|
516
532
|
{ component: this.button(() => this.preferences.buttonStyle === "icons" ? "≡" : "Settings", this.openSettings), basis: TOOLBAR_BUTTON_WIDTH, shrink: 0 },
|
|
517
533
|
], [
|
|
@@ -559,8 +575,9 @@ export class TranscriptLayout {
|
|
|
559
575
|
this.openSearch(target);
|
|
560
576
|
}, () => true, () => palette().fill), basis: TOOLBAR_BUTTON_WIDTH + 1, minSize: TOOLBAR_BUTTON_WIDTH, shrink: 1 },
|
|
561
577
|
{ component: this.button(
|
|
562
|
-
() => this.
|
|
563
|
-
|
|
578
|
+
() => this.zoom === target ? (this.preferences.buttonStyle === "icons" ? "↙" : "Restore") : (this.preferences.buttonStyle === "icons" ? "↗" : "Maximize"),
|
|
579
|
+
// A Pi window's temporary zoom ends when the window closes, not by Restore.
|
|
580
|
+
() => this.maximize(target), () => !this.piWindow, () => palette().fill,
|
|
564
581
|
), basis: 5, shrink: 0 },
|
|
565
582
|
], target === "activity" ? [
|
|
566
583
|
{ index: 1, icon: 6 },
|
|
@@ -574,7 +591,7 @@ export class TranscriptLayout {
|
|
|
574
591
|
headers.push(label);
|
|
575
592
|
const header = new VStack([
|
|
576
593
|
{ component: line, basis: 1, shrink: 0, visible: () =>
|
|
577
|
-
this.
|
|
594
|
+
this.zoom !== null || this.preferences.layout === "columns" ||
|
|
578
595
|
(this.preferences.side === "left" ? target === "chat" : target === "activity") },
|
|
579
596
|
{ component: label, basis: "auto", shrink: 0 },
|
|
580
597
|
{ component: line, basis: 1, shrink: 0 },
|
|
@@ -645,7 +662,7 @@ export class TranscriptLayout {
|
|
|
645
662
|
this.rebuild();
|
|
646
663
|
const surface = new SplitSurface(host, {
|
|
647
664
|
model: () => {
|
|
648
|
-
const zoom = this.
|
|
665
|
+
const zoom = this.zoom;
|
|
649
666
|
if (zoom) return { component: zoom === "chat" ? chatPane : activityPane, fill: false, minSize: MIN_ROWS };
|
|
650
667
|
return this.preferences.layout === "columns" ? { component: columns, fill: true, minSize: 1 } : { component: rows, fill: false, minSize: 1 };
|
|
651
668
|
},
|
|
@@ -745,7 +762,8 @@ export class TranscriptLayout {
|
|
|
745
762
|
/** Scroll the other panel to the same point of history as a block, returning from a zoomed panel first. */
|
|
746
763
|
async goTo(from: Pane, source: Component): Promise<void> {
|
|
747
764
|
const target = this.index?.counterpart(source, from);
|
|
748
|
-
|
|
765
|
+
// The other panel stays hidden while a Pi window maximizes Activity.
|
|
766
|
+
if (!target || !this.searchPane() || this.piWindow) return;
|
|
749
767
|
const pane: Pane = from === "chat" ? "activity" : "chat";
|
|
750
768
|
if (this.preferences.zoom) {
|
|
751
769
|
this.preferences.zoom = null;
|
|
@@ -773,7 +791,7 @@ export class TranscriptLayout {
|
|
|
773
791
|
searchPane(): Pane | undefined {
|
|
774
792
|
if (!this.host || this.host.layoutRoot !== this.mounted || this.failed || this.fallback ||
|
|
775
793
|
this.preferences.mode !== "split") return undefined;
|
|
776
|
-
return this.
|
|
794
|
+
return this.zoom ?? this.activePane;
|
|
777
795
|
}
|
|
778
796
|
|
|
779
797
|
/** Offer block copying only from a currently visible split panel. */
|
|
@@ -919,6 +937,12 @@ export class TranscriptLayout {
|
|
|
919
937
|
this.changed();
|
|
920
938
|
}
|
|
921
939
|
|
|
940
|
+
/** Choose how Pi's own windows open while the panels are side by side. */
|
|
941
|
+
setPiWindows(piWindows: Preferences["piWindows"]): void {
|
|
942
|
+
this.preferences.piWindows = piWindows;
|
|
943
|
+
this.changed();
|
|
944
|
+
}
|
|
945
|
+
|
|
922
946
|
/** Show or hide clock rows without changing their recorded source times. */
|
|
923
947
|
setTimestamps(show: boolean): void {
|
|
924
948
|
this.preferences.showTimestamps = show;
|
|
@@ -983,7 +1007,7 @@ export class TranscriptLayout {
|
|
|
983
1007
|
}
|
|
984
1008
|
|
|
985
1009
|
private currentHeight(): number {
|
|
986
|
-
if (this.preferences.layout === "rows" && !this.
|
|
1010
|
+
if (this.preferences.layout === "rows" && !this.zoom && this.chat?.viewportHeight) {
|
|
987
1011
|
return this.chat.viewportHeight + (this.preferences.side === "left" ? 3 : 2);
|
|
988
1012
|
}
|
|
989
1013
|
return this.preferences.chatHeight ?? this.automaticHeight;
|
|
@@ -1036,7 +1060,7 @@ export class TranscriptLayout {
|
|
|
1036
1060
|
/** Cycle keyboard scrolling and search to the other panel. */
|
|
1037
1061
|
cyclePanel(): void {
|
|
1038
1062
|
const pane = this.searchPane();
|
|
1039
|
-
if (!pane || this.
|
|
1063
|
+
if (!pane || this.zoom) return;
|
|
1040
1064
|
this.activate(pane === "chat" ? "activity" : "chat");
|
|
1041
1065
|
}
|
|
1042
1066
|
|
|
@@ -1068,6 +1092,7 @@ export class TranscriptLayout {
|
|
|
1068
1092
|
this.index = undefined;
|
|
1069
1093
|
this.hoverAct = undefined;
|
|
1070
1094
|
this.moving = undefined;
|
|
1095
|
+
this.piWindow = undefined;
|
|
1071
1096
|
this.drag = undefined;
|
|
1072
1097
|
this.rebuild = () => {};
|
|
1073
1098
|
}
|
package/src/native.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface DocumentTurns {
|
|
|
40
40
|
|
|
41
41
|
/** Decorate one selected block without changing native text or mouse coordinates. */
|
|
42
42
|
class SearchHighlight implements Component {
|
|
43
|
-
private cache?: { lines: string[]; result: string[]; width: number; query: string; hit: SearchHit; revision: number };
|
|
43
|
+
private cache?: { lines: readonly string[]; result: readonly string[]; width: number; query: string; hit: SearchHit; revision: number };
|
|
44
44
|
|
|
45
45
|
constructor(
|
|
46
46
|
private readonly component: Component,
|
|
@@ -50,7 +50,7 @@ class SearchHighlight implements Component {
|
|
|
50
50
|
private readonly revision: () => number,
|
|
51
51
|
) {}
|
|
52
52
|
|
|
53
|
-
render(width: number): string[] {
|
|
53
|
+
render(width: number): readonly string[] {
|
|
54
54
|
const lines = this.component.render(width);
|
|
55
55
|
const hit = this.hit();
|
|
56
56
|
const query = this.query();
|
|
@@ -166,7 +166,7 @@ export class NativeDocument extends Container {
|
|
|
166
166
|
private searchTool?: Component;
|
|
167
167
|
private readonly clockOwners = new WeakMap<Component, Component>();
|
|
168
168
|
private readonly compactBlocks = new Map<Component, CompactMessage>();
|
|
169
|
-
private readonly positions = new Map<Component, { row: number; lines: string[]; clock?: SearchClock; excerptRow?: number }>();
|
|
169
|
+
private readonly positions = new Map<Component, { row: number; lines: readonly string[]; clock?: SearchClock; excerptRow?: number }>();
|
|
170
170
|
private excerpt?: SearchHit;
|
|
171
171
|
private searchAnchor?: SearchHit;
|
|
172
172
|
private searchQuery = "";
|
package/src/nested-tree.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface Node { key: string; summary: ToolSummary; children: Node[]; count?: nu
|
|
|
12
12
|
|
|
13
13
|
/** Structural disclosure only: every result body is the original native component. */
|
|
14
14
|
export class NestedTree extends Container {
|
|
15
|
-
readonly positions = new Map<Component, { row: number; lines: string[]; clock?: SearchClock; excerptRow?: number }>();
|
|
15
|
+
readonly positions = new Map<Component, { row: number; lines: readonly string[]; clock?: SearchClock; excerptRow?: number }>();
|
|
16
16
|
private parent?: NativeTreeBody;
|
|
17
17
|
private panels: NativeTreeBody[] = [];
|
|
18
18
|
private reveal?: Component;
|
|
@@ -56,7 +56,7 @@ export class NestedTree extends Container {
|
|
|
56
56
|
}
|
|
57
57
|
return row;
|
|
58
58
|
}
|
|
59
|
-
override render(width: number): string[] {
|
|
59
|
+
override render(width: number): readonly string[] {
|
|
60
60
|
if (!this.parent) return [];
|
|
61
61
|
if (this.mode !== this.compact()) { this.open.clear(); this.mode = this.compact(); }
|
|
62
62
|
this.revealed.clear();
|
|
@@ -128,7 +128,7 @@ export class NestedTree extends Container {
|
|
|
128
128
|
const result: Component[] = [];
|
|
129
129
|
this.positions.clear();
|
|
130
130
|
let row = 0;
|
|
131
|
-
const append = (component: Component, depth: number, body = false): string[] => {
|
|
131
|
+
const append = (component: Component, depth: number, body = false): readonly string[] => {
|
|
132
132
|
const view = this.indent(component, depth, body);
|
|
133
133
|
result.push(view);
|
|
134
134
|
const lines = view.render(width); row += lines.length; return lines;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as pi from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
3
|
+
|
|
4
|
+
type Matcher = (component: Component) => boolean;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Match components by class. Pi's bundle keeps class names, so a name matches even a class Pi does not export and a
|
|
8
|
+
* component built by another copy of Pi's package; `instanceof` against the exported classes also matches subclasses.
|
|
9
|
+
*/
|
|
10
|
+
function byClass(names: readonly string[]): Matcher {
|
|
11
|
+
const known = new Set(names);
|
|
12
|
+
// A namespace import keeps the extension loading on Pi versions that lack one of these exports.
|
|
13
|
+
const exported = names.map(name => (pi as Record<string, unknown>)[name])
|
|
14
|
+
.filter((value): value is abstract new (...args: never[]) => unknown => typeof value === "function");
|
|
15
|
+
return component => exported.some(type => component instanceof type) || known.has(component.constructor.name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Pi's own windows, such as the session tree, model and session pickers, settings and the `/login` menu. Pi opens them
|
|
20
|
+
* only for the user: by command, double Escape or key binding. `TrustSelectorComponent`, `ScopedModelsSelectorComponent`
|
|
21
|
+
* and `RadiusLoginMenuComponent` are not exported and match by name.
|
|
22
|
+
*/
|
|
23
|
+
const piWindow = byClass([
|
|
24
|
+
"TreeSelectorComponent", "UserMessageSelectorComponent", "SessionSelectorComponent", "ModelSelectorComponent",
|
|
25
|
+
"ScopedModelsSelectorComponent", "SettingsSelectorComponent", "ThemeSelectorComponent", "ThinkingSelectorComponent",
|
|
26
|
+
"ShowImagesSelectorComponent", "TrustSelectorComponent", "OAuthSelectorComponent", "LoginDialogComponent",
|
|
27
|
+
"RadiusLoginMenuComponent",
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Pi's general dialogs. Pi asks its windows' follow-up questions in them, such as "Summarize branch?" after a tree
|
|
32
|
+
* selection or a login prompt, and extensions open them through `ctx.ui.select`, `input` and `editor`.
|
|
33
|
+
*/
|
|
34
|
+
const generalDialog = byClass(["ExtensionSelectorComponent", "ExtensionInputComponent", "ExtensionEditorComponent"]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether Pi's editor slot shows one of Pi's own windows or a chain of windows that one started. Pi swaps a window for
|
|
38
|
+
* its follow-up question within one tick, so the message editor never reaches a frame in between; `previous` is this
|
|
39
|
+
* result for the previous frame. A general dialog that replaces a Pi window directly continues the chain, even an
|
|
40
|
+
* extension's `select`, which then shows at full width as well. Extension dialogs opened over the message editor,
|
|
41
|
+
* including the agent's questions through `ask_user` and tool confirmations, never count: Stereo cannot tell whether
|
|
42
|
+
* the user or the agent opened them.
|
|
43
|
+
*/
|
|
44
|
+
export function showsPiWindow(component: Component | undefined, previous: boolean): boolean {
|
|
45
|
+
return !!component && (piWindow(component) || (previous && generalDialog(component)));
|
|
46
|
+
}
|
package/src/preferences.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface Preferences {
|
|
|
51
51
|
turnHover: boolean;
|
|
52
52
|
/** How a block opens the same point of history in the other panel. */
|
|
53
53
|
goTo: GoTo;
|
|
54
|
+
/** How Pi's own windows, such as the session tree, open while the panels are side by side. */
|
|
55
|
+
piWindows: PiWindows;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
export type TurnStripe = "off" | "block" | "line";
|
|
@@ -60,12 +62,18 @@ export type TurnMarkSetting = "turns" | "turnClock" | "turnStripe" | "turnBackgr
|
|
|
60
62
|
export type GoTo = "clock" | "button" | "both" | "off";
|
|
61
63
|
export const TURN_STRIPES: readonly TurnStripe[] = ["off", "block", "line"];
|
|
62
64
|
export const GO_TO: readonly GoTo[] = ["clock", "button", "both", "off"];
|
|
65
|
+
/**
|
|
66
|
+
* `combined` shows Pi's single history with the window at full width, `maximize` gives Activity the whole screen,
|
|
67
|
+
* `inline` keeps the window under Activity like extension dialogs.
|
|
68
|
+
*/
|
|
69
|
+
export type PiWindows = "combined" | "maximize" | "inline";
|
|
70
|
+
export const PI_WINDOWS: readonly PiWindows[] = ["combined", "maximize", "inline"];
|
|
63
71
|
|
|
64
72
|
export const defaults: Preferences = {
|
|
65
73
|
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",
|
|
66
74
|
// Strengths chosen on dark and light terminals; one gray hover reads as "this turn" without competing with turn hues.
|
|
67
75
|
turns: true, turnClock: true, turnStripe: "block", turnBackground: false, turnSeparator: true,
|
|
68
|
-
turnClockMix: 10, turnStripeMix: 20, turnBackgroundMix: 8, turnHoverMix: 10, turnHoverColor: "#808080", turnHover: true, goTo: "both",
|
|
76
|
+
turnClockMix: 10, turnStripeMix: 20, turnBackgroundMix: 8, turnHoverMix: 10, turnHoverColor: "#808080", turnHover: true, goTo: "both", piWindows: "combined",
|
|
69
77
|
};
|
|
70
78
|
|
|
71
79
|
/** One-color hover choices offered in settings besides each turn's own hue; any `#rrggbb` can be typed in. */
|
|
@@ -111,6 +119,7 @@ export async function loadPreferences(file: string): Promise<Preferences> {
|
|
|
111
119
|
const turnHoverColor = record.turnHoverColor === undefined ? defaults.turnHoverColor : record.turnHoverColor;
|
|
112
120
|
const turnHover = record.turnHover === undefined ? defaults.turnHover : record.turnHover;
|
|
113
121
|
const goTo = record.goTo === undefined ? defaults.goTo : record.goTo;
|
|
122
|
+
const piWindows = record.piWindows === undefined ? defaults.piWindows : record.piWindows;
|
|
114
123
|
if ((record.side !== "left" && record.side !== "right") ||
|
|
115
124
|
(record.chatWidth !== null && (typeof record.chatWidth !== "number" || !Number.isInteger(record.chatWidth) ||
|
|
116
125
|
record.chatWidth < 24 || record.chatWidth > 240)) ||
|
|
@@ -122,13 +131,13 @@ export async function loadPreferences(file: string): Promise<Preferences> {
|
|
|
122
131
|
(buttonStyle !== "icons" && buttonStyle !== "text") || typeof turns !== "boolean" || typeof turnClock !== "boolean" ||
|
|
123
132
|
!TURN_STRIPES.includes(turnStripe as TurnStripe) || typeof turnBackground !== "boolean" || typeof turnSeparator !== "boolean" ||
|
|
124
133
|
!validMix(turnClockMix) || !validMix(turnStripeMix) || !validMix(turnBackgroundMix) || !validMix(turnHoverMix) || !validHoverColor(turnHoverColor) ||
|
|
125
|
-
typeof turnHover !== "boolean" || !GO_TO.includes(goTo as GoTo)) {
|
|
134
|
+
typeof turnHover !== "boolean" || !GO_TO.includes(goTo as GoTo) || !PI_WINDOWS.includes(piWindows as PiWindows)) {
|
|
126
135
|
throw new Error("Invalid pi-stereo-view preferences");
|
|
127
136
|
}
|
|
128
137
|
// Legacy files may contain mode/zoom. Every session starts with both panels visible.
|
|
129
138
|
return { mode: "split", side: record.side, chatWidth: record.chatWidth, layout, chatHeight, zoom: null, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle,
|
|
130
139
|
turns, turnClock, turnStripe: turnStripe as TurnStripe, turnBackground, turnSeparator, turnClockMix, turnStripeMix, turnBackgroundMix, turnHoverMix,
|
|
131
|
-
turnHoverColor: turnHoverColor.toLowerCase(), turnHover, goTo: goTo as GoTo };
|
|
140
|
+
turnHoverColor: turnHoverColor.toLowerCase(), turnHover, goTo: goTo as GoTo, piWindows: piWindows as PiWindows };
|
|
132
141
|
}
|
|
133
142
|
|
|
134
143
|
/** Atomically save only the display settings, never session messages. */
|
|
@@ -137,9 +146,9 @@ export async function savePreferences(file: string, preferences: Preferences): P
|
|
|
137
146
|
const temporary = file + "." + randomUUID() + ".tmp";
|
|
138
147
|
try {
|
|
139
148
|
const { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle,
|
|
140
|
-
turns, turnClock, turnStripe, turnBackground, turnSeparator, turnClockMix, turnStripeMix, turnBackgroundMix, turnHoverMix, turnHoverColor, turnHover, goTo } = preferences;
|
|
149
|
+
turns, turnClock, turnStripe, turnBackground, turnSeparator, turnClockMix, turnStripeMix, turnBackgroundMix, turnHoverMix, turnHoverColor, turnHover, goTo, piWindows } = preferences;
|
|
141
150
|
const saved = { side, chatWidth, layout, chatHeight, showTimestamps, showCopyButtons, compactTools, groupTools, nestedTree, streamTools, streamDelay, buttonStyle,
|
|
142
|
-
turns, turnClock, turnStripe, turnBackground, turnSeparator, turnClockMix, turnStripeMix, turnBackgroundMix, turnHoverMix, turnHoverColor, turnHover, goTo };
|
|
151
|
+
turns, turnClock, turnStripe, turnBackground, turnSeparator, turnClockMix, turnStripeMix, turnBackgroundMix, turnHoverMix, turnHoverColor, turnHover, goTo, piWindows };
|
|
143
152
|
await writeFile(temporary, JSON.stringify(saved, null, 2) + "\n", { mode: 0o600 });
|
|
144
153
|
await rename(temporary, file);
|
|
145
154
|
} finally {
|
package/src/render-cache.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { stripTerminalSequences, type Component } from "@earendil-works/pi-tui";
|
|
|
2
2
|
|
|
3
3
|
const imagePlacement = (line: string): boolean => line.includes("\x1b_G") || line.includes("\x1b]1337;File=");
|
|
4
4
|
|
|
5
|
-
function nativeLines(component: Component, width: number): string[] {
|
|
5
|
+
function nativeLines(component: Component, width: number): readonly string[] {
|
|
6
6
|
const lines = component.render(width);
|
|
7
7
|
const tool = component as Component & {
|
|
8
8
|
toolDefinition?: { renderShell?: string; renderCall?: unknown; renderResult?: unknown };
|
|
@@ -166,7 +166,7 @@ export class NativeRenderCache {
|
|
|
166
166
|
private imagePlacement = false;
|
|
167
167
|
private readonly changed = (): void => { this.invalidations++; this.cached = undefined; this.notify?.(); };
|
|
168
168
|
private readonly watched = new Map<Component, () => void>();
|
|
169
|
-
private cached?: { width: number; theme: object; state: State; lines: string[] };
|
|
169
|
+
private cached?: { width: number; theme: object; state: State; lines: readonly string[] };
|
|
170
170
|
|
|
171
171
|
/** notify runs when an observed native node invalidates, before the next render. */
|
|
172
172
|
constructor(private readonly component: Component, private readonly notify?: () => void) {}
|
|
@@ -206,7 +206,7 @@ export class NativeRenderCache {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/** Render current native state, or reuse only an unchanged, observable block. */
|
|
209
|
-
render(width: number, theme: object): string[] {
|
|
209
|
+
render(width: number, theme: object): readonly string[] {
|
|
210
210
|
const cached = this.cached;
|
|
211
211
|
if (cached?.width === width && cached.theme === theme && matches(this.component, cached.state)) return cached.lines;
|
|
212
212
|
this.cached = undefined;
|
package/src/search-highlight.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface Position { row: number; start: number; end: number }
|
|
|
20
20
|
/** Presentation-only rows supplied by CompactMessage, never guessed from saved text. */
|
|
21
21
|
export interface SearchClock { row: number; column: number; footerRow?: number }
|
|
22
22
|
|
|
23
|
-
function locate(lines: string[], hit: SearchHit, lettersOnly: boolean, clock?: SearchClock): { text: string; positions: Position[] } | undefined {
|
|
23
|
+
function locate(lines: readonly string[], hit: SearchHit, lettersOnly: boolean, clock?: SearchClock): { text: string; positions: Position[] } | undefined {
|
|
24
24
|
const wanted = normalize(hit.text, lettersOnly);
|
|
25
25
|
if (!wanted) return undefined;
|
|
26
26
|
let text = "";
|
|
@@ -55,7 +55,7 @@ function locate(lines: string[], hit: SearchHit, lettersOnly: boolean, clock?: S
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** Locate the exact saved occurrence using the same mapping as its highlight. */
|
|
58
|
-
export function searchHitRow(lines: string[], hit: SearchHit, clock?: SearchClock): number | undefined {
|
|
58
|
+
export function searchHitRow(lines: readonly string[], hit: SearchHit, clock?: SearchClock): number | undefined {
|
|
59
59
|
return (locate(lines, hit, false, clock) ?? locate(lines, hit, true, clock))?.positions[0]?.row;
|
|
60
60
|
}
|
|
61
61
|
function decorate(line: string, selected: Position[], theme: Theme): string {
|
|
@@ -95,7 +95,7 @@ function decorate(line: string, selected: Position[], theme: Theme): string {
|
|
|
95
95
|
* widths, links and markers stay unchanged; images and unmapped fragments are skipped.
|
|
96
96
|
* No query parsing or matching happens during rendering.
|
|
97
97
|
*/
|
|
98
|
-
export function highlightSearchRows(lines: string[], hit: SearchHit, theme: Theme, clock?: SearchClock): string[] {
|
|
98
|
+
export function highlightSearchRows(lines: readonly string[], hit: SearchHit, theme: Theme, clock?: SearchClock): readonly string[] {
|
|
99
99
|
if (!hit.ranges?.length || lines.some(line => line.includes("\x1b_G") || line.includes("\x1b]1337;") || line.includes("\x1bP"))) return lines;
|
|
100
100
|
let lettersOnly = false;
|
|
101
101
|
let found = locate(lines, hit, false, clock);
|
package/src/steady-settings.ts
CHANGED
|
@@ -6,13 +6,23 @@ const HINT_ROWS = 2;
|
|
|
6
6
|
const PI_HINT = "Enter/Space to change";
|
|
7
7
|
const ARROW_HINT = "←/→ or Enter/Space to change";
|
|
8
8
|
|
|
9
|
+
/** Group titles by the id of the setting each group starts with, and how a title looks. */
|
|
10
|
+
export interface SettingGroups {
|
|
11
|
+
titles: ReadonlyMap<string, string>;
|
|
12
|
+
style(title: string): string;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
/**
|
|
10
|
-
* Keep a settings list at one height
|
|
16
|
+
* Keep a settings list at one height, show group titles, and step values with the arrow keys.
|
|
11
17
|
*
|
|
12
18
|
* Pi's list shows the selected item's description between the items and the key hint, so its height follows the
|
|
13
19
|
* description's length; a centered overlay then jumps. Blank rows before the hint make every selection as tall as
|
|
14
20
|
* the one with the longest description. Left and Right pick the previous or next value, wrapping around at either
|
|
15
21
|
* end like Enter and Space, so a strength can be tuned in both directions.
|
|
22
|
+
*
|
|
23
|
+
* Pi's list has no group titles. While it shows every item, its item rows are the items in order, so a title and a
|
|
24
|
+
* blank row before it are inserted above a group's first item; the selection never lands on them, and pointer rows are
|
|
25
|
+
* mapped back to the list's own rows.
|
|
16
26
|
*/
|
|
17
27
|
export class SteadySettings implements Component {
|
|
18
28
|
private measured?: { width: number; rows: number };
|
|
@@ -22,29 +32,56 @@ export class SteadySettings implements Component {
|
|
|
22
32
|
private readonly items: readonly SettingItem[],
|
|
23
33
|
private readonly visible: number,
|
|
24
34
|
private readonly change: (id: string, value: string) => void,
|
|
35
|
+
private readonly groups?: SettingGroups,
|
|
25
36
|
) {}
|
|
26
37
|
|
|
27
|
-
render(width: number): string[] {
|
|
38
|
+
render(width: number): readonly string[] {
|
|
28
39
|
const rows = this.rows(width);
|
|
29
40
|
// A submenu, such as a color input, keeps the list's height too: blank rows follow it.
|
|
30
41
|
if (this.submenuOpen()) {
|
|
31
42
|
const lines = this.list.render(width);
|
|
32
43
|
return lines.length >= rows ? lines : [...lines, ...Array<string>(rows - lines.length).fill("")];
|
|
33
44
|
}
|
|
34
|
-
const lines = this.list.render(width).map(line => line.replace(PI_HINT, ARROW_HINT));
|
|
45
|
+
const lines = this.withTitles(this.list.render(width).map(line => line.replace(PI_HINT, ARROW_HINT)));
|
|
35
46
|
// A list taller than measured renders as it is.
|
|
36
47
|
if (lines.length >= rows) return lines;
|
|
37
48
|
const cut = Math.max(0, lines.length - HINT_ROWS);
|
|
38
49
|
return [...lines.slice(0, cut), ...Array<string>(rows - lines.length).fill(""), ...lines.slice(cut)];
|
|
39
50
|
}
|
|
40
51
|
|
|
52
|
+
/** Each item's row in the rendered list, or undefined while the list scrolls and has no titles. */
|
|
53
|
+
private itemRows(): number[] | undefined {
|
|
54
|
+
if (!this.groups || this.items.length > this.visible) return undefined;
|
|
55
|
+
let row = 0;
|
|
56
|
+
return this.items.map((item, index) => {
|
|
57
|
+
if (this.groups?.titles.has(item.id)) row += index === 0 ? 1 : 2;
|
|
58
|
+
return row++;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private withTitles(lines: readonly string[]): readonly string[] {
|
|
63
|
+
const groups = this.groups;
|
|
64
|
+
if (!groups || !this.itemRows()) return lines;
|
|
65
|
+
const result: string[] = [];
|
|
66
|
+
this.items.forEach((item, index) => {
|
|
67
|
+
const title = groups.titles.get(item.id);
|
|
68
|
+
if (title !== undefined) {
|
|
69
|
+
if (index > 0) result.push("");
|
|
70
|
+
result.push(groups.style(title));
|
|
71
|
+
}
|
|
72
|
+
result.push(lines[index] ?? "");
|
|
73
|
+
});
|
|
74
|
+
return [...result, ...lines.slice(this.items.length)];
|
|
75
|
+
}
|
|
76
|
+
|
|
41
77
|
/** The list's height with the longest description, as Pi's list lays it out at this width. */
|
|
42
78
|
private rows(width: number): number {
|
|
43
79
|
if (this.measured?.width === width) return this.measured.rows;
|
|
44
80
|
const shown = Math.min(this.visible, this.items.length);
|
|
45
81
|
const scroll = this.items.length > this.visible ? 1 : 0;
|
|
82
|
+
const titles = (this.itemRows()?.at(-1) ?? shown - 1) + 1 - shown;
|
|
46
83
|
const description = Math.max(0, ...this.items.map(item => item.description ? 1 + wrapTextWithAnsi(item.description, width - 4).length : 0));
|
|
47
|
-
const rows = shown + scroll + description + HINT_ROWS;
|
|
84
|
+
const rows = shown + titles + scroll + description + HINT_ROWS;
|
|
48
85
|
this.measured = { width, rows };
|
|
49
86
|
return rows;
|
|
50
87
|
}
|
|
@@ -72,6 +109,17 @@ export class SteadySettings implements Component {
|
|
|
72
109
|
this.change(item.id, next);
|
|
73
110
|
}
|
|
74
111
|
|
|
75
|
-
handleMouse(event: TuiMouseEvent): ReturnType<NonNullable<Component["handleMouse"]>> {
|
|
112
|
+
handleMouse(event: TuiMouseEvent): ReturnType<NonNullable<Component["handleMouse"]>> {
|
|
113
|
+
const rows = this.itemRows();
|
|
114
|
+
if (!rows || this.submenuOpen()) return this.list.handleMouse(event);
|
|
115
|
+
const last = rows.at(-1) ?? -1;
|
|
116
|
+
// Rows below the items, such as the description, shift up by the titles above them.
|
|
117
|
+
if (event.y > last) return this.list.handleMouse({ ...event, y: event.y - (last + 1 - this.items.length) });
|
|
118
|
+
const item = rows.indexOf(event.y);
|
|
119
|
+
// A title or a blank row between groups is not a setting.
|
|
120
|
+
if (item < 0) return event.type === "wheel" ? this.list.handleMouse(event) : undefined;
|
|
121
|
+
return this.list.handleMouse({ ...event, y: item });
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
invalidate(): void { this.measured = undefined; this.list.invalidate(); }
|
|
77
125
|
}
|
package/src/surface.ts
CHANGED
|
@@ -26,9 +26,9 @@ type LayoutNode =
|
|
|
26
26
|
| { type: "scroll"; component: Component; state: ScrollView };
|
|
27
27
|
interface Box {
|
|
28
28
|
component: Component; rect: Rect; clip: Rect; children: Box[];
|
|
29
|
-
lines?: string[]; lineOffset?: number; scrollView?: ScrollView; scrollContentLines?: string[];
|
|
29
|
+
lines?: readonly string[]; lineOffset?: number; scrollView?: ScrollView; scrollContentLines?: readonly string[];
|
|
30
30
|
}
|
|
31
|
-
interface Context { viewport: Viewport; cache: Map<Component, Map<number, string[]>>; requestRender: () => void; scrolls: Map<ScrollView, Box> }
|
|
31
|
+
interface Context { viewport: Viewport; cache: Map<Component, Map<number, readonly string[]>>; requestRender: () => void; scrolls: Map<ScrollView, Box> }
|
|
32
32
|
interface Segment { x: number; width: number; line: string; raw?: boolean; background?: boolean }
|
|
33
33
|
interface Geometry { column: number; trackTop: number; trackHeight: number; thumbTop: number; thumbHeight: number; maxScrollTop: number }
|
|
34
34
|
interface Frame { width: number; height: number; root: Box; lines: string[]; scrolls: Map<ScrollView, Box>; indicator?: { row: number; column: number; width: number } }
|
|
@@ -52,7 +52,7 @@ function contains(rect: Rect, x: number, y: number): boolean {
|
|
|
52
52
|
return x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function rendered(context: Context, component: Component, width: number): string[] {
|
|
55
|
+
function rendered(context: Context, component: Component, width: number): readonly string[] {
|
|
56
56
|
const safeWidth = Math.max(1, Math.floor(width));
|
|
57
57
|
let widths = context.cache.get(component);
|
|
58
58
|
if (!widths) { widths = new Map(); context.cache.set(component, widths); }
|
|
@@ -251,7 +251,7 @@ function highlightSelection(text: string): string {
|
|
|
251
251
|
|
|
252
252
|
/** One scroll position for Pi's keyboard scrolling, prompt jumps and follow-end: the active split panel's. */
|
|
253
253
|
export class ActivePaneScrollView extends ScrollView {
|
|
254
|
-
constructor(private readonly target: () => ScrollView | undefined, lines: () => string[]) {
|
|
254
|
+
constructor(private readonly target: () => ScrollView | undefined, lines: () => readonly string[]) {
|
|
255
255
|
super({ render: () => lines(), invalidate() {} }, { follow: "end" });
|
|
256
256
|
Object.defineProperty(this, "primary", { value: true });
|
|
257
257
|
Object.defineProperty(this, "followEnd", { get: () => this.target()?.followEnd ?? false });
|
package/src/tool-indent.ts
CHANGED
|
@@ -9,8 +9,8 @@ export class ToolIndent extends Container {
|
|
|
9
9
|
this.prefix = " ".repeat(gutter) + " │".repeat(depth) + (body ? " " : "");
|
|
10
10
|
}
|
|
11
11
|
// Expanded runs are re-indented on every frame; reuse rows while the native rows are unchanged.
|
|
12
|
-
private cached?: { width: number; prefix: string; source: string[]; lines: string[] };
|
|
13
|
-
override render(width: number): string[] {
|
|
12
|
+
private cached?: { width: number; prefix: string; source: readonly string[]; lines: readonly string[] };
|
|
13
|
+
override render(width: number): readonly string[] {
|
|
14
14
|
const inset = Math.min(width, this.prefix.length);
|
|
15
15
|
const prefix = this.theme().fg("dim", this.prefix.slice(0, inset));
|
|
16
16
|
const source = super.render(Math.max(0, width - inset));
|