pi-session-subagents 0.1.0 → 0.2.0

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/rbajaj1997/pi-session-subagents/compare/v0.1.1...v0.2.0) (2026-11-16)
4
+
5
+
6
+ ### Features
7
+
8
+ * dismiss subagent inspector on outside click ([#4](https://github.com/rbajaj1997/pi-session-subagents/issues/4)) ([c917e49](https://github.com/rbajaj1997/pi-session-subagents/commit/c917e49180cd190ead3f0e7b39fa37e3f7f8a6cc))
9
+
10
+ ## [0.1.1](https://github.com/rbajaj1997/pi-session-subagents/compare/v0.1.0...v0.1.1) (2026-11-15)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * require Node.js 24 ([#2](https://github.com/rbajaj1997/pi-session-subagents/issues/2)) ([b2d8749](https://github.com/rbajaj1997/pi-session-subagents/commit/b2d8749eeadafac621834c0fc18b1ce05fca744a))
16
+
3
17
  ## [0.1.0] - 2026-11-15
4
18
 
5
19
  Initial release.
package/README.md CHANGED
@@ -20,7 +20,7 @@ This is conversational reuse, not a background job service. Workers do not survi
20
20
  ## Requirements
21
21
 
22
22
  - Pi 1.5.2 is the SDK and TUI compatibility target. Older versions are not supported; other versions have not been validated.
23
- - Node.js 22.19.0 or newer.
23
+ - Node.js 24 or newer.
24
24
  - Model credentials and configuration available to Pi.
25
25
 
26
26
  ## Install
@@ -138,6 +138,7 @@ The main widget and the inspector need the interactive TUI. In RPC mode, use `li
138
138
  - Mouse-wheel scrolling and native click controls work in fullscreen mode.
139
139
  - `t` or the configured `app.tools.expand` shortcut expands or collapses tool cards.
140
140
  - The configured `app.thinking.toggle` shortcut changes thinking visibility inside the inspector only.
141
+ - In fullscreen mode, left-click outside the inspector to close it without activating the main session. Clicks anywhere inside its frame keep it open. Scrolling and dragging do not dismiss it. Outside drags are consumed rather than passed to the main session and can clear its existing text selection.
141
142
  - Escape or `q` closes the inspector without stopping the worker.
142
143
 
143
144
  ## Reviewing past work
@@ -185,7 +186,7 @@ Formatting and linting follow Pi's own Biome setup: tabs, a 120-character line w
185
186
 
186
187
  The package ships TypeScript source through `pi.extensions`. Pi loads it directly, so no compilation or bundling step is required. Pi-provided imports are peer dependencies, with pinned development copies for local typechecking. There are no additional runtime dependencies.
187
188
 
188
- `npm test` uses Node's built-in test runner and Jiti to load the TypeScript source. Tests exercise commands, the roster, worker lifecycle and steering, deadlines, report delivery, model selection, result pagination, transcript inspection, the widget, the inspector, and session cleanup. They use a controlled Pi session substitute and temporary directories, without model calls or credentials. Live provider discovery, trust configuration, and interactive TUI behavior still need checks in Pi.
189
+ `npm test` uses Node's built-in test runner with tsx to run the TypeScript tests. The tests use normal imports, and `tsc --noEmit` checks both `src/` and `tests/`. Tests exercise commands, the roster, worker lifecycle and steering, deadlines, report delivery, model selection, result pagination, transcript inspection, the widget, the inspector, and session cleanup. They use a controlled Pi session substitute and temporary directories, without model calls or credentials. Live provider discovery, trust configuration, and interactive TUI behavior still need checks in Pi.
189
190
 
190
191
  ```text
191
192
  src/
@@ -201,10 +202,10 @@ src/
201
202
  ui/
202
203
  widget.ts Worker list above the editor
203
204
  conversation-viewer.ts Framed read-only inspector using Pi's own components
204
- tests/ Behaviour tests, run with node --test through jiti
205
+ tests/ TypeScript behavior tests, run with node --test through tsx
205
206
  ```
206
207
 
207
- CI runs `npm run check`, `npm test`, and `npm pack --dry-run` on Node 22 and 24 for every push to `main` and every pull request.
208
+ CI runs `npm run check`, `npm test`, and `npm pack --dry-run` on Node 24 for every push to `main` and every pull request.
208
209
 
209
210
  ## Releasing
210
211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-session-subagents",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Session-scoped subagents for Pi with idle workers, steering, and native transcript inspection.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "session-workers"
21
21
  ],
22
22
  "engines": {
23
- "node": ">=22.19.0"
23
+ "node": ">=24.0.0"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"
@@ -39,7 +39,7 @@
39
39
  "scripts": {
40
40
  "check": "biome check && tsc --noEmit",
41
41
  "format": "biome check --write",
42
- "test": "node --test --test-timeout=10000 tests/*.test.mjs"
42
+ "test": "node --import tsx --test --test-timeout=10000 tests/*.test.ts"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@earendil-works/pi-agent-core": "*",
@@ -54,8 +54,8 @@
54
54
  "@earendil-works/pi-ai": "1.5.2",
55
55
  "@earendil-works/pi-coding-agent": "1.5.2",
56
56
  "@earendil-works/pi-tui": "1.5.2",
57
- "@types/node": "^22.19.19",
58
- "jiti": "2.7.0",
57
+ "@types/node": "^24.19.2",
58
+ "tsx": "^4.23.15",
59
59
  "typebox": "1.3.27",
60
60
  "typescript": "^5.9.0"
61
61
  }
@@ -17,6 +17,7 @@ import {
17
17
  type Component,
18
18
  Container,
19
19
  matchesKey,
20
+ type OverlayHandle,
20
21
  Text,
21
22
  TruncatedText,
22
23
  type TUI,
@@ -26,6 +27,7 @@ import {
26
27
  } from "@earendil-works/pi-tui";
27
28
  import { clip, formatDuration, formatTokens, shortModelLabel } from "../text";
28
29
  import type { Worker } from "../worker";
30
+ import { dismissOnOutsideClick } from "./outside-click";
29
31
 
30
32
  type ToolView = { component: ToolExecutionComponent; result?: unknown; durationMs?: number };
31
33
 
@@ -57,9 +59,17 @@ export async function openInspector(ctx: ExtensionContext, workers: Worker[], na
57
59
  if (!worker) return;
58
60
  }
59
61
  const selected = worker;
62
+ let viewer: ConversationViewer;
60
63
  await ctx.ui.custom<void>(
61
- (tui, theme, keybindings, done) => new ConversationViewer(tui, selected, theme, keybindings, () => done()),
62
- { overlay: true, overlayOptions: { anchor: "center", width: "90%", margin: 1 } },
64
+ (tui, theme, keybindings, done) => {
65
+ viewer = new ConversationViewer(tui, selected, theme, keybindings, () => done());
66
+ return viewer;
67
+ },
68
+ {
69
+ overlay: true,
70
+ overlayOptions: { anchor: "center", width: "90%", margin: 1 },
71
+ onHandle: (handle) => viewer.attachOverlay(handle),
72
+ },
63
73
  );
64
74
  }
65
75
 
@@ -79,6 +89,7 @@ class ConversationViewer implements Component {
79
89
  private expanded = false;
80
90
  private hideThinking: boolean;
81
91
  private disposed = false;
92
+ private removeOutsideClick: (() => void) | undefined;
82
93
 
83
94
  constructor(
84
95
  private readonly tui: TUI,
@@ -125,6 +136,11 @@ class ConversationViewer implements Component {
125
136
  });
126
137
  }
127
138
 
139
+ attachOverlay(handle: OverlayHandle): void {
140
+ if (this.disposed || this.removeOutsideClick) return;
141
+ this.removeOutsideClick = dismissOnOutsideClick(this.tui, handle, this.done);
142
+ }
143
+
128
144
  handleInput(data: string): void {
129
145
  if (matchesKey(data, "escape") || matchesKey(data, "q") || this.keybindings.matches(data, "tui.select.cancel")) {
130
146
  this.done();
@@ -246,6 +262,7 @@ class ConversationViewer implements Component {
246
262
  dispose(): void {
247
263
  if (this.disposed) return;
248
264
  this.disposed = true;
265
+ this.removeOutsideClick?.();
249
266
  this.unsubscribe();
250
267
  this.history.clear();
251
268
  this.rows.clear();
@@ -0,0 +1,88 @@
1
+ import type { Component, OverlayHandle, TUI, TuiMouseEvent, TuiMouseEventResult } from "@earendil-works/pi-tui";
2
+
3
+ type Dismissal = { handle: OverlayHandle; close: () => void };
4
+ // Pi's TUI proxy forwards symbol values unchanged, but wraps functions on every read.
5
+ const ROUTING = Symbol.for("pi-session-subagents.outside-click");
6
+ type OverlayDispatch = {
7
+ hit: boolean;
8
+ result?: TuiMouseEventResult & {
9
+ target: { component: Component; originX: number; originY: number; width: number; height: number };
10
+ };
11
+ };
12
+ type Registration = {
13
+ dismissals: Set<Dismissal>;
14
+ intercept?: (event: TuiMouseEvent) => OverlayDispatch | undefined;
15
+ };
16
+ type MouseRouter = {
17
+ [ROUTING]?: Registration;
18
+ dispatchMouseToOverlay?: (event: TuiMouseEvent) => OverlayDispatch;
19
+ };
20
+
21
+ /** Pi 1.5.2 consumes fullscreen mouse input before extension input listeners run. */
22
+ export function dismissOnOutsideClick(tui: TUI, handle: OverlayHandle, close: () => void): () => void {
23
+ const router = tui as unknown as MouseRouter;
24
+ if (
25
+ tui.mode !== "fullscreen" ||
26
+ typeof router.dispatchMouseToOverlay !== "function" ||
27
+ typeof handle.getBounds !== "function" ||
28
+ typeof handle.isFocused !== "function"
29
+ ) {
30
+ return () => {};
31
+ }
32
+
33
+ let registration = router[ROUTING];
34
+ if (!registration) {
35
+ const original = router.dispatchMouseToOverlay;
36
+ const state: Registration = { dismissals: new Set() };
37
+ router[ROUTING] = state;
38
+ // Install once per renderer; refresh the interception logic when reopening after /reload.
39
+ router.dispatchMouseToOverlay = (event) => state.intercept?.(event) ?? original.call(tui, event);
40
+ registration = state;
41
+ }
42
+ const active = registration.dismissals;
43
+ registration.intercept = (event) => {
44
+ if (event.type === "press" && event.button === "left") {
45
+ for (const dismissal of active) {
46
+ const bounds = dismissal.handle.getBounds();
47
+ if (!dismissal.handle.isFocused() || !bounds) continue;
48
+ const inside =
49
+ event.screenX >= bounds.col &&
50
+ event.screenX < bounds.col + bounds.width &&
51
+ event.screenY >= bounds.row &&
52
+ event.screenY < bounds.row + bounds.height;
53
+ if (inside) break;
54
+ // Claim the entire gesture. Pi emits click only after a release without a drag.
55
+ const target: Component = {
56
+ render: () => [],
57
+ invalidate: () => {},
58
+ handleMouse: (next) => {
59
+ if (next.type === "click" && active.has(dismissal) && dismissal.handle.isFocused()) {
60
+ dismissal.close();
61
+ }
62
+ return { handled: true };
63
+ },
64
+ };
65
+ return {
66
+ hit: true,
67
+ result: {
68
+ handled: true,
69
+ target: {
70
+ component: target,
71
+ originX: event.screenX - event.x,
72
+ originY: event.screenY - event.y,
73
+ width: event.width,
74
+ height: event.height,
75
+ },
76
+ },
77
+ };
78
+ }
79
+ }
80
+ return undefined;
81
+ };
82
+ const dismissal = { handle, close };
83
+ active.add(dismissal);
84
+ return () => {
85
+ active.delete(dismissal);
86
+ if (active.size === 0) registration.intercept = undefined;
87
+ };
88
+ }