pi-session-subagents 0.1.1 → 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 +7 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/ui/conversation-viewer.ts +19 -2
- package/src/ui/outside-click.ts +88 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## [0.1.1](https://github.com/rbajaj1997/pi-session-subagents/compare/v0.1.0...v0.1.1) (2026-11-15)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -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
|
package/package.json
CHANGED
|
@@ -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) =>
|
|
62
|
-
|
|
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
|
+
}
|