@firstpick/pi-package-webui 0.8.1 → 0.8.3
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 +21 -3
- package/bin/pi-webui.mjs +287 -32
- package/lib/component-update-state.mjs +126 -0
- package/lib/git-workflow-preferences.mjs +246 -19
- package/lib/thinking-stream-recovery.mjs +156 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/lib/ui-layout-settings.mjs +254 -0
- package/package.json +5 -3
- package/public/app.js +3072 -142
- package/public/index.html +188 -39
- package/public/service-worker.js +1 -1
- package/public/styles.css +1091 -39
- package/tests/boot-failure-diagnostics.test.mjs +63 -5
- package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +180 -0
- package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
- package/tests/browser/interaction-continuity.spec.mjs +187 -0
- package/tests/browser/mobile-foundation.spec.mjs +11 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +101 -0
- package/tests/browser/stats-overlay.spec.mjs +265 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/component-update-api-static.test.mjs +67 -0
- package/tests/component-update-state.test.mjs +80 -0
- package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
- package/tests/control-deck-component-updates-static.test.mjs +251 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +172 -0
- package/tests/fixtures/fake-pi.mjs +180 -6
- package/tests/footer-provider-usage-visual-static.test.mjs +71 -0
- package/tests/git-workflow-preferences.test.mjs +4 -2
- package/tests/http-endpoints-harness.test.mjs +88 -1
- package/tests/interaction-state-stability-static.test.mjs +24 -4
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +6 -4
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +34 -16
- package/tests/native-parity-harness.test.mjs +2 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +267 -0
- package/tests/questionnaire-dialog.test.mjs +511 -0
- package/tests/queue-edit-reorder-static.test.mjs +1 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +1 -0
- package/tests/side-panel-section-reorder-static.test.mjs +68 -0
- package/tests/sse-backpressure-harness.test.mjs +51 -12
- package/tests/stats-dashboard-static.test.mjs +266 -0
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/thinking-stream-recovery.test.mjs +88 -0
- package/tests/ui-layout-settings.test.mjs +92 -0
- package/tests/webui-settings-locking.test.mjs +159 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { expect, test } from "@playwright/test";
|
|
10
|
+
|
|
11
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
12
|
+
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
13
|
+
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
14
|
+
|
|
15
|
+
async function freePort() {
|
|
16
|
+
const server = createServer();
|
|
17
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
18
|
+
const { port } = server.address();
|
|
19
|
+
await new Promise((resolve) => server.close(resolve));
|
|
20
|
+
return port;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let child;
|
|
24
|
+
let baseURL;
|
|
25
|
+
let tempRoot;
|
|
26
|
+
let output = "";
|
|
27
|
+
|
|
28
|
+
async function api(page, pathname, { method = "GET", data } = {}) {
|
|
29
|
+
const response = await page.request.fetch(`${baseURL}${pathname}`, {
|
|
30
|
+
method,
|
|
31
|
+
data,
|
|
32
|
+
headers: data === undefined ? undefined : { "content-type": "application/json" },
|
|
33
|
+
});
|
|
34
|
+
const payload = await response.json().catch(() => ({}));
|
|
35
|
+
assert.equal(response.ok(), true, `${method} ${pathname} should succeed: ${payload.error || output}`);
|
|
36
|
+
return payload;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function activeTabId(page) {
|
|
40
|
+
const payload = await api(page, "/api/tabs");
|
|
41
|
+
return payload.data?.activeTabId || payload.data?.tabs?.[0]?.id || "";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function emitDecision(page, mode) {
|
|
45
|
+
const tabId = await activeTabId(page);
|
|
46
|
+
assert.ok(tabId, "the fixture requires an active WebUI tab");
|
|
47
|
+
await api(page, `/api/prompt?tab=${encodeURIComponent(tabId)}`, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
data: { message: `fixture feature decision ${mode}`, requestId: `feature-decision-${mode}-${Date.now()}` },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test.beforeAll(async () => {
|
|
54
|
+
const port = await freePort();
|
|
55
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-feature-decision-popup-"));
|
|
56
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
57
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
env: {
|
|
60
|
+
...process.env,
|
|
61
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
62
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
63
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
67
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
68
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
69
|
+
if (child.exitCode !== null) break;
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
72
|
+
if (response.ok) return;
|
|
73
|
+
} catch {
|
|
74
|
+
// Wait for the isolated WebUI fixture.
|
|
75
|
+
}
|
|
76
|
+
await delay(100);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Pi WebUI did not start:\n${output}`);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test.afterAll(async () => {
|
|
82
|
+
if (child?.exitCode === null) child.kill("SIGTERM");
|
|
83
|
+
if (child && child.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
|
|
84
|
+
await rm(tempRoot, { recursive: true, force: true }).catch(() => {});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const COMPLEX_DIALOG_TEXT = "Decision: Complex feature (feature_complex)\nReason: Crosses the classifier extension and the WebUI status consumer.";
|
|
88
|
+
const LEGACY_DIALOG_TEXT = "Decision: Complex feature (feature_complex)\nReason: The classifier reported feature_complex without a reason.";
|
|
89
|
+
|
|
90
|
+
test("feature tag opens the readable classifier decision and replays it after reconnect", async ({ page }) => {
|
|
91
|
+
await page.goto(baseURL);
|
|
92
|
+
await emitDecision(page, "complex");
|
|
93
|
+
|
|
94
|
+
const tag = page.locator("#featureCategoryTag");
|
|
95
|
+
const dialog = page.locator("#featureDecisionDialog");
|
|
96
|
+
const outputText = page.locator("#featureDecisionDialogOutput");
|
|
97
|
+
const close = page.locator("#featureDecisionDialogCloseButton");
|
|
98
|
+
|
|
99
|
+
await expect(tag).toBeVisible();
|
|
100
|
+
await expect(tag).toBeEnabled();
|
|
101
|
+
await expect(tag).toHaveText("complex-feature");
|
|
102
|
+
|
|
103
|
+
await tag.click();
|
|
104
|
+
await expect(dialog).toBeVisible();
|
|
105
|
+
await expect(outputText).toHaveText(COMPLEX_DIALOG_TEXT);
|
|
106
|
+
await expect(close).toBeFocused();
|
|
107
|
+
|
|
108
|
+
await close.click();
|
|
109
|
+
await expect(dialog).toBeHidden();
|
|
110
|
+
await expect(tag).toBeFocused();
|
|
111
|
+
|
|
112
|
+
await tag.press("Enter");
|
|
113
|
+
await expect(dialog).toBeVisible();
|
|
114
|
+
await page.keyboard.press("Escape");
|
|
115
|
+
await expect(dialog).toBeHidden();
|
|
116
|
+
await expect(tag).toBeFocused();
|
|
117
|
+
|
|
118
|
+
await page.reload();
|
|
119
|
+
await expect(tag).toBeVisible();
|
|
120
|
+
await expect(tag).toBeEnabled();
|
|
121
|
+
await tag.click();
|
|
122
|
+
await expect(outputText).toHaveText(COMPLEX_DIALOG_TEXT);
|
|
123
|
+
await page.keyboard.press("Escape");
|
|
124
|
+
|
|
125
|
+
await emitDecision(page, "clear");
|
|
126
|
+
await expect(dialog).toBeHidden();
|
|
127
|
+
await expect(tag).toBeHidden();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("legacy labels stay readable while mismatched and malformed payloads fail closed", async ({ page }) => {
|
|
131
|
+
await page.goto(baseURL);
|
|
132
|
+
|
|
133
|
+
const tag = page.locator("#featureCategoryTag");
|
|
134
|
+
const dialog = page.locator("#featureDecisionDialog");
|
|
135
|
+
const outputText = page.locator("#featureDecisionDialogOutput");
|
|
136
|
+
|
|
137
|
+
await emitDecision(page, "legacy");
|
|
138
|
+
await expect(tag).toBeEnabled();
|
|
139
|
+
await tag.click();
|
|
140
|
+
await expect(outputText).toHaveText(LEGACY_DIALOG_TEXT);
|
|
141
|
+
await page.keyboard.press("Escape");
|
|
142
|
+
await expect(dialog).toBeHidden();
|
|
143
|
+
|
|
144
|
+
await emitDecision(page, "mismatch");
|
|
145
|
+
await expect(tag).toBeVisible();
|
|
146
|
+
await expect(tag).toHaveText("complex-feature");
|
|
147
|
+
await expect(tag).toBeDisabled();
|
|
148
|
+
|
|
149
|
+
await emitDecision(page, "malformed");
|
|
150
|
+
await expect(tag).toBeVisible();
|
|
151
|
+
await expect(tag).toBeDisabled();
|
|
152
|
+
await expect(dialog).toBeHidden();
|
|
153
|
+
|
|
154
|
+
await emitDecision(page, "clear");
|
|
155
|
+
await expect(tag).toBeHidden();
|
|
156
|
+
});
|
|
@@ -305,6 +305,9 @@ test("main output text selection survives streaming-tail and settlement rerender
|
|
|
305
305
|
await expect.poll(() => originalSurface.evaluate((node) => node.isConnected), { timeout: 8_000 }).toBe(true);
|
|
306
306
|
await expect.poll(() => originalBubble.evaluate((node) => ({ connected: node.isConnected, streaming: node.classList.contains("streaming"), itemKey: node.dataset.itemKey, messageKey: node.dataset.transcriptMessageKey })), { timeout: 8_000 }).toEqual({ connected: true, streaming: false, itemKey: "m:4", messageKey: "m:4" });
|
|
307
307
|
await expect.poll(() => page.evaluate(() => window.getSelection()?.toString() || ""), { timeout: 8_000 }).toBe(selectedText);
|
|
308
|
+
await waitForFixtureSettlement(page, tabId);
|
|
309
|
+
await delay(4_000);
|
|
310
|
+
await expect.poll(() => page.evaluate(() => window.getSelection()?.toString() || "")).toBe(selectedText);
|
|
308
311
|
});
|
|
309
312
|
|
|
310
313
|
test("backward normal-output selection keeps its direction through streaming and exact settlement", async ({ page }) => {
|
|
@@ -428,6 +431,35 @@ test("streaming thinking selection survives a later thinking delta", async ({ pa
|
|
|
428
431
|
await expect.poll(() => page.evaluate(() => window.getSelection()?.toString() || "")).toBe("");
|
|
429
432
|
});
|
|
430
433
|
|
|
434
|
+
test("live thinking, assistant output, and tool calls keep chronological tail order", async ({ page }) => {
|
|
435
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
436
|
+
await page.goto(baseURL);
|
|
437
|
+
await triggerTranscriptContinuity(page, "order");
|
|
438
|
+
|
|
439
|
+
const chat = page.locator("#chat");
|
|
440
|
+
await expect(chat.locator(".message.thinking.streaming").last()).toContainText("ordering thinking");
|
|
441
|
+
await expect(chat.locator(".message.assistant.streaming").last()).toContainText("ordering assistant output");
|
|
442
|
+
await expect.poll(() => chat.evaluate((root) => {
|
|
443
|
+
const messages = [...root.querySelectorAll(":scope > .message")];
|
|
444
|
+
const thinkingIndex = messages.findIndex((message) => message.matches(".thinking.streaming") && message.textContent?.includes("ordering thinking"));
|
|
445
|
+
const outputIndex = messages.findIndex((message) => message.matches(".assistant.streaming") && message.textContent?.includes("ordering assistant output"));
|
|
446
|
+
return thinkingIndex >= 0 && outputIndex > thinkingIndex;
|
|
447
|
+
})).toBe(true);
|
|
448
|
+
|
|
449
|
+
const streamingToolCalls = chat.locator(".message.toolCall.streaming", { hasText: "order.txt" });
|
|
450
|
+
await expect(streamingToolCalls.last()).toContainText("order.txt");
|
|
451
|
+
await expect.poll(() => chat.evaluate((root) => {
|
|
452
|
+
const messages = [...root.querySelectorAll(":scope > .message")];
|
|
453
|
+
const thinkingIndex = messages.findIndex((message) => message.matches(".thinking.streaming") && message.textContent?.includes("ordering thinking"));
|
|
454
|
+
const toolIndex = messages.findIndex((message) => message.matches(".toolCall.streaming") && message.textContent?.includes("order.txt"));
|
|
455
|
+
return thinkingIndex >= 0 && toolIndex > thinkingIndex;
|
|
456
|
+
})).toBe(true);
|
|
457
|
+
await page.waitForTimeout(500);
|
|
458
|
+
await expect(streamingToolCalls).toHaveCount(1);
|
|
459
|
+
await expect(chat.locator(".message.thinking.streaming", { hasText: "ordering thinking" })).toHaveCount(1);
|
|
460
|
+
await waitForFixtureSettlement(page);
|
|
461
|
+
});
|
|
462
|
+
|
|
431
463
|
test("thinking visibility change explicitly invalidates a live thinking selection", async ({ page }) => {
|
|
432
464
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
433
465
|
await page.goto(baseURL);
|
|
@@ -458,6 +490,7 @@ test("selectable live tool output restores an unchanged range across body reconc
|
|
|
458
490
|
const toolBody = page.locator(".message.toolExecution .message-body").last();
|
|
459
491
|
const selectedText = "tool selection literal";
|
|
460
492
|
await expect(toolBody).toContainText("unselected revision one");
|
|
493
|
+
await toolBody.locator(".tool-output-details").evaluate((node) => { node.open = true; });
|
|
461
494
|
assert.equal((await selectRenderedText(toolBody, selectedText)).text, selectedText);
|
|
462
495
|
const bodyHandle = await toolBody.elementHandle();
|
|
463
496
|
assert.ok(bodyHandle, "tool selection continuity needs an inspectable semantic surface");
|
|
@@ -467,6 +500,32 @@ test("selectable live tool output restores an unchanged range across body reconc
|
|
|
467
500
|
await waitForFixtureSettlement(page);
|
|
468
501
|
});
|
|
469
502
|
|
|
503
|
+
test("expanded live tool output preserves reader scroll and summary focus across updates", async ({ page }) => {
|
|
504
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
505
|
+
await page.goto(baseURL);
|
|
506
|
+
await triggerTranscriptContinuity(page, "tool");
|
|
507
|
+
|
|
508
|
+
const toolBody = page.locator(".message.toolExecution .message-body").last();
|
|
509
|
+
const details = toolBody.locator(".tool-output-details");
|
|
510
|
+
const output = details.locator(".tool-output-code");
|
|
511
|
+
const summary = details.locator("summary");
|
|
512
|
+
await expect(toolBody).toContainText("unselected revision one");
|
|
513
|
+
await summary.click();
|
|
514
|
+
const scrollState = await output.evaluate((node) => {
|
|
515
|
+
node.scrollTop = Math.min(180, node.scrollHeight - node.clientHeight);
|
|
516
|
+
return { top: node.scrollTop };
|
|
517
|
+
});
|
|
518
|
+
assert.ok(scrollState.top > 0, "the tool fixture must create vertical reader scroll");
|
|
519
|
+
await summary.focus();
|
|
520
|
+
await expect(summary).toBeFocused();
|
|
521
|
+
|
|
522
|
+
await expect(toolBody).toContainText("unselected revision two");
|
|
523
|
+
await expect.poll(() => details.evaluate((node) => node.open)).toBe(true);
|
|
524
|
+
await expect.poll(() => output.evaluate((node) => node.scrollTop)).toBe(scrollState.top);
|
|
525
|
+
await expect(summary).toBeFocused();
|
|
526
|
+
await waitForFixtureSettlement(page);
|
|
527
|
+
});
|
|
528
|
+
|
|
470
529
|
test("authoritative divergence clears a stale live-output selection", async ({ page }) => {
|
|
471
530
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
472
531
|
await page.goto(baseURL);
|
|
@@ -570,6 +629,134 @@ test("Mermaid async rendering leaves selected source nodes connected", async ({
|
|
|
570
629
|
await waitForFixtureSettlement(page);
|
|
571
630
|
});
|
|
572
631
|
|
|
632
|
+
test("cross-message selection survives a whole transcript rebuild", async ({ page }) => {
|
|
633
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
634
|
+
await page.goto(baseURL);
|
|
635
|
+
await triggerTranscriptContinuity(page, "duplicate");
|
|
636
|
+
await waitForFixtureSettlement(page);
|
|
637
|
+
const surfaces = page.locator(".message.assistant:not(.streaming) .markdown-body");
|
|
638
|
+
await expect.poll(() => surfaces.count()).toBeGreaterThanOrEqual(2);
|
|
639
|
+
const selectedLength = await page.locator("#chat").evaluate((chat) => {
|
|
640
|
+
const outputs = [...chat.querySelectorAll(".message.assistant:not(.streaming) .markdown-body")];
|
|
641
|
+
const textNodes = (root) => {
|
|
642
|
+
const nodes = [];
|
|
643
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
644
|
+
while (walker.nextNode()) {
|
|
645
|
+
if ((walker.currentNode.data || "").trim()) nodes.push(walker.currentNode);
|
|
646
|
+
}
|
|
647
|
+
return nodes;
|
|
648
|
+
};
|
|
649
|
+
const startNodes = textNodes(outputs[0]);
|
|
650
|
+
const endNodes = textNodes(outputs.at(-1));
|
|
651
|
+
const startNode = startNodes.at(-1);
|
|
652
|
+
const endNode = endNodes[0];
|
|
653
|
+
const range = document.createRange();
|
|
654
|
+
range.setStart(startNode, Math.max(0, startNode.data.length - 8));
|
|
655
|
+
range.setEnd(endNode, Math.min(18, endNode.data.length));
|
|
656
|
+
const selection = window.getSelection();
|
|
657
|
+
selection.removeAllRanges();
|
|
658
|
+
selection.addRange(range);
|
|
659
|
+
const textOffset = (surface, node, offset) => {
|
|
660
|
+
const prefix = document.createRange();
|
|
661
|
+
prefix.selectNodeContents(surface);
|
|
662
|
+
prefix.setEnd(node, offset);
|
|
663
|
+
return prefix.toString().length;
|
|
664
|
+
};
|
|
665
|
+
const endpoint = (surface, node, offset) => ({
|
|
666
|
+
itemKey: surface.closest(".message")?.dataset.transcriptMessageKey || surface.closest(".message")?.dataset.itemKey || "",
|
|
667
|
+
surfaceKey: surface.dataset.transcriptSurfaceKey || "",
|
|
668
|
+
offset: textOffset(surface, node, offset),
|
|
669
|
+
});
|
|
670
|
+
window.__crossMessageSelectionText = selection.toString();
|
|
671
|
+
window.__crossMessageSelectionBoundary = {
|
|
672
|
+
start: window.__crossMessageSelectionText.slice(0, 8),
|
|
673
|
+
end: window.__crossMessageSelectionText.slice(-18),
|
|
674
|
+
};
|
|
675
|
+
window.__crossMessageSelectionEndpoints = {
|
|
676
|
+
anchor: endpoint(outputs[0], selection.anchorNode, selection.anchorOffset),
|
|
677
|
+
focus: endpoint(outputs.at(-1), selection.focusNode, selection.focusOffset),
|
|
678
|
+
};
|
|
679
|
+
return window.__crossMessageSelectionText.length;
|
|
680
|
+
});
|
|
681
|
+
assert.ok(selectedLength > 20, "the fixture must create a real cross-message browser Range");
|
|
682
|
+
|
|
683
|
+
await page.evaluate(() => {
|
|
684
|
+
const key = "pi-webui-optional-features-disabled";
|
|
685
|
+
const current = JSON.parse(localStorage.getItem(key) || "[]");
|
|
686
|
+
const next = current.includes("bangCommandAutocomplete")
|
|
687
|
+
? current.filter((id) => id !== "bangCommandAutocomplete")
|
|
688
|
+
: [...current, "bangCommandAutocomplete"];
|
|
689
|
+
localStorage.setItem(key, JSON.stringify(next));
|
|
690
|
+
window.dispatchEvent(new StorageEvent("storage", { key }));
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
await expect.poll(() => page.evaluate(() => {
|
|
694
|
+
const selection = window.getSelection();
|
|
695
|
+
const current = selection?.toString() || "";
|
|
696
|
+
const anchorSurface = selection?.anchorNode?.parentElement?.closest?.("[data-transcript-surface-key]");
|
|
697
|
+
const focusSurface = selection?.focusNode?.parentElement?.closest?.("[data-transcript-surface-key]");
|
|
698
|
+
const anchorBubble = anchorSurface?.closest(".message");
|
|
699
|
+
const focusBubble = focusSurface?.closest(".message");
|
|
700
|
+
const anchorItemKey = anchorBubble?.dataset.transcriptMessageKey || anchorBubble?.dataset.itemKey || "";
|
|
701
|
+
const focusItemKey = focusBubble?.dataset.transcriptMessageKey || focusBubble?.dataset.itemKey || "";
|
|
702
|
+
return current.length > 20
|
|
703
|
+
&& current.startsWith(window.__crossMessageSelectionBoundary.start)
|
|
704
|
+
&& current.endsWith(window.__crossMessageSelectionBoundary.end)
|
|
705
|
+
&& anchorItemKey === window.__crossMessageSelectionEndpoints.anchor.itemKey
|
|
706
|
+
&& focusItemKey === window.__crossMessageSelectionEndpoints.focus.itemKey;
|
|
707
|
+
})).toBe(true);
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
test("individually expanded tool details stay open through transcript rerenders", async ({ page }) => {
|
|
711
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
712
|
+
await page.goto(baseURL);
|
|
713
|
+
await triggerTranscriptContinuity(page, "tool");
|
|
714
|
+
const details = page.locator(".message.toolExecution .tool-raw-details").last();
|
|
715
|
+
await expect(details).toBeAttached();
|
|
716
|
+
await expect.poll(() => details.evaluate((node) => node.open)).toBe(false);
|
|
717
|
+
const summary = details.locator("summary");
|
|
718
|
+
await summary.click();
|
|
719
|
+
await expect.poll(() => details.evaluate((node) => node.open)).toBe(true);
|
|
720
|
+
await waitForFixtureSettlement(page);
|
|
721
|
+
const rawOutput = details.locator(".tool-raw-code");
|
|
722
|
+
const scrollTop = await rawOutput.evaluate((node) => {
|
|
723
|
+
node.scrollTop = Math.min(140, node.scrollHeight - node.clientHeight);
|
|
724
|
+
return node.scrollTop;
|
|
725
|
+
});
|
|
726
|
+
assert.ok(scrollTop > 0, "the settled raw-tool fixture must create reader scroll");
|
|
727
|
+
await summary.focus();
|
|
728
|
+
await expect(summary).toBeFocused();
|
|
729
|
+
|
|
730
|
+
await page.evaluate(() => {
|
|
731
|
+
const key = "pi-webui-optional-features-disabled";
|
|
732
|
+
const current = JSON.parse(localStorage.getItem(key) || "[]");
|
|
733
|
+
const next = current.includes("bangCommandAutocomplete")
|
|
734
|
+
? current.filter((id) => id !== "bangCommandAutocomplete")
|
|
735
|
+
: [...current, "bangCommandAutocomplete"];
|
|
736
|
+
localStorage.setItem(key, JSON.stringify(next));
|
|
737
|
+
window.dispatchEvent(new StorageEvent("storage", { key }));
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
await delay(4_000);
|
|
741
|
+
await expect.poll(() => details.evaluate((node) => node.open)).toBe(true);
|
|
742
|
+
await expect.poll(() => rawOutput.evaluate((node) => node.scrollTop)).toBe(scrollTop);
|
|
743
|
+
await expect(summary).toBeFocused();
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
test("same-mode output control preserves settled output selection", async ({ page }) => {
|
|
747
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
748
|
+
await page.goto(baseURL);
|
|
749
|
+
const output = page.locator(".message.assistant .markdown-body").first();
|
|
750
|
+
const selectedText = "fake answer";
|
|
751
|
+
await expect(output).toContainText(selectedText);
|
|
752
|
+
await waitForFixtureSettlement(page);
|
|
753
|
+
assert.equal((await selectRenderedText(output, selectedText)).text, selectedText);
|
|
754
|
+
|
|
755
|
+
await api(page, "/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
|
|
756
|
+
|
|
757
|
+
await expect.poll(() => page.evaluate(() => window.getSelection()?.toString() || "")).toBe(selectedText);
|
|
758
|
+
});
|
|
759
|
+
|
|
573
760
|
test("tab navigation clears transcript selection and never restores it into another context", async ({ page }) => {
|
|
574
761
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
575
762
|
await page.goto(baseURL);
|
|
@@ -238,6 +238,17 @@ test("mobile continuity preserves drafts, restores metadata honestly, and retrie
|
|
|
238
238
|
await context.close();
|
|
239
239
|
});
|
|
240
240
|
|
|
241
|
+
test("an extension response clears stale local running state after canonical idle", async ({ page }) => {
|
|
242
|
+
await page.goto(baseURL);
|
|
243
|
+
await page.locator("#promptInput").fill("fixture mobile blocker");
|
|
244
|
+
await page.locator("#sendButton").click();
|
|
245
|
+
await expect(page.locator("#dialogTitle")).toHaveText("Fixture blocker");
|
|
246
|
+
await expect(page.locator("#chat .runIndicator")).toContainText("Waiting for your confirm response…");
|
|
247
|
+
await page.locator("#dialogActions").getByRole("button", { name: "Yes", exact: true }).click();
|
|
248
|
+
await expect(page.locator("#dialog")).not.toBeVisible();
|
|
249
|
+
await expect(page.locator("#chat .runIndicator")).toBeHidden({ timeout: 5_000 });
|
|
250
|
+
});
|
|
251
|
+
|
|
241
252
|
test("a blocker notification switches to its background tab before exact-target validation", async ({ browser }) => {
|
|
242
253
|
const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
|
|
243
254
|
const page = await context.newPage();
|