Multiplayer agent harness for work.
Drop source-text assertions from mixed web-ui tests (#2245)
Regan Bellda7257c5a71c
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.tsindex 83253ef82..6c9cdbcf0 100644--- a/plugins/web-ui/src/chat.ts+++ b/plugins/web-ui/src/chat.ts@@ -255,7 +255,7 @@ const connectedConnectors = new Set<string>();const redrawHooks = new Set<() => void>();let proactiveOpenerStarted = false;-export const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));+const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));export function markConnectorConnected(provider: string): void {if (!provider) return;diff --git a/plugins/web-ui/src/composer.ts b/plugins/web-ui/src/composer.tsindex 84a52e480..c142fb985 100644--- a/plugins/web-ui/src/composer.ts+++ b/plugins/web-ui/src/composer.ts@@ -121,7 +121,7 @@ function forgetThreadPick(threadRef: string): void {persistPreference(THREAD_PICKS_STORAGE_KEY, JSON.stringify([...threadModelPicks]));}-export function carryModelPick(fromThreadRef: string | null, toThreadRef: string): void {+function carryModelPick(fromThreadRef: string | null, toThreadRef: string): void {const pick = fromThreadRef ? threadModelPicks.get(fromThreadRef) : undefined;if (pick) rememberThreadPick(toThreadRef, pick);}@@ -170,7 +170,7 @@ export function clearSkillsCache(): void {const SLASH_TOKEN = /(^|\s)\/([a-zA-Z0-9_-]*)$/;-export function slashQuery(draft: string): string | null {+function slashQuery(draft: string): string | null {const m = SLASH_TOKEN.exec(draft);return m ? (m[2] ?? "") : null;}diff --git a/plugins/web-ui/src/core-bridge.ts b/plugins/web-ui/src/core-bridge.tsindex 63832f740..557199e98 100644--- a/plugins/web-ui/src/core-bridge.ts+++ b/plugins/web-ui/src/core-bridge.ts@@ -64,7 +64,7 @@ export function oversizeAttachmentNote(name: string): string {return `"${name}" is too large — files up to ~1 GB can be sent. It was left out.`;}-export function emptyAttachmentNote(name: string): string {+function emptyAttachmentNote(name: string): string {return `"${name}" is empty. It was left out.`;}@@ -73,7 +73,7 @@ export function tooManyFilesNote(names: string[]): string {return `Skipped ${skipped} — too many files in one message (max ${MAX_FILES_PER_MESSAGE}).`;}-export interface SkippedAttachment {+interface SkippedAttachment {id?: string;name: string;note: string;@@ -389,13 +389,6 @@ export async function regenerateTitle(id: string): Promise<{ title: string | nulreturn api<{ title: string | null }>(`/api/sessions/${encodeURIComponent(id)}/title`, { method: "POST" });}-export async function adoptSession(id: string, parentSessionId: string): Promise<{ adopted: true }> {- return api<{ adopted: true }>(`/api/sessions/${encodeURIComponent(id)}/adopt`, {- method: "POST",- body: JSON.stringify({ parentSessionId }),- });-}-export async function detachSession(id: string): Promise<{ detached: true }> {return api<{ detached: true }>(`/api/sessions/${encodeURIComponent(id)}/detach`, { method: "POST" });}@@ -599,7 +592,7 @@ export function continuableMessages(return { messages: kept.length ? kept : [resumeAnchor()], popped };}-export const SUBAGENT_THREAD_PREFIX = "agent:main:subagent:";+const SUBAGENT_THREAD_PREFIX = "agent:main:subagent:";export function isContinuable(s: Pick<CoreSession, "threadRef" | "scopeId">, user: string): boolean {if (s.threadRef.startsWith(SUBAGENT_THREAD_PREFIX))@@ -719,7 +712,7 @@ export function setSigninRequiredHandler(fn: (detail: SigninRequired) => void):onSigninRequired = fn;}-export function reportSigninRequired(detail: SigninRequired): void {+function reportSigninRequired(detail: SigninRequired): void {onSigninRequired?.(detail);}@@ -1162,7 +1155,7 @@ export function mintSendKey(): string {return crypto.randomUUID();}-export function sendKeyOf(message: unknown): string | undefined {+function sendKeyOf(message: unknown): string | undefined {const key = (message as SendKeyed | null)?.idempotencyKey;return typeof key === "string" && key ? key : undefined;}@@ -1762,7 +1755,7 @@ function xmlAttrUnescape(s: string): string {.replace(/&/g, "&");}-export function subagentMailOf(payload: unknown): SubagentMailRef | undefined {+function subagentMailOf(payload: unknown): SubagentMailRef | undefined {const text = (payload as { text?: unknown } | null)?.text;if (typeof text !== "string") return undefined;const m = SUBAGENT_MAIL_RE.exec(text);diff --git a/plugins/web-ui/test/approval-blocks-input.test.ts b/plugins/web-ui/test/approval-blocks-input.test.tsindex c96263791..a7ef866d9 100644--- a/plugins/web-ui/test/approval-blocks-input.test.ts+++ b/plugins/web-ui/test/approval-blocks-input.test.ts@@ -1,11 +1,7 @@import test from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { approvalBlocksComposer, type PendingApproval } from "../src/core-bridge.ts";-const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");-test("only approvals that block input lock the composer", () => {const blocking = { requestId: "a", command: "rm x" } as PendingApproval;const explicit = { requestId: "b", command: "rm y", blocksInput: true } as PendingApproval;@@ -14,55 +10,3 @@ test("only approvals that block input lock the composer", () => {assert.equal(approvalBlocksComposer(explicit), true);assert.equal(approvalBlocksComposer(nonBlocking), false);});--test("hasUnresolvedApproval ignores non-blocking approvals so sending stays possible", () => {- assert.match(- chat,- /function hasUnresolvedApproval\(\): boolean \{\s*return activePendingApprovals\(\)\.some\(approvalBlocksComposer\);/,- );-});--test("the composer locks input on blocking approvals only, while every approval still renders its card", () => {- assert.match(composer, /const blockingPauses = approvalPauses\.filter\(approvalBlocksComposer\);/);- assert.match(- composer,- /const inputBlocked = runtimePending \|\| ctx\.chat\.state\.resolvingApprovals\.size > 0 \|\| blockingPauses\.length > 0;/,- );- assert.match(composer, /\$\{approvalPauses\.length \? composerApprovalPanel\(approvalPauses\) : nothing\}/);- assert.match(composer, /\$\{\s*blockingPauses\.length\s*\?\s*nothing\s*:\s*html`\s*<textarea/);-});--test("a send swallowed by a pending approval is restored to the composer with the reason", () => {- assert.match(- composer,- /await agent\.prompt\(userSendMessage\(text, attachments\.length \? attachments : undefined\)\);\s*restoreBlockedSend\(agent, sentFromThread, text, attachments\);/,- );- const restore = composer.slice(- composer.indexOf("function restoreBlockedSend"),- composer.indexOf("const LARGE_PASTE_CHARS"),- );- assert.match(restore, /last\.sendBlocked !== "pending_approval"\) return;/);- assert.match(restore, /\(agent\.state as \{ errorMessage\?: string \}\)\.errorMessage = undefined;/);- assert.match(- restore,- /composerState\.draft = !typedSince \|\| typedSince === text \? text : `\$\{text\}\\n\$\{composerState\.draft\}`;/,- );- assert.match(- restore,- /const \{ kept, note \} = mergeStagedAttachments\(attachments, composerState\.attachments\);/,- "restored files merge under the cap instead of overwriting concurrent edits",- );- assert.match(restore, /composerState\.error = combineNote\(last\.errorMessage \|\| PENDING_APPROVAL_REASON, note\);/);- assert.match(restore, /persistDraft\(\);/);-});--test("a blocked send whose tab moved on still keeps the text as the origin thread's draft", () => {- const restore = composer.slice(- composer.indexOf("function restoreBlockedSend"),- composer.indexOf("const LARGE_PASTE_CHARS"),- );- assert.match(- restore,- /if \(agent !== ctx\.chat\.state\.agent\) \{\s*if \(sentFromThread\) saveDraft\(sentFromThread, text\);\s*return;\s*\}/,- );-});diff --git a/plugins/web-ui/test/attachment-limits.test.ts b/plugins/web-ui/test/attachment-limits.test.tsindex 290948551..2e15cacfb 100644--- a/plugins/web-ui/test/attachment-limits.test.ts+++ b/plugins/web-ui/test/attachment-limits.test.ts@@ -1,10 +1,8 @@import { test, afterEach } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import {createRunSlot,MAX_ATTACHMENT_BYTES,- MAX_FILES_PER_MESSAGE,oversizeAttachmentNote,requestStop,uploadAttachments,@@ -29,15 +27,6 @@ function attachment(return { id: `id-${name}`, type: "document", fileName: name, mimeType: "text/plain", size, content: "aGV5" };}-test("the client limits mirror core's MAX_BLOB_BYTES and MAX_INBOUND_FILES", () => {- const blobTransfer = readFileSync(new URL("../../../src/persistence/blob-transfer.ts", import.meta.url), "utf8");- assert.match(blobTransfer, /export const MAX_BLOB_BYTES = 1_000_000_000;/);- assert.equal(MAX_ATTACHMENT_BYTES, 1_000_000_000);- const attachments = readFileSync(new URL("../../../src/core/attachments.ts", import.meta.url), "utf8");- assert.match(attachments, /export const MAX_INBOUND_FILES = 10;/);- assert.equal(MAX_FILES_PER_MESSAGE, 10);-});-test("an oversize attachment is skipped before any bytes go out", async () => {let fetched = 0;globalThis.fetch = (() => {@@ -95,72 +84,6 @@ test("requestStop targets the current submit generation, not a fixed flag", () =assert.equal(slot.stopGeneration, slot.generation, "a Stop names the generation live at the moment it is pressed");});-const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");-const bridge = readFileSync(new URL("../src/core-bridge.ts", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");--test("the composer pre-checks size and count before reading files into memory", () => {- const fn = composer.slice(composer.indexOf("function planAdmission"), composer.indexOf("async function addFiles"));- assert.match(fn, /file\.size > MAX_ATTACHMENT_BYTES/, "oversize files never reach loadAnyAttachment");- assert.match(fn, /MAX_FILES_PER_MESSAGE - composerState\.attachments\.length/, "the cap counts already-staged chips");- assert.match(fn, /tooManyFilesNote\(overflow\)/, "skips are named, not silent");- assert.match(- composer,- /const plan = planAdmission\(files, folders\.length\);/,- "drops, picks, and folders all pass the same gate before any bytes are read",- );- assert.match(- composer,- /for \(const folder of folders\.slice\(0, plan\.folders\)\) zipped\.push\(await folderToZipFile\(folder\)\);/,- "folders past the cap are never zipped into memory",- );-});--test("a send whose attachments all failed does not go out as an empty turn", () => {- const fn = bridge.slice(bridge.indexOf("async function drive("), bridge.indexOf("async function resumeDrive"));- assert.match(fn, /if \(!opener && !text\.trim\(\) && attachments\.length === 0\)/);- assert.match(fn, /issues\.join\(" "\) \|\| "Nothing to send\."/);- assert.match(- fn,- /if \(issues\.length\) onSendIssues\?\.\(issues, retryable\);/,- "partial skips surface as a composer note",- );-});--test("skipped files drop off the sent message's chips so the view matches what core got", () => {- const fn = bridge.slice(bridge.indexOf("async function latestUserTurn"), bridge.indexOf("function attachmentBytes"));- assert.match(fn, /m\.attachments = m\.attachments\.filter\(\(a\) => !a\.id \|\| !skippedIds\.has\(a\.id\)\);/);-});--test("queued turns carry the staged attachments; attachment-only queues are real sends", () => {- const fn = composer.slice(- composer.indexOf("async function queueDraft"),- composer.indexOf("async function enqueueTurn"),- );- assert.match(fn, /const staged = composerState\.attachments;/);- assert.match(fn, /if \(\(!text && !staged\.length\) \|\| !threadRef\) return;/);- assert.match(fn, /await uploadAttachments\(staged\)/);- assert.match(fn, /enqueueTurn\(agent, threadRef, text, uploaded, queuedFilesKey\(sendable\)\)/);- assert.match(bridge, /attachments: CoreAttachment\[\] = \[\],\n\): Promise<QueuedRun>/);-});--test("Stop pressed before the run id arrives still stops core's run", () => {- assert.match(chat, /requestStop\(runSlot\);/);- assert.match(composer, /void ctx\.chat\.stopLiveRun\(\)\.catch/);- const followRun = bridge.slice(bridge.indexOf("async function followRun"), bridge.indexOf("function runPath"));- assert.match(followRun, /if \(slot && slot\.stopGeneration === gen\) \{/);- assert.match(followRun, /void signalLiveRun\(slot, "abort", undefined, \{ threadRef: null \}\)/);- assert.match(followRun, /notify\?\.\(\);/);-});--test("confirmed aborted output is preserved during transcript refresh", () => {- assert.match(- chat,- /if \(last\?\.stopReason === "error" && !last\.interruptedRunId\) return drawActiveChat\(agent\);/,- );- assert.match(chat, /if \(last\?\.stopReason === "aborted"\) return drawActiveChat\(agent\);/);-});-test("an empty attachment is reported and left out rather than silently dropped", async () => {const { uploaded, skipped } = await uploadAttachments([{ id: "e1", type: "document", fileName: "empty.txt", mimeType: "text/plain", size: 0, content: "" },diff --git a/plugins/web-ui/test/branding.test.ts b/plugins/web-ui/test/branding.test.tsindex b116d438b..6ac540a2a 100644--- a/plugins/web-ui/test/branding.test.ts+++ b/plugins/web-ui/test/branding.test.ts@@ -1,6 +1,6 @@import { test } from "node:test";import assert from "node:assert/strict";-import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, writeFileSync } from "node:fs";import { fileURLToPath } from "node:url";import { dirname, join } from "node:path";import { createServer, type IncomingMessage } from "node:http";@@ -54,11 +54,6 @@ test("cold start: the FIRST shell render already carries accent, mark, and self-);});-test("the vite template carries the self-label anchor the server injects into", () => {- const template = readFileSync(new URL("../index.html", import.meta.url), "utf8");- assert.match(template, /<meta name="brand-self-label" content="QM"\s*\/?>/);-});-test("injectBranding rewrites the tab title with the escaped label when a suffix is given", async () => {const { injectBranding } = await import("../../chassis/src/branding.ts");const shell =@@ -112,11 +107,6 @@ test("brandName() reads the injected self-label and falls back to the product na});test("the installable-app metadata follows the brand: manifest link, touch icon, home-screen title", async () => {- const template = readFileSync(new URL("../index.html", import.meta.url), "utf8");- assert.match(template, /<link rel="manifest" href="%BASE_URL%manifest\.webmanifest"\s*\/?>/);- assert.match(template, /<link rel="apple-touch-icon" href="%BASE_URL%brand-mark\.svg"\s*\/?>/);- assert.match(template, /<meta name="apple-mobile-web-app-title" content="QM"\s*\/?>/);- assert.match(template, /viewport-fit=cover, interactive-widget=resizes-content/);const { injectBranding } = await import("../../chassis/src/branding.ts");const shell ='<html><head><meta name="brand-self-label" content="QM" /><meta name="apple-mobile-web-app-title" content="QM" /></head></html>';diff --git a/plugins/web-ui/test/browse-grid.test.ts b/plugins/web-ui/test/browse-grid.test.tsindex 53ccf695f..8c8b30fcf 100644--- a/plugins/web-ui/test/browse-grid.test.ts+++ b/plugins/web-ui/test/browse-grid.test.ts@@ -1,6 +1,5 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { nextGridIndex } from "../src/grid-nav.ts";const COLUMNS = 2;@@ -30,22 +29,3 @@ test("an odd row count keeps the last row reachable and never overshoots it", ()assert.equal(nextGridIndex(4, "ArrowDown", 7, COLUMNS), 6);assert.equal(nextGridIndex(6, "ArrowRight", 7, COLUMNS), null);});--const browse = readFileSync(new URL("../src/browse.ts", import.meta.url), "utf8");--test("the browse palette is a 2-column grid over every destination, escape-dismissable", () => {- assert.match(browse, /const BROWSE_COLUMNS = 2;/);- assert.match(- readFileSync(new URL("../src/shell.css", import.meta.url), "utf8"),- /\.browse-grid \{[^}]*grid-template-columns: repeat\(2, minmax\(0, 1fr\)\);/,- );- assert.match(browse, /e\.key === "Escape"[\s\S]{0,80}closeBrowse\(\)/);- for (const label of ["Projects", "Files", "Crons", "Keychain", "Apps", "Memory", "Skills", "Admin"]) {- assert.match(browse, new RegExp(`"${label}"`));- }-});--test("every tile is a real link, so middle-click and open-in-new-tab still work", () => {- assert.match(browse, /<a\s+class="browse-tile[\s\S]{0,400}href=\$\{d\.href\}/);- assert.match(browse, /if \(!isPlainLeftClick\(e\)\) return;/);-});diff --git a/plugins/web-ui/test/calendar-view.test.ts b/plugins/web-ui/test/calendar-view.test.tsindex 71fd1399f..b5ebfbafa 100644--- a/plugins/web-ui/test/calendar-view.test.ts+++ b/plugins/web-ui/test/calendar-view.test.ts@@ -1,28 +1,8 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { deepLinkPath, parseDeepLink } from "../src/deep-link.ts";import { documentTitle, PRODUCT_TITLE } from "../src/document-title.ts";-const calendar = readFileSync(new URL("../src/calendar.ts", import.meta.url), "utf8");-const shell = readFileSync(new URL("../src/shell.ts", import.meta.url), "utf8");-const shellState = readFileSync(new URL("../src/shell-state.ts", import.meta.url), "utf8");--test("calendar is a first-class empty view directly below Inbox", () => {- assert.match(shellState, /"chats",\s*"inbox",\s*"calendar",\s*"contexts"/);- assert.match(shell, /inboxNavRow\(\).*navRow\("calendar", ICON\.calendar, "Calendar"\)/s);- assert.match(shell, /case "calendar":\s*renderCalendar\(\);/);- assert.match(calendar, /host\.className = "pane content-wide-page"/);- assert.match(calendar, /<div class="pane-head">/);- assert.match(calendar, /<h1 class="pane-title">Calendar<\/h1>/);- assert.match(calendar, /Coming soon\./);-});--test("calendar reuses the Inbox permission gate", () => {- assert.match(shell, /can\("inbox"\) \? html`\$\{inboxNavRow\(\)\} \$\{navRow\("calendar"/);- assert.match(shellState, /if \(view === "inbox" \|\| view === "calendar"\) return can\("inbox"\);/);-});-test("calendar has a stable route and document title", () => {assert.equal(deepLinkPath("", "calendar", null), "/calendar");assert.deepEqual(parseDeepLink("", "/calendar", ""), { view: "calendar", session: null, item: null });diff --git a/plugins/web-ui/test/composer-stopping.test.ts b/plugins/web-ui/test/composer-stopping.test.tsindex 1bd9c7ff8..fbbd81997 100644--- a/plugins/web-ui/test/composer-stopping.test.ts+++ b/plugins/web-ui/test/composer-stopping.test.ts@@ -1,6 +1,5 @@import assert from "node:assert/strict";import test from "node:test";-import { readFileSync } from "node:fs";import type { Agent } from "@earendil-works/pi-agent-core";import { JSDOM } from "jsdom";import { createServer } from "vite";@@ -216,8 +215,3 @@ test("stopping returns Send immediately and queues every submit path without int}}});--test("disabled Stop shares Send's muted styling", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- assert.match(css, /\.send-btn:disabled,\s*\.stop-btn:disabled\s*\{[^}]*opacity: 0\.35;[^}]*cursor: not-allowed;/);-});diff --git a/plugins/web-ui/test/copy-button-lit.test.ts b/plugins/web-ui/test/copy-button-lit.test.tsindex 1ea274d1d..6a4afcb20 100644--- a/plugins/web-ui/test/copy-button-lit.test.ts+++ b/plugins/web-ui/test/copy-button-lit.test.ts@@ -1,5 +1,4 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test, { type TestContext } from "node:test";import { JSDOM } from "jsdom";import type { TemplateResult } from "lit";@@ -20,7 +19,6 @@ for (const [key, value] of Object.entries(globals))const { html, render } = await import("lit");const { Check, Copy } = await import("lucide");const { copyText, icon } = await import("../src/ui.ts");-const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");const copy = (event: Event) => void copyText("hello", event.currentTarget as HTMLButtonElement);const flush = () => new Promise((resolve) => setImmediate(resolve));@@ -56,12 +54,3 @@ test("copying from a labelled button survives the next lit render", async (t) =>assert.equal(button.querySelectorAll("svg").length, 1);assert.equal(button.querySelector("span")?.textContent, "Copy URL");});--test("the copied state is drawn by CSS instead of rewriting button children", () => {- assert.match(- css,- /\.msg-copy\.copied > svg:first-of-type,\s*\.msg-copy:not\(\.copied\) > svg:nth-of-type\(2\) \{\s*display: none;/,- );- assert.match(css, /\.btn\.copied > \* \{\s*display: none;/);- assert.match(css, /\.btn\.copied::after \{\s*content: "Copied";/);-});diff --git a/plugins/web-ui/test/deploys-source.test.ts b/plugins/web-ui/test/deploys-source.test.tsindex e8e8029c1..4813ef08e 100644--- a/plugins/web-ui/test/deploys-source.test.ts+++ b/plugins/web-ui/test/deploys-source.test.ts@@ -13,7 +13,6 @@ import {import { deepLinkPath } from "../src/deep-link.ts";const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");-const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");function bodyOf(name: string): string {const start = source.indexOf(`function ${name}(`);@@ -22,91 +21,6 @@ function bodyOf(name: string): string {return source.slice(start, next < 0 ? source.length : next);}-test("app index rows launch live apps by default and use Manage for app details", () => {- const row = bodyOf("deploymentRow");- const title = row.slice(row.indexOf("const title"), row.indexOf("return html`"));- assert.doesNotMatch(- row,- /deploy-row-url|deploy-row-meta|ownerLabel|permissionBadge|versionLabel|deployedLabel|Copy app URL/,- );- assert.match(row, /deploymentTitle\(d\)/);- assert.match(row, /statusLabel\(d\)/);- assert.match(row, /running && d\.webUrl/);- assert.match(row, /href=\$\{withBase\(d\.webUrl\)\}/);- assert.match(row, /target="_blank"/);- assert.match(row, /class="deploy-row-actions"[\s\S]*class="deploy-status/);- assert.doesNotMatch(title, /deploy-status/);- assert.match(row, /class="btn deploy-manage"[\s\S]*@click=\$\{\(\) => void openDeploy\(d\)\}/);- assert.doesNotMatch(row, /deploy-menu|More actions/);- assert.doesNotMatch(row, />Open \$\{icon\(ExternalLink/);- assert.match(css, /\.deploy-row-main\[href\]::after \{\s*position: absolute;\s*inset: 0;/);- assert.match(css, /\.deploy-row-actions \{\s*position: relative;\s*z-index: 1;/);-});--test("app index header keeps search and tabs without secondary controls", () => {- const draw = bodyOf("drawDeploysPage");- assert.doesNotMatch(draw, /onScope:|action:|controls:|deploySort|Deploy with Agent/);- assert.match(draw, /placeholder: "Search apps"/);- assert.match(draw, /deployTabs\(\)/);-});--test("the global Apps route clears a scope inherited from an earlier scoped visit", () => {- assert.match(source, /else \{\s*deployScope = null;\s*\}/);-});--test("app index content uses the shared centered layout", () => {- assert.doesNotMatch(- css,- /\.deploys-page \.list-page-head,\s*\.deploys-page \.list-search,\s*\.deploys-page \.list-rows \{\s*margin-right: 0;\s*margin-left: 0;/,- );- assert.match(- css,- /\.deploy-row-main \{\s*min-width: 0;\s*display: flex;\s*flex-direction: row;\s*align-items: center;\s*justify-content: flex-start;/,- );-});--test("Deploys consumes and clears context deep-link handoff state", () => {- assert.match(source, /deployScope = contextsState\.selected;\s+contextsState\.selected = null;/);-});--test("Deploys clears archive overlay state when the view is entered", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /archiveCandidate = null;\s+restoreArchiveFocus = false;\s+setDeployBackgroundInert\(false\);/);- assert.match(source, /appState\.currentView !== "deploys" \|\| archiveCandidate\?\.id !== d\.id/);-});--test("archive focus restoration yields to a newly opened dialog", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /restoreArchiveFocus = false;\s+drawCurrentDeployView\(\);/);- assert.match(source, /appState\.currentView !== "deploys" \|\| archiveCandidate/);-});--test("archive confirmation synchronously makes background actions inert", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /archiveCandidate = d;\s+drawCurrentDeployView\(\);\s+setDeployBackgroundInert\(true\);/);- assert.match(source, /\.deploy-detail, \.deploy-toast/);-});--test("deployment mutations re-check their target after asynchronous work", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /const restoringActive = activeDeploy\?\.id === d\.id;/);- assert.match(source, /function currentDeployActionView\(targetId: string\)/);- assert.equal(source.match(/currentDeployActionView\(d\.id\)/g)?.length, 6);-});--test("a restored deployment replaces its stale archived list row when refresh fails", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /deployList = deploymentListAfterRestoreRefresh\(deployList, restored, refreshResult\);/);- assert.match(source, /return "superseded";/);-});--test("list refreshes cannot clear detail-scoped errors", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /deployNotices\.detail\?\.id === d\.id/);- assert.match(source, /deployNotices = withDeploymentListNotice\(deployNotices, ""\);/);- assert.doesNotMatch(source, /deployDetailNotice|deployListNotice/);-});-function renderHarness(requestedId: string | null = null) {const requests: Array<{ path: string; resolve: (response: unknown) => void }> = [];const frames: Array<{ view: "list" | "detail"; id?: string; loading?: boolean }> = [];@@ -213,14 +127,6 @@ for (const supersede of ["view", "render"] as const) {});}-test("the empty Yours tab does not imply the account has no deployments", () => {- const source = readFileSync(new URL("../src/deploys.ts", import.meta.url), "utf8");- assert.match(source, /deploymentTabEmptyMessage\(deployTab\)/);- assert.doesNotMatch(source, /No deployments yet\./);- const messages = readFileSync(new URL("../src/deploy-view.ts", import.meta.url), "utf8");- assert.doesNotMatch(messages, /You have no apps\./);-});-for (const count of [0, 7, 23, 150]) {test(`version history reveals ${count} versions in newest-first batches of ten`, () => {const deployment = {diff --git a/plugins/web-ui/test/document-title.test.ts b/plugins/web-ui/test/document-title.test.tsindex a74bece14..5daff7cec 100644--- a/plugins/web-ui/test/document-title.test.ts+++ b/plugins/web-ui/test/document-title.test.ts@@ -1,14 +1,10 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { JSDOM } from "jsdom";import { createServer } from "vite";import { activeSessionForDocumentTitle, documentTitle, PRODUCT_TITLE } from "../src/document-title.ts";-const index = readFileSync(new URL("../index.html", import.meta.url), "utf8");-test("page titles retain the static product title", () => {- assert.ok(index.includes(`<title>${PRODUCT_TITLE}</title>`));assert.equal(documentTitle("chats", "Quarterly planning", true), `Quarterly planning · ${PRODUCT_TITLE}`);assert.equal(documentTitle(), PRODUCT_TITLE);});diff --git a/plugins/web-ui/test/keychain-flow.test.ts b/plugins/web-ui/test/keychain-flow.test.tsindex a02b9b259..8c8a2803c 100644--- a/plugins/web-ui/test/keychain-flow.test.ts+++ b/plugins/web-ui/test/keychain-flow.test.ts@@ -1,12 +1,7 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { isActiveGrant, isExpiredCredential, KeychainOperations, keychainSummary } from "../src/keychain-state.ts";-const connectorsSource = readFileSync(new URL("../src/connectors.ts", import.meta.url), "utf8");-const shellSource = readFileSync(new URL("../src/shell.ts", import.meta.url), "utf8");-const shellCssSource = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");-test("reset invalidates identity-bound loads and operations", () => {const operations = new KeychainOperations();const load = operations.beginLoad();@@ -24,7 +19,6 @@ test("reset invalidates identity-bound loads and operations", () => {assert.equal(operations.beginMutation(), null);operations.finishMutation(currentMutation);assert.ok(operations.beginMutation());- assert.match(shellSource, /resetKeychainState\(\);\s*appState\.me =/);});test("a reversed keychain load cannot overwrite the latest response", async () => {@@ -51,7 +45,6 @@ test("a reversed keychain load cannot overwrite the latest response", async () =await older;assert.equal(value, "latest");- assert.match(connectorsSource, /keychainOperations\.isCurrentLoad\(load\)/);});test("identity reset invalidates a pending connector start", async () => {@@ -72,10 +65,6 @@ test("identity reset invalidates a pending connector start", async () => {await continuation;assert.equal(navigated, false);- assert.match(- connectorsSource,- /const stateEpoch = keychainOperations\.captureEpoch\(\);[\s\S]*api<\{ authorizeUrl\?: string \}>[\s\S]*isCurrentEpoch\(stateEpoch\)/,- );});test("destructive mutations and secure drops are single-flight", () => {@@ -128,77 +117,6 @@ test("keychain summary excludes expired grants and counts pending asks", () => {assert.deepEqual(summary, { connected: 1, activeGrants: 3, attention: 3 });});-test("keychain overview wires managed connector grants into account controls", () => {- assert.match(connectorsSource, /connectorCredentials\?: KeychainConnectorCredential\[\]/);- assert.match(- connectorsSource,- /keychainConnectorCredentials\.filter\(\(credential\) => hosts\.has\(credential\.host\)\)/,- );- assert.match(connectorsSource, /isActiveGrant\(grant, credentialsById\.get\(grant\.credentialId\)\)/);- assert.match(connectorsSource, /isExpiredCredential\(c\)/);-});--test("destructive controls settle duplicate attempts while a mutation is busy", () => {- assert.match(connectorsSource, /\?disabled=\$\{keychainOperations\.mutationInFlight\}/);- assert.match(connectorsSource, /connectorNotice = "Another keychain change is still in progress\."/);- assert.equal(connectorsSource.match(/const operation = beginKeychainMutation\(\)/g)?.length, 3);- assert.equal(- connectorsSource.match(/if \(keychainOperations\.finishMutation\(operation\)\) drawConnectors\(\)/g)?.length,- 3,- );-});--test("keychain rows reserve success badges for actionable states", () => {- assert.doesNotMatch(connectorsSource, /Stored securely/);- assert.doesNotMatch(connectorsSource, />Connected<\/span>/);- assert.match(connectorsSource, /expired \? html`<span class="kc-state warning">Expired<\/span>` : ""/);- assert.match(connectorsSource, /<span class="kc-state warning">Reconnect needed<\/span>/);-});--test("keychain index keeps operational state and removes redundant explanatory copy", () => {- assert.doesNotMatch(connectorsSource, /Accounts and credentials your agent may use on your behalf/);- assert.doesNotMatch(connectorsSource, /Provider APIs the agent can use as you/);- assert.doesNotMatch(connectorsSource, /API keys, tokens, and files you added/);- assert.doesNotMatch(connectorsSource, /kc-summary|kc-resource-description|No audited use yet|Last used |Added \$\{/);- assert.match(connectorsSource, /class="kc-access-label">Access/);- assert.match(connectorsSource, /expires \$\{fmtDate\(/);- assert.match(connectorsSource, />\s*Revoke\s*</);- assert.match(connectorsSource, /encrypted one-time page next/);-});--test("keychain access rows retain security-relevant mode and purpose", () => {- assert.match(connectorsSource, /accessModeLabel\(ask\.requestedMode\)/);- assert.match(connectorsSource, /ask\.purpose/);- assert.equal(connectorsSource.match(/accessModeLabel\(grant\.mode\)/g)?.length, 2);- assert.equal(connectorsSource.match(/grant\.purpose/g)?.length, 2);-});--test("keychain actions keep secondary weight and compact mobile sizing", () => {- assert.match(connectorsSource, /\$\{available \? html`<button class="btn" type="button"/);- assert.doesNotMatch(shellCssSource, /\.kc-hero-actions \.btn\s*\{\s*flex:\s*1;/);- assert.doesNotMatch(shellCssSource, /sidebar-closed \.kc-hero-copy/);-});--test("keychain page renders loading placeholders instead of empty states while loading", () => {- assert.match(connectorsSource, /let connectorsLoading = false/);- assert.match(connectorsSource, /let keysLoading = false/);- assert.match(connectorsSource, /connectorsLoading && !connectorsEverLoaded/);- assert.match(connectorsSource, /keysLoading && !keysEverLoaded/);- assert.match(connectorsSource, /keysLoading = true;\s*\n\s*drawConnectors\(\)/);- assert.match(connectorsSource, /if \(accountsLoading\) accountsContent = loadingPlaceholder\("Loading accounts/);- assert.match(- connectorsSource,- /if \(keysLoadingFresh\) credentialsContent = loadingPlaceholder\("Loading credentials/,- );-- assert.match(- connectorsSource,- /api<\{ providers\?: Record<string, ConnectorProvider> \}>\("\/api\/connectors"\)\.then\(/,- );- assert.doesNotMatch(connectorsSource, /drawConnectors\((true|false)\)/);- assert.match(shellCssSource, /\.kc-loading \.spinner/);-});-test("an inline credential card decides through the keychain approval route, not the command route", async () => {const calls: Array<{ url: string; body: unknown }> = [];const realFetch = globalThis.fetch;diff --git a/plugins/web-ui/test/lazy-libs.test.ts b/plugins/web-ui/test/lazy-libs.test.tsindex db8004c71..15ed57c61 100644--- a/plugins/web-ui/test/lazy-libs.test.ts+++ b/plugins/web-ui/test/lazy-libs.test.ts@@ -1,5 +1,4 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import katexFacade from "../src/lazy-katex.ts";import hljsFacade from "../src/lazy-hljs.ts";@@ -25,23 +24,3 @@ test("hljs facade reports no language pre-load, so code-block takes the auto pattest("stub grammar registration is a safe no-op", () => {assert.doesNotThrow(() => hljsFacade.registerLanguage("javascript", () => ({})));});--const vite = readFileSync(new URL("../vite.config.ts", import.meta.url), "utf8");--test("vite aliases route katex and highlight.js through the lazy facades", () => {- assert.match(vite, /find: \/\^katex\$\/, replacement: here\("src\/lazy-katex\.ts"\)/);- assert.match(vite, /find: \/\^highlight\\\.js\\\/lib\\\/core\$\/, replacement: here\("src\/lazy-hljs\.ts"\)/);- assert.match(- vite,- /find: \/\^highlight\\\.js\\\/lib\\\/languages\\\/\.\*\$\/, replacement: here\("src\/hljs-lang-stub\.ts"\)/,- );- const langOrder = ["javascript", "typescript", "python", "xml", "css", "json", "bash", "sql", "markdown"];- for (const lang of langOrder) {- assert.ok(vite.includes(`hljs-real-${lang}`), `real grammar alias for ${lang}`);- }-});--test("the real-library aliases point INTO the packages, never back at the facades", () => {- assert.match(vite, /find: "katex-real", replacement: here\("node_modules\/katex\/dist\/katex\.mjs"\)/);- assert.match(vite, /find: "hljs-real", replacement: here\("node_modules\/highlight\.js\/lib\/core\.js"\)/);-});diff --git a/plugins/web-ui/test/linkify.test.ts b/plugins/web-ui/test/linkify.test.tsindex 931b7c473..602c20402 100644--- a/plugins/web-ui/test/linkify.test.ts+++ b/plugins/web-ui/test/linkify.test.ts@@ -1,6 +1,5 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { splitLinks, splitMentions } from "../src/linkify.ts";test("plain text stays a single text segment", () => {@@ -78,38 +77,3 @@ test("several mentions each become their own segment", () => {test("a lone @ is left as text", () => {assert.deepEqual(splitMentions("meet @ 3pm"), [{ kind: "text", text: "meet @ 3pm" }]);});--const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");--test("expanded pinned items render text and preview through the linkifier", () => {- assert.match(- chat,- /pinned-item-text">\$\{linkifiedText\(p\.text \?\? p\.preview \?\? `entry #\$\{p\.entrySeq\}`\)\}/,- );- assert.match(chat, /pinned-item-preview">\$\{linkifiedText\(p\.preview\)\}/);-});--test("pinned links open in a new tab without an opener", () => {- assert.match(chat, /target="_blank"\s+rel="noreferrer noopener"/);-});--test("the collapsed peek is linkified and lives outside the toggle button", () => {- assert.match(chat, /pinned-strip-peek"\s*>\$\{linkifiedText\(first\.text \?\? first\.preview/);- assert.match(chat, /<div class="pinned-strip-head" @click=\$\{togglePins\}>/);- assert.match(chat, /class="pinned-strip-toggle"/);-});--test("clicking a pin link follows the link instead of toggling the strip", () => {- assert.match(- chat,- /function togglePins\(e: Event\): void \{\s*if \(\(e\.target as Element \| null\)\?\.closest\("a"\)\) return;/,- );-});--const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");--test("pinned strip links are styled as links (colored + underlined)", () => {- const rule = css.match(/\.pinned-strip a \{[^}]*\}/)?.[0] ?? "";- assert.match(rule, /color: var\(--primary\)/);- assert.match(rule, /text-decoration: underline/);-});diff --git a/plugins/web-ui/test/model-options.test.ts b/plugins/web-ui/test/model-options.test.tsindex ecd502c04..bad2bf93b 100644--- a/plugins/web-ui/test/model-options.test.ts+++ b/plugins/web-ui/test/model-options.test.ts@@ -1,7 +1,6 @@import { applyRuntimeOptions } from "./runtime-fixture.ts";import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import {defaultModelValue,getModelOptions,@@ -73,13 +72,6 @@ test("OpenRouter and custom provider metadata retains provider grouping", async);});-test("picker has no model IDs, clone templates or runtime SDK model registry imports", async () => {- const source = ["pi-models.ts", "model-options.ts"]- .map((file) => readFileSync(new URL(`../src/${file}`, import.meta.url), "utf8"))- .join("\n");- assert.doesNotMatch(source, /MODEL_CATALOG|CLONE_TEMPLATES|gpt-5|claude-opus|openrouter\/auto|import \{ getModel/);-});-test("harness controls retain their supported surfaces", async () => {assert.equal(harnessSupportsEffort("pi"), true);assert.equal(harnessSupportsEffort("opencode"), false);diff --git a/plugins/web-ui/test/open-to-new-chat.test.ts b/plugins/web-ui/test/open-to-new-chat.test.tsindex cc5785922..749cb367a 100644--- a/plugins/web-ui/test/open-to-new-chat.test.ts+++ b/plugins/web-ui/test/open-to-new-chat.test.ts@@ -1,34 +1,6 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";-const read = (f: string): string => readFileSync(new URL(`../src/${f}`, import.meta.url), "utf8");--test("opening the app restores the last session unless the person opted into a new chat", () => {- const shell = read("shell.ts");- const boot = shell.slice(shell.indexOf("const remoteSplitFetch = fetchRemoteSplit();"));- assert.match(boot, /const restoreLast = viewIntent \|\| !\(await openNewChatFetch\);/);- assert.match(boot, /if \(restoreLast\) loadPersistedSplit\(\);/, "the saved layout is only adopted when restoring");- assert.match(- boot,- /if \(restoreLast && bareEntry && !restoredCanvasNeedsSessionList\(\)\) mountRestoredCanvas\(true\);/,- );- assert.match(- boot,- /\} else if \(!\(restoreLast && mountRestoredCanvas\(\)\) && !mainConversation\(\)\.state\.threadRef\) \{\s*mainConversation\(\)\.newChat\(\);/,- );- assert.doesNotMatch(boot, /^ {2}loadPersistedSplit\(\);$/m, "no unconditional layout restore on open");-});--test("the open setting is stored per user and defaults to the last session", () => {- const settings = read("settings.ts");- assert.match(settings, /openNewChat = rec\.value === true;/);- assert.match(settings, /putUiState\(OPEN_NEW_CHAT_KEY/);- assert.doesNotMatch(settings, /localStorage\.\w+\(OPEN_NEW_CHAT_KEY/);- assert.match(settings, /\$\{openBehaviorRow\(\)\}/);- assert.match(settings, /\{ newChat: false, label: "Last session" \}/);-});-test("opting into a new chat skips the saved multiview layout on a bare visit", async () => {const { harness } = await import("./deep-link-boot-fixture.ts");const h = await harness({ path: "/", savedCanvas: true, openNewChat: true });diff --git a/plugins/web-ui/test/pane-composer-source.test.ts b/plugins/web-ui/test/pane-composer-source.test.tsdeleted file mode 100644index bee028ceb..000000000--- a/plugins/web-ui/test/pane-composer-source.test.ts+++ /dev/null@@ -1,136 +0,0 @@-import assert from "node:assert/strict";-import { readFileSync } from "node:fs";-import test from "node:test";-import { JSDOM } from "jsdom";--const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");-const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");--test("single-pane composers default to the full-width input above a separate toolbar", () => {- assert.doesNotMatch(css, /\.embed-layout/, "panes are elements now, not framed documents");- const wrap = css.match(/^\.composer-wrap \{[^}]*\}/m)?.[0] ?? "";- assert.doesNotMatch(wrap, /display: flex;/);- assert.match(css, /^\.composer-input \{[^}]*width: 100%;[^}]*min-height: 48px;/m);- assert.match(css, /^\.composer-toolbar \{[^}]*display: flex;[^}]*justify-content: space-between;/m);- assert.doesNotMatch(css, /\[data-density[^\]]*\] \.composer-(?:wrap|input|toolbar)\s*\{/);- assert.match(composer, /Math\.max\(ctx\.pane \? 0 : 48, content\)/);-});--test("a multipane composer fills the surface with square edges and no outer gutter", () => {- const block =- css.match(- /\.split-canvas:not\(\.single-pane\) \.split-pane-chat \.custom-chat-shell \.composer-wrap \{[^}]*\}/,- )?.[0] ?? "";- assert.match(block, /width: 100%;/);- assert.match(block, /margin: 0;/);- assert.match(block, /border-radius: 0;/);- assert.match(block, /box-shadow: none;/);-});--test("phone touch layout cannot inflate a pane's composer controls", () => {- assert.match(- css,- /\[data-density\] \.composer-toolbar \.icon-btn,\s*\[data-density\] \.composer-toolbar \.menu-button,\s*\[data-density\] \.composer-toolbar \.send-btn \{\s*width: 34px;\s*height: 34px;\s*min-height: 34px;/,- );- assert.doesNotMatch(css, /\[data-density[^\]]*\] \.composer-(?:left|right)[^{]*\{/);-});--test("pane settings control is visible without hover", () => {- assert.doesNotMatch(css, /\.composer-wrap:hover \.settings-control/);- const block = css.match(/\.settings-control \.menu-button \{[^}]*\}/)?.[0] ?? "";- assert.doesNotMatch(block, /opacity: 0;/);-});--test("multiview composers use one row regardless of pane dimensions and reset in single view", () => {- assert.doesNotMatch(css, /@container split-pane \(max-height: 480px\) or \(max-width: 560px\)/);- const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)]- .filter(([, selector]) => selector.includes(".split-canvas:not(.single-pane) .composer-wrap"))- .map(([rule]) => rule)- .join("\n");- const dom = new JSDOM(`<style>${rules}</style><div class="split-canvas">- <div class="split-pane-content" style="width: 1050px; height: 510px">- <form class="composer-wrap">- <div class="attachment-strip"></div>- <textarea class="composer-input"></textarea>- <div class="composer-toolbar"></div>- </form>- </div>- </div>`);- const canvas = dom.window.document.querySelector(".split-canvas")!;- const style = (selector: string) => dom.window.getComputedStyle(canvas.querySelector(selector)!);- assert.equal(style(".composer-wrap").display, "grid");- assert.equal(style(".composer-wrap").gridTemplateColumns, "minmax(0, 1fr) auto");- assert.equal(style(".attachment-strip").gridColumn, "1 / -1");- assert.equal(style(".composer-input").gridColumn, "1");- assert.equal(style(".composer-toolbar").gridColumn, "2");- assert.equal(style(".composer-input").minHeight, "34px");- assert.equal(style(".composer-input").maxHeight, "120px");- canvas.classList.add("single-pane");- assert.notEqual(style(".composer-wrap").display, "grid");- assert.notEqual(style(".composer-input").gridColumn, "1");- assert.notEqual(style(".composer-toolbar").gridColumn, "2");- dom.window.close();-});--test("narrow panes hide runtime labels, not the accessible picker", () => {- const narrow = css.slice(css.indexOf("@container split-pane (max-width: 470px)"));- assert.match(narrow, /\.loadout-button \.menu-label,/);- assert.match(narrow, /\.loadout-button \.menu-suffix \{\s*display: none;/);- assert.match(narrow, /\.loadout-button \{[^}]*width: 34px;/);- assert.doesNotMatch(narrow, /\.loadout-(?:button|control) \{[^}]*display: none;/);- assert.match(- readFileSync(new URL("../src/model-picker.ts", import.meta.url), "utf8"),- /aria-label=\$\{choice \? `Model:/,- );-});--test("the smallest panes leave text space even with stop controls", () => {- const minimum = css.slice(css.indexOf("@container split-pane (max-width: 300px)"));- assert.match(minimum, /\.composer-toolbar \.stop-btn \{\s*width: 28px;\s*height: 28px;\s*min-height: 28px;/);- assert.match(minimum, /\.composer-attach \{\s*transform: none;/);-});--test("compact overrides stop matching when the canvas returns to one pane", () => {- const dom = new JSDOM(`<div class="split-canvas single-pane">- <div class="split-pane-chat">- <div class="custom-chat-shell in-pane empty-chat">- <div class="message-stack"><div class="assistant-body"></div><div class="message-bubble"></div></div>- <div class="chat-cta"></div><div class="composer-wrap"></div>- </div>- </div>- </div>`);- const canvas = dom.window.document.querySelector(".split-canvas")!;- const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)];- const overrides = rules.filter(- ([, selector, declarations]) =>- selector.includes(".split-pane-chat") &&- /(?:font-size: 12px|--composer-font-size: 12px|font-size: var\(--font-21\))/.test(declarations),- );- assert.equal(overrides.length, 4);- for (const [, selector] of overrides) {- assert.equal(canvas.querySelector(selector.trim()), null, selector);- }- canvas.classList.remove("single-pane");- for (const [, selector] of overrides) {- assert.ok(canvas.querySelector(selector.trim()), selector);- }- canvas.classList.add("single-pane");- for (const [, selector] of overrides) {- assert.equal(canvas.querySelector(selector.trim()), null, selector);- }- dom.window.close();-});--test("phone composers keep input and touch controls on one row outside split panes", () => {- const phone = css.slice(- css.indexOf(" --composer-font-size: 16px;"),- css.indexOf(" .live-work-line {", css.indexOf(" --composer-font-size: 16px;")),- );- assert.match(phone, /display: grid;[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto;/);- assert.match(phone, /\.composer-wrap > \* \{\s*grid-column: 1 \/ -1;/);- assert.match(phone, /\.composer-input \{[^}]*grid-column: 1;[^}]*min-width: 0;/);- assert.match(phone, /\.composer-wrap \.composer-toolbar \{[^}]*grid-column: 2;[^}]*flex-wrap: nowrap;/);- assert.match(phone, /\.loadout-button \.menu-suffix \{\s*display: none;/);- assert.match(phone, /\.composer-input::placeholder \{\s*white-space: nowrap;/);- assert.match(phone, /\.composer-toolbar \.send-btn \{[^}]*width: 44px;[^}]*height: 44px;/);-});diff --git a/plugins/web-ui/test/pane-focus.test.ts b/plugins/web-ui/test/pane-focus.test.tsindex 566749006..92a896f5d 100644--- a/plugins/web-ui/test/pane-focus.test.ts+++ b/plugins/web-ui/test/pane-focus.test.ts@@ -1,7 +1,6 @@import { test } from "node:test";import assert from "node:assert/strict";import { JSDOM } from "jsdom";-import { readFileSync } from "node:fs";import {focusComposerOnPaneClick,focusPaneComposer,@@ -45,14 +44,6 @@ test("activating a pane cannot cost the composer its focus or caret", () => {assert.equal(ta.selectionStart, 1);});-test("a pane focusin never re-activates the pane it is already in", () => {- const split = readFileSync(new URL("../src/split.ts", import.meta.url), "utf8");- const focusPane = split.match(/function focusPane\([\s\S]*?\n\}/)?.[0] ?? "";- assert.ok(focusPane, "focusPane not found");- assert.match(focusPane, /if \(!panel \|\| panel\.api\.isActive\) return;/, "re-activation remounts the pane");- assert.match(focusPane, /preservingFocus\(document, \(\) => activatePanel\(panel\)\)/, "activation drops focus");-});-function clickFixture(secondContent = '<textarea class="composer-input">draft</textarea>') {const dom = new JSDOM(`<main>diff --git a/plugins/web-ui/test/pinned-prompt-collapse.test.ts b/plugins/web-ui/test/pinned-prompt-collapse.test.tsindex ac1e29b0f..accc54bde 100644--- a/plugins/web-ui/test/pinned-prompt-collapse.test.ts+++ b/plugins/web-ui/test/pinned-prompt-collapse.test.ts@@ -1,6 +1,5 @@import assert from "node:assert/strict";import test from "node:test";-import { readFileSync } from "node:fs";import { JSDOM } from "jsdom";import { createTranscriptViewport } from "../src/transcript-viewport.ts";@@ -371,49 +370,6 @@ test("rest heights are never taken from an expanded prompt", () => {}});-test("the disclosure rides the last visible line while clamped and drops to a row when expanded or over rich content", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- const bubble = css.match(/\n\.user-bubble \{[^}]*\}/)?.[0] ?? "";- assert.match(bubble, /--bubble-bg: color-mix/);- assert.match(bubble, /position: relative/);- const toggle = css.match(/\n\.pin-toggle \{[^}]*\}/)?.[0] ?? "";- assert.match(toggle, /position: absolute/);- assert.match(toggle, /height: 1lh/);- assert.match(toggle, /background: linear-gradient\(to right, transparent, var\(--bubble-bg\)/);- assert.doesNotMatch(toggle, /font-size/);- const row =- css.match(- /\.user-row\.pin-expanded > \.user-bubble > \.pin-toggle,\s*\.message-stack\s+\.user-bubble\s+> \.pin-content:has\(code-block[^{]*~ \.pin-toggle \{[^}]*\}/,- )?.[0] ?? "";- assert.match(row, /position: static/);- assert.match(row, /margin: 6px 0 0 auto/);- assert.match(- css,- /\.user-row\.pin-expanded > \.user-bubble > \.pin-toggle > \.icon \{\s*transform: rotate\(180deg\);/,- );-});--test("the condensed strip keeps the resting line layout, with a scroll-driven height on stuck", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- const stuck =- css.match(/\.message-stack \.user-row\.stuck:not\(\.pin-expanded\) \.user-bubble > \.pin-content \{[^}]*\}/)?.[0] ??- "";- assert.match(stuck, /max-height: var\(--pin-content-max, none\)/);- assert.doesNotMatch(stuck, /line-clamp|transition/);- assert.match(css, /\.user-row\.stuck:not\(\.pin-expanded\) \{\s*min-height: var\(--pin-rest-height\)/);- assert.match(- css,- /\.user-row\.stuck:not\(\.pin-expanded\)\s+\.user-bubble\s+> \.pin-content:has\(code-block[^{]*\{\s*max-height: var\(--pin-content-max, 6lh\)/,- );- const rest =- css.match(- /\.message-stack \.user-row\.latest-prompt:not\(\.pin-expanded\) \.user-bubble > \.pin-content \{[^}]*\}/,- )?.[0] ?? "";- assert.match(rest, /-webkit-line-clamp: 6/);- assert.doesNotMatch(rest, /max-height|transition/);- assert.doesNotMatch(css, /pin-condensed[^{]*\{[^}]*transition/);-});-test("expanded prompts reserve pins and chrome when panes resize or content grows", () => {const f = fixture();try {@@ -490,12 +446,6 @@ test("ordinary multi-line prompts stay fully visible without a disclosure", () =}});-test("condensing clips content without changing its typography", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- const rules = css.match(/[^{}]*\.pin-condensed[^{}]*\{[^}]*\}/g) ?? [];- for (const rule of rules) assert.doesNotMatch(rule, /margin|font-size|line-height|line-clamp/);-});-test("border-box prompts reserve the entire row including the metadata lane", () => {const f = fixture();try {@@ -510,11 +460,3 @@ test("border-box prompts reserve the entire row including the metadata lane", ()f.close();}});--test("pinned image chips cannot grow into more rows than their thumbnails", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- const rule = css.match(/\.user-row\.stuck > \.message-files > \.attachment-images \{[^}]*\}/)?.[0] ?? "";- assert.match(rule, /flex-wrap: nowrap/);- assert.match(rule, /overflow-x: auto/);- assert.match(rule, /justify-content: safe flex-end/);-});diff --git a/plugins/web-ui/test/queue-by-default.test.ts b/plugins/web-ui/test/queue-by-default.test.tsdeleted file mode 100644index 4fcfad04e..000000000--- a/plugins/web-ui/test/queue-by-default.test.ts+++ /dev/null@@ -1,230 +0,0 @@-import test from "node:test";-import assert from "node:assert/strict";-import { existsSync, readFileSync, readdirSync } from "node:fs";-import { harnessSupportsSteer } from "../src/model-options.ts";--const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");-const bridge = readFileSync(new URL("../src/core-bridge.ts", import.meta.url), "utf8");-const server = readFileSync(new URL("../server/index.ts", import.meta.url), "utf8");-const shell = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");--test("a mid-turn Enter queues the message — it no longer steers the running turn", () => {- assert.match(composer, /if \(agent\.state\.isStreaming\) return queueDraft\(agent\);/);- assert.doesNotMatch(composer, /isStreaming\) return sendSteer\(/);- assert.match(composer, /placeholder = "Queue a message for after this turn…"/);- assert.match(composer, /\$\{tip\("Queue for after this turn"\)\}/);-});--// The whole point of the rewrite: the queue is core's, not the browser's. A queued message is a-// real run core will execute whether or not this tab survives, so there is nothing to flush, no-// per-tab store to keep in sync, and no way for two tabs to send the same message twice.-test("the queue lives in core, not in the browser", () => {- assert.ok(!existsSync(new URL("../src/message-queue.ts", import.meta.url)), "the localStorage queue module is gone");- for (const [name, src] of [- ["composer", composer],- ["chat", chat],- ] as const) {- assert.doesNotMatch(src, /"web-ui:queued"/, `${name} persists no queue of its own`);- assert.doesNotMatch(src, /flushQueuedMessages/, `${name} has no flush path left`);- }- assert.match(- composer,- /const queuedRuns = new Map<string, QueuedRun\[\]>\(\);/,- "what the composer holds is a view of core's queue, rebuilt from core — not a store",- );- assert.match(- composer,- /const queued = await queueTurn\(threadRef, text, agent, ctx\.chat\.currentTurnOptions, idempotencyKey, attachments\);/,- );- assert.match(- bridge,- /export async function queueTurn\([\s\S]{0,600}?api<\{ status\?: string; runId\?: string; reason\?: string \}>\("\/api\/turn"/,- "queuing is an ordinary turn submission; core enqueues it behind the live run",- );-});--test("a queued turn carries the same model, effort and scope a typed one would", () => {- assert.match(bridge, /function turnRequestBody\(/);- const body = bridge.slice(bridge.indexOf("function turnRequestBody"));- assert.match(body, /thinkingLevel/);- assert.match(body, /scopeId: turnOptions\.scopeId/);- assert.match(- bridge,- /\.\.\.turnRequestBody\(threadRef, text, model, agent, getTurnOptions, \{ idempotencyKey, attachments \}\),/,- );- assert.match(- bridge,- /turnRequestBody\(threadRef, text, agent\.state\.model, agent, getTurnOptions, \{ idempotencyKey, attachments \}\)/,- );-});--// Found in live QA: when the Steer control was swapped in and out of an existing strip, a tab that-// opened the conversation BEFORE its run attached (the queue draws first, the live run a moment-// later) ended up with a Steer button that received clicks but ran nothing. Whether the harness can-// steer is fixed for the conversation, so the button's presence must be too — only its enabled-// state may change.-test("the Steer control's presence is fixed for the conversation; only enablement changes", () => {- const strip = composer.slice(- composer.indexOf("function queuedStrip"),- composer.indexOf("function composerApprovalPanel"),- );- assert.match(strip, /\?disabled=\$\{!steerable\}/, "an unusable Steer is disabled, never removed");- assert.doesNotMatch(- strip,- /steerable\s*\?\s*html`<button/,- "the button must not be conditionally inserted into a strip that is already on screen",- );-});--test("steering is reachable only as an explicit act on a queued row", () => {- const strip = composer.slice(- composer.indexOf("function queuedStrip"),- composer.indexOf("function composerApprovalPanel"),- );- assert.match(strip, /class="queued-steer"/);- assert.match(strip, /steerQueued\(agent, q\)/);- assert.match(strip, /class="chip-x"[\s\S]{0,240}removeQueued\(agent, q\)/);- assert.match(- composer,- /const steerable =\s*agent\.state\.isStreaming &&\s*!ctx\.chat\.isStopping\(\) &&\s*ctx\.chat\.hasLiveRun\(\) &&\s*harnessSupportsSteer\(currentModelOption\(\)\?\.harnessId \?\? ""\);/,- "Steer acts only against a live run on a harness that can fold one in",- );-});--test("Steer asks core to transfer the durable queued message before showing it as delivered", () => {- const fn = composer.slice(- composer.indexOf("async function steerQueued"),- composer.indexOf("async function sendPrompt"),- );- assert.match(fn, /signalLiveRun\("steer", queued\.text, queued\.runId\)/);- assert.doesNotMatch(fn, /withdrawRun|enqueueTurn|verifySteerDelivered/);- assert.ok(fn.indexOf("signalLiveRun") < fn.indexOf("agent.state.messages.push"));- assert.match(fn, /agent === ctx\.chat\.state\.agent && threadRef === ctx\.chat\.state\.threadRef/);-});--test("× cancels the queued run in core, and treats a lost race as running rather than removed", () => {- const fn = composer.slice(- composer.indexOf("async function removeQueued"),- composer.indexOf("async function steerQueued"),- );- assert.match(fn, /await withdrawRun\(queued\.runId\)/);- assert.match(- fn,- /if \(!\(err instanceof ApiError && \(err\.status === 409 \|\| err\.status === 404\)\)\)/,- "409 (claimed) and 404 (withdrawn elsewhere) both mean the run left the queue — the chip goes",- );- assert.match(bridge, /export async function withdrawRun\(runId: string\): Promise<boolean>/);- assert.match(- server,- /path: "\/api\/runs\/:id\/withdraw"[\s\S]{0,320}?\/v1\/runs\/\$\{encodeURIComponent\(id\)\}\/withdraw/,- );-});--// A queue outlives the run it was sent behind: when the head finishes between core's read and the-// surface's, the answer has no live run but the queue is still real. Reporting the followed run as-// queued, or dropping the queue with the run, both put the strip out of step with core.-test("a thread with no live run still reports its queue, and the followed run is never in it", () => {- assert.match(server, /const waiting = queued\.filter\(\(q\) => q\.runId !== runId\);/);- assert.match(bridge, /queued: QueuedRun\[\];/, "the queue is always present, not optional");- assert.match(bridge, /return \{ \.\.\.live, queued: r\.queued \?\? \[\] \};/);- assert.match(- bridge,- /export async function activeRunForThread\(threadRef: string\): Promise<ActiveRun>/,- "the call no longer answers null, which used to take the queue down with it",- );-});--test("the strip renders core's queue, refreshed from the same read that names the live run", () => {- assert.match(composer, /function queuedStrip[\s\S]{0,140}?queuedRunsFor\(ctx\.chat\.state\.threadRef\)/);- assert.match(chat, /setQueuedRuns\(threadRef, activeRun\.queued\)/);- assert.match(bridge, /queued\?: QueuedRun\[\]/);- assert.match(server, /json\(res, 200, \{ runId, run, \.\.\.\(waiting\.length \? \{ queued: waiting \} : \{\}\) \}\)/);-});--test("the queued strip sits behind and outside the composer form", () => {- assert.match(chat, /ctx\.composer\.queuedStrip\(agent\)[\s\S]*?ctx\.composer\.composerForm\(agent\)/);- const composerMarkup = composer.slice(composer.indexOf('<form class="composer-wrap"'), composer.indexOf("</form>"));- assert.doesNotMatch(composerMarkup, /queuedStrip\(agent\)/);- const queuedRule = shell.match(/(?:^|\n)\.queued-strip,\s*\.chat-bottom-dock > \.bg-activity \{[^}]*\}/)?.[0] ?? "";- const composerRule = shell.match(/(?:^|\n)\.composer-wrap \{[^}]*\}/)?.[0] ?? "";- assert.match(queuedRule, /z-index: 0;/);- assert.match(queuedRule, /width: min\(calc\(var\(--content-w\) - 24px\), calc\(100% - 56px\)\);/);- assert.match(queuedRule, /margin: 0 auto -10px;/);- assert.match(composerRule, /position: relative;\s*z-index: 1;/);- const midStart = shell.indexOf("@container chat (max-width: 860px)");- const narrowStart = shell.indexOf("@container chat (max-width: 470px)", midStart);- const midWidth = shell.slice(midStart, narrowStart);- const narrow = shell.slice(narrowStart, shell.indexOf('[data-density="card"]', narrowStart));- assert.match(- midWidth,- /\.queued-strip,\s*\.chat-bottom-dock > \.bg-activity \{[^}]*margin-right: max\(28px, calc\(22px \+ env\(safe-area-inset-right\)\)\);[^}]*margin-left: max\(28px, calc\(22px \+ env\(safe-area-inset-left\)\)\);[^}]*\}/,- );- assert.match(- narrow,- /\.queued-strip,\s*\.chat-bottom-dock > \.bg-activity \{[^}]*margin-right: calc\(22px \+ env\(safe-area-inset-right\)\);[^}]*margin-left: calc\(22px \+ env\(safe-area-inset-left\)\);[^}]*\}/,- );-});--// Nothing is sent when a turn settles: core already started the next queued run. The client's only-// job is to show it, so a client that never comes back costs the person nothing but the view.-test("settling a turn follows the next queued run instead of sending it", () => {- assert.match(chat, /void followNextQueuedRun\(agent, threadRef, normalStreamFn, onWork\);/);- const fn = chat.slice(- chat.indexOf("async function followNextQueuedRun"),- chat.indexOf("async function resumeTrackedRun"),- );- assert.match(fn, /makeRunResumeStreamFn\(active\.runId, active\.run, onWork, runSlot\)/, "it attaches to core's run");- assert.doesNotMatch(fn, /queueTurn/, "it never submits anything");- assert.match(- fn,- /await \(!active\.run\.input && next && !recorded \? agent\.prompt\(next\.text\) : agent\.continue\(\)\)/,- "an already-recorded turn is resumed, never prompted a second time onto the screen",- );- assert.match(fn, /await refreshTranscriptFromEntries\(agent\)/);- // A second tab watching the same conversation never saw the send, so only core can say what is- // still queued — trusting this tab's list left it drawing a turn a worker had already claimed.- assert.match(fn, /active = await activeRunForThread\(threadRef\)/, "the queue is re-read from core on settle");- assert.match(fn, /setQueuedRuns\(threadRef, active\.queued\)/, "core's answer replaces the list");- assert.match(- fn,- /const next = ctx\.composer\.queuedRunsFor\(threadRef\)\.find\(\(r\) => r\.runId === active\.runId\)/,- "it renders the live run as ours only when it is one this tab queued",- );- // A tab that was already open when ANOTHER tab queued work has an empty local list. Bailing on- // that emptiness meant it never asked core, so it sat idle through a run core had already- // started — the exact staleness re-reading core exists to cure.- assert.doesNotMatch(fn, /queuedRunsFor\(threadRef\)\.length\) return;/, "emptiness must not skip the re-read");- assert.match(- fn,- /const recorded = \(agent\.state\.messages\.at\(-1\) as \{ role\?: string \} \| undefined\)\?\.role === "user";/,- "a trailing user entry is how a tab recognises a queued turn it never sent",- );-});--// A spine-routed turn's `text` is a <wake> envelope; the person's words are in displayText. A-// surface that renders `text` shows the envelope, and Steer would fold the envelope into the live-// turn in place of the message.-test("the queue exposes what the person typed, never the wake envelope that wraps it", () => {- const appTurn = readFileSync(new URL("../../../src/api/app-turn.ts", import.meta.url), "utf8");- const fn = appTurn.slice(appTurn.indexOf("async activeRunForThread"), appTurn.indexOf("async withdrawRun"));- assert.match(fn, /text: run\.request\.displayText \?\? run\.request\.text \?\? ""/);-});--// The Steer button is only honest if the harness running the conversation can actually fold a-// mid-turn message in. Core declares that per adapter; this keeps the client's copy from drifting.-test("every harness core says can steer is one the web UI offers Steer for", () => {- const dir = new URL("../../../src/harness/", import.meta.url);- const declared = new Map<string, boolean>();- for (const file of readdirSync(dir)) {- if (!file.endsWith("-harness.ts")) continue;- const src = readFileSync(new URL(file, dir), "utf8");- const id = /defineHarness\(\s*\{\s*id:\s*"([^"]+)"/.exec(src)?.[1] ?? file.replace("-harness.ts", "");- const caps = /capabilities: new Set\(\[([^\]]*)\]\)/.exec(src)?.[1] ?? "";- declared.set(id, caps.includes('"steer"'));- }- assert.ok(declared.size >= 4, `expected to find the harness adapters, saw ${[...declared.keys()].join(", ")}`);- for (const [id, canSteer] of declared) {- assert.equal(harnessSupportsSteer(id), canSteer, `harnessSupportsSteer("${id}") disagrees with core`);- }-});diff --git a/plugins/web-ui/test/resume-without-user-message.test.ts b/plugins/web-ui/test/resume-without-user-message.test.tsindex 3031013f7..ecc4f0b69 100644--- a/plugins/web-ui/test/resume-without-user-message.test.ts+++ b/plugins/web-ui/test/resume-without-user-message.test.ts@@ -1,11 +1,8 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import type { AgentMessage } from "@earendil-works/pi-web-ui";import { continuableMessages, entriesToMessages, resumeAnchor, runIsTerminal } from "../src/core-bridge.ts";-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");-const assistant = (text: string): AgentMessage =>({ role: "assistant", content: [{ type: "text", text }] }) as unknown as AgentMessage;const user = (text: string): AgentMessage => ({ role: "user", content: text }) as unknown as AgentMessage;@@ -87,39 +84,11 @@ test("an empty window anchors rather than refusing", () => {});test("the anchor is never drawn", () => {- assert.match(chat, /const hidden = message as \{ opener\?: boolean; resumeAnchor\?: boolean \};/);- assert.match(chat, /if \(hidden\.opener \|\| hidden\.resumeAnchor\) return nothing;/);assert.equal((resumeAnchor() as { content?: unknown }).content, "");});-test("neither attach path refuses a live run over the shape of the loaded transcript", () => {- const resume = chat.slice(chat.indexOf("async function resumeTrackedRun"));- const body = resume.slice(0, resume.indexOf("agent.streamFn = makeRunResumeStreamFn"));- assert.doesNotMatch(body, /if \(!msgs\.length\) return false;/, "resume no longer bails on an anchorless window");- assert.doesNotMatch(body, /if \(!agent\.state\.messages\.length\) return false;/, "nor on an empty one");- assert.match(- body,- /const \{ messages: msgs, popped \} = continuableMessages\(agent\.state\.messages, initialRun\.input\);/,- );-- const follow = chat.slice(chat.indexOf("async function followNextQueuedRun"));- const followBody = follow.slice(0, follow.indexOf("agent.streamFn = makeRunResumeStreamFn"));- assert.doesNotMatch(followBody, /if \(!recorded && !next\) return drawActiveChat/, "following no longer bails");- assert.match(followBody, /agent\.state\.messages = \[\.\.\.agent\.state\.messages, resumeAnchor\(\)\];/);-});-test("a run whose reply already landed is not something to attach to", () => {assert.equal(runIsTerminal({ status: "running", result: null, replyComplete: true }), true);assert.equal(runIsTerminal({ status: "done", result: null }), true);assert.equal(runIsTerminal({ status: "running", result: null }), false);-- const follow = chat.slice(chat.indexOf("async function followNextQueuedRun"));- const followBody = follow.slice(0, follow.indexOf("agent.streamFn = makeRunResumeStreamFn"));- assert.match(- followBody,- /if \(!active\.runId \|\| !active\.run \|\| runIsTerminal\(active\.run\)\) return drawActiveChat\(agent\);/,- "anchoring a finished run would end its stream at once and re-enter this path forever",- );- const resume = chat.slice(chat.indexOf("async function resumeTrackedRun"));- assert.match(resume.slice(0, resume.indexOf("await refreshTranscript")), /runIsTerminal\(activeRun\.run\)/);});diff --git a/plugins/web-ui/test/rtl-direction.test.ts b/plugins/web-ui/test/rtl-direction.test.tsindex dd3b137c7..4bc3d54e2 100644--- a/plugins/web-ui/test/rtl-direction.test.ts+++ b/plugins/web-ui/test/rtl-direction.test.ts@@ -1,28 +1,7 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { JSDOM } from "jsdom";-const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");-const messageMarkdown = readFileSync(new URL("../src/message-markdown.ts", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");--test("composer text entry selects direction from its content", () => {- assert.match(composer, /<textarea\s+class="composer-input"\s+dir="auto"/);- assert.match(composer, /<textarea\s+class="paste-dialog-text"\s+dir="auto"/);- assert.match(composer, /class="queued-text" dir="auto"/);-});--test("settled and streaming transcript blocks select direction from their content", () => {- assert.match(chat, /import \{ markdown \} from "\.\/message-markdown"/);- assert.match(- messageMarkdown,- /<qm-markdown\s+dir="auto"[^>]*?\.content=\$\{escapeLoneDollars\(normalizePlainTextFences\(text\)\)\}/,- );- assert.match(chat, /\$\{markdown\(body, animating, /);- assert.match(chat, /class="streaming-text \$\{animating \? "live-stream" : ""\}" dir="auto"/);-});-test("search group headers select direction from the authored session title", async () => {const dom = new JSDOM('<!doctype html><main id="host"></main>');Object.defineProperty(globalThis, "document", { configurable: true, value: dom.window.document });diff --git a/plugins/web-ui/test/single-view-navigation.test.ts b/plugins/web-ui/test/single-view-navigation.test.tsindex a49daea57..4a7298e9b 100644--- a/plugins/web-ui/test/single-view-navigation.test.ts+++ b/plugins/web-ui/test/single-view-navigation.test.ts@@ -221,11 +221,3 @@ test("single and multiview headers render mutually exclusive tools and pane contassert.equal(actions.menuOpen, false);assert.doesNotMatch(output, /split-tools-btn|role="menu"|Close pane/);});--test("single-pane toolbar and split menu put Crons and Apps first", () => {- const tools = split.slice(split.indexOf("const PANE_TOOLS:"), split.indexOf("function openPaneTool"));- assert.deepEqual(- [...tools.matchAll(/tool: "([^"]+)"/g)].map((match) => match[1]),- ["crons", "apps", "files", "skills", "memory", "keychain"],- );-});diff --git a/plugins/web-ui/test/skills-flow.test.ts b/plugins/web-ui/test/skills-flow.test.tsindex 8caf71378..367b731b9 100644--- a/plugins/web-ui/test/skills-flow.test.ts+++ b/plugins/web-ui/test/skills-flow.test.ts@@ -1,84 +1,8 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { SkillsRefreshSequence } from "../src/skills-refresh.ts";import { SkillsMutationSequence } from "../src/skills-mutation.ts";-const source = readFileSync(new URL("../src/skills.ts", import.meta.url), "utf8");--function bodyOf(name: string): string {- const start = source.indexOf(`function ${name}(`);- assert.notEqual(start, -1, `${name} exists`);- const next = source.indexOf("\nfunction ", start + 1);- return source.slice(start, next < 0 ? source.length : next);-}--test("focused create/edit flows leave list search and filters untouched on open and close", () => {- const flow = `${bodyOf("startCreate")}\n${bodyOf("startEdit")}\n${bodyOf("closeFocusedFlow")}`;- assert.doesNotMatch(flow, /skillSearch\s*=|scopeFilter\s*=|sourceFilter\s*=|statusFilter\s*=/);- assert.match(- source,- /if \(creating \|\| editingTarget\) \{\s*render\(creating \? creatorPane\(\) : editorPane\(\), skillsPageHost\);\s*return;/,- );-});--test("skill rows omit redundant active, local-source, and box decorations", () => {- const variant = bodyOf("skillVariant");- assert.doesNotMatch(variant, /icon\(Box|>Active<|skill-active|skill-variant-icon/);- assert.doesNotMatch(source, /Created here/);- assert.match(variant, />Archived</);-});--test("closing a focused flow clears an unfinished edit loading notice", () => {- assert.match(bodyOf("startEdit"), /skillsNotice = "Loading skill instructions…"/);- assert.match(bodyOf("closeFocusedFlow"), /skillsNotice = ""/);-});--test("entering Skills clears archive overlay state from an earlier visit", () => {- assert.match(- bodyOf("renderSkills"),- /if \(!skillsPageHost \|\| skillsPageHost\.parentElement !== appState\.mainEl\) \{\s*archiveConfirmation = null;\s*archiveFocusTarget = null;\s*setSkillsBackgroundInert\(false\);\s*\}/,- );-});--test("edit loading and successful saves always move focus to a surviving control", () => {- const startEdit = bodyOf("startEdit");- assert.match(- startEdit,- /drawSkills\(\);\s*queueMicrotask\(\(\) => skillsPageHost\?\.querySelector<HTMLElement>\("\.context-back"\)\?\.focus\(\)\)/,- );- assert.match(- startEdit,- /querySelector<HTMLElement>\("#skill-edit-description"\)[\s\S]*querySelector<HTMLElement>\("\.context-back"\)/,- );- assert.match(- bodyOf("saveEdit"),- /await renderSkills\(\);\s*if \(!skillMutations\.isCurrent\(operation\)\) return;\s*restoreFocusedFlow\(returnTarget\)/,- );- assert.match(- bodyOf("saveCreate"),- /await renderSkills\(\);\s*if \(!skillMutations\.isCurrent\(operation\)\) return;\s*restoreFocusedFlow\(returnTarget\)/,- );- assert.match(- bodyOf("saveEdit"),- /if \(!skillMutations\.isCurrent\(operation\)\) \{\s*await renderSkills\(\);\s*return;/,- );- assert.match(- bodyOf("saveCreate"),- /if \(!skillMutations\.isCurrent\(operation\)\) \{\s*await renderSkills\(\);\s*return;/,- );- assert.match(- bodyOf("restoreFocusedFlow"),- /if \(creating \|\| editingTarget \|\| archiveConfirmation \|\| appState\.currentView !== "skills"\) return;/,- );- assert.match(- bodyOf("restoreFocusedFlow"),- /skillId\s*\?\s*\(?matchingEdit \?\? search \?\? create\)?\s*:\s*\(?create \?\? search\)?/,- );- assert.match(bodyOf("editorPane"), /editError \? "Instructions unavailable\." : "Loading instructions…"/);- assert.equal(source.match(/shouldBlockRepeatedPublishClick\(reviewed, event\.detail\)/g)?.length, 2);-});-test("a reversed completion cannot let an older Skills refresh overwrite the latest response", async () => {const sequence = new SkillsRefreshSequence();let rows = "initial";@@ -103,7 +27,6 @@ test("a reversed completion cannot let an older Skills refresh overwrite the latawait older;assert.equal(rows, "latest");- assert.equal(source.match(/!skillsRefreshes\.isCurrent\(request\) \|\| seq !== appState\.viewRenderSeq/g)?.length, 2);});test("a completed save cannot clear a newer skill draft", async () => {@@ -157,17 +80,3 @@ test("a completed save refresh cannot consume a newer flow opener", async () =>assert.equal(restored, null);assert.equal(refreshed, true);});--test("archive uses a modal dialog with an impact description and managed focus", () => {- assert.match(- source,- /role="dialog"\s+aria-modal="true"\s+aria-labelledby="skill-archive-title"\s+aria-describedby="skill-archive-impact"/,- );- assert.match(source, /trapDialogFocus\(event, closeArchiveDialog\)/);- assert.match(source, /restoreDialogFocus\(target, \(\) => fallback\)/);- assert.match(source, /focusDialogCancel\(skillsPageHost\)/);- assert.match(- source,- /querySelector<HTMLElement>\("\.list-search input"\)[\s\S]*querySelector<HTMLElement>\("\.list-page-action"\)/,- );-});diff --git a/plugins/web-ui/test/slack-text.test.ts b/plugins/web-ui/test/slack-text.test.tsindex 18c081d6a..dc13150c7 100644--- a/plugins/web-ui/test/slack-text.test.ts+++ b/plugins/web-ui/test/slack-text.test.ts@@ -1,5 +1,4 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { splitMentions } from "../src/linkify.ts";@@ -120,28 +119,6 @@ test("the directive grammar resists catastrophic backtracking", () => {}});-test("the local grammar mirrors the Slack plugin, ReDoS-hardened in lockstep with core", () => {- const reactions = readFileSync(new URL("../../../src/slack/reactions.ts", import.meta.url), "utf8");- const directives = readFileSync(new URL("../../../src/slack/directives.ts", import.meta.url), "utf8");- const local = readFileSync(new URL("../src/slack-text.ts", import.meta.url), "utf8");- assert.ok(reactions.includes("/\\[\\[react:([^\\]]*)\\]\\]/gi"));- assert.ok(local.includes("/\\[\\[react:[^\\]]*\\]\\]/gi"));- assert.ok(- !directives.includes("[ \\t]+\\n") && !local.includes("[ \\t]+\\n"),- "the tidy step is linear on both sides",- );- assert.ok(directives.includes("/```[\\s\\S]*?```|`[^`\\n]*`/g"));- assert.ok(local.includes("/```[\\s\\S]*?```|`[^`\\n]*`/g"));-});--test("the local entity decode matches core's decodeSlackEntities", () => {- const mrkdwn = readFileSync(new URL("../../../src/slack/mrkdwn.ts", import.meta.url), "utf8");- const decode = 'text.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&")';- assert.ok(mrkdwn.includes(decode));- const local = readFileSync(new URL("../src/slack-text.ts", import.meta.url), "utf8");- assert.ok(local.includes(decode));-});-test("a labeled user mention never doubles its at-sign", () => {assert.deepEqual(splitSlackWire("<@U1|@ada>"), [{ kind: "mention", handle: "ada" }]);assert.deepEqual(splitSlackWire("<@U1|@@ada>"), [{ kind: "mention", handle: "ada" }]);diff --git a/plugins/web-ui/test/split-layout.test.ts b/plugins/web-ui/test/split-layout.test.tsindex afd174705..da9d6b22e 100644--- a/plugins/web-ui/test/split-layout.test.ts+++ b/plugins/web-ui/test/split-layout.test.ts@@ -1,6 +1,5 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { layoutNeedsSessionList, MAX_TILES, paneNeedsSessionList, v1PaneSeeds } from "../src/split-layout.ts";const leaf = (sessionId: string | null = null, threadRef: string | null = null): object => ({@@ -39,18 +38,6 @@ test("v1PaneSeeds normalizes non-string ids to null", () => {]);});-test("a conversation can be dropped onto a pane's tab strip to become a tab", () => {- const splitTs = readFileSync(new URL("../src/split.ts", import.meta.url), "utf8");- assert.match(splitTs, /class StripDrop implements IHeaderActionsRenderer/, "no strip drop target");- assert.match(splitTs, /^class StripDrop[\s\S]*?tabIntoPane\(/m, "the strip drop must join the pane");- const edges = new Set([...splitTs.matchAll(/zoneTpl\("([a-z]+)"/g)].map((m) => m[1]));- assert.deepEqual(- edges,- new Set(["center", "left", "right", "top", "bottom"]),- "the body zones must not restate the strip",- );-});-test("a pane needs the session list only when it remembers a thread but not its session", () => {assert.equal(paneNeedsSessionList({ sessionId: "s1", threadRef: "t1" }), false, "named session");assert.equal(paneNeedsSessionList({ sessionId: "s1" }), false);diff --git a/plugins/web-ui/test/split-single-header.test.ts b/plugins/web-ui/test/split-single-header.test.tsdeleted file mode 100644index 9f6bea084..000000000--- a/plugins/web-ui/test/split-single-header.test.ts+++ /dev/null@@ -1,96 +0,0 @@-import assert from "node:assert/strict";-import { readFileSync } from "node:fs";-import { runInNewContext } from "node:vm";-import test from "node:test";--const split = readFileSync(new URL("../src/split.ts", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");-const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");--test("only full standalone chats render their own session topbar", () => {- const expression = chat.match(/\$\{([^{}]+\? nothing : sessionTopbar\(\))\}/)?.[1];- assert.ok(expression);- for (const pane of [false, true]) {- for (const editingApp of [null, "my-app"]) {- for (const glanceTier of [null, "card", "strip"]) {- const shown = runInNewContext(expression, {- ctx: { pane },- editingApp,- glanceTier,- nothing: false,- sessionTopbar: () => true,- });- assert.equal(shown, !pane && !editingApp && !glanceTier);- }- }- }-});--test("the pane tab carries the scope / title breadcrumb", () => {- assert.match(split, /function paneCrumb\(panel: IDockviewPanel\): string \| null/);- assert.match(split, /class="split-pane-crumb"/);- const tooltip = split.match(/attachTooltip\(this\.element, (.*crumb.*)\);/)?.[1];- assert.ok(tooltip);- for (const crumb of [null, "Project"]) {- for (const parent of [undefined, { title: "Parent" }]) {- const actual = runInNewContext(tooltip, {- crumb,- parent,- title: "Child",- sessionTitle: (session: { title: string }) => session.title,- });- assert.equal(actual, `${crumb ? "Project / " : ""}${parent ? "Parent / " : ""}Child`);- }- }- // crumb changes must retrigger a header redraw- assert.match(split, /\$\{paneCrumb\(p\) \?\? ""\}\|\$\{paneTitle\(p\)\}/);- assert.match(css, /\.split-pane-crumb \{/);-});--test("project tools live behind the header overflow menu, left of the split button", () => {- const toolsIdx = split.indexOf("split-tools-btn");- const plusIdx = split.indexOf("Split this pane with a new session");- assert.ok(toolsIdx > 0 && plusIdx > 0 && toolsIdx < plusIdx, "tools menu renders before the + button");- for (const tool of ['"crons"', '"files"', '"apps"', '"skills"', '"memory"', '"keychain"']) {- assert.ok(split.includes(`tool: ${tool}`), `${tool} reachable from the pane menu`);- }- assert.match(split, /switchView\(tool === "apps" \? "deploys" : tool\)/);- assert.match(split, /setScopedSession\(\{/);-});--test("the tools menu closes on any click outside the \u22ef control \u2014 sibling buttons included", () => {- const cls = split.slice(split.indexOf("class GroupActions"), split.indexOf("function notePaneSession"));- assert.match(cls, /e\.composedPath\(\)\.includes\(tools\)/);- // the toggle must not swallow the click, or another pane's open menu never hears it- const toggle = cls.slice(cls.indexOf('class="icon-btn subtle split-tools-btn'), cls.indexOf("MoreHorizontal"));- assert.doesNotMatch(toggle, /stopPropagation/);-});--test("inline pane chrome is exactly tools, split, full screen, close", () => {- const draw = split.slice(split.indexOf("class GroupActions"), split.indexOf("function notePaneSession"));- // focus-over-grid moved into the menu; not an inline button- const inlineButtons = draw.slice(draw.indexOf("const buttons"));- assert.doesNotMatch(inlineButtons, /Focus this pane over the grid/);- assert.match(draw, /Restore to grid \(Esc\)/); // still reachable via the menu- assert.match(inlineButtons, /Open full screen/);- assert.match(inlineButtons, /Close pane/);-});--test("a topbar-less pane keeps the two-row grid: transcript bounded, composer at the bottom", () => {- const classes = chat.match(/class="(custom-chat-shell [\s\S]*?)"\s+@dragenter/)?.[1];- assert.ok(classes);- for (const pane of [false, true]) {- for (const editingApp of [null, "my-app"]) {- const rendered: string[] = runInNewContext(`\`${classes}\``, {- ctx: { pane, composer: { state: { dragging: false } } },- editingApp,- emptyChat: false,- glanceTier: null,- }).split(/\s+/);- assert.equal(rendered.includes("in-pane"), pane);- assert.equal(rendered.includes("app-edit-chat"), Boolean(editingApp));- }- }- assert.match(css, /\.custom-chat-shell\.in-pane \{\s*grid-template-rows: minmax\(0, 1fr\) auto;\s*\}/);- assert.match(css, /\.app-edit-chat \{\s*grid-template-rows: minmax\(0, 1fr\) auto;\s*\}/);-});diff --git a/plugins/web-ui/test/split-tiles-and-titles.test.ts b/plugins/web-ui/test/split-tiles-and-titles.test.tsindex 7bbb107a2..5f0c2e8bc 100644--- a/plugins/web-ui/test/split-tiles-and-titles.test.ts+++ b/plugins/web-ui/test/split-tiles-and-titles.test.ts@@ -1,32 +1,15 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { dropAddsTile, MAX_PANES, MAX_TILES, serializedTileCount, v1PaneSeeds } from "../src/split-layout.ts";-const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");-const split = readFileSync(new URL("../src/split.ts", import.meta.url), "utf8");-const leaf = (views: string[]): object => ({ type: "leaf", data: { views, activeView: views[0], id: "g" } });const branch = (...kids: object[]): object => ({ type: "branch", data: kids });test("the tile cap counts tiles and turns the overflow into a tab", () => {- assert.match(split, /dockApi\.groups\.length >= MAX_TILES/);- assert.doesNotMatch(split, /panels\.length >= MAX_TILES/, "the tile cap must count tiles, not conversations");- assert.doesNotMatch(split, /limit reached/i, "a full grid must not refuse the conversation");- const tabInto = split.match(/^function tabIntoPane\([\s\S]*?\n\}/m)?.[0] ?? "";- assert.ok(tabInto, "tabIntoPane not found");- assert.doesNotMatch(tabInto, /MAX_TILES/, "tabs are what the tile cap overflows into — the tile cap cannot bind");- assert.match(tabInto, /roomForAnotherPane\(\)/, "but the resource ceiling must");- const splitFn = split.match(/^function splitPane\([\s\S]*?\n\}/m)?.[0] ?? "";- assert.ok(splitFn, "splitPane not found");- assert.match(splitFn, /roomForAnotherPane\(\)/, "and it must bind splits too, not only tabs");- assert.match(split, /function roomForAnotherPane\(\): boolean \{[\s\S]*?panels\.length \?\? 0\) < MAX_PANES/);assert.ok(MAX_PANES >= MAX_TILES, "the conversation ceiling must allow every tile to be used");});test("a revived canvas is bounded by both caps and cannot blow the stack", () => {- assert.match(split, /if \(n < 1 \|\| n > MAX_PANES \|\| serializedTileCount\(o\.layout\) > MAX_TILES\) return;/);-const tiles = (...kids: object[]): object => ({ grid: { root: branch(...kids) } });assert.equal(serializedTileCount(tiles(leaf(["a", "b", "c"]), leaf(["d"]))), 2, "tabs are not tiles");assert.equal(serializedTileCount(tiles(branch(leaf(["a"]), leaf(["b"])), branch(leaf(["c"]), leaf(["d"])))), 4);@@ -47,10 +30,6 @@ test("a revived canvas is bounded by both caps and cannot blow the stack", () =>});test("only the native drops that would add a tile are refused", () => {- assert.match(split, /api\.onWillDrop\(holdTileCap\);/);- assert.match(split, /group\.model\.onWillDrop\(holdTileCap\);/);- assert.match(split, /dropAddsTile\(nativeDrop\(api, e\)\)/);-assert.equal(dropAddsTile({ edge: true, wholeTile: false, sourceTilePanes: 2 }), true, "a tab out of a shared tile");assert.equal(dropAddsTile({ edge: false, wholeTile: false, sourceTilePanes: 2 }), false, "joining a tab strip");assert.equal(dropAddsTile({ edge: true, wholeTile: true, sourceTilePanes: 1 }), false, "a whole tile only moves");@@ -60,102 +39,4 @@ test("only the native drops that would add a tile are refused", () => {"the last pane out of a tile takes that tile with it",);assert.equal(dropAddsTile({ edge: true, wholeTile: false, sourceTilePanes: 0 }), true, "an unrecognized drag");-- assert.match(split, /from\.panelId === null && !from\.tabGroupId/);-});--test("only strip tabs redraw, and only strip tabs can close a pane", () => {- assert.match(split, /this\.inStrip = p\.tabLocation === "header";/);- assert.match(split, /if \(this\.inStrip\) paneTabs\.add\(this\);/);- const draw = split.match(/^ {2}draw\(\): void \{[\s\S]*?\n {2}\}/m)?.[0] ?? "";- assert.ok(draw, "PaneTab.draw not found");- const gate = draw.indexOf("this.inStrip");- const close = draw.indexOf("split-tab-close");- assert.ok(gate >= 0 && close > gate, "the close button must render behind the inStrip gate");-});--test("a pane title ellipsizes rather than being clipped or wrapped", () => {- const tab = css.match(/\.dockview-theme-qm \.dv-tab \{[^}]*\}/)?.[0] ?? "";- assert.match(tab, /flex-shrink: 1;/);- assert.match(tab, /min-width: 0;/);- assert.match(css, /\.split-pane-title-text \{[^}]*text-overflow: ellipsis;[^}]*white-space: nowrap;/);- assert.match(css, /\.split-pane-title \{[^}]*min-width: 0;/);-});--test("the active tab keeps a higher floor than its neighbours and runs down onto the body", () => {- const multi = css.match(/:not\(\.dv-single-tab\) \.dv-tab \{[^}]*\}/)?.[0] ?? "";- assert.match(multi, /flex: 0 1 auto;/);- assert.match(multi, /min-width: 72px;/);- assert.match(multi, /max-width: 320px;/);- const active = css.match(/:not\(\.dv-single-tab\) \.dv-tab\.dv-active-tab \{[^}]*\}/)?.[0] ?? "";- assert.match(active, /flex: 0 1 auto;/);- assert.match(active, /min-width: 150px;/);- assert.match(active, /align-self: stretch;/);- assert.match(active, /padding-bottom: var\(--split-strip-pad\);/);- assert.match(active, /border-bottom-color: transparent;/);- const strip =- css.match(/^\.dockview-theme-qm \.dv-tabs-and-actions-container:not\(\.dv-single-tab\) \{[^}]*\}/m)?.[0] ?? "";- assert.match(strip, /padding-bottom: 0;/);- assert.match(strip, /border-bottom: 0;/);- assert.match(- strip,- /linear-gradient\(var\(--split-strip-line\), var\(--split-strip-line\)\) bottom \/ 100% 1px no-repeat/,- );-});--test("tab actions sit in the title's flow so the title truncates around them", () => {- const actions = css.match(/^\.split-tab-actions \{[^}]*\}/m)?.[0] ?? "";- assert.doesNotMatch(actions, /position: absolute;|right: 0;|transform:/, "nothing may paint over the title");- assert.match(actions, /flex: 0 0 auto;/);- assert.doesNotMatch(css, /\.split-pane-title:has\(> \.session-status\) \.split-tab-actions/);- assert.match(css, /\.split-pane-title-text \{[^}]*overflow: hidden;/);- assert.match(css, /\.dv-tab \.split-pane-title \{[^}]*flex: 1 1 auto;/);- const draw = split.slice(split.indexOf("class PaneTab"), split.indexOf("class StripDrop"));- assert.equal((draw.match(/class="split-tab-actions"/g) ?? []).length, 2);- assert.equal((draw.match(/split-tab-close/g) ?? []).length, 2, "each tab form carries exactly one close control");-});--test("the tab close control stays at the trailing edge of a wide tab", () => {- const title = css.match(/^\.dv-tab \.split-pane-title-text \{[^}]*\}/m)?.[0] ?? "";- assert.match(title, /flex: 1 1 auto;/);- assert.match(title, /min-width: 0;/);-});--test("the tab overflow menu is lifted above the panes and styled", () => {- const anchor = css.match(/\.dockview-theme-qm \.dv-popover-anchor \{[^}]*\}/)?.[0] ?? "";- assert.ok(Number(anchor.match(/z-index: (\d+);/)?.[1] ?? 0) >= 999, `anchor z-index too low: ${anchor}`);- const menu = css.match(/\.dv-tabs-overflow-container \{[^}]*\}/)?.[0] ?? "";- assert.match(menu, /background: var\(--background\);/);- assert.match(menu, /border: 1px solid var\(--border\);/);-});--// Detached background work belongs to the conversation, so it shows wherever the-// conversation's header does: the sidebar row and — once a pane is stacked behind a tab —-// the tab. Both read one derivation, and the header signature has to move with the count-// or a tab never redraws when the work starts or ends.-test("a pane tab carries the conversation's background chip, from the sidebar's derivation", () => {- const draw = split.match(/^ {2}draw\(\): void \{[\s\S]*?^ {2}\}/m)?.[0] ?? "";- assert.ok(draw, "PaneTab.draw not found");- assert.match(draw, /class="bg-chip"/, "the tab must show the same chip the sidebar row does");- assert.match(split, /function paneBackground\([\s\S]*?conversationBackground\(sessionsState\.list,/);- const signature = split.match(/^function computeHeaderSignature\(\)[\s\S]*?\n\}/m)?.[0] ?? "";- assert.match(signature, /paneBackground\(p\)/, "a change in the count must move the header signature");- // Only the sidebar's chip opens the inspector; the tab's is a mark on a tab that is- // itself the control, so the clickable affordance hangs off the clickable one.- assert.match(css, /\.bg-chip\[role="button"\] \{[^}]*cursor: pointer;/);-});--test("tab actions only fade on hover or keyboard focus, never shifting the title", () => {- const actions = css.match(/^\.split-tab-actions \{[^}]*\}/m)?.[0] ?? "";- assert.match(actions, /transition: opacity 0\.12s ease;/);- assert.match(actions, /opacity: 0;/);- assert.match(actions, /pointer-events: none;/);- const states = [...css.matchAll(/([^{}]*\.split-tab-(?:actions|close)[^{}]*)\{([^{}]*)\}/g)].filter(([, selector]) =>- /:(?:not|hover|focus|focus-within|focus-visible)|\.dv-active-tab/.test(selector),- );- assert.ok(states.length > 0);- for (const [, selector, declarations] of states) {- assert.doesNotMatch(declarations, /(?:width|margin|padding|display|flex|gap)\s*:/, selector);- }- assert.match(css, /\.dv-tab:focus-within \.split-tab-actions \{[^}]*pointer-events: auto;/);});diff --git a/plugins/web-ui/test/suggested-activities-ui.test.ts b/plugins/web-ui/test/suggested-activities-ui.test.tsindex d322a9e9f..2e0596fe7 100644--- a/plugins/web-ui/test/suggested-activities-ui.test.ts+++ b/plugins/web-ui/test/suggested-activities-ui.test.ts@@ -1,5 +1,4 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { JSDOM } from "jsdom";import { createServer } from "vite";@@ -7,22 +6,6 @@ import type { Agent } from "@earendil-works/pi-agent-core";import type { ComposerSurface, ConvCtx } from "../src/conv-types.ts";import type { SuggestedActivity } from "../../chassis/src/suggested-activities.ts";-test("suggested prompts stay in regular docks but move into multiview chat areas", () => {- const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");- const activeChat = chat.slice(chat.indexOf("const emptyChat ="));- const stack = activeChat.slice(activeChat.indexOf('<div class="message-stack'), activeChat.indexOf("</section>"));- const dock = chat.slice(- chat.indexOf('<div class="chat-bottom-dock">'),- chat.indexOf("transcriptViewport.afterRender()"),- );- assert.match(stack, /ctx\.pane \? suggestions : nothing/);- const composerIndex = dock.indexOf("ctx.composer.composerForm(agent)");- const suggestionsIndex = dock.indexOf("ctx.pane ? nothing : suggestions");- assert.notEqual(composerIndex, -1);- assert.notEqual(suggestionsIndex, -1);- assert.ok(composerIndex < suggestionsIndex);-});-test("activity selection fills and persists an editable draft without sending or overwriting work", async () => {const dom = new JSDOM('<!doctype html><div id="app"></div><main></main>', {url: "http://localhost/",diff --git a/plugins/web-ui/test/transcript-viewport.test.ts b/plugins/web-ui/test/transcript-viewport.test.tsindex c09040a89..0c74e1ee7 100644--- a/plugins/web-ui/test/transcript-viewport.test.ts+++ b/plugins/web-ui/test/transcript-viewport.test.ts@@ -1,26 +1,5 @@import assert from "node:assert/strict";import test from "node:test";-import { readFileSync } from "node:fs";--const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");-const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");--test("only an actually stuck prompt gets elevation", () => {- const normal = css.match(/\.message-stack \.user-row\.latest-prompt > \.user-bubble \{[^}]*\}/)?.[0] ?? "";- assert.doesNotMatch(normal, /box-shadow: var/);- assert.match(css, /\.user-row\.stuck > \.user-bubble/);-});--test("prompt offset reserves the pane's measured pins height", () => {- assert.match(css, /top: var\(--chat-sticky-top, 0px\)/);- assert.match(css, /max-height: min\(38cqh, 240px\)/);-});--test("stream following never uses smooth scrolling or a near-bottom zone", () => {- const scroller = css.match(/\.chat-scroll \{[^}]*\}/)?.[0] ?? "";- assert.doesNotMatch(scroller, /scroll-behavior: smooth/);- assert.doesNotMatch(chat, /<= 120/);-});import { JSDOM } from "jsdom";import { createTranscriptViewport, preserveTranscriptScroll } from "../src/transcript-viewport.ts";@@ -493,28 +472,6 @@ test("a prompt stays in flow when pins leave too little room, and can stick agai}});-test("prompt expansion control belongs inside the bubble in both renderers", () => {- for (const [source, start] of [- [chat, /<article\s+class="message-row user-row/],- [readFileSync(new URL("../src/shared-session.ts", import.meta.url), "utf8"), /<article\s+class=\$\{/],- ]) {- const rowStart = (source as string).search(start as RegExp);- assert.ok(rowStart >= 0);- const text = source as string;- const row = text.slice(rowStart, text.indexOf("</article>", rowStart) + "</article>".length);- const dom = new JSDOM(row);- try {- const toggle = dom.window.document.querySelector(".pin-toggle");- assert.equal(toggle?.parentElement?.tagName, "DIV");- assert.equal(toggle?.parentElement?.parentElement?.tagName, "ARTICLE");- } finally {- dom.window.close();- }- }- assert.match(css, /:not\(\.pin-expanded\)\s+\.user-bubble\s+>\s+\.pin-content \{/);- assert.match(css, /\.user-bubble > \.pin-toggle:not\(\[hidden\]\)/);-});-test("nested paste and attachment controls do not toggle the whole prompt", () => {const f = fixture();try {@@ -541,12 +498,6 @@ test("nested paste and attachment controls do not toggle the whole prompt", () =}});-test("plain-text copy confirmation can grow beyond its icon width", () => {- const rule = css.match(/\.user-bubble code-block\[language="text"\] copy-button button \{[^}]*\}/)?.[0] ?? "";- assert.match(rule, /min-width: var\(--meta-lane\)/);- assert.doesNotMatch(rule, /(?:^|[;{])\s*width:/);-});-test("prompt clipping tolerates rounding but discloses any additional text line", () => {const f = fixture();try {@@ -679,10 +630,6 @@ test("passing the previous bottom without reaching the new bottom does not resum}});-test("the changing streamed reply cannot become the browser's native scroll anchor", () => {- assert.match(css, /\.streaming-text\.live-stream \{\s*overflow-anchor: none;/);-});-test("asynchronous growth leaves a reader in place", () => {const f = fixture();try {diff --git a/plugins/web-ui/test/turn-idempotency-key.test.ts b/plugins/web-ui/test/turn-idempotency-key.test.tsindex b743a01b8..e798bf264 100644--- a/plugins/web-ui/test/turn-idempotency-key.test.ts+++ b/plugins/web-ui/test/turn-idempotency-key.test.ts@@ -3,7 +3,6 @@ import { test } from "node:test";import assert from "node:assert/strict";import { createServer, type IncomingMessage } from "node:http";import type { AddressInfo } from "node:net";-import { readFileSync } from "node:fs";const coreTurnBodies: Array<Record<string, unknown>> = [];@@ -80,60 +79,3 @@ test("keys with separator characters are dropped so a send can't collide with anassert.ok(!("idempotencyKey" in turn), `key ${JSON.stringify(bad)} must not forward`);}});--const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");-const bridge = readFileSync(new URL("../src/core-bridge.ts", import.meta.url), "utf8");-const crons = readFileSync(new URL("../src/crons.ts", import.meta.url), "utf8");-const search = readFileSync(new URL("../src/search.ts", import.meta.url), "utf8");--test("every send gesture mints exactly one key, carried on the prompt message so drive re-invocations reuse it", () => {- const at = bridge.indexOf("export function userSendMessage");- assert.ok(at >= 0);- const body = bridge.slice(at, bridge.indexOf("export interface UiStateRecord", at));- assert.match(body, /idempotencyKey: mintSendKey\(\)/);- const send = composer.slice(- composer.indexOf("async function sendPrompt"),- composer.indexOf("const LARGE_PASTE_CHARS"),- );- assert.match(send, /agent\.prompt\(userSendMessage\(text, attachments\.length \? attachments : undefined\)\)/);-});--test("the queue path keys each message and a resend after a failed submit reuses the same key", () => {- const at = composer.indexOf("async function enqueueTurn");- assert.ok(at >= 0);- const body = composer.slice(at, composer.indexOf("async function removeQueued", at));- assert.match(body, /const idempotencyKey = queueSendKey\(threadRef, text, filesKey\);/);- assert.match(body, /failedQueueSend = \{ threadRef, text, filesKey, idempotencyKey \};/);- assert.match(- composer,- /failedQueueSend\?\.threadRef === threadRef &&\s*failedQueueSend\.text === text &&\s*failedQueueSend\.filesKey === filesKey/,- );-});--test("drive forwards the message's key so a duplicate POST of the same gesture dedups in core", () => {- const at = bridge.indexOf("async function drive(");- assert.ok(at >= 0);- const body = bridge.slice(at, bridge.indexOf("async function resumeDrive", at));- assert.match(body, /const \{ text, attachments, idempotencyKey, issues, droppedIds, retryable \} = opener/);- assert.match(body, /turnRequestBody\([\s\S]{0,200}?\{ idempotencyKey, attachments \}\)/);-});--test("latestUserTurn is the send chokepoint: it mints a key for any unkeyed message and writes it back", () => {- const at = bridge.indexOf("async function latestUserTurn");- assert.ok(at >= 0);- const body = bridge.slice(at, bridge.indexOf("function attachmentBytes", at));- assert.match(body, /const idempotencyKey = sendKeyOf\(m\) \?\? mintSendKey\(\);/);- assert.match(body, /m\.idempotencyKey = idempotencyKey;/);-});--test("the pane send paths (crons, search) mint keys like the composer does", () => {- for (const [name, src] of [- ["crons", crons],- ["search", search],- ] as const) {- const prompts = src.match(/agent\?\.prompt\(/g) ?? [];- const keyed = src.match(/agent\?\.prompt\(\s*userSendMessage\(/g) ?? [];- assert.equal(keyed.length, prompts.length, `${name}: every prompt goes through userSendMessage`);- assert.ok(prompts.length > 0, `${name}: has at least one send path`);- }-});diff --git a/plugins/web-ui/test/viewport.test.ts b/plugins/web-ui/test/viewport.test.tsindex 0a7347861..87e6588fe 100644--- a/plugins/web-ui/test/viewport.test.ts+++ b/plugins/web-ui/test/viewport.test.ts@@ -1,5 +1,4 @@import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import test from "node:test";import { JSDOM } from "jsdom";@@ -85,26 +84,3 @@ test("browsers without VisualViewport use the CSS fallback", () => {assert.doesNotThrow(trackVisualViewport);Object.defineProperty(dom.window, "visualViewport", { value: vv, configurable: true });});--test("the phone shell is anchored to the layout viewport rather than document flow", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- const layout = [...css.matchAll(/\.layout \{([^}]+)\}/g)].find((match) => match[1]!.includes("--vvh"))![1]!;- assert.match(css, /@media \(max-width: 860px\), \(hover: none\) and \(pointer: coarse\)/);- assert.match(layout, /position: fixed;/);- assert.match(layout, /inset: 0 0 auto;/);- assert.match(layout, /height: var\(--vvh, 100dvh\);/);- assert.match(layout, /transform: translateY\(var\(--vv-top, 0px\)\);/);-});--test("keyboard sizing includes bannered shells and touch inputs avoid focus zoom", () => {- const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");- assert.match(- css,- /\.layout\.bannered,\s*\.layout\.impersonating \{\s*height: calc\(var\(--vvh, 100dvh\) - 38px - env\(safe-area-inset-top\)\);/,- );- assert.match(css, /\.top-banner,\s*\.impersonation-banner \{\s*transform: translateY\(var\(--vv-top, 0px\)\);/);- assert.match(- css,- /\.composer-input,\s*\.live-work-line \{\s*font-size: max\(16px, var\(--composer-font-size, 16px\)\);/,- );-});diff --git a/plugins/web-ui/test/work-duration-reconciliation.test.ts b/plugins/web-ui/test/work-duration-reconciliation.test.tsindex dd06cfaeb..71b9e6ebf 100644--- a/plugins/web-ui/test/work-duration-reconciliation.test.ts+++ b/plugins/web-ui/test/work-duration-reconciliation.test.ts@@ -1,6 +1,5 @@import { test } from "node:test";import assert from "node:assert/strict";-import { readFileSync } from "node:fs";import { entriesToMessages, type AssistantWork, type SessionEntry, type WorkBlock } from "../src/core-bridge.ts";import { workSeconds, workedLabel } from "../src/work-duration.ts";@@ -133,18 +132,6 @@ test("historical transcripts without persisted timing keep the activity-inferencassert.equal(work?.finishedAt, 130);});-test("live and historical rendering consume the same duration helper (source-level guard)", () => {- const chat = readFileSync(new URL("../src/chat.ts", import.meta.url), "utf8");- assert.match(- chat,- /import \{[^}]*\bworkSeconds, workedLabel \} from "\.\/work-duration"/,- "chat renders via the shared helper",- );-- assert.match(chat, /workedLabel\(work.status === "working" \? "Working" : "Worked", secs\)/);- assert.match(chat, /function workLabel[\s\S]{0,400}?workSeconds\(work\)/);-});-test("live and completed work use compact minute and second labels", () => {for (const prefix of ["Working", "Worked"]) {for (const [seconds, duration] of [diff --git a/src/core/attachments.ts b/src/core/attachments.tsindex 41568c7f4..139cab517 100644--- a/src/core/attachments.ts+++ b/src/core/attachments.ts@@ -24,7 +24,6 @@ import { downscaleVisionImage } from "./image-downscale.ts";import { NoDefaultSandboxError } from "../sandbox/sandbox-routing.ts";export const INBOX_DIR = "inbox";-export const SHARED_DIR = "shared";export const TURN_FILES_DIR = ".agent-turn";export function turnFileId(runId?: string, attempt = 1, now = Date.now()): string {