@firstpick/pi-package-webui 0.9.4 → 0.9.6
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 +7 -2
- package/bin/pi-webui.mjs +90 -5
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-actions.mjs +20 -2
- package/lib/ui-layout-settings.mjs +37 -6
- package/package.json +1 -1
- package/public/app.js +2311 -257
- package/public/index.html +82 -55
- package/public/service-worker.js +4 -1
- package/public/stream-derived-output.mjs +799 -0
- package/public/stream-markdown-tail.mjs +204 -0
- package/public/stream-output-controller.mjs +222 -51
- package/public/stream-render-scheduler.mjs +85 -0
- package/public/styles.css +276 -20
- package/public/transcript-renderer.mjs +73 -24
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
- package/tests/browser/control-deck-side-panels.spec.mjs +42 -0
- package/tests/browser/control-visibility.spec.mjs +396 -0
- package/tests/browser/mobile-foundation.spec.mjs +28 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +9 -9
- package/tests/browser/stream-output-isolation.spec.mjs +308 -3
- package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
- package/tests/control-deck-side-panels-static.test.mjs +3 -1
- package/tests/control-visibility-static.test.mjs +294 -0
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/cwd-footer-reliability-static.test.mjs +1 -1
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +57 -10
- package/tests/fixtures/streaming-workloads.mjs +167 -0
- package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
- package/tests/git-workflow-preferences.test.mjs +2 -2
- package/tests/http-endpoints-harness.test.mjs +4 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +4 -4
- package/tests/intercom-conversations-http.test.mjs +16 -0
- package/tests/main-output-loading-static.test.mjs +3 -3
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +77 -66
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/persistent-ui-layout-static.test.mjs +7 -7
- package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/runtime-error-visibility.test.mjs +3 -3
- package/tests/session-auth-harness.test.mjs +26 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-derived-output.test.mjs +121 -0
- package/tests/stream-markdown-tail.test.mjs +218 -0
- package/tests/stream-output-controller.test.mjs +119 -4
- package/tests/stream-output-isolation-static.test.mjs +34 -6
- package/tests/stream-output-workloads.test.mjs +276 -0
- package/tests/stream-render-scheduler.test.mjs +115 -0
- package/tests/streaming-ui-coupling.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-format-parser.test.mjs +15 -0
- package/tests/todo-filter-static.test.mjs +148 -0
- package/tests/transcript-markdown-tail.test.mjs +137 -0
- package/tests/ui-layout-settings.test.mjs +54 -7
- package/tests/webui-settings-locking.test.mjs +3 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
3
4
|
import { createServer } from "node:net";
|
|
4
5
|
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
6
|
+
import { cpus, hostname, release, totalmem } from "node:os";
|
|
5
7
|
import { tmpdir } from "node:os";
|
|
6
8
|
import { dirname, join } from "node:path";
|
|
7
9
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -76,7 +78,7 @@ async function waitForPhase(runId, phase) {
|
|
|
76
78
|
|
|
77
79
|
async function assertFixtureContract(runId, mode, scenario = "standard") {
|
|
78
80
|
const entries = await waitForPhase(runId, scenario === "abort" ? "abort-ready" : "settled");
|
|
79
|
-
const textDeltas = entries.filter((entry) => entry.isolationPhase === "raw" && entry.type === "message_update" && entry.assistantMessageEventType === "text_delta");
|
|
81
|
+
const textDeltas = entries.filter((entry) => entry.isolationPhase === "raw" && entry.type === "message_update" && entry.assistantMessageEventType === "text_delta" && Number.isInteger(entry.isolationDeltaIndex));
|
|
80
82
|
const expectedCount = scenario === "abort" ? 500 : deltaCount;
|
|
81
83
|
assert.equal(textDeltas.length, expectedCount, `${mode}/${scenario} fixture must emit the expected non-empty text deltas`);
|
|
82
84
|
assert.deepEqual(textDeltas.map((entry) => entry.isolationDeltaIndex), expectedIndexes.slice(0, expectedCount));
|
|
@@ -177,6 +179,7 @@ async function installIsolationInstrumentation(page, { pauseChat = false } = {})
|
|
|
177
179
|
};
|
|
178
180
|
const underTranscript = (node) => (node?.nodeType === Node.ELEMENT_NODE ? node : node?.parentElement)?.closest?.("#chat") !== null;
|
|
179
181
|
const allowedFollowMutation = (record) => record.type === "attributes" && record.attributeName === "hidden" && record.target === document.querySelector("#jumpToLatestButton");
|
|
182
|
+
const allowedElapsedMetadataMutation = (record) => record.type === "childList" && record.target?.matches?.("span.run-indicator-meta") === true;
|
|
180
183
|
const scrollNodes = [...document.querySelectorAll("*")].filter((node) => {
|
|
181
184
|
if (node.closest?.("#chat")) return false;
|
|
182
185
|
return node === document.scrollingElement || node.scrollHeight > node.clientHeight || node.scrollWidth > node.clientWidth || node.scrollTop !== 0 || node.scrollLeft !== 0;
|
|
@@ -185,6 +188,7 @@ async function installIsolationInstrumentation(page, { pauseChat = false } = {})
|
|
|
185
188
|
const proof = {
|
|
186
189
|
allowedMutations: { attributes: 0, characterData: 0, childList: 0 },
|
|
187
190
|
allowedFollowMutations: 0,
|
|
191
|
+
allowedElapsedMetadataMutations: 0,
|
|
188
192
|
forbiddenMutations: { attributes: 0, characterData: 0, childList: 0 },
|
|
189
193
|
forbiddenMutationExamples: [],
|
|
190
194
|
focusEvents: [], focusCalls: [], scrollIntoViewCalls: [], fetchCalls: [], eventSourceConstructions: [],
|
|
@@ -202,6 +206,7 @@ async function installIsolationInstrumentation(page, { pauseChat = false } = {})
|
|
|
202
206
|
for (const record of records) {
|
|
203
207
|
if (underTranscript(record.target)) proof.allowedMutations[record.type] += 1;
|
|
204
208
|
else if (allowedFollowMutation(record)) proof.allowedFollowMutations += 1;
|
|
209
|
+
else if (allowedElapsedMetadataMutation(record)) proof.allowedElapsedMetadataMutations += 1;
|
|
205
210
|
else {
|
|
206
211
|
proof.forbiddenMutations[record.type] += 1;
|
|
207
212
|
if (proof.forbiddenMutationExamples.length < 20) proof.forbiddenMutationExamples.push(`${record.type}:${describe(record.target)}:${record.attributeName || ""}`);
|
|
@@ -244,6 +249,7 @@ async function finishIsolationInstrumentation(page) {
|
|
|
244
249
|
return {
|
|
245
250
|
allowedMutations: proof.allowedMutations,
|
|
246
251
|
allowedFollowMutations: proof.allowedFollowMutations,
|
|
252
|
+
allowedElapsedMetadataMutations: proof.allowedElapsedMetadataMutations,
|
|
247
253
|
forbiddenMutations: proof.forbiddenMutations,
|
|
248
254
|
forbiddenMutationExamples: proof.forbiddenMutationExamples,
|
|
249
255
|
focusEvents: proof.focusEvents,
|
|
@@ -266,6 +272,7 @@ async function finishIsolationInstrumentation(page) {
|
|
|
266
272
|
counters: { ...ledger.counters },
|
|
267
273
|
receivedIndexes: [...ledger.receivedIndexes],
|
|
268
274
|
appliedIndexes: [...ledger.appliedIndexes],
|
|
275
|
+
records: ledger.records.map((record) => ({ ...record })),
|
|
269
276
|
},
|
|
270
277
|
};
|
|
271
278
|
});
|
|
@@ -290,6 +297,12 @@ async function holdIndependentPollResponses(page) {
|
|
|
290
297
|
};
|
|
291
298
|
}
|
|
292
299
|
|
|
300
|
+
function percentileNearestRank(values, percentile) {
|
|
301
|
+
if (!values.length) return null;
|
|
302
|
+
const sorted = [...values].sort((left, right) => left - right);
|
|
303
|
+
return sorted[Math.max(0, Math.ceil(percentile * sorted.length) - 1)];
|
|
304
|
+
}
|
|
305
|
+
|
|
293
306
|
function assertIsolationMetrics(metrics, networkRequests, surface, expectedSelection, expectedIndexCount = deltaCount) {
|
|
294
307
|
assert.deepEqual(metrics.forbiddenMutations, { attributes: 0, characterData: 0, childList: 0 }, `${surface}: ${metrics.forbiddenMutationExamples.join(", ")}`);
|
|
295
308
|
assert.deepEqual(metrics.focusEvents, []);
|
|
@@ -321,7 +334,12 @@ async function startFixture(page, mode, scenario = "standard") {
|
|
|
321
334
|
data: { message: `fixture stream isolation ${mode} ${scenario}`, requestId: `stream-isolation-${mode}-${scenario}-${Date.now()}` },
|
|
322
335
|
});
|
|
323
336
|
assert.equal(response.data?.deltaCount, deltaCount);
|
|
324
|
-
assert.equal(response.data?.finalText, expectedFinalText);
|
|
337
|
+
if (scenario !== "long-transcript") assert.equal(response.data?.finalText, expectedFinalText);
|
|
338
|
+
else {
|
|
339
|
+
assert.equal(response.data?.retainedMessageCount, 1000);
|
|
340
|
+
assert.ok(response.data?.finalText?.startsWith("```js\nconst v0000 = 0;\n"));
|
|
341
|
+
assert.ok(response.data?.finalText?.endsWith("```\nLONG-STREAM-TAIL"));
|
|
342
|
+
}
|
|
325
343
|
await waitForPhase(response.data.runId, "ready");
|
|
326
344
|
await expect(page.locator("#abortButton")).toBeVisible();
|
|
327
345
|
await expect(page.locator(".message.toolExecution").last()).toContainText("read");
|
|
@@ -342,7 +360,7 @@ async function startFixture(page, mode, scenario = "standard") {
|
|
|
342
360
|
// stream-delta-caused chrome mutation in the observed window.
|
|
343
361
|
await expect(page.locator("#optionalFeatureMigrationSurface")).toBeHidden();
|
|
344
362
|
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
|
345
|
-
return { tabId, runId: response.data.runId };
|
|
363
|
+
return { tabId, runId: response.data.runId, finalText: response.data.finalText, retainedMessageCount: response.data.retainedMessageCount || 0 };
|
|
346
364
|
}
|
|
347
365
|
|
|
348
366
|
async function continueFixture(tabId, runId) {
|
|
@@ -444,6 +462,54 @@ test("desktop compact isolation preserves paused reader and modal", async ({ pag
|
|
|
444
462
|
test("mobile 390x844 normal isolation", async ({ page }) => runIsolationCase(page, { mode: "normal", viewport: { width: 390, height: 844 }, label: "mobile-390" }));
|
|
445
463
|
test("mobile 320x568 compact isolation", async ({ page }) => runIsolationCase(page, { mode: "compact", viewport: { width: 320, height: 568 }, pauseChat: true, label: "mobile-320" }));
|
|
446
464
|
|
|
465
|
+
test("Chromium streaming baseline: hidden output reconciles exactly on foreground", async ({ page }) => {
|
|
466
|
+
await serverApi("/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
|
|
467
|
+
const expectedSelection = await prepareInteractiveState(page, { viewport: { width: 1280, height: 720 }, pauseChat: true });
|
|
468
|
+
const completed = page.locator(".message.assistant:not(.streaming) .markdown-body", { hasText: "ISOLATION-TEXT-TAIL" });
|
|
469
|
+
const completedBefore = await completed.count();
|
|
470
|
+
const { tabId, runId } = await startFixture(page, "normal", "background");
|
|
471
|
+
const before = await page.evaluate(() => ({
|
|
472
|
+
activeElement: document.activeElement?.id || "",
|
|
473
|
+
selection: window.getSelection()?.toString() || "",
|
|
474
|
+
chatTop: document.querySelector("#chat")?.scrollTop || 0,
|
|
475
|
+
}));
|
|
476
|
+
|
|
477
|
+
await page.evaluate(() => {
|
|
478
|
+
window.__ws0VisibilityState = "hidden";
|
|
479
|
+
Object.defineProperty(document, "visibilityState", {
|
|
480
|
+
configurable: true,
|
|
481
|
+
get: () => window.__ws0VisibilityState,
|
|
482
|
+
});
|
|
483
|
+
document.dispatchEvent(new Event("visibilitychange"));
|
|
484
|
+
});
|
|
485
|
+
await page.waitForTimeout(200);
|
|
486
|
+
await continueFixture(tabId, runId);
|
|
487
|
+
await waitForPhase(runId, "settled");
|
|
488
|
+
await expect(completed).toHaveCount(completedBefore);
|
|
489
|
+
|
|
490
|
+
await page.evaluate(() => {
|
|
491
|
+
window.__ws0VisibilityState = "visible";
|
|
492
|
+
document.dispatchEvent(new Event("visibilitychange"));
|
|
493
|
+
});
|
|
494
|
+
await expect(completed).toHaveCount(completedBefore + 1);
|
|
495
|
+
await waitForSettlement(page, tabId);
|
|
496
|
+
const after = await page.evaluate(() => {
|
|
497
|
+
const selection = window.getSelection();
|
|
498
|
+
return {
|
|
499
|
+
activeElement: document.activeElement?.id || "",
|
|
500
|
+
selection: selection?.toString() || "",
|
|
501
|
+
selectionConnected: selection?.anchorNode?.isConnected === true && selection?.focusNode?.isConnected === true,
|
|
502
|
+
chatTop: document.querySelector("#chat")?.scrollTop || 0,
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
assert.equal(before.activeElement, "promptInput");
|
|
506
|
+
assert.equal(after.activeElement, before.activeElement, "foreground reconciliation must preserve composer focus");
|
|
507
|
+
assert.equal(after.selection, expectedSelection, "foreground reconciliation must preserve exact selected text");
|
|
508
|
+
assert.equal(after.selectionConnected, true);
|
|
509
|
+
assert.equal(after.chatTop, before.chatTop, "foreground reconciliation must preserve detached scroll position exactly");
|
|
510
|
+
await assertFixtureContract(runId, "normal", "background");
|
|
511
|
+
});
|
|
512
|
+
|
|
447
513
|
test("abort flushes and preserves the partial text tail before lifecycle chrome settles", async ({ page }) => {
|
|
448
514
|
await serverApi("/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
|
|
449
515
|
const expectedSelection = await prepareInteractiveState(page, { viewport: { width: 1280, height: 720 } });
|
|
@@ -508,3 +574,242 @@ test("retry compaction reconnect and settlement retain lifecycle control identit
|
|
|
508
574
|
assert.equal(await steer.evaluate((node) => node.isConnected), true, "Steer must retain node identity through settlement");
|
|
509
575
|
assert.equal(await followUp.evaluate((node) => node.isConnected), true, "Follow-up must retain node identity through settlement");
|
|
510
576
|
});
|
|
577
|
+
|
|
578
|
+
test("WS3 paced cadence and slow-renderer queue pressure remain bounded", async ({ page }) => {
|
|
579
|
+
test.setTimeout(120_000);
|
|
580
|
+
await serverApi("/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
|
|
581
|
+
const expectedSelection = await prepareInteractiveState(page, { viewport: { width: 1280, height: 720 }, pauseChat: true });
|
|
582
|
+
const { tabId, runId, finalText } = await startFixture(page, "normal", "paced-pressure");
|
|
583
|
+
const releaseIndependentPolls = await holdIndependentPollResponses(page);
|
|
584
|
+
const networkRequests = [];
|
|
585
|
+
const onRequest = (request) => networkRequests.push(`${request.method()} ${request.url()}`);
|
|
586
|
+
page.on("request", onRequest);
|
|
587
|
+
await installIsolationInstrumentation(page, { pauseChat: true });
|
|
588
|
+
await page.evaluate(() => {
|
|
589
|
+
const original = window.requestAnimationFrame.bind(window);
|
|
590
|
+
window.__ws3OriginalRequestAnimationFrame = original;
|
|
591
|
+
window.requestAnimationFrame = (callback) => original((timestamp) => {
|
|
592
|
+
const deadline = performance.now() + 8;
|
|
593
|
+
while (performance.now() < deadline) { /* deterministic slow-renderer pressure */ }
|
|
594
|
+
callback(timestamp);
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
await continueFixture(tabId, runId);
|
|
599
|
+
await waitForPhase(runId, "text-complete");
|
|
600
|
+
await expect.poll(() => page.evaluate(() => window.__piStreamIsolationDebug?.appliedIndexes?.length || 0)).toBe(deltaCount);
|
|
601
|
+
const liveMarkdown = page.locator(".message.assistant.streaming .streaming-markdown").last();
|
|
602
|
+
await expect(liveMarkdown).toContainText("ISOLATION-TEXT-TAIL");
|
|
603
|
+
assert.equal((await liveMarkdown.textContent()).trim(), finalText, "paced pressure must end on the authoritative exact snapshot");
|
|
604
|
+
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
|
605
|
+
|
|
606
|
+
const metrics = await finishIsolationInstrumentation(page);
|
|
607
|
+
await page.evaluate(() => {
|
|
608
|
+
if (window.__ws3OriginalRequestAnimationFrame) window.requestAnimationFrame = window.__ws3OriginalRequestAnimationFrame;
|
|
609
|
+
delete window.__ws3OriginalRequestAnimationFrame;
|
|
610
|
+
});
|
|
611
|
+
page.off("request", onRequest);
|
|
612
|
+
await releaseIndependentPolls();
|
|
613
|
+
|
|
614
|
+
assert.deepEqual(metrics.forbiddenMutations, { attributes: 0, characterData: 0, childList: 0 }, metrics.forbiddenMutationExamples.join(", "));
|
|
615
|
+
assert.deepEqual(metrics.focusEvents, []);
|
|
616
|
+
assert.deepEqual(metrics.focusCalls, []);
|
|
617
|
+
assert.equal(metrics.activeElementChanged, false);
|
|
618
|
+
assert.deepEqual(metrics.identityChanges, []);
|
|
619
|
+
assert.deepEqual(metrics.scrollChanges, []);
|
|
620
|
+
assert.equal(metrics.chatTopAfter, metrics.chatTopBefore, "slow rendering must not move a detached reader");
|
|
621
|
+
assert.equal(metrics.selectionBefore, expectedSelection);
|
|
622
|
+
assert.equal(metrics.selectionAfter, expectedSelection);
|
|
623
|
+
assert.equal(metrics.selectionNodesConnected, true);
|
|
624
|
+
assert.deepEqual(metrics.debug.receivedIndexes, expectedIndexes);
|
|
625
|
+
assert.deepEqual(metrics.debug.appliedIndexes, expectedIndexes);
|
|
626
|
+
assert.deepEqual(networkRequests.filter((request) => !isIndependentPollRequest(request.split(" ").slice(1).join(" "))), []);
|
|
627
|
+
|
|
628
|
+
const counters = metrics.debug.counters;
|
|
629
|
+
assert.ok(counters.renderSchedulerFlushes > 2, "paced output must exercise sustained normal formatting");
|
|
630
|
+
assert.ok(counters.renderSchedulerDefers > 0, "paced output must defer at least one latest-wins render");
|
|
631
|
+
assert.ok(counters.renderSchedulerFlushes < counters.appliedEvents, "formatting publishes must remain below applied transport sources");
|
|
632
|
+
assert.ok(counters.pressureDeferred > 0, "the first queue-pressure drain must leave the EventSource callback");
|
|
633
|
+
assert.ok(counters.pressureSynchronousFallbacks > 0, "repeated same-task pressure must exercise the synchronous lossless fallback");
|
|
634
|
+
assert.ok(counters.highWaterPendingCount <= 129, `primary plus urgent entry should cap at 129, got ${counters.highWaterPendingCount}`);
|
|
635
|
+
assert.ok(counters.highWaterPendingBytes <= 2 * 256 * 1024, "primary plus urgent bytes must remain explicitly bounded");
|
|
636
|
+
assert.equal(counters.focusLossNearStreamBatch, 0);
|
|
637
|
+
assert.equal(counters.detachedScrollMoves, 0);
|
|
638
|
+
|
|
639
|
+
const records = metrics.debug.records;
|
|
640
|
+
const paintMs = records.filter((record) => record.type === "paint-opportunity").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
641
|
+
const longTaskMs = records.filter((record) => record.type === "longtask").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
642
|
+
const longFrameMs = records.filter((record) => record.type === "long-animation-frame").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
643
|
+
console.log(`WS3_STREAMING_CANDIDATE ${JSON.stringify({
|
|
644
|
+
scenario: {
|
|
645
|
+
sourceIndexedTextDeltas: deltaCount,
|
|
646
|
+
finalTextBytesUtf8: Buffer.byteLength(finalText),
|
|
647
|
+
finalTextSha256: createHash("sha256").update(finalText).digest("hex"),
|
|
648
|
+
injectedFrameDelayMs: 8,
|
|
649
|
+
selectedCadenceMs: 40,
|
|
650
|
+
},
|
|
651
|
+
eventAndRenderCounts: {
|
|
652
|
+
receivedEvents: counters.receivedEvents,
|
|
653
|
+
appliedEvents: counters.appliedEvents,
|
|
654
|
+
sinkCalls: counters.sinkCalls,
|
|
655
|
+
controllerBatches: counters.batches,
|
|
656
|
+
renderSchedulerFlushes: counters.renderSchedulerFlushes,
|
|
657
|
+
renderSchedulerDefers: counters.renderSchedulerDefers,
|
|
658
|
+
markdownCommits: counters.markdownCommits,
|
|
659
|
+
},
|
|
660
|
+
pressure: {
|
|
661
|
+
overflows: counters.overflows,
|
|
662
|
+
deferred: counters.pressureDeferred,
|
|
663
|
+
synchronousFallbacks: counters.pressureSynchronousFallbacks,
|
|
664
|
+
queueHighWaterEntries: counters.highWaterPendingCount,
|
|
665
|
+
queueHighWaterBytes: counters.highWaterPendingBytes,
|
|
666
|
+
},
|
|
667
|
+
receiptToPaintMs: {
|
|
668
|
+
samples: paintMs.length,
|
|
669
|
+
p95: percentileNearestRank(paintMs, 0.95),
|
|
670
|
+
max: paintMs.length ? Math.max(...paintMs) : null,
|
|
671
|
+
},
|
|
672
|
+
longestMs: {
|
|
673
|
+
batchDrain: counters.batchDrainMaxMs,
|
|
674
|
+
markdownCommit: counters.markdownCommitMaxMs,
|
|
675
|
+
longTask: longTaskMs.length ? Math.max(...longTaskMs) : null,
|
|
676
|
+
longAnimationFrame: longFrameMs.length ? Math.max(...longFrameMs) : null,
|
|
677
|
+
},
|
|
678
|
+
continuity: {
|
|
679
|
+
focusLossNearStreamBatch: counters.focusLossNearStreamBatch,
|
|
680
|
+
detachedScrollMoves: counters.detachedScrollMoves,
|
|
681
|
+
},
|
|
682
|
+
})}`);
|
|
683
|
+
|
|
684
|
+
await waitForSettlement(page, tabId);
|
|
685
|
+
await assertFixtureContract(runId, "normal", "paced-pressure");
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
test("Chromium streaming baseline: long transcript plus active fenced stream", async ({ page, browser }) => {
|
|
689
|
+
test.setTimeout(120_000);
|
|
690
|
+
await serverApi("/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
|
|
691
|
+
await page.setViewportSize({ width: 1280, height: 720 });
|
|
692
|
+
await page.goto(`${baseURL}/?streamIsolationDebug=1`);
|
|
693
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
694
|
+
const initialTabId = await activeTabId(page);
|
|
695
|
+
const populated = await serverApi(`/api/prompt?tab=${encodeURIComponent(initialTabId)}`, {
|
|
696
|
+
method: "POST",
|
|
697
|
+
data: { message: "fixture stream isolation populate long transcript", requestId: `stream-isolation-populate-${Date.now()}` },
|
|
698
|
+
});
|
|
699
|
+
assert.equal(populated.data?.retainedMessageCount, 1000);
|
|
700
|
+
|
|
701
|
+
// Load the deterministic retained transcript before the active stream starts.
|
|
702
|
+
await page.reload();
|
|
703
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
704
|
+
const retained = page.locator("#chat .message", { hasText: /LONG-TRANSCRIPT-\d{4}/ });
|
|
705
|
+
await expect(retained).toHaveCount(1000);
|
|
706
|
+
await expect(retained.first()).toContainText("LONG-TRANSCRIPT-0000");
|
|
707
|
+
await expect(retained.last()).toContainText("LONG-TRANSCRIPT-0999");
|
|
708
|
+
const { tabId, runId, finalText, retainedMessageCount } = await startFixture(page, "normal", "long-transcript");
|
|
709
|
+
assert.equal(retainedMessageCount, 1000);
|
|
710
|
+
|
|
711
|
+
const pausedTop = await page.locator("#chat").evaluate((node) => {
|
|
712
|
+
node.style.scrollBehavior = "auto";
|
|
713
|
+
node.scrollTop = Math.max(1, Math.floor((node.scrollHeight - node.clientHeight) / 3));
|
|
714
|
+
node.dispatchEvent(new WheelEvent("wheel", { deltaY: -160, bubbles: true }));
|
|
715
|
+
node.dispatchEvent(new Event("scroll", { bubbles: true }));
|
|
716
|
+
node.style.removeProperty("scroll-behavior");
|
|
717
|
+
return node.scrollTop;
|
|
718
|
+
});
|
|
719
|
+
assert.ok(pausedTop > 0, "long-transcript baseline requires a detached reader position");
|
|
720
|
+
await page.locator("#promptInput").focus();
|
|
721
|
+
const expectedSelection = await selectPreservedText(page);
|
|
722
|
+
const releaseIndependentPolls = await holdIndependentPollResponses(page);
|
|
723
|
+
const networkRequests = [];
|
|
724
|
+
const onRequest = (request) => networkRequests.push(`${request.method()} ${request.url()}`);
|
|
725
|
+
page.on("request", onRequest);
|
|
726
|
+
await installIsolationInstrumentation(page, { pauseChat: true });
|
|
727
|
+
await continueFixture(tabId, runId);
|
|
728
|
+
await waitForPhase(runId, "raw-start");
|
|
729
|
+
await waitForPhase(runId, "text-complete");
|
|
730
|
+
await expect.poll(() => page.evaluate(() => window.__piStreamIsolationDebug?.appliedIndexes?.length || 0)).toBe(deltaCount);
|
|
731
|
+
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
|
732
|
+
|
|
733
|
+
// The Markdown renderer intentionally omits the delimiter-adjacent trailing
|
|
734
|
+
// newline from the code text node; every source character before it remains
|
|
735
|
+
// exact and the authoritative raw-output hash below covers the full string.
|
|
736
|
+
const expectedCode = finalText.slice("```js\n".length, finalText.lastIndexOf("```\n")).replace(/\n$/, "");
|
|
737
|
+
const liveMarkdown = page.locator(".message.assistant.streaming .streaming-markdown").last();
|
|
738
|
+
await expect(liveMarkdown).toContainText("LONG-STREAM-TAIL");
|
|
739
|
+
assert.equal(await liveMarkdown.locator("code").textContent(), expectedCode, "live fenced source must remain exact");
|
|
740
|
+
|
|
741
|
+
const metrics = await finishIsolationInstrumentation(page);
|
|
742
|
+
page.off("request", onRequest);
|
|
743
|
+
await releaseIndependentPolls();
|
|
744
|
+
assertIsolationMetrics(metrics, networkRequests, "long-transcript-active-stream", expectedSelection);
|
|
745
|
+
assert.equal(metrics.debug.counters.focusLossNearStreamBatch, 0);
|
|
746
|
+
assert.equal(metrics.debug.counters.detachedScrollMoves, 0);
|
|
747
|
+
assert.ok(metrics.debug.counters.transcriptNodeMax >= 1000, "node ledger must observe the retained transcript");
|
|
748
|
+
assert.ok(metrics.debug.counters.currentMessageNodeMax > 0, "node ledger must observe the active stream");
|
|
749
|
+
assert.ok(metrics.debug.counters.deriveCalls > 0, "derived-text diagnostics must be exercised");
|
|
750
|
+
assert.ok(metrics.debug.counters.markdownCommits > 0, "Markdown diagnostics must be exercised");
|
|
751
|
+
assert.equal(metrics.debug.counters.tokenizeCalls, 1, "the live open fence must skip accumulated syntax tokenization and highlight authoritatively once");
|
|
752
|
+
|
|
753
|
+
const records = metrics.debug.records;
|
|
754
|
+
const markdownRecords = records.filter((record) => record.type === "markdown-commit");
|
|
755
|
+
const tokenizeRecords = records.filter((record) => record.type === "tokenize");
|
|
756
|
+
const boundaryScannedChars = markdownRecords.reduce((sum, record) => sum + (Number(record.boundaryScannedChars) || 0), 0);
|
|
757
|
+
assert.equal(tokenizeRecords.length, 1, "only the authoritative fence close/completion may invoke the tokenizer");
|
|
758
|
+
assert.ok(boundaryScannedChars <= finalText.length, "incremental boundary work must not rescan the committed prefix");
|
|
759
|
+
const paintMs = records.filter((record) => record.type === "paint-opportunity").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
760
|
+
const markdownMs = markdownRecords.map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
761
|
+
const tokenizeMs = tokenizeRecords.map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
762
|
+
const longTaskMs = records.filter((record) => record.type === "longtask").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
763
|
+
const longFrameMs = records.filter((record) => record.type === "long-animation-frame").map((record) => Number(record.ms)).filter(Number.isFinite);
|
|
764
|
+
const environment = await page.evaluate(() => ({
|
|
765
|
+
userAgent: navigator.userAgent,
|
|
766
|
+
hardwareConcurrency: navigator.hardwareConcurrency,
|
|
767
|
+
deviceMemoryGiB: navigator.deviceMemory ?? null,
|
|
768
|
+
viewport: { width: innerWidth, height: innerHeight, devicePixelRatio },
|
|
769
|
+
}));
|
|
770
|
+
const counters = metrics.debug.counters;
|
|
771
|
+
const baseline = {
|
|
772
|
+
scenario: { retainedMessages: retainedMessageCount, sourceDeltaEvents: deltaCount, finalTextBytesUtf8: Buffer.byteLength(finalText), finalTextSha256: createHash("sha256").update(finalText).digest("hex") },
|
|
773
|
+
eventAndBatchCounts: { receivedEvents: counters.receivedEvents, appliedEvents: counters.appliedEvents, sinkCalls: counters.sinkCalls, batches: counters.batches, barriers: counters.barriers, overflows: counters.overflows },
|
|
774
|
+
receiptToPaintMs: { samples: paintMs.length, p50: percentileNearestRank(paintMs, 0.50), p95: percentileNearestRank(paintMs, 0.95), max: paintMs.length ? Math.max(...paintMs) : null },
|
|
775
|
+
longestCostsMs: { batchReceiptAge: counters.batchLatencyMaxMs, batchDrain: counters.batchDrainMaxMs, derive: counters.deriveMaxMs, tokenize: counters.tokenizeMaxMs, markdownCommit: counters.markdownCommitMaxMs, longTask: longTaskMs.length ? Math.max(...longTaskMs) : null, longAnimationFrame: longFrameMs.length ? Math.max(...longFrameMs) : null },
|
|
776
|
+
costInputs: { deriveCalls: counters.deriveCalls, deriveMaxBytes: counters.deriveMaxBytes, tokenizeCalls: counters.tokenizeCalls, tokenizeMaxBytes: counters.tokenizeMaxBytes, markdownCommits: counters.markdownCommits, tailMaxBytes: counters.tailMaxBytes },
|
|
777
|
+
queueHighWater: { entries: counters.highWaterPendingCount, bytes: counters.highWaterPendingBytes },
|
|
778
|
+
nodeMax: { transcript: counters.transcriptNodeMax, currentMessage: counters.currentMessageNodeMax },
|
|
779
|
+
continuity: { focusLossNearStreamBatch: counters.focusLossNearStreamBatch, detachedScrollMoves: counters.detachedScrollMoves },
|
|
780
|
+
environment: {
|
|
781
|
+
browserName: "chromium",
|
|
782
|
+
browserVersion: browser.version(),
|
|
783
|
+
...environment,
|
|
784
|
+
node: process.version,
|
|
785
|
+
platform: process.platform,
|
|
786
|
+
architecture: process.arch,
|
|
787
|
+
hostname: hostname(),
|
|
788
|
+
kernelRelease: release(),
|
|
789
|
+
cpuModel: cpus()[0]?.model || "unknown",
|
|
790
|
+
logicalCpuCount: cpus().length,
|
|
791
|
+
totalMemoryBytes: totalmem(),
|
|
792
|
+
},
|
|
793
|
+
};
|
|
794
|
+
console.log(`WS0_STREAMING_BASELINE ${JSON.stringify(baseline)}`);
|
|
795
|
+
console.log(`WS2_STREAMING_CANDIDATE ${JSON.stringify({
|
|
796
|
+
...baseline,
|
|
797
|
+
incrementalMarkdown: {
|
|
798
|
+
boundaryScannedChars,
|
|
799
|
+
tokenizeCalls: tokenizeRecords.length,
|
|
800
|
+
authoritativeCommits: markdownRecords.filter((record) => record.authoritative).length,
|
|
801
|
+
reusedTailCommits: markdownRecords.filter((record) => record.reusedTail).length,
|
|
802
|
+
markdownTotalMs: markdownMs.reduce((sum, value) => sum + value, 0),
|
|
803
|
+
tokenizeTotalMs: tokenizeMs.reduce((sum, value) => sum + value, 0),
|
|
804
|
+
},
|
|
805
|
+
})}`);
|
|
806
|
+
|
|
807
|
+
await expect.poll(
|
|
808
|
+
async () => (await serverApi(`/api/state?tab=${encodeURIComponent(tabId)}`)).data?.isStreaming,
|
|
809
|
+
{ timeout: 30_000 },
|
|
810
|
+
).toBe(false);
|
|
811
|
+
const settled = page.locator(".message.assistant:not(.streaming) .markdown-body", { hasText: "LONG-STREAM-TAIL" }).last();
|
|
812
|
+
await expect(settled).toContainText("LONG-STREAM-TAIL");
|
|
813
|
+
assert.equal(await settled.locator("code").textContent(), expectedCode, "settled fenced source must remain exact");
|
|
814
|
+
await assertFixtureContract(runId, "normal", "long-transcript");
|
|
815
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createServer } from "node:net";
|
|
3
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { expect, test } from "@playwright/test";
|
|
10
|
+
|
|
11
|
+
// Browser coverage for plans/planned/webui-user-noticeable-improvements.md.
|
|
12
|
+
|
|
13
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
14
|
+
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
15
|
+
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
16
|
+
|
|
17
|
+
async function freePort() {
|
|
18
|
+
const server = createServer();
|
|
19
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
20
|
+
const { port } = server.address();
|
|
21
|
+
await new Promise((resolve) => server.close(resolve));
|
|
22
|
+
return port;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let child;
|
|
26
|
+
let baseURL;
|
|
27
|
+
let tempRoot;
|
|
28
|
+
let output = "";
|
|
29
|
+
|
|
30
|
+
test.beforeAll(async () => {
|
|
31
|
+
const port = await freePort();
|
|
32
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-user-noticeable-"));
|
|
33
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
34
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
35
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36
|
+
env: {
|
|
37
|
+
...process.env,
|
|
38
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
39
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
40
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
44
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
45
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
46
|
+
if (child.exitCode !== null) break;
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
49
|
+
if (response.ok) return;
|
|
50
|
+
} catch {
|
|
51
|
+
// Wait for the local server and fake Pi fixture.
|
|
52
|
+
}
|
|
53
|
+
await delay(100);
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Pi Web UI did not start:\n${output}`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test.afterAll(async () => {
|
|
59
|
+
child?.kill("SIGTERM");
|
|
60
|
+
if (child) await new Promise((resolve) => child.once("exit", resolve));
|
|
61
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
async function layoutMetrics(page) {
|
|
65
|
+
return page.evaluate(() => {
|
|
66
|
+
const workspace = document.querySelector(".workspace-column").getBoundingClientRect();
|
|
67
|
+
const prompt = document.querySelector("#promptInput").getBoundingClientRect();
|
|
68
|
+
return {
|
|
69
|
+
bodyClasses: document.body.className,
|
|
70
|
+
gridColumns: getComputedStyle(document.querySelector("main.layout")).gridTemplateColumns,
|
|
71
|
+
workspaceWidth: workspace.width,
|
|
72
|
+
promptWidth: prompt.width,
|
|
73
|
+
viewportWidth: window.innerWidth,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// P0-1: with the Control Deck collapsed in overlay presentation (phones, tablets, laptops <= 1050px)
|
|
79
|
+
// the workspace must take the full viewport width instead of collapsing to a few pixels.
|
|
80
|
+
for (const viewport of [{ width: 390, height: 844 }, { width: 820, height: 1180 }, { width: 1024, height: 700 }]) {
|
|
81
|
+
test(`overlay presentation keeps the workspace full-width at ${viewport.width}px`, async ({ page }) => {
|
|
82
|
+
await page.setViewportSize(viewport);
|
|
83
|
+
await page.goto(baseURL);
|
|
84
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
85
|
+
await expect.poll(async () => (await layoutMetrics(page)).bodyClasses).toContain("control-deck-overlay");
|
|
86
|
+
const metrics = await layoutMetrics(page);
|
|
87
|
+
assert.ok(metrics.bodyClasses.includes("side-panel-collapsed"), `overlay deck should start collapsed: ${metrics.bodyClasses}`);
|
|
88
|
+
assert.ok(metrics.workspaceWidth >= metrics.viewportWidth * 0.9, `workspace should fill the viewport: ${JSON.stringify(metrics)}`);
|
|
89
|
+
assert.ok(metrics.promptWidth >= metrics.viewportWidth * 0.6, `prompt should be usable: ${JSON.stringify(metrics)}`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// P0-2: native selector dialogs (/model, /theme, /resume, …) — Enter in the filter selects the
|
|
94
|
+
// highlighted choice instead of closing the dialog; arrows move the highlight; the current
|
|
95
|
+
// choice is highlighted when unfiltered.
|
|
96
|
+
test("model selector supports Enter-to-select and arrow-key navigation from the filter box", async ({ page }) => {
|
|
97
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
98
|
+
const models = [
|
|
99
|
+
{ provider: "fake", id: "fake-model", name: "Fake Model" },
|
|
100
|
+
{ provider: "fake", id: "alpha-one", name: "Alpha One" },
|
|
101
|
+
{ provider: "fake", id: "beta-two", name: "Beta Two" },
|
|
102
|
+
{ provider: "other", id: "gamma-three", name: "Gamma Three" },
|
|
103
|
+
];
|
|
104
|
+
await page.route("**/api/models*", async (route) => {
|
|
105
|
+
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: { models } }) });
|
|
106
|
+
});
|
|
107
|
+
const setModelCalls = [];
|
|
108
|
+
await page.route(/\/api\/model(\?.*)?$/, async (route) => {
|
|
109
|
+
setModelCalls.push(route.request().postDataJSON());
|
|
110
|
+
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: route.request().postDataJSON() }) });
|
|
111
|
+
});
|
|
112
|
+
await page.goto(baseURL);
|
|
113
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
114
|
+
|
|
115
|
+
await page.keyboard.press("Control+l");
|
|
116
|
+
const dialog = page.locator("#nativeCommandDialog");
|
|
117
|
+
await expect(dialog).toBeVisible();
|
|
118
|
+
const search = page.locator("#nativeCommandSearch");
|
|
119
|
+
await expect(search).toBeFocused();
|
|
120
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item")).toHaveCount(4);
|
|
121
|
+
// The current model is highlighted before any filtering.
|
|
122
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/fake-model");
|
|
123
|
+
|
|
124
|
+
await page.keyboard.press("ArrowDown");
|
|
125
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/alpha-one");
|
|
126
|
+
await expect(search).toHaveAttribute("aria-activedescendant", /nativeSelectorItem-1/);
|
|
127
|
+
await page.keyboard.press("End");
|
|
128
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("other/gamma-three");
|
|
129
|
+
|
|
130
|
+
await search.fill("beta");
|
|
131
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item")).toHaveCount(1);
|
|
132
|
+
await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/beta-two");
|
|
133
|
+
await page.keyboard.press("Enter");
|
|
134
|
+
await expect(dialog).toBeHidden();
|
|
135
|
+
assert.deepEqual(setModelCalls, [{ provider: "fake", modelId: "beta-two" }], "Enter should select the highlighted model");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// P0-3: Enter accepts the highlighted slash suggestion instead of sending the partial token;
|
|
139
|
+
// once the token equals the suggestion, Enter sends as usual.
|
|
140
|
+
test("Enter accepts the highlighted slash suggestion before sending", async ({ page }) => {
|
|
141
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
142
|
+
await page.goto(baseURL);
|
|
143
|
+
const prompt = page.locator("#promptInput");
|
|
144
|
+
await expect(prompt).toBeVisible();
|
|
145
|
+
await prompt.click();
|
|
146
|
+
await page.keyboard.type("/work");
|
|
147
|
+
const suggest = page.locator("#commandSuggest");
|
|
148
|
+
await expect(suggest).toBeVisible();
|
|
149
|
+
await expect(suggest.locator(".command-suggest-item").first()).toContainText("/workflow");
|
|
150
|
+
await expect(suggest.locator(".command-suggest-hint")).toContainText("Enter or Tab accept");
|
|
151
|
+
await page.keyboard.press("Enter");
|
|
152
|
+
await expect(prompt).toHaveValue("/workflow ");
|
|
153
|
+
await expect(suggest).toBeHidden();
|
|
154
|
+
// Nothing was sent: the transcript has no user message for the partial token.
|
|
155
|
+
await expect(page.locator("#chat")).not.toContainText("/work\n");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// P0-5: warnings/errors that used to land only in the collapsed Events log now surface as a
|
|
159
|
+
// non-blocking toast and increment an unread badge on the Events section header.
|
|
160
|
+
test("errors surface as a toast and an Events unread badge", async ({ page }) => {
|
|
161
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
162
|
+
await page.route(/\/api\/tabs(\?.*)?$/, async (route) => {
|
|
163
|
+
if (route.request().method() !== "POST") return route.fallback();
|
|
164
|
+
await route.fulfill({ status: 500, contentType: "application/json", body: JSON.stringify({ ok: false, error: "tab spawn exploded" }) });
|
|
165
|
+
});
|
|
166
|
+
await page.goto(baseURL);
|
|
167
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
168
|
+
await expect(page.locator("#eventsUnreadBadge")).toBeHidden();
|
|
169
|
+
|
|
170
|
+
// Palette → "New tab" fails server-side; previously this only wrote to the collapsed Events log.
|
|
171
|
+
await page.keyboard.press("Control+k");
|
|
172
|
+
await page.locator("#commandPaletteInput").fill("New tab");
|
|
173
|
+
await page.keyboard.press("Enter");
|
|
174
|
+
const toast = page.locator("#noticeToastStack .notice-toast.error");
|
|
175
|
+
await expect(toast.first()).toContainText("tab spawn exploded");
|
|
176
|
+
await expect(page.locator("#eventsUnreadBadge")).toBeVisible();
|
|
177
|
+
await expect(page.locator("#eventsUnreadBadge")).toHaveText("1");
|
|
178
|
+
|
|
179
|
+
// "Events" on the toast opens the Control Deck Events section and clears the unread badge.
|
|
180
|
+
await toast.first().locator(".notice-toast-events").click();
|
|
181
|
+
await expect(page.locator("#sidePanelSectionEvents")).toBeVisible();
|
|
182
|
+
await expect(page.locator("#eventsUnreadBadge")).toBeHidden();
|
|
183
|
+
await expect(page.locator("#eventLog .event.error").first()).toContainText("tab spawn exploded");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// P1-1: hover/focus-opened composer menus close on Escape even while the trigger keeps focus
|
|
187
|
+
// (previously the panel stayed visible because :focus-within re-opened it immediately).
|
|
188
|
+
test("Escape closes the composer options menu while its trigger keeps focus", async ({ page }) => {
|
|
189
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
190
|
+
await page.goto(baseURL);
|
|
191
|
+
await expect(page.locator("#promptInput")).toBeVisible();
|
|
192
|
+
const trigger = page.locator("#optionsMenuButton");
|
|
193
|
+
const panel = page.locator("#optionsMenu");
|
|
194
|
+
await trigger.click();
|
|
195
|
+
await expect(panel).toBeVisible();
|
|
196
|
+
await page.keyboard.press("Escape");
|
|
197
|
+
await expect(panel).toBeHidden();
|
|
198
|
+
await expect(trigger).toBeFocused();
|
|
199
|
+
// Explicit click reopens it.
|
|
200
|
+
await trigger.click();
|
|
201
|
+
await expect(panel).toBeVisible();
|
|
202
|
+
await page.keyboard.press("Escape");
|
|
203
|
+
await expect(panel).toBeHidden();
|
|
204
|
+
});
|
|
@@ -55,7 +55,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
|
|
|
55
55
|
assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
|
|
56
56
|
assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
|
|
57
57
|
// Intent preserved: browser-asset changes must advance the coherent cache tuple.
|
|
58
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
59
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
58
|
+
assert.match(serviceWorker, /pi-webui-pwa-v123/, "PWA cache identity should be bumped for changed browser assets");
|
|
59
|
+
assert.match(html, /data-app-src="\/app\.js\?v=157"/, "browser module URL should be cache-busted for Fast-mode wiring");
|
|
60
60
|
|
|
61
61
|
console.log("codex-fast-mode-static.test.mjs passed");
|