@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,65 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import vm from "node:vm";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const [app, css, html] = await Promise.all([
|
|
9
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
assert.match(
|
|
15
|
+
html,
|
|
16
|
+
/id="fileViewerSearchBar"[\s\S]*role="search"[\s\S]*id="fileViewerSearchInput"[\s\S]*id="fileViewerSearchCount"[\s\S]*id="fileViewerSearchPrevButton"[\s\S]*id="fileViewerSearchNextButton"[\s\S]*id="fileViewerSearchCloseButton"/,
|
|
17
|
+
"the file viewer should expose an accessible in-file search bar with match navigation",
|
|
18
|
+
);
|
|
19
|
+
assert.match(html, /id="fileViewerSearchInput"[^>]*aria-controls="fileViewerEditor"/, "the in-file search input should identify the source editor it searches");
|
|
20
|
+
assert.match(app, /fileViewerSearchInput: \$\("#fileViewerSearchInput"\)/, "file search controls should be registered in the element map");
|
|
21
|
+
assert.match(app, /const FILE_VIEWER_SEARCH_MATCH_LIMIT = 10_000;/, "in-file search should bound match collection for large files");
|
|
22
|
+
assert.match(app, /function collectFileViewerSearchMatches\([\s\S]*fileViewerSearchText\(\)\.toLowerCase\(\)[\s\S]*haystack\.indexOf\(needle, offset\)/, "in-file search should collect case-insensitive matches from the active viewer surface");
|
|
23
|
+
|
|
24
|
+
const helperStart = app.indexOf("const FILE_VIEWER_SEARCH_MATCH_LIMIT = 10_000;");
|
|
25
|
+
const helperEnd = app.indexOf("\nfunction updateFileViewerSearchCount()", helperStart);
|
|
26
|
+
assert.ok(helperStart >= 0 && helperEnd > helperStart, "file viewer search matching should remain independently testable");
|
|
27
|
+
const helperSource = app.slice(helperStart, helperEnd);
|
|
28
|
+
const sourceMatches = JSON.parse(vm.runInNewContext(`${helperSource}\nJSON.stringify(collectFileViewerSearchMatches("alpha"))`, {
|
|
29
|
+
activeFileViewer: { mode: "source", content: "stale" },
|
|
30
|
+
elements: { fileViewerEditor: { value: "Alpha beta ALPHA" }, fileViewerPreview: { textContent: "preview" }, fileViewerChanges: { textContent: "changes" } },
|
|
31
|
+
resolveFileViewerMode: (viewer) => viewer.mode,
|
|
32
|
+
}));
|
|
33
|
+
assert.deepEqual(sourceMatches, { matches: [{ start: 0, end: 5 }, { start: 11, end: 16 }], truncated: false }, "source search should use live edited text and match case-insensitively");
|
|
34
|
+
const previewMatches = JSON.parse(vm.runInNewContext(`${helperSource}\nJSON.stringify(collectFileViewerSearchMatches("rendered"))`, {
|
|
35
|
+
activeFileViewer: { mode: "preview" },
|
|
36
|
+
elements: { fileViewerEditor: { value: "source" }, fileViewerPreview: { textContent: "Rendered preview" }, fileViewerChanges: { textContent: "changes" } },
|
|
37
|
+
resolveFileViewerMode: (viewer) => viewer.mode,
|
|
38
|
+
}));
|
|
39
|
+
assert.deepEqual(previewMatches, { matches: [{ start: 0, end: 8 }], truncated: false }, "preview search should use the rendered file surface instead of hidden source text");
|
|
40
|
+
const truncatedMatches = JSON.parse(vm.runInNewContext(`${helperSource}\nJSON.stringify(collectFileViewerSearchMatches("a"))`, {
|
|
41
|
+
activeFileViewer: { mode: "source" },
|
|
42
|
+
elements: { fileViewerEditor: { value: "a".repeat(10_001) }, fileViewerPreview: { textContent: "" }, fileViewerChanges: { textContent: "" } },
|
|
43
|
+
resolveFileViewerMode: (viewer) => viewer.mode,
|
|
44
|
+
}));
|
|
45
|
+
assert.equal(truncatedMatches.matches.length, 10_000, "large-file match collection should stop at the declared bound");
|
|
46
|
+
assert.equal(truncatedMatches.truncated, true, "large-file match collection should disclose additional matches beyond the bound");
|
|
47
|
+
assert.match(app, /function fileViewerSearchSurface\(\)[\s\S]*mode === "preview"[\s\S]*mode === "changes"[\s\S]*fileViewerEditor/, "search should stay scoped to the current Source, Preview, or Changes surface");
|
|
48
|
+
assert.match(app, /function focusFileViewerSearchMatch\([\s\S]*setSelectionRange\(match\.start, match\.end\)[\s\S]*textOffsetPosition\(surface, match\.start\)[\s\S]*CSS\?\.highlights[\s\S]*scrollIntoView/, "match navigation should select source matches and highlight rendered matches without mutating the document selection");
|
|
49
|
+
assert.doesNotMatch(app.slice(app.indexOf("function focusFileViewerSearchMatch("), app.indexOf("\nfunction runFileViewerSearch(", app.indexOf("function focusFileViewerSearchMatch("))), /getSelection|addRange|removeAllRanges/, "rendered file search must not overwrite selections used by the Send to Pi workflow");
|
|
50
|
+
assert.match(app, /function runFileViewerSearch\([\s\S]*setAttribute\("aria-controls", surface\.id\)/, "the search input should identify the active Source, Preview, or Changes surface");
|
|
51
|
+
assert.match(app, /function setFileViewerMode\([\s\S]*updateFileViewerUi\(\);[\s\S]*runFileViewerSearch\(\{ navigate: true \}\)/, "an explicit mode switch should reveal the first match on the new surface");
|
|
52
|
+
assert.match(app, /function updateFileViewerUi\([\s\S]*runFileViewerSearch\(\{ navigate: false \}\)/, "background viewer refreshes should reindex without stealing focus or scrolling to a match");
|
|
53
|
+
assert.match(app, /fileViewerSearchInput\?\.addEventListener\("input"[\s\S]*setTimeout\([\s\S]*runFileViewerSearch\(\{ navigate: true \}\)[\s\S]*150/, "typing should debounce search work for large files");
|
|
54
|
+
assert.match(app, /fileViewerSearchInput\?\.addEventListener\("keydown"[\s\S]*event\.key === "Enter"[\s\S]*stepFileViewerSearch\(event\.shiftKey \? -1 : 1\)[\s\S]*event\.key === "Escape"[\s\S]*closeFileViewerSearch\(\)/, "Enter, Shift+Enter, and Escape should navigate or close in-file search");
|
|
55
|
+
assert.match(
|
|
56
|
+
app,
|
|
57
|
+
/if \(activeFileViewer && elements\.fileViewerPane\?\.contains\(event\.target\)\) openFileViewerSearch\(\);\s*else openChatSearch\(\);/,
|
|
58
|
+
"Ctrl/Cmd+F should route to in-file search only when the event target is inside the open file viewer",
|
|
59
|
+
);
|
|
60
|
+
assert.match(app, /function openChatSearch\(\)[\s\S]*closeFileViewerSearch\(\{ restoreFocus: false \}\)/, "opening transcript search should close any stale in-file search bar");
|
|
61
|
+
assert.match(css, /\.chat-search-bar,\s*\.file-viewer-search-bar \{/, "file search should reuse the transcript search layout conventions");
|
|
62
|
+
assert.match(css, /\.file-viewer-search-bar\[hidden\] \{ display: none; \}/, "the hidden file search bar should not consume viewer space");
|
|
63
|
+
assert.match(css, /::highlight\(file-viewer-search-current\)[\s\S]*\.file-viewer-search-current-fallback/, "rendered matches should have an exact CSS Highlight and a non-destructive fallback affordance");
|
|
64
|
+
|
|
65
|
+
console.log("file viewer focused search static tests passed");
|
|
@@ -28,6 +28,8 @@ let activeBash = 0;
|
|
|
28
28
|
let peakBash = 0;
|
|
29
29
|
let thinkingLevel = "off";
|
|
30
30
|
let conversationEnabled = false;
|
|
31
|
+
let codexFastModeEnabled = false;
|
|
32
|
+
let rejectNextCodexFastModeMutation = false;
|
|
31
33
|
const fakeTools = [
|
|
32
34
|
{ name: "read", description: "Read files", sourceInfo: { source: "builtin", scope: "temporary", origin: "top-level" } },
|
|
33
35
|
{ name: "bash", description: "Run shell commands", sourceInfo: { source: "builtin", scope: "temporary", origin: "top-level" } },
|
|
@@ -58,6 +60,66 @@ let dynamicLeafId = "u0000002";
|
|
|
58
60
|
let scriptedStreaming = false;
|
|
59
61
|
let continuityRun = 0;
|
|
60
62
|
let largeTranscriptEnabled = false;
|
|
63
|
+
const fixtureSubagentRuns = [];
|
|
64
|
+
const fixtureSubagentGates = [];
|
|
65
|
+
const runtimeQueue = {
|
|
66
|
+
steering: ["runtime steering"],
|
|
67
|
+
followUp: ["runtime first", "runtime second", "runtime third"],
|
|
68
|
+
steeringMessages: [],
|
|
69
|
+
followUpMessages: [],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function runtimeQueuedMessage(text, timestamp) {
|
|
73
|
+
return {
|
|
74
|
+
role: "user",
|
|
75
|
+
timestamp,
|
|
76
|
+
metadata: { fixture: "runtime-queue" },
|
|
77
|
+
content: [{ type: "text", text }, { type: "image", mimeType: "image/png", data: "iVBORw0KGgo=" }],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
runtimeQueue.steeringMessages = runtimeQueue.steering.map((text, index) => runtimeQueuedMessage(text, 100 + index));
|
|
82
|
+
runtimeQueue.followUpMessages = runtimeQueue.followUp.map((text, index) => runtimeQueuedMessage(text, 200 + index));
|
|
83
|
+
|
|
84
|
+
function runtimeQueueSnapshot() {
|
|
85
|
+
return { source: "pi-runtime", steering: [...runtimeQueue.steering], followUp: [...runtimeQueue.followUp] };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function sameRuntimeQueue(expected) {
|
|
89
|
+
return Array.isArray(expected?.steering) && Array.isArray(expected?.followUp)
|
|
90
|
+
&& expected.steering.length === runtimeQueue.steering.length
|
|
91
|
+
&& expected.followUp.length === runtimeQueue.followUp.length
|
|
92
|
+
&& expected.steering.every((text, index) => text === runtimeQueue.steering[index])
|
|
93
|
+
&& expected.followUp.every((text, index) => text === runtimeQueue.followUp[index]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function mutateRuntimeQueue(payload = {}) {
|
|
97
|
+
const failed = (reason) => ({ mutated: false, reason, queue: runtimeQueueSnapshot() });
|
|
98
|
+
if (payload.source !== "pi-runtime" || payload.kind !== "followUp" || !sameRuntimeQueue(payload.expected)) return failed("queue-changed");
|
|
99
|
+
const operation = payload.operation;
|
|
100
|
+
if (!operation || typeof operation.expectedText !== "string") return failed("invalid-request");
|
|
101
|
+
if (operation.type === "edit") {
|
|
102
|
+
if (!Number.isInteger(operation.index) || operation.index < 0 || operation.index >= runtimeQueue.followUp.length
|
|
103
|
+
|| runtimeQueue.followUp[operation.index] !== operation.expectedText || typeof operation.text !== "string" || !operation.text.trim()) return failed("invalid-request");
|
|
104
|
+
const message = runtimeQueue.followUpMessages[operation.index];
|
|
105
|
+
const textPartIndex = message.content.findIndex((part) => part?.type === "text");
|
|
106
|
+
if (textPartIndex < 0) return failed("queue-desynchronized");
|
|
107
|
+
runtimeQueue.followUp[operation.index] = operation.text;
|
|
108
|
+
runtimeQueue.followUpMessages[operation.index] = { ...message, content: message.content.map((part, index) => index === textPartIndex ? { ...part, text: operation.text } : part) };
|
|
109
|
+
} else if (operation.type === "move") {
|
|
110
|
+
if (!Number.isInteger(operation.from) || !Number.isInteger(operation.to) || operation.from < 0 || operation.to < 0
|
|
111
|
+
|| operation.from >= runtimeQueue.followUp.length || operation.to >= runtimeQueue.followUp.length || operation.from === operation.to
|
|
112
|
+
|| runtimeQueue.followUp[operation.from] !== operation.expectedText) return failed("invalid-request");
|
|
113
|
+
const [text] = runtimeQueue.followUp.splice(operation.from, 1);
|
|
114
|
+
const [message] = runtimeQueue.followUpMessages.splice(operation.from, 1);
|
|
115
|
+
runtimeQueue.followUp.splice(operation.to, 0, text);
|
|
116
|
+
runtimeQueue.followUpMessages.splice(operation.to, 0, message);
|
|
117
|
+
} else {
|
|
118
|
+
return failed("invalid-request");
|
|
119
|
+
}
|
|
120
|
+
emitEvent({ type: "queue_update", steering: [...runtimeQueue.steering], followUp: [...runtimeQueue.followUp] });
|
|
121
|
+
return { mutated: true, source: "pi-runtime", queue: runtimeQueueSnapshot() };
|
|
122
|
+
}
|
|
61
123
|
|
|
62
124
|
function allSessionEntries() {
|
|
63
125
|
return [...staticEntries, ...dynamicEntries];
|
|
@@ -266,6 +328,43 @@ function emitConversationStatus() {
|
|
|
266
328
|
});
|
|
267
329
|
}
|
|
268
330
|
|
|
331
|
+
function emitCodexFastModeStatus() {
|
|
332
|
+
emitEvent({
|
|
333
|
+
type: "extension_ui_request",
|
|
334
|
+
id: randomUUID(),
|
|
335
|
+
method: "setStatus",
|
|
336
|
+
statusKey: "codex-fast-mode",
|
|
337
|
+
statusText: codexFastModeEnabled ? "on" : "off",
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function handleCodexFastModePrompt(command, base) {
|
|
342
|
+
const message = String(command.message || "").trim();
|
|
343
|
+
if (message === "fixture reject next codex fast mode mutation") {
|
|
344
|
+
rejectNextCodexFastModeMutation = true;
|
|
345
|
+
// Prompt routing marks the tab active before RPC dispatch; settle this control-only fixture
|
|
346
|
+
// synchronously so the following PUT exercises status confirmation rather than preflight busy.
|
|
347
|
+
emitEvent({ type: "agent_start" });
|
|
348
|
+
emitEvent({ type: "agent_settled" });
|
|
349
|
+
respond({ ...base, data: { output: "next Codex Fast mode mutation will be rejected" } });
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
const match = message.match(/^\/fast-mode(?:\s+(on|off|status))?$/i);
|
|
353
|
+
if (!match) return false;
|
|
354
|
+
const subcommand = String(match[1] || "").toLowerCase();
|
|
355
|
+
if (subcommand !== "status" && rejectNextCodexFastModeMutation) {
|
|
356
|
+
rejectNextCodexFastModeMutation = false;
|
|
357
|
+
respond({ ...base, data: { output: "Fast mode mutation rejected while busy" } });
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
if (!subcommand) codexFastModeEnabled = !codexFastModeEnabled;
|
|
361
|
+
else if (subcommand === "on") codexFastModeEnabled = true;
|
|
362
|
+
else if (subcommand === "off") codexFastModeEnabled = false;
|
|
363
|
+
emitCodexFastModeStatus();
|
|
364
|
+
respond({ ...base, data: { output: `Fast mode ${codexFastModeEnabled ? "on" : "off"}.` } });
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
|
|
269
368
|
function handleWebuiHelperPrompt(command, base) {
|
|
270
369
|
const message = String(command.message || "").trim();
|
|
271
370
|
const match = message.match(/^\/webui-helper\s+(\{[\s\S]*\})$/);
|
|
@@ -310,26 +409,35 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
310
409
|
respondHelper({ requestId, ok: true, data: { skills: fakeSkills.map((skill) => ({ ...skill, enabled: enabledSkillNames.has(skill.name) })) } });
|
|
311
410
|
return true;
|
|
312
411
|
}
|
|
313
|
-
case "
|
|
412
|
+
case "queue-mutate":
|
|
413
|
+
respondHelper({ requestId, ok: true, data: mutateRuntimeQueue(request.payload) });
|
|
414
|
+
return true;
|
|
415
|
+
case "subagent-output": {
|
|
416
|
+
const run = fixtureSubagentRuns.find((candidate) => candidate.id === request.payload?.runId);
|
|
417
|
+
const agent = run?.agents?.find((candidate) => candidate.id === request.payload?.agentId);
|
|
418
|
+
if (!run || !agent) {
|
|
419
|
+
respondHelper({ requestId, ok: false, error: "Subagent output is no longer tracked" });
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
314
422
|
respondHelper({
|
|
315
423
|
requestId,
|
|
316
424
|
ok: true,
|
|
317
425
|
data: {
|
|
318
426
|
version: 1,
|
|
319
|
-
runId:
|
|
320
|
-
source:
|
|
321
|
-
mode:
|
|
322
|
-
startedAt:
|
|
323
|
-
updatedAt: Date.now(),
|
|
427
|
+
runId: run.id,
|
|
428
|
+
source: run.source,
|
|
429
|
+
mode: run.mode,
|
|
430
|
+
startedAt: run.startedAt,
|
|
431
|
+
updatedAt: run.endedAt || Date.now(),
|
|
324
432
|
agent: {
|
|
325
|
-
id:
|
|
326
|
-
name:
|
|
327
|
-
index:
|
|
328
|
-
status:
|
|
433
|
+
id: agent.id,
|
|
434
|
+
name: agent.name,
|
|
435
|
+
index: agent.index,
|
|
436
|
+
status: agent.status,
|
|
329
437
|
currentTool: "read",
|
|
330
438
|
currentToolArgs: "README.md",
|
|
331
|
-
model: "anthropic/claude-opus-4-8:high",
|
|
332
|
-
thinking: "high",
|
|
439
|
+
model: agent.model || "anthropic/claude-opus-4-8:high",
|
|
440
|
+
thinking: agent.thinking || "high",
|
|
333
441
|
recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
|
|
334
442
|
recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
|
|
335
443
|
transcript: [
|
|
@@ -359,6 +467,37 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
359
467
|
},
|
|
360
468
|
});
|
|
361
469
|
return true;
|
|
470
|
+
}
|
|
471
|
+
case "subagent-cancel": {
|
|
472
|
+
const run = fixtureSubagentRuns.find((candidate) => candidate.id === request.payload?.runId);
|
|
473
|
+
if (!run || run.status !== "running") {
|
|
474
|
+
respondHelper({ requestId, ok: false, error: "Subagent run is not running" });
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
const reason = String(request.payload?.reason || "").trim().slice(0, 120) || undefined;
|
|
478
|
+
const note = String(request.payload?.note || "").trim().slice(0, 2000) || undefined;
|
|
479
|
+
run.status = "cancelled";
|
|
480
|
+
run.endedAt = Date.now();
|
|
481
|
+
run.cancelReason = reason;
|
|
482
|
+
run.cancelNote = note;
|
|
483
|
+
run.cancelledBy = "user";
|
|
484
|
+
run.agents = run.agents.map((agent) => ({ ...agent, status: "cancelled" }));
|
|
485
|
+
emitSubagentFixtureStatus();
|
|
486
|
+
respondHelper({ requestId, ok: true, data: { runId: run.id, state: "cancelled", delivery: "context", rpcMethod: "stop" } });
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
case "subagent-dismiss": {
|
|
490
|
+
const index = fixtureSubagentRuns.findIndex((candidate) => candidate.id === request.payload?.runId);
|
|
491
|
+
const run = fixtureSubagentRuns[index];
|
|
492
|
+
if (!run || run.status === "running") {
|
|
493
|
+
respondHelper({ requestId, ok: false, error: "Subagent run cannot be dismissed" });
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
fixtureSubagentRuns.splice(index, 1);
|
|
497
|
+
emitSubagentFixtureStatus();
|
|
498
|
+
respondHelper({ requestId, ok: true, data: { runId: request.payload?.runId, dismissed: true } });
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
362
501
|
default:
|
|
363
502
|
respondHelper({ requestId, ok: false, error: `Unknown webui-helper action: ${String(request.action || "")}` });
|
|
364
503
|
return true;
|
|
@@ -460,43 +599,75 @@ function handleTransportFixturePrompt(command, base) {
|
|
|
460
599
|
return false;
|
|
461
600
|
}
|
|
462
601
|
|
|
463
|
-
function
|
|
464
|
-
const message = String(command.message || "").trim();
|
|
465
|
-
if (message !== "fixture subagents running" && message !== "fixture subagents clear") return false;
|
|
466
|
-
const clearing = message.endsWith("clear");
|
|
467
|
-
const runs = clearing ? [] : [{
|
|
468
|
-
id: "fixture-run",
|
|
469
|
-
source: "async",
|
|
470
|
-
mode: "parallel",
|
|
471
|
-
status: "running",
|
|
472
|
-
startedAt: Date.now() - 2500,
|
|
473
|
-
agents: [
|
|
474
|
-
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false },
|
|
475
|
-
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
|
|
476
|
-
],
|
|
477
|
-
}];
|
|
478
|
-
const gates = clearing ? [] : [{
|
|
479
|
-
version: 1,
|
|
480
|
-
id: "fixture-gate",
|
|
481
|
-
status: "running",
|
|
482
|
-
requiredSuccesses: 2,
|
|
483
|
-
qualifyingSuccesses: 1,
|
|
484
|
-
requireDistinctProviders: true,
|
|
485
|
-
startedAt: Date.now() - 3000,
|
|
486
|
-
updatedAt: Date.now(),
|
|
487
|
-
attempts: [
|
|
488
|
-
{ id: "fixture-gate:0:1", taskIndex: 0, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-1", model: "anthropic/claude-opus-4-8", provider: "anthropic", status: "succeeded" },
|
|
489
|
-
{ id: "fixture-gate:1:1", taskIndex: 1, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-2", model: "openrouter/moonshotai/kimi-k3", provider: "openrouter", status: "failed", failureKind: "transient-provider", error: "provider overloaded" },
|
|
490
|
-
],
|
|
491
|
-
}];
|
|
492
|
-
respond({ ...base, data: { output: "fake subagent status emitted" } });
|
|
602
|
+
function emitSubagentFixtureStatus() {
|
|
493
603
|
emitEvent({
|
|
494
604
|
type: "extension_ui_request",
|
|
495
605
|
id: randomUUID(),
|
|
496
606
|
method: "setStatus",
|
|
497
607
|
statusKey: "webui-subagents",
|
|
498
|
-
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs, gates })}`,
|
|
608
|
+
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs: fixtureSubagentRuns, gates: fixtureSubagentGates })}`,
|
|
499
609
|
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function handleSubagentFixturePrompt(command, base) {
|
|
613
|
+
const message = String(command.message || "").trim();
|
|
614
|
+
if (!["fixture subagents running", "fixture subagents clear", "fixture subagents retained"].includes(message)) return false;
|
|
615
|
+
const now = Date.now();
|
|
616
|
+
fixtureSubagentRuns.splice(0, fixtureSubagentRuns.length);
|
|
617
|
+
fixtureSubagentGates.splice(0, fixtureSubagentGates.length);
|
|
618
|
+
if (message === "fixture subagents running") {
|
|
619
|
+
fixtureSubagentRuns.push({
|
|
620
|
+
id: "fixture-run",
|
|
621
|
+
source: "async",
|
|
622
|
+
mode: "parallel",
|
|
623
|
+
status: "running",
|
|
624
|
+
startedAt: now - 2500,
|
|
625
|
+
agents: [
|
|
626
|
+
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false },
|
|
627
|
+
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
|
|
628
|
+
],
|
|
629
|
+
});
|
|
630
|
+
fixtureSubagentGates.push({
|
|
631
|
+
version: 1,
|
|
632
|
+
id: "fixture-gate",
|
|
633
|
+
status: "running",
|
|
634
|
+
requiredSuccesses: 2,
|
|
635
|
+
qualifyingSuccesses: 1,
|
|
636
|
+
requireDistinctProviders: true,
|
|
637
|
+
startedAt: now - 3000,
|
|
638
|
+
updatedAt: now,
|
|
639
|
+
attempts: [
|
|
640
|
+
{ id: "fixture-gate:0:1", taskIndex: 0, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-1", model: "anthropic/claude-opus-4-8", provider: "anthropic", status: "succeeded" },
|
|
641
|
+
{ id: "fixture-gate:1:1", taskIndex: 1, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-2", model: "openrouter/moonshotai/kimi-k3", provider: "openrouter", status: "failed", failureKind: "transient-provider", error: "provider overloaded" },
|
|
642
|
+
],
|
|
643
|
+
});
|
|
644
|
+
} else if (message === "fixture subagents retained") {
|
|
645
|
+
fixtureSubagentRuns.push(
|
|
646
|
+
{
|
|
647
|
+
id: "fixture-done",
|
|
648
|
+
source: "foreground",
|
|
649
|
+
mode: "single",
|
|
650
|
+
status: "done",
|
|
651
|
+
startedAt: now - 5000,
|
|
652
|
+
endedAt: now - 2000,
|
|
653
|
+
agents: [{ id: "fixture-done:0", name: "tester", status: "done", index: 0, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false }],
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: "fixture-cancelled",
|
|
657
|
+
source: "async",
|
|
658
|
+
mode: "parallel",
|
|
659
|
+
status: "cancelled",
|
|
660
|
+
startedAt: now - 4000,
|
|
661
|
+
endedAt: now - 1000,
|
|
662
|
+
cancelledBy: "user",
|
|
663
|
+
cancelReason: "Taking too long",
|
|
664
|
+
cancelNote: "Use the existing result instead.",
|
|
665
|
+
agents: [{ id: "fixture-cancelled:0", name: "reviewer", status: "cancelled", index: 0, model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false }],
|
|
666
|
+
},
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
respond({ ...base, data: { output: "fake subagent status emitted" } });
|
|
670
|
+
emitSubagentFixtureStatus();
|
|
500
671
|
return true;
|
|
501
672
|
}
|
|
502
673
|
|
|
@@ -616,6 +787,7 @@ rl.on("line", (line) => {
|
|
|
616
787
|
{ name: "talk", source: "extension", description: "Toggle Natural Conversation Mode" },
|
|
617
788
|
{ name: "voice", source: "extension", description: "Natural Conversation Mode alias" },
|
|
618
789
|
{ name: "conversation", source: "extension", description: "Natural Conversation Mode alias" },
|
|
790
|
+
{ name: "fast-mode", source: "extension", description: "Toggle Codex subscription Fast mode" },
|
|
619
791
|
{ name: "workflow", source: "extension", description: "Run and inspect JavaScript workflows" },
|
|
620
792
|
],
|
|
621
793
|
},
|
|
@@ -645,6 +817,7 @@ rl.on("line", (line) => {
|
|
|
645
817
|
if (handleSubagentFixturePrompt(command, base)) return;
|
|
646
818
|
if (handleDocumentArtifactFixturePrompt(command, base)) return;
|
|
647
819
|
if (handleWorkflowFixturePrompt(command, base)) return;
|
|
820
|
+
if (handleCodexFastModePrompt(command, base)) return;
|
|
648
821
|
if (handleTalkPrompt(command, base)) return;
|
|
649
822
|
if (handleContinuityPrompt(command, base)) return;
|
|
650
823
|
if (handleLargePayloadPrompt(command, base)) return;
|
|
@@ -31,8 +31,11 @@ const combinedSyntaxSource = sourceBetween("function gitFileDiffUsesCombinedSynt
|
|
|
31
31
|
const snapshotSource = sourceBetween("async function loadGitFileChangesSnapshot(", "\nfunction gitFileChangesPlaceholder(", "loadGitFileChangesSnapshot");
|
|
32
32
|
const applySnapshotSource = sourceBetween("function gitFileChangesPlaceholder(", "\nasync function openFileInViewer(", "gitFileChangesPlaceholder");
|
|
33
33
|
const openFileSource = sourceBetween("async function openFileInViewer(", "\nasync function openAurReviewReportInViewer(", "openFileInViewer");
|
|
34
|
-
const
|
|
34
|
+
const viewerPersistenceSource = sourceBetween("function cacheActiveFileViewerForTab(", "\n// Side-panel Git categories are UI labels", "file viewer tab persistence");
|
|
35
35
|
const moveSource = sourceBetween("function updateActiveFileViewerAfterMove(", "\nfunction closeActiveFileViewerIfDeleted(", "updateActiveFileViewerAfterMove");
|
|
36
|
+
const resetActiveTabUiSource = sourceBetween("function resetActiveTabUi(", "\nfunction tabGroupStatusRank(", "resetActiveTabUi");
|
|
37
|
+
const switchTabSource = sourceBetween("async function switchTab(", "\nfunction currentDirectoryForNewTab(", "switchTab");
|
|
38
|
+
const closeTabsSource = sourceBetween("async function closeTerminalTabs(", "\nasync function closeTerminalTab(", "closeTerminalTabs");
|
|
36
39
|
|
|
37
40
|
const targets = JSON.parse(vm.runInNewContext(`${normalizePathSource}\n${targetSource}\nJSON.stringify([
|
|
38
41
|
gitFileViewerTarget("sub/active.js", "/repo", [{ tabId: "repo-tab", cwd: "/repo" }]),
|
|
@@ -152,8 +155,8 @@ assert.match(app, /let fileViewerGitChangesRequestSerial = 0;/, "Git changes ope
|
|
|
152
155
|
assert.match(applySnapshotSource, /loading: true, requestSerial/, "the viewer should show an identified loading snapshot until the bounded diff arrives");
|
|
153
156
|
assert.match(
|
|
154
157
|
applySnapshotSource,
|
|
155
|
-
/
|
|
156
|
-
"a late diff response should
|
|
158
|
+
/const viewer = tabContext\.tabId === activeTabId \? activeFileViewer : fileViewersByTab\.get\(tabContext\.tabId\);\s*if \(!viewer\?\.gitChanges\?\.loading \|\| viewer\.path !== viewerPath \|\| viewer\.gitChanges\.requestSerial !== requestSerial\) return;/,
|
|
159
|
+
"a late diff response should update the owning terminal's cached viewer while still rejecting stale viewer identities",
|
|
157
160
|
);
|
|
158
161
|
|
|
159
162
|
// --- Open flow: Git default, normal-open isolation, deleted files ---
|
|
@@ -180,10 +183,22 @@ assert.match(
|
|
|
180
183
|
assert.match(openFileSource, /mode: "changes",\s*dirty: false,\s*readOnly: true,\s*sourceAvailable: false,/, "a deleted tracked file should open read-only in Changes mode");
|
|
181
184
|
assert.match(openFileSource, /setFileViewerStatus\("File content unavailable; showing Git changes \(read-only\)\.", "warn"\)/, "the deleted-file fallback should explain itself in the viewer status");
|
|
182
185
|
assert.match(openFileSource, /setFileViewerStatus\(message, "error"\);\s*addEvent\(`file open failed: \$\{message\}`, "error"\);/, "a total failure should still report the original open error");
|
|
183
|
-
assert.match(
|
|
184
|
-
assert.match(
|
|
186
|
+
assert.match(viewerPersistenceSource, /function resetFileViewerUi\(\) \{\s*fileViewerOpenRequestSerial \+= 1;\s*activeFileViewer = null;/, "resetting the visible viewer should invalidate pending source and deleted-file opens");
|
|
187
|
+
assert.match(viewerPersistenceSource, /elements\.fileViewerChanges\.hidden = true;\s*elements\.fileViewerChanges\.replaceChildren\(\);/, "resetting the visible viewer should clear the changes surface");
|
|
185
188
|
assert.match(moveSource, /gitChanges: null,/, "renaming the open file should drop its stale open-time diff snapshot");
|
|
186
189
|
|
|
190
|
+
// --- Per-terminal viewer persistence ---
|
|
191
|
+
|
|
192
|
+
assert.match(app, /let fileViewersByTab = new Map\(\);/, "open file viewers should be stored per terminal tab");
|
|
193
|
+
assert.match(app, /let fileViewerSelectionsByTab = new Map\(\);/, "viewer selections should be stored with their owning terminal tab");
|
|
194
|
+
assert.match(viewerPersistenceSource, /fileViewersByTab\.set\(tabId, activeFileViewer\)/, "caching a terminal should retain its active viewer object, including dirty edits and mode");
|
|
195
|
+
assert.match(viewerPersistenceSource, /fileViewerSelectionsByTab\.set\(tabId, fileViewerSelection\)/, "caching a terminal should retain its active file selection");
|
|
196
|
+
assert.match(viewerPersistenceSource, /activeFileViewer = activeTabId \? fileViewersByTab\.get\(activeTabId\) \|\| null : null;\s*fileViewerSelection = activeTabId \? fileViewerSelectionsByTab\.get\(activeTabId\) \|\| null : null;\s*updateFileViewerUi\(\);/, "activating a terminal should restore its own viewer and selection");
|
|
197
|
+
assert.match(viewerPersistenceSource, /function closeFileViewer\(\) \{\s*if \(activeTabId\) \{\s*fileViewersByTab\.delete\(activeTabId\);\s*fileViewerSelectionsByTab\.delete\(activeTabId\);/, "explicitly closing a viewer should remove only the active terminal's cached state");
|
|
198
|
+
assert.match(switchTabSource, /cacheActiveFileViewerForTab\(activeTabId\);\s*const tabContext = setActiveTabId\(tabId, \{ remember: true \}\);/, "switching terminals should cache the outgoing viewer before changing the active tab identity");
|
|
199
|
+
assert.match(resetActiveTabUiSource, /resetFileViewerUi\(\);\s*resetFileTreeState\(\);\s*restoreFileViewerForActiveTab\(\);/, "resetting tab UI should restore the incoming terminal's viewer instead of closing it");
|
|
200
|
+
assert.match(closeTabsSource, /fileViewersByTab\.delete\(id\);\s*fileViewerSelectionsByTab\.delete\(id\);/, "closing terminal tabs should discard their cached viewers and selections");
|
|
201
|
+
|
|
187
202
|
// --- Changes rendering contracts ---
|
|
188
203
|
|
|
189
204
|
const combined = JSON.parse(vm.runInNewContext(`${combinedSyntaxSource}\nJSON.stringify([
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
GIT_WORKFLOW_SETUP_VERSION,
|
|
7
7
|
gitWorkflowPreferencesSummary,
|
|
8
8
|
isGitWorkflowSetupComplete,
|
|
9
|
+
normalizeInterfacePreferences,
|
|
9
10
|
readGitWorkflowPreferences,
|
|
10
11
|
readWebuiSettings,
|
|
11
12
|
supportedGitWorkflowThinkingLevels,
|
|
@@ -24,6 +25,10 @@ assert.deepEqual(
|
|
|
24
25
|
["off", "low", "medium", "high", "max"],
|
|
25
26
|
"null map entries should be hidden while explicit extended levels remain available",
|
|
26
27
|
);
|
|
28
|
+
assert.deepEqual(normalizeInterfacePreferences({}), { sidePanelWidth: null });
|
|
29
|
+
assert.deepEqual(normalizeInterfacePreferences({ sidePanelWidth: 617.6 }), { sidePanelWidth: 618 });
|
|
30
|
+
assert.deepEqual(normalizeInterfacePreferences({ sidePanelWidth: 10 }), { sidePanelWidth: 320 });
|
|
31
|
+
assert.deepEqual(normalizeInterfacePreferences({ sidePanelWidth: 9000 }), { sidePanelWidth: 4096 });
|
|
27
32
|
|
|
28
33
|
const root = await mkdtemp(path.join(tmpdir(), "pi-webui-git-preferences-"));
|
|
29
34
|
const settingsFile = path.join(root, "settings.json");
|
|
@@ -62,6 +67,7 @@ try {
|
|
|
62
67
|
tools: { enabledTools: ["read", " write ", "read", ""] },
|
|
63
68
|
skills: { enabledSkills: ["repo-explorer", "code-security"] },
|
|
64
69
|
},
|
|
70
|
+
interfacePreferences: { sidePanelWidth: 612 },
|
|
65
71
|
}, settingsFile);
|
|
66
72
|
|
|
67
73
|
const partiallyUpdated = await writeGitWorkflowPreferences({ deliveryMode: "current" }, settingsFile);
|
|
@@ -76,6 +82,8 @@ try {
|
|
|
76
82
|
assert.equal(persisted.gitWorkflow.generation.provider, "fake");
|
|
77
83
|
assert.deepEqual(persisted.resourceDefaults.tools.enabledTools, ["read", "write"], "global tool defaults should be normalized and deduplicated");
|
|
78
84
|
assert.deepEqual(persisted.resourceDefaults.skills.enabledSkills, ["repo-explorer", "code-security"], "global skill defaults should persist beside other Web UI settings");
|
|
85
|
+
assert.equal(persisted.interfacePreferences.sidePanelWidth, 612, "the user-scoped Control Deck width should persist beside other Web UI settings");
|
|
86
|
+
assert.equal((await readWebuiSettings(settingsFile)).interfacePreferences.sidePanelWidth, 612);
|
|
79
87
|
assert.match(gitWorkflowPreferencesSummary(await readGitWorkflowPreferences(settingsFile)), /fake\/fake-model/);
|
|
80
88
|
if (process.platform !== "win32") assert.equal((await stat(settingsFile)).mode & 0o777, 0o600);
|
|
81
89
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const server = await readFile(new URL("../bin/pi-webui.mjs", import.meta.url), "utf8");
|
|
5
|
+
|
|
6
|
+
assert.match(
|
|
7
|
+
server,
|
|
8
|
+
/if \(push && \/fatal:\\s\+no configured push destination\\\.\/\.test\(text\)\) \{\s*return \{ code: "NO_REMOTE", hint: NO_REMOTE_HINT \};/,
|
|
9
|
+
"only Git's explicit no-push-destination failure should receive NO_REMOTE classification",
|
|
10
|
+
);
|
|
11
|
+
assert.doesNotMatch(
|
|
12
|
+
server,
|
|
13
|
+
/does not appear to be a git repository[\s\S]{0,160}NO_REMOTE|NO_REMOTE[\s\S]{0,160}does not appear to be a git repository/,
|
|
14
|
+
"an invalid configured remote must not be reclassified as remote-less",
|
|
15
|
+
);
|
|
16
|
+
assert.match(
|
|
17
|
+
server,
|
|
18
|
+
/const GIT_WORKFLOW_MUTATING_PATHS = new Set\(\[[\s\S]*"\/api\/git-workflow\/publish"[\s\S]*\]\);/,
|
|
19
|
+
"publication must use the POST-only mutating workflow allowlist",
|
|
20
|
+
);
|
|
21
|
+
assert.match(
|
|
22
|
+
server,
|
|
23
|
+
/case "\/api\/git-workflow\/publish": \{[\s\S]*cleanGitHubRepoName\(body\.repoName\)[\s\S]*visibility !== "public" && visibility !== "private"[\s\S]*requireConfirmed\(body,[\s\S]*getGitRoot\(cwd\)[\s\S]*gitRemoteNames\(root\)[\s\S]*remotes\.length[\s\S]*currentGitBranch\(root\)/,
|
|
24
|
+
"the server must validate name/visibility/confirmation and refuse existing-remote repair before publication",
|
|
25
|
+
);
|
|
26
|
+
assert.match(
|
|
27
|
+
server,
|
|
28
|
+
/runGitHubWorkflowCommand\(\s*\["repo", "create", repoName, `--\$\{visibility\}`, "--source", root, "--remote", "origin", "--push"\],[\s\S]*timeoutMs: 15 \* 60 \* 1000/,
|
|
29
|
+
"publication must run the approved non-interactive gh repo create command through the bounded workflow runner",
|
|
30
|
+
);
|
|
31
|
+
assert.match(
|
|
32
|
+
server,
|
|
33
|
+
/if \(payload\.ok\) Object\.assign\(payload\.data, \{ repoName, visibility, remote: "origin", branch, protectedBranch \}\);/,
|
|
34
|
+
"successful publication must extend the process envelope with the approved metadata",
|
|
35
|
+
);
|
|
36
|
+
assert.match(server, /payload\.code = "AUTH";[\s\S]*gh auth login/, "gh authentication failures should receive an actionable AUTH hint");
|
|
37
|
+
assert.match(server, /name already exists on this account\|repository \.\+ already exists[\s\S]*Choose another repository name/, "safe name-conflict output should receive a retry hint");
|
|
38
|
+
assert.match(server, /GH_PROMPT_DISABLED: process\.env\.GH_PROMPT_DISABLED \|\| "1"/, "gh publication must inherit disabled interactive prompts");
|
|
39
|
+
|
|
40
|
+
console.log("guided git publication backend static tests passed");
|