pi-stereo-view 0.1.12 → 0.1.13

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
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.1.13 - 2026-11-06
6
+
7
+ ### Changed
8
+
9
+ - Show native inline extension dialogs below Activity history alongside widgets. Keep message editors full width, explicit overlays unchanged and native placement available when the surface does not fit.
10
+ - Preserve an inline dialog's keyboard focus when pressing the panel search shortcut.
11
+
3
12
  ## 0.1.12 - 2026-11-04
4
13
 
5
14
  ### Changed
package/README.md CHANGED
@@ -29,7 +29,9 @@ Late output linked to a tool call appears directly below that call in Activity,
29
29
 
30
30
  Expand a parent tool such as Codemode to browse its nested call tree. Adjacent calls of the same tool form a group with individual call headers. Each independent native result opens under its call. A combined result covering several calls stays whole inside their group. Panels without child execution identities remain available inside the parent's output disclosure. Session restoration uses Pi's saved nested-call metadata and the original saved panels.
31
31
 
32
- Messages and tools keep their familiar appearance. Extension widgets appear at the bottom of Activity when they fit, below its independently scrolling history, while the input stays full width below both panels. If the widgets cannot fit without being clipped, the view temporarily returns to combined history and Pi's normal widget placement. Combined history and zoomed Conversation also keep normal widget placement.
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
+
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.
33
35
 
34
36
  ## Features
35
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-stereo-view",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "description": "Keep Pi conversation separate from tool output and agent activity.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import { TranscriptLayout } from "./layout.js";
5
5
  import { TOOL_START_ENTRY, TranscriptTimestamps } from "./timestamps.js";
6
6
  import { defaults, loadPreferences, savePreferences, type Preferences } from "./preferences.js";
7
7
  import { beforeFirstFrame } from "./startup.js";
8
+ import { observeNativeEditor } from "./native-editor.js";
8
9
  import { NestedCalls } from "./nested-calls.js";
9
10
 
10
11
  /** Split native fullscreen history without changing message content or the input dock. */
@@ -13,6 +14,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
13
14
  let host: TUI | undefined;
14
15
  let timestamps: TranscriptTimestamps | undefined;
15
16
  const nested = new NestedCalls();
17
+ const nativeEditor = observeNativeEditor();
16
18
  let unsubscribeInput: (() => void) | undefined;
17
19
  let writes = Promise.resolve();
18
20
  let preferences: Preferences = { ...defaults };
@@ -110,7 +112,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
110
112
  }
111
113
  void copyToClipboard(text).then(() => ui.notify("Block sent to clipboard.", "info"),
112
114
  error => ui.notify("Could not copy block: " + String(error), "error"));
113
- }, () => pi.getAllTools(), nested);
115
+ }, () => pi.getAllTools(), nested, () => nativeEditor.get(tui));
114
116
  try { ensureLayout(); }
115
117
  catch (error) {
116
118
  layout.dispose();
@@ -201,6 +203,7 @@ export default async function transcript(pi: ExtensionAPI): Promise<void> {
201
203
  pi.on("session_compact", (_event, ctx) => { closeSearch(); nested.restore(ctx.sessionManager.getBranch()); timestamps?.reset(); host?.requestRender(); });
202
204
  pi.on("session_shutdown", async () => {
203
205
  releaseStartup();
206
+ nativeEditor.dispose();
204
207
  closeSearch();
205
208
  unsubscribeInput?.();
206
209
  unsubscribeInput = undefined;
package/src/layout.ts CHANGED
@@ -35,7 +35,7 @@ class PanelScrollView extends ScrollView {
35
35
  return undefined;
36
36
  }
37
37
  }
38
- class WidgetScrollView extends ScrollView {
38
+ class NativeSurfaceScrollView extends ScrollView {
39
39
  override handleMouse(event: TuiMouseEvent): ReturnType<Container["handleMouse"]> {
40
40
  if (event.type !== "wheel" || !event.wheelDelta) return undefined;
41
41
  this.scrollBy(event.wheelDelta);
@@ -116,7 +116,7 @@ class TranscriptPane extends VStack {
116
116
  }
117
117
  }
118
118
 
119
- /** Own only guarded fullscreen history controls; never replace the input dock. */
119
+ /** Project native fullscreen history and transient surfaces without taking ownership of their lifecycle. */
120
120
  export class TranscriptLayout {
121
121
  private host?: NativeTui;
122
122
  private original?: Container;
@@ -151,6 +151,7 @@ export class TranscriptLayout {
151
151
  private readonly copy?: (text: string | undefined) => void,
152
152
  private readonly getTools: () => readonly ToolInfo[] = () => [],
153
153
  private readonly nested = new NestedCalls(),
154
+ private readonly getEditor: () => Component | undefined = () => undefined,
154
155
  ) {}
155
156
 
156
157
  private button(icon: () => string, action: () => void, enabled = (): boolean => true, background?: () => Color): Component {
@@ -213,16 +214,28 @@ export class TranscriptLayout {
213
214
  // Route only the known native dock shape. Keep the original untouched for fallback.
214
215
  const nativeDock = dock as unknown as { entries: Array<Exclude<StackChild, Component>>; children: Component[] };
215
216
  const entries = Array.isArray(nativeDock.entries) ? nativeDock.entries.map(entry => ({ ...entry })) : [];
216
- const supportedWidgets = entries.length === 6 && entries.every((entry, i) => entry.component === nativeDock.children[i]) &&
217
+ const supportedDock = entries.length === 6 && entries.every((entry, i) => entry.component === nativeDock.children[i]) &&
217
218
  [2, 4].every(i => entries[i].component.constructor.name === "Container") &&
218
219
  entries[3].minSize === 3;
219
- const above = supportedWidgets ? entries[2].component as Container : undefined;
220
- const below = supportedWidgets ? entries[4].component as Container : undefined;
221
- const projectedDock = supportedWidgets ? new VStack(entries.filter((_, i) => i !== 2 && i !== 4)) : undefined;
222
- const widgetTree = above && below ? new VStack([above, below]) : undefined;
223
- const widgetView = widgetTree ? new WidgetScrollView(widgetTree, { overscroll: "contain" }) : undefined;
220
+ const above = supportedDock ? entries[2].component as Container : undefined;
221
+ const below = supportedDock ? entries[4].component as Container : undefined;
222
+ const editorSlot = supportedDock && entries[3].component.constructor.name === "Container"
223
+ ? entries[3].component as Container : undefined;
224
+ let projectDialog = false;
225
+ const dialogPresent = (): boolean => {
226
+ const editor = this.getEditor();
227
+ return !!editor && !!editorSlot && editorSlot.children.length === 1 && editorSlot.children[0] !== editor;
228
+ };
229
+ const projectedDock = supportedDock ? new VStack(entries.filter((_, i) => i !== 2 && i !== 4).map(entry =>
230
+ entry.component === editorSlot ? { ...entry, visible: () => !projectDialog } : entry)) : undefined;
231
+ // Preserve the original containers and Pi's above/editor/below order. Pi still owns their lifecycle.
232
+ const surfaceTree = above && below ? new VStack([
233
+ above, ...(editorSlot ? [{ component: editorSlot, visible: () => projectDialog }] : []), below,
234
+ ]) : undefined;
235
+ const surfaceView = surfaceTree ? new NativeSurfaceScrollView(surfaceTree, { overscroll: "contain" }) : undefined;
224
236
  const widgetsPresent = (): boolean => !!above && !!below && (above.children.length > 1 || below.children.length > 0);
225
- const dockUnchanged = (): boolean => supportedWidgets && nativeDock.entries.length === 6 &&
237
+ const surfacePresent = (): boolean => widgetsPresent() || projectDialog;
238
+ const dockUnchanged = (): boolean => supportedDock && nativeDock.entries.length === 6 &&
226
239
  nativeDock.entries.every((entry, i) => entry.component === nativeDock.children[i] &&
227
240
  Object.keys({ ...entry, ...entries[i] }).every(key =>
228
241
  entry[key as keyof typeof entry] === entries[i][key as keyof typeof entry]));
@@ -256,11 +269,12 @@ export class TranscriptLayout {
256
269
  () => this.searchPane() === "activity");
257
270
  this.chat = new PanelScrollView(chatDocument, scrollOptions, () => this.activate("chat"), () => this.searchPane() === "chat");
258
271
  let historyHeight = 0;
259
- let projectWidgets = false;
272
+ let projectSurface = false;
260
273
  const shown = ({ width, height }: { width: number; height: number }): boolean => {
261
274
  const previousHeight = historyHeight;
262
- const candidate = !!projectedDock && widgetsPresent() && dockUnchanged() && !this.failed &&
275
+ const candidate = !!projectedDock && (widgetsPresent() || dialogPresent()) && dockUnchanged() && !this.failed &&
263
276
  this.preferences.mode === "split" && this.preferences.zoom !== "chat";
277
+ projectDialog = candidate && dialogPresent();
264
278
  historyHeight = Math.max(0, height - (candidate ? projectedDock : dock).render(width).length - 1);
265
279
  const search = this.search;
266
280
  if (search && previousHeight !== historyHeight) queueMicrotask(() => {
@@ -272,7 +286,7 @@ export class TranscriptLayout {
272
286
  this.preferences.layout === "columns" ? width >= MIN_CHAT + MIN_ACTIVITY + 1 && historyHeight >= MIN_ROWS + searchRows :
273
287
  width >= MIN_CHAT && historyHeight >= MIN_ROWS * 2 + 1 + searchRows;
274
288
  this.fallback = this.preferences.mode === "split" && !fits;
275
- projectWidgets = candidate && fits;
289
+ projectSurface = candidate && fits;
276
290
  if (this.search && (this.fallback || this.failed || this.preferences.mode !== "split" ||
277
291
  (this.preferences.zoom && this.preferences.zoom !== this.search.pane))) this.closeSearch(false);
278
292
  this.searchShortcut.sync(!this.failed && this.preferences.mode === "split" && fits);
@@ -281,7 +295,7 @@ export class TranscriptLayout {
281
295
  if (this.preferences.mode !== "split" || !fits) return false;
282
296
  // Both panels project the same native history and supported content kinds.
283
297
  activityDocument.check();
284
- if (projectWidgets && widgetTree && widgetsPresent()) {
298
+ if (projectSurface && surfaceTree && surfacePresent()) {
285
299
  const chatWidth = Math.min(width - MIN_ACTIVITY - 1,
286
300
  Math.max(MIN_CHAT, this.preferences.chatWidth ?? this.defaultWidth(width)));
287
301
  const widgetWidth = this.preferences.zoom === "activity" || this.preferences.layout === "rows"
@@ -294,11 +308,11 @@ export class TranscriptLayout {
294
308
  historyHeight - activityMin - 1));
295
309
  const activityHeight = this.preferences.zoom || this.preferences.layout === "columns" ? historyHeight :
296
310
  historyHeight - 1 - Math.min(chatLimit, Math.max(chatMin, chatPane.render(width).length));
297
- // Do not clip opaque interactive widgets: their own wheel handlers may consume scrolling.
311
+ // Do not clip opaque interactive surfaces: their own wheel handlers may consume scrolling.
298
312
  // If the entire surface cannot fit, leave Pi's original dock available instead.
299
313
  const budget = Math.max(0, activityHeight - 3 - activitySearch);
300
- if (widgetTree.render(widgetWidth).length > budget) {
301
- projectWidgets = false;
314
+ if (surfaceTree.render(widgetWidth).length > budget) {
315
+ projectSurface = false;
302
316
  this.fallback = true;
303
317
  return false;
304
318
  }
@@ -315,7 +329,7 @@ export class TranscriptLayout {
315
329
  historyHeight - activityMinimum - 1)), chatMinimum, activityMinimum);
316
330
  return true;
317
331
  } catch (error) {
318
- projectWidgets = false;
332
+ projectSurface = false;
319
333
  this.failed = true;
320
334
  this.searchShortcut.dispose();
321
335
  this.disposeDocuments?.();
@@ -391,7 +405,7 @@ export class TranscriptLayout {
391
405
  visible: () => this.search?.pane === target },
392
406
  ]);
393
407
  return new TranscriptPane(header, view, () => historyHeight,
394
- target === "activity" ? widgetView : undefined, () => projectWidgets && widgetsPresent());
408
+ target === "activity" ? surfaceView : undefined, () => projectSurface && surfacePresent());
395
409
  };
396
410
  const activityPane = pane("Activity", "activity", this.activity);
397
411
  const chatPane = pane("Conversation", "chat", this.chat);
@@ -468,8 +482,8 @@ export class TranscriptLayout {
468
482
  visible: viewport => shown(viewport) && this.preferences.zoom === "chat" },
469
483
  { component: transcript, basis: 0, grow: 1, minSize: 1, visible: viewport => !shown(viewport) },
470
484
  ...(projectedDock ? [{ component: projectedDock, basis: "auto" as const, shrink: 0, minSize: 1,
471
- visible: () => projectWidgets }] : []),
472
- { component: dock, basis: "auto", shrink: 0, minSize: 1, visible: () => !projectWidgets },
485
+ visible: () => projectSurface }] : []),
486
+ { component: dock, basis: "auto", shrink: 0, minSize: 1, visible: () => !projectSurface },
473
487
  ]);
474
488
  this.mounted = mounted;
475
489
  host.setLayoutRoot(mounted);
@@ -497,6 +511,8 @@ export class TranscriptLayout {
497
511
  private canFocusSearch(): boolean {
498
512
  const focused = this.host?.getFocusedComponent();
499
513
  if (!focused || focused === this.search?.bar.input) return true;
514
+ const editor = this.getEditor();
515
+ if (editor) return focused === editor;
500
516
  const dock = this.original?.children[1];
501
517
  const pending = dock ? [dock] : [];
502
518
  const visited = new Set<Component>();
@@ -0,0 +1,41 @@
1
+ import { InteractiveMode } from "@earendil-works/pi-coding-agent";
2
+ import type { Component, TUI } from "@earendil-works/pi-tui";
3
+
4
+ type Host = { ui?: unknown; renderer?: unknown; editor?: Component };
5
+ type Boundary = "createExtensionUIContext" | "rebuildChatFromMessages";
6
+ type Prototype = Partial<Record<Boundary, (this: Host, ...args: unknown[]) => unknown>>;
7
+
8
+ /**
9
+ * Observe the native editor identity at UI binding or reload's history rebuild.
10
+ * No dialog APIs, factories, components or focus are wrapped. Unknown hosts stay native.
11
+ */
12
+ export function observeNativeEditor(): { get(tui: TUI): Component | undefined; dispose(): void } {
13
+ const prototype = InteractiveMode.prototype as unknown as Prototype;
14
+ const restorers: Array<() => void> = [];
15
+ let owner: Host | undefined;
16
+ let active = true;
17
+ const restore = (): void => { for (const release of restorers) release(); };
18
+ for (const name of ["createExtensionUIContext", "rebuildChatFromMessages"] as const) {
19
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
20
+ const original = prototype[name];
21
+ if (typeof original !== "function" || !descriptor?.writable) continue;
22
+ function observe(this: Host, ...args: unknown[]): unknown {
23
+ const result = original!.apply(this, args);
24
+ // A later wrapper can retain this trampoline after cancellation.
25
+ if (active && this.editor && typeof this.editor.render === "function" &&
26
+ typeof this.editor.invalidate === "function" && (this.ui || this.renderer)) {
27
+ owner = this;
28
+ restore();
29
+ }
30
+ return result;
31
+ }
32
+ restorers.push(() => {
33
+ if (prototype[name] === observe) Object.defineProperty(prototype, name, descriptor);
34
+ });
35
+ prototype[name] = observe;
36
+ }
37
+ return {
38
+ get: tui => active && owner && (owner.ui === tui || owner.renderer === tui) ? owner.editor : undefined,
39
+ dispose: () => { active = false; owner = undefined; restore(); },
40
+ };
41
+ }