@firstpick/pi-package-webui 0.7.8 → 0.8.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/README.md +10 -4
- package/bin/pi-webui.mjs +696 -69
- package/lib/git-workflow-preferences.mjs +16 -0
- package/lib/git-worktrees.mjs +43 -4
- package/lib/queue-mutation.mjs +109 -0
- package/lib/scoped-models.mjs +19 -0
- package/lib/webui-workspaces.mjs +265 -0
- package/package.json +4 -2
- package/public/app.js +2074 -188
- package/public/index.html +105 -4
- package/public/service-worker.js +1 -1
- package/public/styles.css +618 -73
- package/public/voice-conversation.mjs +1 -1
- package/tests/boot-failure-diagnostics.test.mjs +2 -2
- package/tests/codex-fast-mode-static.test.mjs +56 -0
- package/tests/compaction-mutation-contract.test.mjs +166 -0
- package/tests/compaction-resume-harness.test.mjs +113 -2
- package/tests/compaction-static.test.mjs +5 -0
- package/tests/composer-skill-tag-layout.test.mjs +70 -0
- package/tests/cwd-footer-reliability-static.test.mjs +5 -0
- package/tests/fast-mode-client-static.test.mjs +8 -8
- package/tests/file-selection-overlay-static.test.mjs +21 -0
- package/tests/file-viewer-search-static.test.mjs +65 -0
- package/tests/fixtures/fake-pi.mjs +216 -43
- package/tests/git-panel-file-preview-static.test.mjs +20 -5
- package/tests/git-workflow-preferences.test.mjs +8 -0
- package/tests/guided-git-publication-backend-static.test.mjs +40 -0
- package/tests/http-endpoints-harness.test.mjs +422 -2
- package/tests/mobile-static.test.mjs +111 -42
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/queue-edit-reorder-static.test.mjs +101 -0
- package/tests/queue-mutation-contract.test.mjs +143 -0
- package/tests/scoped-models.test.mjs +42 -0
- package/tests/side-panel-resize-static.test.mjs +8 -1
- package/tests/subagents-helper.test.mjs +216 -3
- package/tests/terminal-tab-workspace-static.test.mjs +4 -2
- package/tests/webui-workspaces-harness.test.mjs +223 -0
- package/tests/webui-workspaces.test.mjs +106 -0
- package/tests/workspace-save-load-static.test.mjs +69 -0
- package/webui-rpc-helper.mjs +300 -41
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mutatePiRuntimeFollowUpQueue } from "../lib/queue-mutation.mjs";
|
|
3
|
+
|
|
4
|
+
function queuedMessage(text, extra = {}) {
|
|
5
|
+
return {
|
|
6
|
+
role: "user",
|
|
7
|
+
timestamp: 1234,
|
|
8
|
+
metadata: { origin: "fixture" },
|
|
9
|
+
content: [{ type: "text", text }, { type: "image", mimeType: "image/png", data: "iVBORw0KGgo=" }],
|
|
10
|
+
...extra,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function fixture({ steering = ["steer"], followUp = ["first", "second", "third"], steeringMessages, followUpMessages } = {}) {
|
|
15
|
+
let events = 0;
|
|
16
|
+
const session = {
|
|
17
|
+
_steeringMessages: [...steering],
|
|
18
|
+
_followUpMessages: [...followUp],
|
|
19
|
+
agent: {
|
|
20
|
+
steeringQueue: { messages: steeringMessages || steering.map((text) => queuedMessage(text)) },
|
|
21
|
+
followUpQueue: { messages: followUpMessages || followUp.map((text) => queuedMessage(text)) },
|
|
22
|
+
},
|
|
23
|
+
_emitQueueUpdate() { events += 1; },
|
|
24
|
+
};
|
|
25
|
+
return { session, eventCount: () => events };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function expected(session) {
|
|
29
|
+
return { steering: [...session._steeringMessages], followUp: [...session._followUpMessages] };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function editRequest(session, index, text, expectedText = session._followUpMessages[index]) {
|
|
33
|
+
return {
|
|
34
|
+
source: "pi-runtime",
|
|
35
|
+
kind: "followUp",
|
|
36
|
+
expected: expected(session),
|
|
37
|
+
operation: { type: "edit", index, expectedText, text },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function moveRequest(session, from, to, expectedText = session._followUpMessages[from]) {
|
|
42
|
+
return {
|
|
43
|
+
source: "pi-runtime",
|
|
44
|
+
kind: "followUp",
|
|
45
|
+
expected: expected(session),
|
|
46
|
+
operation: { type: "move", from, to, expectedText },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
const { session, eventCount } = fixture();
|
|
52
|
+
const beforeMessage = session.agent.followUpQueue.messages[1];
|
|
53
|
+
const beforeImage = beforeMessage.content[1];
|
|
54
|
+
const result = mutatePiRuntimeFollowUpQueue(session, editRequest(session, 1, "edited"));
|
|
55
|
+
assert.deepEqual(result, {
|
|
56
|
+
mutated: true,
|
|
57
|
+
source: "pi-runtime",
|
|
58
|
+
queue: { source: "pi-runtime", steering: ["steer"], followUp: ["first", "edited", "third"] },
|
|
59
|
+
});
|
|
60
|
+
assert.deepEqual(session._followUpMessages, ["first", "edited", "third"]);
|
|
61
|
+
assert.equal(session.agent.followUpQueue.messages[1].role, "user", "edit preserves message role");
|
|
62
|
+
assert.equal(session.agent.followUpQueue.messages[1].timestamp, 1234, "edit preserves message timestamp");
|
|
63
|
+
assert.deepEqual(session.agent.followUpQueue.messages[1].metadata, { origin: "fixture" }, "edit preserves metadata");
|
|
64
|
+
assert.strictEqual(session.agent.followUpQueue.messages[1].content[1], beforeImage, "edit preserves image content exactly");
|
|
65
|
+
assert.equal(beforeMessage.content[0].text, "second", "edit does not mutate the original message object");
|
|
66
|
+
assert.equal(eventCount(), 1, "successful edit emits exactly one queue update");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
const { session, eventCount } = fixture();
|
|
71
|
+
const firstMessage = session.agent.followUpQueue.messages[0];
|
|
72
|
+
const result = mutatePiRuntimeFollowUpQueue(session, moveRequest(session, 0, 2));
|
|
73
|
+
assert.equal(result.mutated, true);
|
|
74
|
+
assert.deepEqual(session._followUpMessages, ["second", "third", "first"], "move uses the final post-removal index");
|
|
75
|
+
assert.strictEqual(session.agent.followUpQueue.messages[2], firstMessage, "move keeps the message object paired with its tracking string");
|
|
76
|
+
assert.equal(eventCount(), 1, "successful move emits exactly one queue update");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
const { session, eventCount } = fixture({ followUp: ["same", "same"] });
|
|
81
|
+
const result = mutatePiRuntimeFollowUpQueue(session, editRequest(session, 1, "changed"));
|
|
82
|
+
assert.equal(result.mutated, true, "duplicate text is safe when the requested index and complete snapshot match");
|
|
83
|
+
assert.deepEqual(session._followUpMessages, ["same", "changed"]);
|
|
84
|
+
assert.equal(eventCount(), 1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
for (const staleMutation of [
|
|
88
|
+
(session) => { session._followUpMessages.push("new"); session.agent.followUpQueue.messages.push(queuedMessage("new")); },
|
|
89
|
+
(session) => { session._followUpMessages.shift(); session.agent.followUpQueue.messages.shift(); },
|
|
90
|
+
(session) => { session._followUpMessages.reverse(); session.agent.followUpQueue.messages.reverse(); },
|
|
91
|
+
]) {
|
|
92
|
+
const { session, eventCount } = fixture();
|
|
93
|
+
const request = editRequest(session, 1, "edited");
|
|
94
|
+
staleMutation(session);
|
|
95
|
+
const before = structuredClone({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages });
|
|
96
|
+
const result = mutatePiRuntimeFollowUpQueue(session, request);
|
|
97
|
+
assert.equal(result.mutated, false);
|
|
98
|
+
assert.equal(result.reason, "queue-changed", "a stale full snapshot is rejected");
|
|
99
|
+
assert.deepEqual({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages }, before, "stale mutations leave paired arrays untouched");
|
|
100
|
+
assert.equal(eventCount(), 0, "stale mutations emit no queue update");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
const { session, eventCount } = fixture();
|
|
105
|
+
session.agent.followUpQueue.messages[1] = queuedMessage("different");
|
|
106
|
+
const before = structuredClone({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages });
|
|
107
|
+
const result = mutatePiRuntimeFollowUpQueue(session, editRequest(session, 1, "edited"));
|
|
108
|
+
assert.equal(result.reason, "queue-desynchronized");
|
|
109
|
+
assert.deepEqual({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages }, before);
|
|
110
|
+
assert.equal(eventCount(), 0);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const requestFor of [
|
|
114
|
+
(session) => ({ ...editRequest(session, 1, ""), operation: { ...editRequest(session, 1, "").operation, text: " " } }),
|
|
115
|
+
(session) => editRequest(session, 99, "edited"),
|
|
116
|
+
(session) => moveRequest(session, 0, 0),
|
|
117
|
+
(session) => moveRequest(session, 0, 99),
|
|
118
|
+
(session) => ({ ...editRequest(session, 1, "edited"), source: "webui-compaction" }),
|
|
119
|
+
(session) => ({ ...editRequest(session, 1, "edited"), kind: "steering" }),
|
|
120
|
+
]) {
|
|
121
|
+
const { session, eventCount } = fixture();
|
|
122
|
+
const before = structuredClone({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages });
|
|
123
|
+
const result = mutatePiRuntimeFollowUpQueue(session, requestFor(session));
|
|
124
|
+
assert.equal(result.mutated, false);
|
|
125
|
+
assert.equal(result.reason, "invalid-request");
|
|
126
|
+
assert.deepEqual({ tracking: session._followUpMessages, messages: session.agent.followUpQueue.messages }, before);
|
|
127
|
+
assert.equal(eventCount(), 0, "invalid mutations emit no queue update");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
{
|
|
131
|
+
const { session, eventCount } = fixture();
|
|
132
|
+
session.agent.followUpQueue.messages[0].content.push({ type: "text", text: "unexpected" });
|
|
133
|
+
const result = mutatePiRuntimeFollowUpQueue(session, editRequest(session, 0, "edited"));
|
|
134
|
+
assert.equal(result.reason, "queue-desynchronized", "unknown message text layouts fail closed");
|
|
135
|
+
assert.equal(eventCount(), 0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
{
|
|
139
|
+
const result = mutatePiRuntimeFollowUpQueue({}, { source: "pi-runtime", kind: "followUp", expected: { steering: [], followUp: [] }, operation: { type: "edit", index: 0, expectedText: "x", text: "y" } });
|
|
140
|
+
assert.deepEqual(result, { mutated: false, reason: "queue-unsupported", queue: { source: "pi-runtime", steering: [], followUp: [] } }, "missing private Pi structures fail closed");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.log("queue-mutation-contract.test.mjs passed");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { resolveScopedModelsFromPatterns } from "../lib/scoped-models.mjs";
|
|
3
|
+
|
|
4
|
+
const models = [
|
|
5
|
+
{ provider: "anthropic", id: "claude-fable-5", name: "Claude Fable 5" },
|
|
6
|
+
{ provider: "openrouter", id: "anthropic/claude-fable-5", name: "Claude Fable 5" },
|
|
7
|
+
{ provider: "openrouter", id: "anthropic/claude-fable-5:batch", name: "Claude Fable 5 Batch" },
|
|
8
|
+
{ provider: "openrouter", id: "google/gemini-3.6-flash", name: "Gemini 3.6 Flash" },
|
|
9
|
+
{ provider: "openrouter", id: "google/gemini-3.6-flash:batch", name: "Gemini 3.6 Flash Batch" },
|
|
10
|
+
{ provider: "openrouter", id: "openrouter/auto", name: "Auto" },
|
|
11
|
+
{ provider: "openrouter", id: "openrouter/auto-beta", name: "Auto Beta" },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const exactPatterns = [
|
|
15
|
+
"anthropic/claude-fable-5",
|
|
16
|
+
"openrouter/google/gemini-3.6-flash",
|
|
17
|
+
"openrouter/openrouter/auto",
|
|
18
|
+
];
|
|
19
|
+
const exact = await resolveScopedModelsFromPatterns(exactPatterns, models);
|
|
20
|
+
assert.deepEqual(
|
|
21
|
+
exact.map((model) => `${model.provider}/${model.id}`),
|
|
22
|
+
exactPatterns,
|
|
23
|
+
"exact Pi scope entries must not expand to cross-provider, batch, or similarly named models",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const withThinking = await resolveScopedModelsFromPatterns(["anthropic/claude-fable-5:high"], models);
|
|
27
|
+
assert.deepEqual(withThinking.map((model) => `${model.provider}/${model.id}`), ["anthropic/claude-fable-5"]);
|
|
28
|
+
|
|
29
|
+
const exactColonId = await resolveScopedModelsFromPatterns(["openrouter/anthropic/claude-fable-5:batch"], models);
|
|
30
|
+
assert.deepEqual(exactColonId.map((model) => `${model.provider}/${model.id}`), ["openrouter/anthropic/claude-fable-5:batch"]);
|
|
31
|
+
|
|
32
|
+
const glob = await resolveScopedModelsFromPatterns(["openrouter/google/gemini-3.6-flash*"], models);
|
|
33
|
+
assert.deepEqual(
|
|
34
|
+
glob.map((model) => `${model.provider}/${model.id}`),
|
|
35
|
+
["openrouter/google/gemini-3.6-flash", "openrouter/google/gemini-3.6-flash:batch"],
|
|
36
|
+
"explicit Pi glob patterns must retain their intentional expansion behavior",
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
assert.deepEqual(await resolveScopedModelsFromPatterns([null, ""], models), []);
|
|
40
|
+
assert.deepEqual(await resolveScopedModelsFromPatterns(exactPatterns, null), []);
|
|
41
|
+
|
|
42
|
+
console.log("scoped-models.test.mjs passed");
|
|
@@ -8,6 +8,7 @@ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
8
8
|
const html = fs.readFileSync(path.join(root, "public/index.html"), "utf8");
|
|
9
9
|
const css = fs.readFileSync(path.join(root, "public/styles.css"), "utf8");
|
|
10
10
|
const app = fs.readFileSync(path.join(root, "public/app.js"), "utf8");
|
|
11
|
+
const server = fs.readFileSync(path.join(root, "bin/pi-webui.mjs"), "utf8");
|
|
11
12
|
|
|
12
13
|
test("Control Deck exposes an accessible resize separator", () => {
|
|
13
14
|
assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize Control Deck width"[^>]*tabindex="0"/);
|
|
@@ -22,8 +23,14 @@ test("desktop layouts and Control Deck content follow the selected width", () =>
|
|
|
22
23
|
assert.match(css, /\.side-panel \{[\s\S]*width:\s*100%;[\s\S]*min-width:\s*0/);
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
test("Control Deck width is clamped, persisted, pointer-resizable, and keyboard-resizable", () => {
|
|
26
|
+
test("Control Deck width is clamped, user-persisted, pointer-resizable, and keyboard-resizable", () => {
|
|
26
27
|
assert.match(app, /const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width"/);
|
|
28
|
+
assert.match(app, /const SIDE_PANEL_WIDTH_MAX_PX = 4096/);
|
|
29
|
+
assert.match(app, /width >= SIDE_PANEL_WIDTH_MIN_PX && width <= SIDE_PANEL_WIDTH_MAX_PX/);
|
|
30
|
+
assert.match(app, /function persistSidePanelWidth\(width\)[\s\S]*\/api\/interface-preferences[\s\S]*sidePanelWidth: rounded[\s\S]*scoped: false/);
|
|
31
|
+
assert.match(app, /async function restoreSidePanelWidthPreference\(\)[\s\S]*\/api\/interface-preferences[\s\S]*response\.data\?\.preferences\?\.sidePanelWidth[\s\S]*cacheSidePanelWidth/);
|
|
32
|
+
assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "GET"/);
|
|
33
|
+
assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "PUT"/);
|
|
27
34
|
assert.match(app, /function sidePanelMaxWidth\(\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*primaryMinWidth[\s\S]*available/);
|
|
28
35
|
assert.match(app, /function applySidePanelWidth\(width, \{ persist = false \} = \{\}\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
|
|
29
36
|
assert.match(app, /function beginSidePanelResize\(event\)[\s\S]*setPointerCapture[\s\S]*pointermove[\s\S]*pointercancel/);
|
|
@@ -30,7 +30,12 @@ const extensionHandlers = new Map();
|
|
|
30
30
|
const registeredCommands = new Map();
|
|
31
31
|
const statuses = [];
|
|
32
32
|
const notifications = [];
|
|
33
|
+
const sentMessages = [];
|
|
34
|
+
const subagentRpcRequests = [];
|
|
35
|
+
let branchEntries = [];
|
|
36
|
+
let idle = true;
|
|
33
37
|
let subagentStatusRequestCount = 0;
|
|
38
|
+
let subagentRpcReplyHook = null;
|
|
34
39
|
const pi = {
|
|
35
40
|
events: bus,
|
|
36
41
|
on(name, handler) {
|
|
@@ -42,7 +47,8 @@ const pi = {
|
|
|
42
47
|
getAllTools() { return []; },
|
|
43
48
|
getActiveTools() { return []; },
|
|
44
49
|
setActiveTools() {},
|
|
45
|
-
appendEntry() {},
|
|
50
|
+
appendEntry(customType, data) { branchEntries.push({ type: "custom", customType, data }); },
|
|
51
|
+
sendMessage(message, options) { sentMessages.push({ message, options }); },
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
const ctx = {
|
|
@@ -50,8 +56,9 @@ const ctx = {
|
|
|
50
56
|
hasUI: true,
|
|
51
57
|
cwd: "/tmp/subagent-helper-test",
|
|
52
58
|
sessionManager: {
|
|
53
|
-
getBranch() { return
|
|
59
|
+
getBranch() { return branchEntries; },
|
|
54
60
|
},
|
|
61
|
+
isIdle() { return idle; },
|
|
55
62
|
getSystemPromptOptions() {
|
|
56
63
|
return {
|
|
57
64
|
skills: [
|
|
@@ -112,10 +119,12 @@ const statusText = `Active async runs: 2
|
|
|
112
119
|
|
|
113
120
|
webuiRpcHelper(pi);
|
|
114
121
|
const unsubscribeRpc = bus.on("subagents:rpc:v1:request", (request) => {
|
|
122
|
+
subagentRpcRequests.push(request);
|
|
115
123
|
subagentStatusRequestCount += 1;
|
|
116
124
|
const text = request.params?.id === "run-a"
|
|
117
125
|
? `Run: run-a\nState: running\nMode: parallel\nDir: ${asyncRunDir}`
|
|
118
126
|
: statusText;
|
|
127
|
+
subagentRpcReplyHook?.(request);
|
|
119
128
|
bus.emit(`subagents:rpc:v1:reply:${request.requestId}`, {
|
|
120
129
|
version: 1,
|
|
121
130
|
requestId: request.requestId,
|
|
@@ -164,6 +173,13 @@ function latestPayload() {
|
|
|
164
173
|
return JSON.parse(entry.text.slice("PI_WEBUI_SUBAGENTS_V1 ".length));
|
|
165
174
|
}
|
|
166
175
|
|
|
176
|
+
function helperResponse(requestId) {
|
|
177
|
+
const notice = notifications.findLast((entry) => entry.message.startsWith("__PI_WEBUI_HELPER_RESPONSE__:")
|
|
178
|
+
&& JSON.parse(entry.message.slice("__PI_WEBUI_HELPER_RESPONSE__:".length)).requestId === requestId);
|
|
179
|
+
assert.ok(notice, `helper action ${requestId} should return a response notification`);
|
|
180
|
+
return JSON.parse(notice.message.slice("__PI_WEBUI_HELPER_RESPONSE__:".length));
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
let payload = latestPayload();
|
|
168
184
|
assert.equal(payload.available, true, "successful pi-subagents RPC should mark status available");
|
|
169
185
|
assert.deepEqual(payload.runs.map((run) => run.id), ["run-a", "run-b"]);
|
|
@@ -441,7 +457,17 @@ for (const handler of extensionHandlers.get("tool_execution_end") || []) {
|
|
|
441
457
|
handler({ type: "tool_execution_end", toolCallId: "foreground-call", toolName: "subagent" }, ctx);
|
|
442
458
|
}
|
|
443
459
|
payload = latestPayload();
|
|
444
|
-
|
|
460
|
+
foreground = payload.runs.find((run) => run.id === "foreground-call");
|
|
461
|
+
assert.deepEqual(foreground && {
|
|
462
|
+
status: foreground.status,
|
|
463
|
+
endedAt: typeof foreground.endedAt,
|
|
464
|
+
agents: foreground.agents.map((agent) => [agent.name, agent.status]),
|
|
465
|
+
}, {
|
|
466
|
+
status: "done",
|
|
467
|
+
endedAt: "number",
|
|
468
|
+
agents: [["reviewer", "done"], ["tester", "done"]],
|
|
469
|
+
}, "foreground children should remain viewable with final statuses when their tool finishes");
|
|
470
|
+
assert.equal(branchEntries.at(-1)?.customType, "webui-subagent-retained-runs-v1", "terminal runs should persist as parent-session custom snapshots");
|
|
445
471
|
|
|
446
472
|
const boundedWorkflowSnapshot = {
|
|
447
473
|
version: 1,
|
|
@@ -495,6 +521,193 @@ payload = latestPayload();
|
|
|
495
521
|
assert.equal(payload.runs.some((run) => run.source === "workflow"), false, "an empty workflow snapshot should clear only workflow rows");
|
|
496
522
|
assert.ok(payload.runs.some((run) => run.id === "run-a") && payload.runs.some((run) => run.id === "run-b"), "workflow cleanup must preserve ordinary async rows");
|
|
497
523
|
|
|
524
|
+
await helperCommand.handler(JSON.stringify({
|
|
525
|
+
requestId: "dismiss-finished-foreground",
|
|
526
|
+
action: "subagent-dismiss",
|
|
527
|
+
payload: { runId: "foreground-call" },
|
|
528
|
+
}), ctx);
|
|
529
|
+
assert.deepEqual(helperResponse("dismiss-finished-foreground"), {
|
|
530
|
+
requestId: "dismiss-finished-foreground",
|
|
531
|
+
ok: true,
|
|
532
|
+
data: { runId: "foreground-call", dismissed: true },
|
|
533
|
+
}, "dismiss should remove only a retained finished run");
|
|
534
|
+
payload = latestPayload();
|
|
535
|
+
assert.equal(payload.runs.some((run) => run.id === "foreground-call"), false, "a dismissed finished run should disappear from the published snapshot");
|
|
536
|
+
|
|
537
|
+
await helperCommand.handler(JSON.stringify({
|
|
538
|
+
requestId: "dismiss-running-async",
|
|
539
|
+
action: "subagent-dismiss",
|
|
540
|
+
payload: { runId: "run-a" },
|
|
541
|
+
}), ctx);
|
|
542
|
+
assert.equal(helperResponse("dismiss-running-async").ok, false, "dismiss should reject a still-running run");
|
|
543
|
+
|
|
544
|
+
for (const handler of extensionHandlers.get("tool_execution_start") || []) {
|
|
545
|
+
handler({
|
|
546
|
+
type: "tool_execution_start",
|
|
547
|
+
toolCallId: "foreground-cancel",
|
|
548
|
+
toolName: "subagent",
|
|
549
|
+
args: { agent: "tester", model: "openai-codex/gpt-5.6-terra:xhigh" },
|
|
550
|
+
}, ctx);
|
|
551
|
+
}
|
|
552
|
+
await helperCommand.handler(JSON.stringify({
|
|
553
|
+
requestId: "cancel-foreground-not-ready",
|
|
554
|
+
action: "subagent-cancel",
|
|
555
|
+
payload: { runId: "foreground-cancel" },
|
|
556
|
+
}), ctx);
|
|
557
|
+
assert.equal(helperResponse("cancel-foreground-not-ready").ok, false, "foreground cancellation should wait until pi-subagents publishes its control run id");
|
|
558
|
+
for (const handler of extensionHandlers.get("tool_execution_update") || []) {
|
|
559
|
+
handler({
|
|
560
|
+
type: "tool_execution_update",
|
|
561
|
+
toolCallId: "foreground-cancel",
|
|
562
|
+
toolName: "subagent",
|
|
563
|
+
partialResult: { details: { runId: "foreground-control", mode: "single", progress: [{ agent: "tester", status: "running", index: 0 }] } },
|
|
564
|
+
}, ctx);
|
|
565
|
+
}
|
|
566
|
+
const interruptRequestsBefore = subagentRpcRequests.length;
|
|
567
|
+
idle = true;
|
|
568
|
+
await helperCommand.handler(JSON.stringify({
|
|
569
|
+
requestId: "cancel-foreground",
|
|
570
|
+
action: "subagent-cancel",
|
|
571
|
+
payload: { runId: "foreground-control" },
|
|
572
|
+
}), ctx);
|
|
573
|
+
assert.deepEqual(helperResponse("cancel-foreground"), {
|
|
574
|
+
requestId: "cancel-foreground",
|
|
575
|
+
ok: true,
|
|
576
|
+
data: { runId: "foreground-control", state: "cancelled", delivery: "context", rpcMethod: "interrupt" },
|
|
577
|
+
}, "foreground cancellation should report a context delivery after an interrupt RPC");
|
|
578
|
+
assert.deepEqual(subagentRpcRequests.slice(interruptRequestsBefore).find((request) => request.method === "interrupt")?.params, { id: "foreground-control" }, "foreground cancellation should target pi-subagents' published control run id");
|
|
579
|
+
assert.equal(sentMessages.at(-1)?.message?.customType, "webui-subagent-cancelled");
|
|
580
|
+
assert.equal(sentMessages.at(-1)?.options, undefined, "idle parent sessions should receive cancellation notices as context");
|
|
581
|
+
|
|
582
|
+
const longReason = "R".repeat(125);
|
|
583
|
+
const longNote = "N".repeat(2_010);
|
|
584
|
+
const stopRequestsBefore = subagentRpcRequests.length;
|
|
585
|
+
idle = false;
|
|
586
|
+
await helperCommand.handler(JSON.stringify({
|
|
587
|
+
requestId: "cancel-async",
|
|
588
|
+
action: "subagent-cancel",
|
|
589
|
+
payload: { runId: "run-a", agentId: "run-a:step:0:reviewer", reason: longReason, note: longNote },
|
|
590
|
+
}), ctx);
|
|
591
|
+
const asyncCancel = helperResponse("cancel-async");
|
|
592
|
+
assert.deepEqual(asyncCancel, {
|
|
593
|
+
requestId: "cancel-async",
|
|
594
|
+
ok: true,
|
|
595
|
+
data: { runId: "run-a", state: "cancelled", delivery: "steer", rpcMethod: "stop" },
|
|
596
|
+
}, "async cancellation should report a steer delivery after a stop RPC");
|
|
597
|
+
assert.deepEqual(subagentRpcRequests.slice(stopRequestsBefore).find((request) => request.method === "stop")?.params, { id: "run-a" }, "async cancellation should target the tracked run with stop");
|
|
598
|
+
const asyncCancelMessage = sentMessages.at(-1);
|
|
599
|
+
assert.equal(asyncCancelMessage?.message?.customType, "webui-subagent-cancelled");
|
|
600
|
+
assert.deepEqual(asyncCancelMessage?.options, { deliverAs: "steer" }, "busy parent sessions should receive cancellation notices as steer messages");
|
|
601
|
+
assert.equal(asyncCancelMessage?.message?.display, true);
|
|
602
|
+
assert.equal(asyncCancelMessage?.message?.details?.runId, "run-a");
|
|
603
|
+
assert.deepEqual(asyncCancelMessage?.message?.details?.agentNames, ["reviewer", "reviewer"]);
|
|
604
|
+
assert.equal(asyncCancelMessage?.message?.details?.reason.length, 120, "cancel reasons should retain the documented 120-character bound");
|
|
605
|
+
assert.equal(asyncCancelMessage?.message?.details?.note.length, 2000, "cancel notes should retain the documented 2000-character bound");
|
|
606
|
+
assert.match(asyncCancelMessage?.message?.content || "", /should not be automatically retried without asking/, "parent cancellation notices should prevent silent retries");
|
|
607
|
+
payload = latestPayload();
|
|
608
|
+
const cancelledAsync = payload.runs.find((run) => run.id === "run-a");
|
|
609
|
+
assert.deepEqual(cancelledAsync && {
|
|
610
|
+
status: cancelledAsync.status,
|
|
611
|
+
cancelledBy: cancelledAsync.cancelledBy,
|
|
612
|
+
cancelReasonLength: cancelledAsync.cancelReason?.length,
|
|
613
|
+
cancelNoteLength: cancelledAsync.cancelNote?.length,
|
|
614
|
+
agentStatuses: cancelledAsync.agents.map((agent) => agent.status),
|
|
615
|
+
}, {
|
|
616
|
+
status: "cancelled",
|
|
617
|
+
cancelledBy: "user",
|
|
618
|
+
cancelReasonLength: 120,
|
|
619
|
+
cancelNoteLength: 2000,
|
|
620
|
+
agentStatuses: ["cancelled", "cancelled"],
|
|
621
|
+
}, "cancelled runs should remain published with bounded user cancellation metadata");
|
|
622
|
+
|
|
623
|
+
await helperCommand.handler(JSON.stringify({
|
|
624
|
+
requestId: "cancel-finished-async",
|
|
625
|
+
action: "subagent-cancel",
|
|
626
|
+
payload: { runId: "run-a" },
|
|
627
|
+
}), ctx);
|
|
628
|
+
assert.equal(helperResponse("cancel-finished-async").ok, false, "cancel should reject a retained terminal run");
|
|
629
|
+
|
|
630
|
+
bus.emit("subagent:async-started", { id: "run-race", mode: "single", agent: "tester" });
|
|
631
|
+
subagentRpcReplyHook = (request) => {
|
|
632
|
+
if (request.method !== "stop" || request.params?.id !== "run-race") return;
|
|
633
|
+
subagentRpcReplyHook = null;
|
|
634
|
+
bus.emit("subagent:async-complete", { id: "run-race" });
|
|
635
|
+
};
|
|
636
|
+
await helperCommand.handler(JSON.stringify({
|
|
637
|
+
requestId: "cancel-complete-race",
|
|
638
|
+
action: "subagent-cancel",
|
|
639
|
+
payload: { runId: "run-race", reason: "Stopped by the user" },
|
|
640
|
+
}), ctx);
|
|
641
|
+
assert.equal(helperResponse("cancel-complete-race").ok, true);
|
|
642
|
+
const racedCancel = latestPayload().runs.find((run) => run.id === "run-race");
|
|
643
|
+
assert.equal(racedCancel?.status, "cancelled", "a successful user cancel should remain authoritative when completion races the RPC reply");
|
|
644
|
+
assert.equal(racedCancel?.cancelledBy, "user");
|
|
645
|
+
assert.equal(racedCancel?.cancelReason, "Stopped by the user");
|
|
646
|
+
|
|
647
|
+
bus.emit("subagent:async-complete", { id: "run-b" });
|
|
648
|
+
payload = latestPayload();
|
|
649
|
+
const completedAsync = payload.runs.find((run) => run.id === "run-b");
|
|
650
|
+
assert.deepEqual(completedAsync && {
|
|
651
|
+
status: completedAsync.status,
|
|
652
|
+
endedAt: typeof completedAsync.endedAt,
|
|
653
|
+
agentStatuses: completedAsync.agents.map((agent) => agent.status),
|
|
654
|
+
}, {
|
|
655
|
+
status: "done",
|
|
656
|
+
endedAt: "number",
|
|
657
|
+
agentStatuses: ["done", "done"],
|
|
658
|
+
}, "async completion should retain a final run rather than deleting it");
|
|
659
|
+
|
|
660
|
+
const persistedSnapshot = branchEntries.at(-1);
|
|
661
|
+
assert.equal(persistedSnapshot?.customType, "webui-subagent-retained-runs-v1", "the latest parent-session custom entry should own retained run state");
|
|
662
|
+
assert.equal(persistedSnapshot?.data?.version, 1);
|
|
663
|
+
assert.equal(persistedSnapshot?.data?.runs?.find((run) => run.id === "run-a")?.agents?.[0]?.transcript, undefined, "retained snapshots should store output locators rather than redundant transcripts");
|
|
664
|
+
|
|
665
|
+
for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "resume" }, ctx);
|
|
666
|
+
payload = latestPayload();
|
|
667
|
+
assert.equal(payload.runs.find((run) => run.id === "run-a")?.status, "cancelled", "resuming the same parent session should restore retained cancellation state");
|
|
668
|
+
assert.equal(payload.runs.find((run) => run.id === "run-b")?.status, "done", "resuming the same parent session should restore completed runs");
|
|
669
|
+
await helperCommand.handler(JSON.stringify({
|
|
670
|
+
requestId: "restored-async-output",
|
|
671
|
+
action: "subagent-output",
|
|
672
|
+
payload: { runId: "run-a", agentId: "run-a:step:0:reviewer" },
|
|
673
|
+
}), ctx);
|
|
674
|
+
const restoredOutput = helperResponse("restored-async-output");
|
|
675
|
+
assert.equal(restoredOutput.ok, true, "retained async output should remain accessible after a parent-session resume");
|
|
676
|
+
assert.equal(restoredOutput.data.agent.status, "cancelled");
|
|
677
|
+
|
|
678
|
+
const retainedParentBranch = branchEntries;
|
|
679
|
+
branchEntries = [];
|
|
680
|
+
for (const handler of extensionHandlers.get("session_tree") || []) await handler({ reason: "different-branch" }, ctx);
|
|
681
|
+
payload = latestPayload();
|
|
682
|
+
assert.equal(payload.runs.some((run) => ["run-a", "run-b", "foreground-cancel"].includes(run.id)), false, "a different parent branch must not inherit retained runs");
|
|
683
|
+
branchEntries = retainedParentBranch;
|
|
684
|
+
for (const handler of extensionHandlers.get("session_tree") || []) await handler({ reason: "return-to-parent-branch" }, ctx);
|
|
685
|
+
payload = latestPayload();
|
|
686
|
+
assert.equal(payload.runs.find((run) => run.id === "run-a")?.status, "cancelled", "returning to the parent branch should restore its retained runs");
|
|
687
|
+
|
|
688
|
+
await helperCommand.handler(JSON.stringify({
|
|
689
|
+
requestId: "dismiss-cancelled-async",
|
|
690
|
+
action: "subagent-dismiss",
|
|
691
|
+
payload: { runId: "run-a" },
|
|
692
|
+
}), ctx);
|
|
693
|
+
assert.equal(helperResponse("dismiss-cancelled-async").ok, true, "dismiss should accept a retained cancelled run");
|
|
694
|
+
assert.equal(branchEntries.at(-1)?.data?.runs?.some((run) => run.id === "run-a"), false, "dismiss should persist a tombstone snapshot without the removed run");
|
|
695
|
+
for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "resume" }, ctx);
|
|
696
|
+
payload = latestPayload();
|
|
697
|
+
assert.equal(payload.runs.some((run) => run.id === "run-a"), false, "a dismissed run must remain absent after resume");
|
|
698
|
+
|
|
699
|
+
for (let index = 0; index < 17; index += 1) {
|
|
700
|
+
const runId = `retention-cap-${index}`;
|
|
701
|
+
for (const handler of extensionHandlers.get("tool_execution_start") || []) {
|
|
702
|
+
handler({ type: "tool_execution_start", toolCallId: runId, toolName: "subagent", args: { agent: "tester" } }, ctx);
|
|
703
|
+
}
|
|
704
|
+
for (const handler of extensionHandlers.get("tool_execution_end") || []) {
|
|
705
|
+
handler({ type: "tool_execution_end", toolCallId: runId, toolName: "subagent" }, ctx);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
payload = latestPayload();
|
|
709
|
+
assert.ok(payload.runs.filter((run) => run.source !== "workflow" && run.status !== "running").length <= 16, "ordinary retained runs should enforce the 16-run finished retention cap");
|
|
710
|
+
|
|
498
711
|
for (const handler of extensionHandlers.get("session_shutdown") || []) await handler({ reason: "quit" }, ctx);
|
|
499
712
|
unsubscribeRpc();
|
|
500
713
|
delete process.env.PI_WEBUI_SETTINGS_FILE;
|
|
@@ -88,12 +88,14 @@ assert.match(results.group, /^Tooltip group · 2 tabs\nWorkspaces: projects\/pi-
|
|
|
88
88
|
assert.match(results.group, /Click to switch · Drop tabs here to add$/, "group hover summary should preserve the drop-target affordance");
|
|
89
89
|
assert.doesNotMatch(terminalTabMetaSource, /\bpid\b/i, "compact tab metadata should not expose the process PID");
|
|
90
90
|
assert.equal(app.match(/applyStyledTooltip\(button, terminalTabTooltip\(tab\)/g)?.length, 2, "single and grouped-item tabs should share one tooltip formatter");
|
|
91
|
-
assert.match(renderTerminalTabGroupSource, /
|
|
91
|
+
assert.match(renderTerminalTabGroupSource, /applyStyledTooltip\(button, terminalTabGroupTooltip\(group, groupTitle\), \{ ariaLabel: false, description: true, placement: "right", variant: "workspace" \}\)/, "group hover disclosure should use the shared floating tooltip layer to the right of its trigger");
|
|
92
|
+
assert.doesNotMatch(renderTerminalTabGroupSource, /terminal-tab-group-summary|menu\.append\(summary\)/, "group hover disclosure should not render an in-flow summary that shifts group menu items");
|
|
92
93
|
assert.match(app, /footerTooltipNode\.setAttribute\("role", "tooltip"\)/, "the shared visual tooltip should expose tooltip semantics");
|
|
93
94
|
assert.match(app, /document\.addEventListener\("keydown", \(event\) => \{[\s\S]*event\.key === "Escape" && footerTooltipTarget[\s\S]*hideFooterTooltip\(footerTooltipTarget\)[\s\S]*\}, true\)/, "Escape should dismiss both hover- and focus-triggered tooltips from the document capture phase");
|
|
94
95
|
assert.match(app, /data-tooltip-variant"\) === "workspace" && !node\.matches\(":focus-visible"\)/, "touch focus should not flash the large workspace tooltip while keyboard focus remains supported");
|
|
95
96
|
assert.match(app, /styled-tooltip-description[\s\S]*aria-describedby/, "detailed tab tooltip text should be available as an accessible description");
|
|
96
97
|
assert.match(styles, /footer-floating-tooltip\[data-variant="workspace"\][\s\S]*line-height: 1\.52/, "workspace tooltips should use the readable visual variant");
|
|
97
|
-
assert.
|
|
98
|
+
assert.doesNotMatch(styles, /terminal-tab-group-summary/, "group tooltip styling should not reserve in-flow menu space");
|
|
99
|
+
assert.match(app, /placement === "right"[\s\S]*left = rect\.right \+ gap;[\s\S]*top = rect\.top;/, "right-placed tooltips should overlay beside and top-align with their trigger");
|
|
98
100
|
|
|
99
101
|
console.log("terminal tab workspace static tests passed");
|