@firstpick/pi-package-webui 0.7.7 → 0.7.9
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 +23 -0
- package/bin/pi-webui-rpc-supervisor.mjs +115 -21
- package/bin/pi-webui.mjs +447 -88
- package/lib/queue-mutation.mjs +109 -0
- package/lib/rpc-supervisor-client.mjs +18 -2
- package/lib/rpc-supervisor-protocol.mjs +11 -2
- package/lib/scoped-models.mjs +19 -0
- package/lib/webui-workspaces.mjs +265 -0
- package/package.json +4 -4
- package/public/app.js +2227 -195
- package/public/index.html +143 -2
- package/public/issue-bot-client.mjs +344 -0
- package/public/issue-wizard-state.mjs +443 -0
- package/public/service-worker.js +3 -1
- package/public/styles.css +787 -56
- package/public/voice-conversation.mjs +1 -1
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- 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/completion-signal-contract.test.mjs +156 -0
- package/tests/cwd-footer-reliability-static.test.mjs +112 -0
- package/tests/durable-rpc-supervisor-harness.test.mjs +25 -2
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/file-selection-overlay-static.test.mjs +21 -0
- package/tests/file-viewer-search-static.test.mjs +65 -0
- package/tests/fixtures/compacting-pi.mjs +0 -0
- package/tests/fixtures/fake-pi.mjs +186 -49
- package/tests/footer-context-contrast-static.test.mjs +10 -0
- package/tests/git-panel-file-preview-static.test.mjs +20 -5
- package/tests/git-panel-render-stability-static.test.mjs +11 -1
- package/tests/http-endpoints-harness.test.mjs +160 -1
- package/tests/issue-bot-client.test.mjs +135 -0
- package/tests/issue-wizard-state.test.mjs +126 -0
- package/tests/mobile-static.test.mjs +61 -42
- package/tests/native-parity.test.mjs +3 -3
- package/tests/open-issue-wizard-static.test.mjs +75 -0
- package/tests/prompt-routing-tab-status.test.mjs +5 -0
- package/tests/queue-edit-reorder-static.test.mjs +101 -0
- package/tests/queue-mutation-contract.test.mjs +143 -0
- package/tests/rpc-supervisor-host.test.mjs +135 -2
- package/tests/rpc-supervisor-protocol.test.mjs +26 -0
- package/tests/scoped-models.test.mjs +42 -0
- package/tests/streaming-ui-coupling.test.mjs +3 -2
- package/tests/subagents-helper.test.mjs +216 -3
- package/tests/terminal-tab-workspace-static.test.mjs +101 -0
- 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
|
@@ -110,6 +110,7 @@ async function readLog(logFile) {
|
|
|
110
110
|
const work = await mkdtemp(path.join(tmpdir(), "pi-webui-continuity-harness-"));
|
|
111
111
|
const agentDir = path.join(work, "agent");
|
|
112
112
|
const cwd = path.join(work, "cwd");
|
|
113
|
+
const changedCwd = path.join(work, "changed-cwd");
|
|
113
114
|
const settingsFile = path.join(work, "settings.json");
|
|
114
115
|
const sessionFile = path.join(work, "fixture-session.jsonl");
|
|
115
116
|
const logFile = path.join(work, "fake-pi.jsonl");
|
|
@@ -132,6 +133,7 @@ let observedTabId;
|
|
|
132
133
|
try {
|
|
133
134
|
await writeFile(settingsFile, "{}\n");
|
|
134
135
|
await mkdir(cwd, { recursive: true });
|
|
136
|
+
await mkdir(changedCwd, { recursive: true });
|
|
135
137
|
initialServer = spawnServer({ cwd, env: environment, output });
|
|
136
138
|
|
|
137
139
|
const initialHealth = await waitFor("initial supervised server health", health);
|
|
@@ -147,6 +149,27 @@ try {
|
|
|
147
149
|
assert.equal(initialTab.cwd, cwd, "tab metadata must retain the isolated cwd");
|
|
148
150
|
assert.equal(initialTab.sessionFile, sessionFile, "fixture session metadata must be captured before restart");
|
|
149
151
|
|
|
152
|
+
const concurrentCwdChanges = await Promise.all([
|
|
153
|
+
request(`/api/tabs/${encodeURIComponent(observedTabId)}`, { method: "PATCH", body: { cwd: changedCwd }, timeoutMs: 12_000 }),
|
|
154
|
+
request(`/api/tabs/${encodeURIComponent(observedTabId)}`, { method: "PATCH", body: { cwd: changedCwd }, timeoutMs: 12_000 }),
|
|
155
|
+
]);
|
|
156
|
+
assert.deepEqual(concurrentCwdChanges.map((response) => response.status).sort(), [200, 409], "overlapping existing-tab cwd changes should allow one restart and reject the duplicate deterministically");
|
|
157
|
+
const cwdChange = concurrentCwdChanges.find((response) => response.status === 200);
|
|
158
|
+
const rejectedCwdChange = concurrentCwdChanges.find((response) => response.status === 409);
|
|
159
|
+
assert.match(String(rejectedCwdChange.body?.error || ""), /already changing its working folder/i, "rejected overlapping cwd change should explain the active restart");
|
|
160
|
+
assert.equal(cwdChange.body?.data?.changed, true, "existing-tab cwd change should report a real restart");
|
|
161
|
+
assert.equal(cwdChange.body?.data?.tab?.cwd, changedCwd, "cwd change response should expose the replacement cwd");
|
|
162
|
+
assert.notEqual(cwdChange.body?.data?.tab?.pid, observedPiPid, "cwd change should replace the managed Pi child");
|
|
163
|
+
observedPiPid = cwdChange.body.data.tab.pid;
|
|
164
|
+
const cwdChangeState = await request(`/api/state?tab=${encodeURIComponent(observedTabId)}`);
|
|
165
|
+
assert.equal(cwdChangeState.status, 200, "replacement child should answer state requests before cwd PATCH resolves");
|
|
166
|
+
const cwdChangeCommands = await request(`/api/commands?tab=${encodeURIComponent(observedTabId)}`);
|
|
167
|
+
assert.equal(cwdChangeCommands.status, 200, "replacement child should answer command discovery after cwd change");
|
|
168
|
+
const replacementStartup = await waitFor("replacement cwd startup", async () => (
|
|
169
|
+
(await readLog(logFile)).find((entry) => entry.direction === "startup" && entry.pid === observedPiPid && entry.cwd === changedCwd)
|
|
170
|
+
));
|
|
171
|
+
assert.equal(replacementStartup.cwd, changedCwd, "replacement child process should actually run in the requested cwd");
|
|
172
|
+
|
|
150
173
|
const controlledPrompt = await request("/api/prompt", { method: "POST", body: { tab: observedTabId, message: streamPrompt } });
|
|
151
174
|
assert.equal(controlledPrompt.status, 200, "controlled-restart prompt must be accepted once");
|
|
152
175
|
const preRestartTab = (await tabs())[0];
|
|
@@ -162,7 +185,7 @@ try {
|
|
|
162
185
|
assert.equal(controlledTabs.length, 1, "controlled restart must hydrate instead of spawning duplicate tabs");
|
|
163
186
|
assert.deepEqual(
|
|
164
187
|
controlledTabs.map((tab) => ({ id: tab.id, pid: tab.pid, cwd: tab.cwd, sessionFile: tab.sessionFile, title: tab.title, index: tab.index })),
|
|
165
|
-
[{ id: preRestartTab.id, pid: observedPiPid, cwd, sessionFile, title: preRestartTab.title, index: preRestartTab.index }],
|
|
188
|
+
[{ id: preRestartTab.id, pid: observedPiPid, cwd: changedCwd, sessionFile, title: preRestartTab.title, index: preRestartTab.index }],
|
|
166
189
|
"controlled restart must retain the same managed tab metadata and Pi PID",
|
|
167
190
|
);
|
|
168
191
|
assert.equal(restartedHealth.piPid, observedPiPid, "controlled restart must retain the active Pi process");
|
|
@@ -189,7 +212,7 @@ try {
|
|
|
189
212
|
assert.equal(manualTabs.length, 1, "manual relaunch must not duplicate the supervised tab");
|
|
190
213
|
assert.deepEqual(
|
|
191
214
|
manualTabs.map((tab) => ({ id: tab.id, pid: tab.pid, cwd: tab.cwd, sessionFile: tab.sessionFile, title: tab.title, index: tab.index })),
|
|
192
|
-
[{ id: preRestartTab.id, pid: observedPiPid, cwd, sessionFile, title: preRestartTab.title, index: preRestartTab.index }],
|
|
215
|
+
[{ id: preRestartTab.id, pid: observedPiPid, cwd: changedCwd, sessionFile, title: preRestartTab.title, index: preRestartTab.index }],
|
|
193
216
|
"manual relaunch must retain tab ID, PID, and persisted metadata",
|
|
194
217
|
);
|
|
195
218
|
|
|
@@ -152,7 +152,7 @@ assert.match(helper, /FAST_OUTPUT_FLUSH_INTERVAL_MS = 100/, "the live scheduler
|
|
|
152
152
|
assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
|
|
153
153
|
assert.match(html, /<label for="fastOutputModeSelect">Fast mode \(Experimental\)<\/label>/, "the sidebar should mark fast mode as experimental");
|
|
154
154
|
assert.match(html, /Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish live and stored thinking defaults");
|
|
155
|
-
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=
|
|
155
|
+
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=92"/, "the guarded PWA entry point should cache-bust browser wiring");
|
|
156
156
|
assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
|
|
157
157
|
|
|
158
158
|
const events = createFastModeOutputEvents();
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const css = await readFile(join(root, "public", "styles.css"), "utf8");
|
|
8
|
+
|
|
9
|
+
const selectionBarRule = css.match(/\.file-selection-bar \{[^}]*\}/)?.[0] || "";
|
|
10
|
+
assert.match(
|
|
11
|
+
selectionBarRule,
|
|
12
|
+
/position:\s*absolute;[^}]*right:\s*0\.72rem;[^}]*bottom:\s*1\.68rem;[^}]*left:\s*0\.72rem;[^}]*z-index:\s*7;/,
|
|
13
|
+
"the file selection comment bar should overlay the viewer instead of shifting selected text",
|
|
14
|
+
);
|
|
15
|
+
assert.doesNotMatch(
|
|
16
|
+
selectionBarRule,
|
|
17
|
+
/flex:\s*0\s+0\s+auto;/,
|
|
18
|
+
"the file selection comment bar must stay out of the viewer's flex layout",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
console.log("file selection overlay static tests passed");
|
|
@@ -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");
|
|
File without changes
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// ({direction:"event", type}), so browser-driver tests can assert ordering.
|
|
12
12
|
// - FAKE_PI_VOICE_SCRIPTS=1: prompts containing "voice test say|question|tool|slow"
|
|
13
13
|
// respond success and then asynchronously emit a scripted agent event flow
|
|
14
|
-
// (agent_start/message_*/tool_execution_*/agent_end) over stdout; the scripted
|
|
14
|
+
// (agent_start/message_*/tool_execution_*/agent_end/agent_settled) over stdout; the scripted
|
|
15
15
|
// assistant turns are appended to a dynamic transcript returned by
|
|
16
16
|
// get_messages AFTER the three baseline messages, and get_state reports
|
|
17
17
|
// isStreaming=true while a scripted flow runs.
|
|
@@ -58,6 +58,66 @@ let dynamicLeafId = "u0000002";
|
|
|
58
58
|
let scriptedStreaming = false;
|
|
59
59
|
let continuityRun = 0;
|
|
60
60
|
let largeTranscriptEnabled = false;
|
|
61
|
+
const fixtureSubagentRuns = [];
|
|
62
|
+
const fixtureSubagentGates = [];
|
|
63
|
+
const runtimeQueue = {
|
|
64
|
+
steering: ["runtime steering"],
|
|
65
|
+
followUp: ["runtime first", "runtime second", "runtime third"],
|
|
66
|
+
steeringMessages: [],
|
|
67
|
+
followUpMessages: [],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function runtimeQueuedMessage(text, timestamp) {
|
|
71
|
+
return {
|
|
72
|
+
role: "user",
|
|
73
|
+
timestamp,
|
|
74
|
+
metadata: { fixture: "runtime-queue" },
|
|
75
|
+
content: [{ type: "text", text }, { type: "image", mimeType: "image/png", data: "iVBORw0KGgo=" }],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
runtimeQueue.steeringMessages = runtimeQueue.steering.map((text, index) => runtimeQueuedMessage(text, 100 + index));
|
|
80
|
+
runtimeQueue.followUpMessages = runtimeQueue.followUp.map((text, index) => runtimeQueuedMessage(text, 200 + index));
|
|
81
|
+
|
|
82
|
+
function runtimeQueueSnapshot() {
|
|
83
|
+
return { source: "pi-runtime", steering: [...runtimeQueue.steering], followUp: [...runtimeQueue.followUp] };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function sameRuntimeQueue(expected) {
|
|
87
|
+
return Array.isArray(expected?.steering) && Array.isArray(expected?.followUp)
|
|
88
|
+
&& expected.steering.length === runtimeQueue.steering.length
|
|
89
|
+
&& expected.followUp.length === runtimeQueue.followUp.length
|
|
90
|
+
&& expected.steering.every((text, index) => text === runtimeQueue.steering[index])
|
|
91
|
+
&& expected.followUp.every((text, index) => text === runtimeQueue.followUp[index]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function mutateRuntimeQueue(payload = {}) {
|
|
95
|
+
const failed = (reason) => ({ mutated: false, reason, queue: runtimeQueueSnapshot() });
|
|
96
|
+
if (payload.source !== "pi-runtime" || payload.kind !== "followUp" || !sameRuntimeQueue(payload.expected)) return failed("queue-changed");
|
|
97
|
+
const operation = payload.operation;
|
|
98
|
+
if (!operation || typeof operation.expectedText !== "string") return failed("invalid-request");
|
|
99
|
+
if (operation.type === "edit") {
|
|
100
|
+
if (!Number.isInteger(operation.index) || operation.index < 0 || operation.index >= runtimeQueue.followUp.length
|
|
101
|
+
|| runtimeQueue.followUp[operation.index] !== operation.expectedText || typeof operation.text !== "string" || !operation.text.trim()) return failed("invalid-request");
|
|
102
|
+
const message = runtimeQueue.followUpMessages[operation.index];
|
|
103
|
+
const textPartIndex = message.content.findIndex((part) => part?.type === "text");
|
|
104
|
+
if (textPartIndex < 0) return failed("queue-desynchronized");
|
|
105
|
+
runtimeQueue.followUp[operation.index] = operation.text;
|
|
106
|
+
runtimeQueue.followUpMessages[operation.index] = { ...message, content: message.content.map((part, index) => index === textPartIndex ? { ...part, text: operation.text } : part) };
|
|
107
|
+
} else if (operation.type === "move") {
|
|
108
|
+
if (!Number.isInteger(operation.from) || !Number.isInteger(operation.to) || operation.from < 0 || operation.to < 0
|
|
109
|
+
|| operation.from >= runtimeQueue.followUp.length || operation.to >= runtimeQueue.followUp.length || operation.from === operation.to
|
|
110
|
+
|| runtimeQueue.followUp[operation.from] !== operation.expectedText) return failed("invalid-request");
|
|
111
|
+
const [text] = runtimeQueue.followUp.splice(operation.from, 1);
|
|
112
|
+
const [message] = runtimeQueue.followUpMessages.splice(operation.from, 1);
|
|
113
|
+
runtimeQueue.followUp.splice(operation.to, 0, text);
|
|
114
|
+
runtimeQueue.followUpMessages.splice(operation.to, 0, message);
|
|
115
|
+
} else {
|
|
116
|
+
return failed("invalid-request");
|
|
117
|
+
}
|
|
118
|
+
emitEvent({ type: "queue_update", steering: [...runtimeQueue.steering], followUp: [...runtimeQueue.followUp] });
|
|
119
|
+
return { mutated: true, source: "pi-runtime", queue: runtimeQueueSnapshot() };
|
|
120
|
+
}
|
|
61
121
|
|
|
62
122
|
function allSessionEntries() {
|
|
63
123
|
return [...staticEntries, ...dynamicEntries];
|
|
@@ -101,6 +161,7 @@ function logJsonLine(entry) {
|
|
|
101
161
|
|
|
102
162
|
logJsonLine({
|
|
103
163
|
direction: "startup",
|
|
164
|
+
cwd: process.cwd(),
|
|
104
165
|
recoveryUrl: String(process.env.PI_WEBUI_RECOVERY_URL || ""),
|
|
105
166
|
recoveryTokenConfigured: Boolean(process.env.PI_WEBUI_RECOVERY_TOKEN),
|
|
106
167
|
...(continuityModeEnabled ? { pid: process.pid, continuityMode: true } : {}),
|
|
@@ -155,7 +216,7 @@ function cancelScriptedSteps() {
|
|
|
155
216
|
}
|
|
156
217
|
|
|
157
218
|
// Emits a full scripted assistant turn: agent_start, optional tool phase,
|
|
158
|
-
// streamed assistant text, message_end, agent_end. The final assistant text is
|
|
219
|
+
// streamed assistant text, message_end, agent_end, agent_settled. The final assistant text is
|
|
159
220
|
// appended to the dynamic transcript so get_messages returns it afterwards.
|
|
160
221
|
function runVoiceScriptFlow({ text, chunks, chunkSpacingMs = 60, toolPhase = false, toolDurationMs = 1500 }) {
|
|
161
222
|
scriptedStreaming = true;
|
|
@@ -177,11 +238,12 @@ function runVoiceScriptFlow({ text, chunks, chunkSpacingMs = 60, toolPhase = fal
|
|
|
177
238
|
emitScriptedEvent({ type: "message_end", message });
|
|
178
239
|
},
|
|
179
240
|
});
|
|
241
|
+
steps.push({ afterMs: 60, run: () => emitScriptedEvent({ type: "agent_end" }) });
|
|
180
242
|
steps.push({
|
|
181
|
-
afterMs:
|
|
243
|
+
afterMs: 10,
|
|
182
244
|
run: () => {
|
|
183
245
|
scriptedStreaming = false;
|
|
184
|
-
emitScriptedEvent({ type: "
|
|
246
|
+
emitScriptedEvent({ type: "agent_settled" });
|
|
185
247
|
},
|
|
186
248
|
});
|
|
187
249
|
runScriptedSteps(steps);
|
|
@@ -203,9 +265,10 @@ function runContinuityDelayedStream() {
|
|
|
203
265
|
appendDynamicMessage(message);
|
|
204
266
|
emitScriptedEvent(tagged({ type: "message_end", continuityStep: "message-end", message }));
|
|
205
267
|
} },
|
|
206
|
-
{ afterMs: 80, run: () => {
|
|
268
|
+
{ afterMs: 80, run: () => emitScriptedEvent(tagged({ type: "agent_end", continuityStep: "end" })) },
|
|
269
|
+
{ afterMs: 10, run: () => {
|
|
207
270
|
scriptedStreaming = false;
|
|
208
|
-
emitScriptedEvent(tagged({ type: "
|
|
271
|
+
emitScriptedEvent(tagged({ type: "agent_settled", continuityStep: "settled" }));
|
|
209
272
|
} },
|
|
210
273
|
];
|
|
211
274
|
runScriptedSteps(steps);
|
|
@@ -307,26 +370,35 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
307
370
|
respondHelper({ requestId, ok: true, data: { skills: fakeSkills.map((skill) => ({ ...skill, enabled: enabledSkillNames.has(skill.name) })) } });
|
|
308
371
|
return true;
|
|
309
372
|
}
|
|
310
|
-
case "
|
|
373
|
+
case "queue-mutate":
|
|
374
|
+
respondHelper({ requestId, ok: true, data: mutateRuntimeQueue(request.payload) });
|
|
375
|
+
return true;
|
|
376
|
+
case "subagent-output": {
|
|
377
|
+
const run = fixtureSubagentRuns.find((candidate) => candidate.id === request.payload?.runId);
|
|
378
|
+
const agent = run?.agents?.find((candidate) => candidate.id === request.payload?.agentId);
|
|
379
|
+
if (!run || !agent) {
|
|
380
|
+
respondHelper({ requestId, ok: false, error: "Subagent output is no longer tracked" });
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
311
383
|
respondHelper({
|
|
312
384
|
requestId,
|
|
313
385
|
ok: true,
|
|
314
386
|
data: {
|
|
315
387
|
version: 1,
|
|
316
|
-
runId:
|
|
317
|
-
source:
|
|
318
|
-
mode:
|
|
319
|
-
startedAt:
|
|
320
|
-
updatedAt: Date.now(),
|
|
388
|
+
runId: run.id,
|
|
389
|
+
source: run.source,
|
|
390
|
+
mode: run.mode,
|
|
391
|
+
startedAt: run.startedAt,
|
|
392
|
+
updatedAt: run.endedAt || Date.now(),
|
|
321
393
|
agent: {
|
|
322
|
-
id:
|
|
323
|
-
name:
|
|
324
|
-
index:
|
|
325
|
-
status:
|
|
394
|
+
id: agent.id,
|
|
395
|
+
name: agent.name,
|
|
396
|
+
index: agent.index,
|
|
397
|
+
status: agent.status,
|
|
326
398
|
currentTool: "read",
|
|
327
399
|
currentToolArgs: "README.md",
|
|
328
|
-
model: "anthropic/claude-opus-4-8:high",
|
|
329
|
-
thinking: "high",
|
|
400
|
+
model: agent.model || "anthropic/claude-opus-4-8:high",
|
|
401
|
+
thinking: agent.thinking || "high",
|
|
330
402
|
recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
|
|
331
403
|
recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
|
|
332
404
|
transcript: [
|
|
@@ -356,6 +428,37 @@ function handleWebuiHelperPrompt(command, base) {
|
|
|
356
428
|
},
|
|
357
429
|
});
|
|
358
430
|
return true;
|
|
431
|
+
}
|
|
432
|
+
case "subagent-cancel": {
|
|
433
|
+
const run = fixtureSubagentRuns.find((candidate) => candidate.id === request.payload?.runId);
|
|
434
|
+
if (!run || run.status !== "running") {
|
|
435
|
+
respondHelper({ requestId, ok: false, error: "Subagent run is not running" });
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
const reason = String(request.payload?.reason || "").trim().slice(0, 120) || undefined;
|
|
439
|
+
const note = String(request.payload?.note || "").trim().slice(0, 2000) || undefined;
|
|
440
|
+
run.status = "cancelled";
|
|
441
|
+
run.endedAt = Date.now();
|
|
442
|
+
run.cancelReason = reason;
|
|
443
|
+
run.cancelNote = note;
|
|
444
|
+
run.cancelledBy = "user";
|
|
445
|
+
run.agents = run.agents.map((agent) => ({ ...agent, status: "cancelled" }));
|
|
446
|
+
emitSubagentFixtureStatus();
|
|
447
|
+
respondHelper({ requestId, ok: true, data: { runId: run.id, state: "cancelled", delivery: "context", rpcMethod: "stop" } });
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
case "subagent-dismiss": {
|
|
451
|
+
const index = fixtureSubagentRuns.findIndex((candidate) => candidate.id === request.payload?.runId);
|
|
452
|
+
const run = fixtureSubagentRuns[index];
|
|
453
|
+
if (!run || run.status === "running") {
|
|
454
|
+
respondHelper({ requestId, ok: false, error: "Subagent run cannot be dismissed" });
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
fixtureSubagentRuns.splice(index, 1);
|
|
458
|
+
emitSubagentFixtureStatus();
|
|
459
|
+
respondHelper({ requestId, ok: true, data: { runId: request.payload?.runId, dismissed: true } });
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
359
462
|
default:
|
|
360
463
|
respondHelper({ requestId, ok: false, error: `Unknown webui-helper action: ${String(request.action || "")}` });
|
|
361
464
|
return true;
|
|
@@ -389,6 +492,7 @@ function runFastModeFixtureFlow({ barrierOnly = false } = {}) {
|
|
|
389
492
|
const finish = () => {
|
|
390
493
|
emitEvent({ type: "message_end", message: { role: "assistant", content: [{ type: "text", text: finalText }] } });
|
|
391
494
|
emitEvent({ type: "agent_end" });
|
|
495
|
+
emitEvent({ type: "agent_settled" });
|
|
392
496
|
};
|
|
393
497
|
emitEvent({ type: "agent_start" });
|
|
394
498
|
emitEvent({ type: "message_start", message: { role: "assistant" } });
|
|
@@ -419,6 +523,7 @@ function runFastModeHistoryFlow() {
|
|
|
419
523
|
}
|
|
420
524
|
emitEvent({ type: "message_end", message: { role: "assistant", content: [{ type: "text", text: accumulated }] } });
|
|
421
525
|
emitEvent({ type: "agent_end" });
|
|
526
|
+
emitEvent({ type: "agent_settled" });
|
|
422
527
|
}
|
|
423
528
|
|
|
424
529
|
function handleFastModeFixturePrompt(command, base) {
|
|
@@ -455,43 +560,75 @@ function handleTransportFixturePrompt(command, base) {
|
|
|
455
560
|
return false;
|
|
456
561
|
}
|
|
457
562
|
|
|
458
|
-
function
|
|
459
|
-
const message = String(command.message || "").trim();
|
|
460
|
-
if (message !== "fixture subagents running" && message !== "fixture subagents clear") return false;
|
|
461
|
-
const clearing = message.endsWith("clear");
|
|
462
|
-
const runs = clearing ? [] : [{
|
|
463
|
-
id: "fixture-run",
|
|
464
|
-
source: "async",
|
|
465
|
-
mode: "parallel",
|
|
466
|
-
status: "running",
|
|
467
|
-
startedAt: Date.now() - 2500,
|
|
468
|
-
agents: [
|
|
469
|
-
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false },
|
|
470
|
-
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
|
|
471
|
-
],
|
|
472
|
-
}];
|
|
473
|
-
const gates = clearing ? [] : [{
|
|
474
|
-
version: 1,
|
|
475
|
-
id: "fixture-gate",
|
|
476
|
-
status: "running",
|
|
477
|
-
requiredSuccesses: 2,
|
|
478
|
-
qualifyingSuccesses: 1,
|
|
479
|
-
requireDistinctProviders: true,
|
|
480
|
-
startedAt: Date.now() - 3000,
|
|
481
|
-
updatedAt: Date.now(),
|
|
482
|
-
attempts: [
|
|
483
|
-
{ 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" },
|
|
484
|
-
{ 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" },
|
|
485
|
-
],
|
|
486
|
-
}];
|
|
487
|
-
respond({ ...base, data: { output: "fake subagent status emitted" } });
|
|
563
|
+
function emitSubagentFixtureStatus() {
|
|
488
564
|
emitEvent({
|
|
489
565
|
type: "extension_ui_request",
|
|
490
566
|
id: randomUUID(),
|
|
491
567
|
method: "setStatus",
|
|
492
568
|
statusKey: "webui-subagents",
|
|
493
|
-
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs, gates })}`,
|
|
569
|
+
statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs: fixtureSubagentRuns, gates: fixtureSubagentGates })}`,
|
|
494
570
|
});
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function handleSubagentFixturePrompt(command, base) {
|
|
574
|
+
const message = String(command.message || "").trim();
|
|
575
|
+
if (!["fixture subagents running", "fixture subagents clear", "fixture subagents retained"].includes(message)) return false;
|
|
576
|
+
const now = Date.now();
|
|
577
|
+
fixtureSubagentRuns.splice(0, fixtureSubagentRuns.length);
|
|
578
|
+
fixtureSubagentGates.splice(0, fixtureSubagentGates.length);
|
|
579
|
+
if (message === "fixture subagents running") {
|
|
580
|
+
fixtureSubagentRuns.push({
|
|
581
|
+
id: "fixture-run",
|
|
582
|
+
source: "async",
|
|
583
|
+
mode: "parallel",
|
|
584
|
+
status: "running",
|
|
585
|
+
startedAt: now - 2500,
|
|
586
|
+
agents: [
|
|
587
|
+
{ id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false },
|
|
588
|
+
{ id: "fixture-run:1", name: "scout", status: "running", index: 1, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
|
|
589
|
+
],
|
|
590
|
+
});
|
|
591
|
+
fixtureSubagentGates.push({
|
|
592
|
+
version: 1,
|
|
593
|
+
id: "fixture-gate",
|
|
594
|
+
status: "running",
|
|
595
|
+
requiredSuccesses: 2,
|
|
596
|
+
qualifyingSuccesses: 1,
|
|
597
|
+
requireDistinctProviders: true,
|
|
598
|
+
startedAt: now - 3000,
|
|
599
|
+
updatedAt: now,
|
|
600
|
+
attempts: [
|
|
601
|
+
{ 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" },
|
|
602
|
+
{ 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" },
|
|
603
|
+
],
|
|
604
|
+
});
|
|
605
|
+
} else if (message === "fixture subagents retained") {
|
|
606
|
+
fixtureSubagentRuns.push(
|
|
607
|
+
{
|
|
608
|
+
id: "fixture-done",
|
|
609
|
+
source: "foreground",
|
|
610
|
+
mode: "single",
|
|
611
|
+
status: "done",
|
|
612
|
+
startedAt: now - 5000,
|
|
613
|
+
endedAt: now - 2000,
|
|
614
|
+
agents: [{ id: "fixture-done:0", name: "tester", status: "done", index: 0, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false }],
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
id: "fixture-cancelled",
|
|
618
|
+
source: "async",
|
|
619
|
+
mode: "parallel",
|
|
620
|
+
status: "cancelled",
|
|
621
|
+
startedAt: now - 4000,
|
|
622
|
+
endedAt: now - 1000,
|
|
623
|
+
cancelledBy: "user",
|
|
624
|
+
cancelReason: "Taking too long",
|
|
625
|
+
cancelNote: "Use the existing result instead.",
|
|
626
|
+
agents: [{ id: "fixture-cancelled:0", name: "reviewer", status: "cancelled", index: 0, model: "anthropic/claude-opus-4-8:high", thinking: "high", nested: false }],
|
|
627
|
+
},
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
respond({ ...base, data: { output: "fake subagent status emitted" } });
|
|
631
|
+
emitSubagentFixtureStatus();
|
|
495
632
|
return true;
|
|
496
633
|
}
|
|
497
634
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const css = await readFile(new URL("../public/styles.css", import.meta.url), "utf8");
|
|
5
|
+
const progressOverlay = css.match(/\.footer-context-card\.has-context-usage::before\s*\{([^}]+)\}/)?.[1] ?? "";
|
|
6
|
+
|
|
7
|
+
assert.match(progressOverlay, /background:\s*var\(--context-card-gradient\)/, "context usage should retain its themed progress gradient");
|
|
8
|
+
assert.match(progressOverlay, /opacity:\s*0\.34/, "context progress should stay translucent enough for readable text");
|
|
9
|
+
|
|
10
|
+
console.log("footer context contrast static tests passed");
|
|
@@ -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([
|
|
@@ -15,6 +15,8 @@ function functionBody(name) {
|
|
|
15
15
|
|
|
16
16
|
const renderGitPanel = functionBody("renderGitPanel");
|
|
17
17
|
const renderGitPanelFolder = functionBody("renderGitPanelFolder");
|
|
18
|
+
const renderGitPanelRepositoryCard = functionBody("renderGitPanelRepositoryCard");
|
|
19
|
+
const updateGitPanelRepositoryMeta = functionBody("updateGitPanelRepositoryMeta");
|
|
18
20
|
const renderContextMeter = functionBody("renderContextMeter");
|
|
19
21
|
const renderWorkspaceDashboard = functionBody("renderWorkspaceDashboard");
|
|
20
22
|
|
|
@@ -29,8 +31,16 @@ assert.doesNotMatch(renderGitPanel, /\bsectionExpanded\b/, "Git panel signature
|
|
|
29
31
|
const gitGuard = renderGitPanel.indexOf("signature === gitPanelRenderSignature");
|
|
30
32
|
const gitRebuild = renderGitPanel.indexOf("elements.gitPanelGroups.replaceChildren");
|
|
31
33
|
assert.ok(gitGuard > 0 && gitGuard < gitRebuild, "Git panel signature guard should precede its DOM rebuild");
|
|
32
|
-
assert.
|
|
34
|
+
assert.doesNotMatch(renderGitPanel, /snapshot\?\.loadedAt|data\?\.generatedAt/, "Git panel signature should ignore refresh timestamps");
|
|
35
|
+
assert.match(renderGitPanel, /!data && !!snapshot\?\.loading/, "initial repository loads should still update their loading state");
|
|
36
|
+
assert.match(renderGitPanel, /gitPanelDataRenderSignature\(data\)/, "Git panel signature should still track rendered repository data");
|
|
33
37
|
assert.match(renderGitPanel, /gitPanelState\.activeViews\.get/, "Git panel signature should include active repository views");
|
|
38
|
+
assert.match(renderGitPanelRepositoryCard, /section\.dataset\.gitRoot = card\.root;/, "repository cards should expose a stable root for targeted metadata updates");
|
|
39
|
+
assert.match(updateGitPanelRepositoryMeta, /\.git-side-panel-repository-updated/, "refresh state should target only the update-time label");
|
|
40
|
+
assert.match(updateGitPanelRepositoryMeta, /snapshot\.loading \? "Refreshing…" : `Updated /, "the targeted label should reflect refresh progress and completion time");
|
|
41
|
+
|
|
42
|
+
const gitMetaUpdate = renderGitPanel.indexOf("updateGitPanelRepositoryMeta(cards)");
|
|
43
|
+
assert.ok(gitMetaUpdate > gitGuard && gitMetaUpdate < gitRebuild, "unchanged Git content should update metadata before returning without a DOM rebuild");
|
|
34
44
|
|
|
35
45
|
const contextGuard = renderContextMeter.indexOf("signature === contextMeterSignature");
|
|
36
46
|
const contextRebuild = renderContextMeter.lastIndexOf("root.replaceChildren");
|