From 7db17aaf99b19999da9184bbb7db1e623e803c9b Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 01:38:32 +0000 Subject: [PATCH 01/11] test(web): gate composer send, thread switch and app mount at 400 ms Adds a latency vitest browser project run on production React, timed from the input event to the frame after the UI shows the result, median of five samples. Composer send is gated. Thread switch and mount to an open thread are measured and reported but not gated yet because they currently miss the budget. ARC CI installs headless Chromium unprivileged and runs the gate. Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/closura-arc-ci.yml | 21 ++++ apps/web/package.json | 1 + apps/web/test/app.latency.tsx | 157 +++++++++++++++++++++++++++ apps/web/test/interactionLatency.ts | 87 +++++++++++++++ apps/web/vite.config.ts | 16 +++ 5 files changed, 282 insertions(+) create mode 100644 apps/web/test/app.latency.tsx create mode 100644 apps/web/test/interactionLatency.ts diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 6ab8a3312e27c..c1de6341ec743 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -186,6 +186,27 @@ jobs: apps/server/src/ws.test.ts \ packages/contracts/src/environment.test.ts + - name: Gate interaction latency at 400 ms + shell: bash + working-directory: apps/web + run: | + set -euo pipefail + export PLAYWRIGHT_BROWSERS_PATH="$RUNNER_TEMP/ms-playwright" + vp exec playwright install --only-shell chromium + missing=$(vp exec playwright install-deps --dry-run chromium 2>&1 \ + | sed -n 's/^ \([a-z0-9][a-z0-9.+-]*\)$/\1/p' | grep -Ev '^x?fonts-' || true) + if test -n "$missing"; then + apt_dir="$RUNNER_TEMP/chromium-apt" + mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/debs" "$apt_dir/root" + apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1 -o "APT::Sandbox::User=$(id -un)") + apt-get "${apt_options[@]}" update -qq + closure=$(apt-get "${apt_options[@]}" install -s --no-install-recommends $missing | awk '/^Inst /{print $2}') + (cd "$apt_dir/debs" && apt-get "${apt_options[@]}" download $closure) + for deb in "$apt_dir"/debs/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done + export LD_LIBRARY_PATH="$apt_dir/root/usr/lib/x86_64-linux-gnu:$apt_dir/root/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + fi + vp run test:latency + - name: Test mobile new-task placement, outbox and uploads shell: bash working-directory: apps/mobile diff --git a/apps/web/package.json b/apps/web/package.json index fd3aca76ad247..3483675e7d67e 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -11,6 +11,7 @@ "i18n:generate": "gt generate", "preview": "vp preview", "test": "vp test run --passWithNoTests --project unit --project browser", + "test:latency": "NODE_ENV=production vp test run --project latency", "i18n:translate": "gt translate" }, "dependencies": { diff --git a/apps/web/test/app.latency.tsx b/apps/web/test/app.latency.tsx new file mode 100644 index 0000000000000..33d7f07ab66a8 --- /dev/null +++ b/apps/web/test/app.latency.tsx @@ -0,0 +1,157 @@ +import { createMemoryHistory } from "@tanstack/react-router"; +import type { ThreadId } from "@t3tools/contracts"; +import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; +import type * as Context from "effect/Context"; +import { expect, it, vi } from "vite-plus/test"; +import { page, userEvent } from "vite-plus/test/browser"; + +import "~/index.css"; +import "~/components/ChatView"; + +import * as React from "react"; +import { createRoot } from "react-dom/client"; + +import { AppRoot } from "~/AppRoot"; +import { __setClientSettingsForTests } from "~/hooks/useSettings"; +import { getRouter, type AppRouter } from "~/router"; +import { + ENVIRONMENT_ID, + installFakeEnvironment, + threadWithHistory, + type FakeDriver, +} from "./fakeEnvironment"; +import { expectWithinBudget, settle, timeInteraction } from "./interactionLatency"; + +vi.mock("../../../packages/client-runtime/src/connection/driver.ts", async (importOriginal) => { + const [actual, { fakeDriver }, Layer] = await Promise.all([ + importOriginal<{ readonly ConnectionDriver: Context.Key }>(), + import("./fakeEnvironment"), + import("effect/Layer"), + ]); + return { ...actual, layer: Layer.succeed(actual.ConnectionDriver, fakeDriver) }; +}); + +vi.mock(import("~/rpc/requestLatencyState"), async (original) => ({ + ...(await original()), + trackRpcRequestSent: () => {}, +})); + +const HISTORY_TURNS = 20; +const SWITCH = ["latency-a", "latency-b"].map((name) => threadWithHistory(name, HISTORY_TURNS)); +const SEND = [0, 1, 2, 3, 4].map((index) => + threadWithHistory(`latency-send-${index}`, HISTORY_TURNS), +); +const [A, B] = SWITCH.map((thread) => thread.id) as [ThreadId, ThreadId]; + +installFakeEnvironment([...SWITCH, ...SEND], { acceptCommands: true }); +await page.viewport(1400, 900); +__setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + onboardingCompletedAt: "2026-01-01T00:00:00.000Z", +}); + +const threadPath = (threadId: ThreadId) => `/${ENVIRONMENT_ID}/${threadId}`; +const lastAnswer = (threadId: ThreadId) => `Answer ${HISTORY_TURNS - 1} for ${threadId}.`; +const bodyText = () => document.body.textContent ?? ""; +const occurrences = (text: string, needle: string) => text.split(needle).length - 1; +const composerEditor = () => document.querySelector('[data-testid="composer-editor"]'); + +async function mountApp(path: string) { + const router = getRouter(createMemoryHistory({ initialEntries: [path] })); + await router.load(); + const container = document.createElement("div"); + container.style.cssText = "height: 900px; width: 1400px;"; + document.body.append(container); + const root = createRoot(container); + root.render(); + return { + router, + [Symbol.dispose]() { + root.unmount(); + container.remove(); + }, + }; +} + +const threadOpen = (router: AppRouter, threadId: ThreadId) => () => + router.state.location.pathname === threadPath(threadId) && + bodyText().includes(lastAnswer(threadId)) && + composerEditor() !== null; + +async function openThread(threadId: ThreadId) { + const app = await mountApp(threadPath(threadId)); + await expect.element(page.getByText(lastAnswer(threadId))).toBeVisible(); + await settle(); + return app; +} + +const goToThread = (router: AppRouter, threadId: ThreadId) => + router.navigate({ + to: "/$environmentId/$threadId", + params: { environmentId: ENVIRONMENT_ID, threadId }, + }); + +it("warm up on production React", async () => { + expect( + React.act, + "run through `vp run test:latency`, which sets NODE_ENV=production", + ).toBeUndefined(); + using _app = await openThread(A); + await document.fonts.ready; + await settle(); +}); + +it("app launch: mounting the app shows the open thread and its composer", async () => { + await expectWithinBudget( + "app launch (mount to an open thread)", + async () => { + let app: Awaited> | undefined; + const elapsed = await timeInteraction( + async () => { + app = await mountApp(threadPath(B)); + }, + () => app !== undefined && threadOpen(app.router, B)(), + { from: "call" }, + ); + app?.[Symbol.dispose](); + return elapsed; + }, + { knownOverBudget: true }, + ); +}); + +it("thread switch: clicking a sidebar row shows that thread", async () => { + using app = await openThread(A); + await expectWithinBudget( + "thread switch", + async (index) => { + const target = index % 2 === 0 ? B : A; + await settle(); + return timeInteraction( + () => userEvent.click(page.getByText(`Thread ${target}`, { exact: true }).first()), + threadOpen(app.router, target), + ); + }, + { knownOverBudget: true }, + ); +}); + +it("composer send: Enter puts the message in the thread", async () => { + using app = await openThread(SEND[0]!.id); + await expectWithinBudget("composer send", async (index) => { + const thread = SEND[index]!.id; + await goToThread(app.router, thread); + await expect.element(page.getByText(lastAnswer(thread))).toBeVisible(); + const prompt = `latency prompt ${index}`; + const editor = page.getByTestId("composer-editor"); + await userEvent.click(editor); + await userEvent.keyboard(prompt); + await expect.element(editor).toHaveTextContent(prompt); + await settle(); + return timeInteraction( + () => userEvent.keyboard("{Enter}"), + () => + occurrences(bodyText(), prompt) > occurrences(composerEditor()?.textContent ?? "", prompt), + ); + }); +}); diff --git a/apps/web/test/interactionLatency.ts b/apps/web/test/interactionLatency.ts new file mode 100644 index 0000000000000..5142305a65cbb --- /dev/null +++ b/apps/web/test/interactionLatency.ts @@ -0,0 +1,87 @@ +import { expect } from "vite-plus/test"; + +export const INTERACTION_BUDGET_MS = 400; +const SAMPLES = 5; +const QUIET_MS = 150; +const INPUT_EVENTS = ["pointerdown", "keydown"] as const; + +const nextFrame = () => + new Promise((resolve) => requestAnimationFrame(() => resolve(performance.now()))); + +export async function settle(): Promise { + await new Promise((resolve) => { + let timer = setTimeout(done, QUIET_MS); + const observer = new MutationObserver(() => { + clearTimeout(timer); + timer = setTimeout(done, QUIET_MS); + }); + function done() { + observer.disconnect(); + resolve(); + } + observer.observe(document.body, { + subtree: true, + childList: true, + characterData: true, + attributes: true, + }); + }); + await nextFrame(); +} + +export async function timeInteraction( + action: () => Promise, + isDone: () => boolean, + { from = "input" }: { readonly from?: "input" | "call" } = {}, +): Promise { + let start: number | null = from === "call" ? performance.now() : null; + const onInput = (event: Event) => { + start ??= event.timeStamp; + }; + let finish!: (at: number) => void; + const finished = new Promise((resolve) => { + finish = resolve; + }); + let seen = false; + const check = () => { + if (seen || start === null || !isDone()) return; + seen = true; + void nextFrame().then(finish); + }; + const observer = new MutationObserver(check); + for (const type of INPUT_EVENTS) window.addEventListener(type, onInput, { capture: true }); + observer.observe(document.body, { + subtree: true, + childList: true, + characterData: true, + attributes: true, + }); + try { + await action(); + check(); + const end = await finished; + return end - (start ?? end); + } finally { + observer.disconnect(); + for (const type of INPUT_EVENTS) window.removeEventListener(type, onInput, { capture: true }); + } +} + +export async function expectWithinBudget( + interaction: string, + sample: (index: number) => Promise, + { knownOverBudget = false }: { readonly knownOverBudget?: boolean } = {}, +): Promise { + const samples: number[] = []; + for (let index = 0; index < SAMPLES; index++) samples.push(await sample(index)); + const median = samples.toSorted((a, b) => a - b)[Math.floor(SAMPLES / 2)]!; + const report = `${interaction}: median ${median.toFixed(1)} ms, samples ${samples + .map((value) => value.toFixed(1)) + .join(", ")} ms, budget ${INTERACTION_BUDGET_MS} ms`; + if (knownOverBudget) { + console.warn(`known over budget, not gated: ${report}`); + return; + } + console.info(report); + expect(median, report).toBeLessThanOrEqual(INTERACTION_BUDGET_MS); +} diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index 1a55244ddc9a3..e37a1b3cb3fc0 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -182,6 +182,21 @@ const renderScenariosProject = { }, } satisfies TestProjectInlineConfiguration; +const latencyProject = { + ...browserTestProject, + test: { + ...browserTestProject.test, + name: "latency", + include: ["test/*.latency.tsx", "src/**/*Latency.browser.test.{ts,tsx}"], + hookTimeout: 60_000, + testTimeout: 60_000, + browser: { + ...browserTestProject.test.browser, + instances: [{ browser: "chromium" }], + }, + }, +} satisfies TestProjectInlineConfiguration; + function resolveDevProxyTarget( backendPort: string | undefined, wsUrl: string | undefined, @@ -446,6 +461,7 @@ export default defineConfig(({ command }) => { defineProject(unitTestProject), defineProject(browserTestProject), defineProject(renderScenariosProject), + defineProject(latencyProject), ], }, }; From 6243a9b1ae74760067cadb23577f43b5133cdf3b Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 03:02:02 +0000 Subject: [PATCH 02/11] ci(t3): extract headless Chromium's noble libraries from Playwright's own list The dry-run parse found nothing on the ARC runner, so the gate launched Chromium without libnspr4. The step now resolves Playwright's Ubuntu 24.04 Chromium packages directly and fails with the missing names if ldd still reports any. Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/closura-arc-ci.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index c1de6341ec743..64d424c4e083c 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -193,18 +193,26 @@ jobs: set -euo pipefail export PLAYWRIGHT_BROWSERS_PATH="$RUNNER_TEMP/ms-playwright" vp exec playwright install --only-shell chromium - missing=$(vp exec playwright install-deps --dry-run chromium 2>&1 \ - | sed -n 's/^ \([a-z0-9][a-z0-9.+-]*\)$/\1/p' | grep -Ev '^x?fonts-' || true) - if test -n "$missing"; then - apt_dir="$RUNNER_TEMP/chromium-apt" - mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/debs" "$apt_dir/root" - apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1 -o "APT::Sandbox::User=$(id -un)") - apt-get "${apt_options[@]}" update -qq - closure=$(apt-get "${apt_options[@]}" install -s --no-install-recommends $missing | awk '/^Inst /{print $2}') + shell=$(find "$PLAYWRIGHT_BROWSERS_PATH" -type f -name chrome-headless-shell | head -1) + test -x "$shell" + packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 + libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 + libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) + apt_dir="$RUNNER_TEMP/chromium-apt" + mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/debs" "$apt_dir/root" + apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1 -o "APT::Sandbox::User=$(id -un)") + apt-get "${apt_options[@]}" update -qq + closure=$(apt-get "${apt_options[@]}" install -s --no-install-recommends "${packages[@]}" | awk '/^Inst /{print $2}') + printf 'Chromium libraries to extract: %s\n' "${closure:-none}" + if test -n "$closure"; then (cd "$apt_dir/debs" && apt-get "${apt_options[@]}" download $closure) for deb in "$apt_dir"/debs/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done export LD_LIBRARY_PATH="$apt_dir/root/usr/lib/x86_64-linux-gnu:$apt_dir/root/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" fi + if ldd "$shell" | grep 'not found'; then + echo "::error::Headless Chromium still misses the libraries above." + exit 1 + fi vp run test:latency - name: Test mobile new-task placement, outbox and uploads From 28c83cba57b5d6db26fcc422917d3f58195f2a88 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 03:12:19 +0000 Subject: [PATCH 03/11] test(web): keep the latency budget module-private until another test imports it Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- apps/web/test/interactionLatency.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/test/interactionLatency.ts b/apps/web/test/interactionLatency.ts index 5142305a65cbb..4e8f854661ee1 100644 --- a/apps/web/test/interactionLatency.ts +++ b/apps/web/test/interactionLatency.ts @@ -1,6 +1,6 @@ import { expect } from "vite-plus/test"; -export const INTERACTION_BUDGET_MS = 400; +const INTERACTION_BUDGET_MS = 400; const SAMPLES = 5; const QUIET_MS = 150; const INPUT_EVENTS = ["pointerdown", "keydown"] as const; From 91827a680f9f100926e0598335b3123f45f19e3d Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 03:37:27 +0000 Subject: [PATCH 04/11] test(web): time latency to after paint and gate thread switch Review found the done check ran a full-page text scan on every mutation inside the timed window, the end time was taken before the final paint, a missing input event hung until the test timeout, and the transcribe test name would also run in the dev-React browser project. Each frame now checks once and the end is read in a task after that frame paints; the result must not already show before the input, and an action without input fails at once. Latency tests are named *.latency.ts so only the latency project runs them, and the report goes to stdout through a browser command so CI keeps every sample. Measured on an idle ASUS: composer send about 66 ms and thread switch about 150 ms, both gated now; mount to an open thread about 350 ms, reported but not gated. Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/closura-arc-ci.yml | 5 ++- apps/web/test/app.latency.tsx | 22 +++++------- apps/web/test/interactionLatency.ts | 54 ++++++++++++++-------------- apps/web/vite.config.ts | 8 ++++- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 64d424c4e083c..980719c3b8d60 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -194,7 +194,10 @@ jobs: export PLAYWRIGHT_BROWSERS_PATH="$RUNNER_TEMP/ms-playwright" vp exec playwright install --only-shell chromium shell=$(find "$PLAYWRIGHT_BROWSERS_PATH" -type f -name chrome-headless-shell | head -1) - test -x "$shell" + if ! test -x "$shell"; then + echo "::error::Playwright installed no chrome-headless-shell under $PLAYWRIGHT_BROWSERS_PATH." + exit 1 + fi packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) diff --git a/apps/web/test/app.latency.tsx b/apps/web/test/app.latency.tsx index 33d7f07ab66a8..7cb716ff53a48 100644 --- a/apps/web/test/app.latency.tsx +++ b/apps/web/test/app.latency.tsx @@ -116,24 +116,20 @@ it("app launch: mounting the app shows the open thread and its composer", async app?.[Symbol.dispose](); return elapsed; }, - { knownOverBudget: true }, + { ungated: "about 350 ms on an idle ASUS, too close to the budget for a shared runner" }, ); }); it("thread switch: clicking a sidebar row shows that thread", async () => { using app = await openThread(A); - await expectWithinBudget( - "thread switch", - async (index) => { - const target = index % 2 === 0 ? B : A; - await settle(); - return timeInteraction( - () => userEvent.click(page.getByText(`Thread ${target}`, { exact: true }).first()), - threadOpen(app.router, target), - ); - }, - { knownOverBudget: true }, - ); + await expectWithinBudget("thread switch", async (index) => { + const target = index % 2 === 0 ? B : A; + await settle(); + return timeInteraction( + () => userEvent.click(page.getByText(`Thread ${target}`, { exact: true }).first()), + threadOpen(app.router, target), + ); + }); }); it("composer send: Enter puts the message in the thread", async () => { diff --git a/apps/web/test/interactionLatency.ts b/apps/web/test/interactionLatency.ts index 4e8f854661ee1..614619b3046c2 100644 --- a/apps/web/test/interactionLatency.ts +++ b/apps/web/test/interactionLatency.ts @@ -1,4 +1,11 @@ import { expect } from "vite-plus/test"; +import { commands } from "vite-plus/test/browser"; + +declare module "vite-plus/test/browser" { + interface BrowserCommands { + reportLatency: (line: string) => Promise; + } +} const INTERACTION_BUDGET_MS = 400; const SAMPLES = 5; @@ -34,35 +41,33 @@ export async function timeInteraction( isDone: () => boolean, { from = "input" }: { readonly from?: "input" | "call" } = {}, ): Promise { + expect(isDone(), "the result already shows before the interaction").toBe(false); let start: number | null = from === "call" ? performance.now() : null; const onInput = (event: Event) => { start ??= event.timeStamp; }; - let finish!: (at: number) => void; - const finished = new Promise((resolve) => { - finish = resolve; + let stopped = false; + const painted = new Promise((resolve) => { + const frame = () => { + if (stopped) return; + if (start === null || !isDone()) { + requestAnimationFrame(frame); + return; + } + const channel = new MessageChannel(); + channel.port1.onmessage = () => resolve(performance.now()); + channel.port2.postMessage(null); + }; + requestAnimationFrame(frame); }); - let seen = false; - const check = () => { - if (seen || start === null || !isDone()) return; - seen = true; - void nextFrame().then(finish); - }; - const observer = new MutationObserver(check); for (const type of INPUT_EVENTS) window.addEventListener(type, onInput, { capture: true }); - observer.observe(document.body, { - subtree: true, - childList: true, - characterData: true, - attributes: true, - }); try { await action(); - check(); - const end = await finished; - return end - (start ?? end); + const began = start; + if (began === null) throw new Error("the interaction dispatched no pointerdown or keydown"); + return (await painted) - began; } finally { - observer.disconnect(); + stopped = true; for (const type of INPUT_EVENTS) window.removeEventListener(type, onInput, { capture: true }); } } @@ -70,7 +75,7 @@ export async function timeInteraction( export async function expectWithinBudget( interaction: string, sample: (index: number) => Promise, - { knownOverBudget = false }: { readonly knownOverBudget?: boolean } = {}, + { ungated }: { readonly ungated?: string } = {}, ): Promise { const samples: number[] = []; for (let index = 0; index < SAMPLES; index++) samples.push(await sample(index)); @@ -78,10 +83,7 @@ export async function expectWithinBudget( const report = `${interaction}: median ${median.toFixed(1)} ms, samples ${samples .map((value) => value.toFixed(1)) .join(", ")} ms, budget ${INTERACTION_BUDGET_MS} ms`; - if (knownOverBudget) { - console.warn(`known over budget, not gated: ${report}`); - return; - } - console.info(report); + await commands.reportLatency(ungated ? `not gated, ${ungated}: ${report}` : report); + if (ungated) return; expect(median, report).toBeLessThanOrEqual(INTERACTION_BUDGET_MS); } diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index e37a1b3cb3fc0..176e6c74c9a95 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -187,12 +187,18 @@ const latencyProject = { test: { ...browserTestProject.test, name: "latency", - include: ["test/*.latency.tsx", "src/**/*Latency.browser.test.{ts,tsx}"], + include: ["test/*.latency.tsx", "src/**/*.latency.{ts,tsx}"], hookTimeout: 60_000, testTimeout: 60_000, browser: { ...browserTestProject.test.browser, instances: [{ browser: "chromium" }], + commands: { + ...browserTestProject.test.browser.commands, + reportLatency: async (_context, line: string) => { + process.stdout.write(`${line}\n`); + }, + }, }, }, } satisfies TestProjectInlineConfiguration; From a28920595aba63ba7354bcc0f8dbc1f1eb1a83f4 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 04:49:20 +0000 Subject: [PATCH 05/11] test(web): unmount a thread that fails to open and absorb the cold first mount On the ARC runner the first mount's connection failed transiently and the thread never showed. The mount stayed in the page, so later tests found two copies of every thread. A thread that fails to open now unmounts, and the warm-up's first mount may fail before the measured mounts start. Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- apps/web/test/app.latency.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/test/app.latency.tsx b/apps/web/test/app.latency.tsx index 7cb716ff53a48..25530225e34de 100644 --- a/apps/web/test/app.latency.tsx +++ b/apps/web/test/app.latency.tsx @@ -79,9 +79,11 @@ const threadOpen = (router: AppRouter, threadId: ThreadId) => () => composerEditor() !== null; async function openThread(threadId: ThreadId) { - const app = await mountApp(threadPath(threadId)); + using stack = new DisposableStack(); + const app = stack.use(await mountApp(threadPath(threadId))); await expect.element(page.getByText(lastAnswer(threadId))).toBeVisible(); await settle(); + stack.move(); return app; } @@ -96,6 +98,12 @@ it("warm up on production React", async () => { React.act, "run through `vp run test:latency`, which sets NODE_ENV=production", ).toBeUndefined(); + { + using _cold = await mountApp(threadPath(A)); + await vi + .waitFor(() => expect(bodyText()).toContain(lastAnswer(A)), { timeout: 20_000 }) + .catch(() => undefined); + } using _app = await openThread(A); await document.fonts.ready; await settle(); From 600868e7a9c8c18c929f076310c381a5d6d99f8c Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 05:24:54 +0000 Subject: [PATCH 06/11] ci(t3): give headless Chromium a font on the ARC runner The runner image has no fonts, so text laid out with no size and every visibility wait in the latency gate timed out, while the text-only app launch check passed. The step now extracts DejaVu and fontconfig, points Chromium at them with FONTCONFIG_FILE, and fails early when no font is found. Model: claude-opus-5-5 Task: implementation Agent: Claude Code (CLO-868 feature map lane) Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: df60fa7be83ccc7a8e3c64e3c58ba9ed7a84cfc4 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/closura-arc-ci.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 980719c3b8d60..877bd622f606d 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -200,7 +200,8 @@ jobs: fi packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 - libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) + libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 + libfontconfig1 fonts-dejavu-core) apt_dir="$RUNNER_TEMP/chromium-apt" mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/debs" "$apt_dir/root" apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1 -o "APT::Sandbox::User=$(id -un)") @@ -212,6 +213,16 @@ jobs: for deb in "$apt_dir"/debs/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done export LD_LIBRARY_PATH="$apt_dir/root/usr/lib/x86_64-linux-gnu:$apt_dir/root/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" fi + mkdir -p "$RUNNER_TEMP/fontconfig-cache" + printf '\n/usr/share/fonts%s%s\n' \ + "$apt_dir/root/usr/share/fonts" "$RUNNER_TEMP/fontconfig-cache" > "$RUNNER_TEMP/fonts.conf" + export FONTCONFIG_FILE="$RUNNER_TEMP/fonts.conf" + fonts=$(find /usr/share/fonts "$apt_dir/root/usr/share/fonts" -name '*.ttf' 2>/dev/null | wc -l) + if test "$fonts" -eq 0; then + echo "::error::No fonts for headless Chromium, so text has no size and is never visible." + exit 1 + fi + printf 'Fonts available to Chromium: %s\n' "$fonts" if ldd "$shell" | grep 'not found'; then echo "::error::Headless Chromium still misses the libraries above." exit 1 From 3d4e72b99ed340d11709ba4b13daed4a484a664a Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:05:14 +0000 Subject: [PATCH 07/11] ci(t3): download Chromium's libraries instead of simulating the install The simulation wrote its log where the runner cannot, so the 400 ms latency gate died before running. Download-only is the path the voice gate already uses. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/closura-arc-ci.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 877bd622f606d..438780d8e1d15 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -203,16 +203,12 @@ jobs: libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 libfontconfig1 fonts-dejavu-core) apt_dir="$RUNNER_TEMP/chromium-apt" - mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/debs" "$apt_dir/root" - apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1 -o "APT::Sandbox::User=$(id -un)") + mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" + apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) apt-get "${apt_options[@]}" update -qq - closure=$(apt-get "${apt_options[@]}" install -s --no-install-recommends "${packages[@]}" | awk '/^Inst /{print $2}') - printf 'Chromium libraries to extract: %s\n' "${closure:-none}" - if test -n "$closure"; then - (cd "$apt_dir/debs" && apt-get "${apt_options[@]}" download $closure) - for deb in "$apt_dir"/debs/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done - export LD_LIBRARY_PATH="$apt_dir/root/usr/lib/x86_64-linux-gnu:$apt_dir/root/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - fi + apt-get "${apt_options[@]}" -qq install --download-only --no-install-recommends -y "${packages[@]}" + for deb in "$apt_dir"/cache/archives/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done + export LD_LIBRARY_PATH="$apt_dir/root/usr/lib/x86_64-linux-gnu:$apt_dir/root/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" mkdir -p "$RUNNER_TEMP/fontconfig-cache" printf '\n/usr/share/fonts%s%s\n' \ "$apt_dir/root/usr/share/fonts" "$RUNNER_TEMP/fontconfig-cache" > "$RUNNER_TEMP/fonts.conf" From a0641c2aea2db454a47f9fbedf09b937fb91d03c Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:23:17 +0000 Subject: [PATCH 08/11] ci: stop the latency gate fetching a font package fonts-dejavu-core depends on fonts-dejavu-mono, and resolving that dependency makes apt clean the root archive dir, which this runner cannot write. The library list now matches the voice step that already passes. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/closura-arc-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 438780d8e1d15..ac6698be3e9c8 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -201,7 +201,7 @@ jobs: packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 - libfontconfig1 fonts-dejavu-core) + libfontconfig1) apt_dir="$RUNNER_TEMP/chromium-apt" mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) From 59067a6a6233061bc84b996cd9daf5fd853466fd Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:26:46 +0000 Subject: [PATCH 09/11] ci: drop libfontconfig1 from the latency gate libfontconfig1 depends on fontconfig-config, which depends on fonts-dejavu-core and fonts-dejavu-mono. Resolving those sends apt back to the root archive dir, which this runner cannot write. The package list now matches the voice step that already passes. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/closura-arc-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index ac6698be3e9c8..9300f9dfdfd36 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -200,8 +200,7 @@ jobs: fi packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 - libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 - libfontconfig1) + libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) apt_dir="$RUNNER_TEMP/chromium-apt" mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) From 1810d4e88bf57c65229813a3fc4806ee013a9c31 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:12:12 +0000 Subject: [PATCH 10/11] ci: skip the image apt hooks in the latency gate apt-get update runs APT::Update::Post-Invoke from the runner image, and that hook removes /var/cache/apt/archives/partial/*.deb, which this runner cannot write. Job 136517003866 died there before the 400 ms gate ran. Pointing Dir::Etc::Main and Dir::Etc::Parts at empty files in the runner temp dir drops those hooks while the download still uses the system source lists. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/closura-arc-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 9300f9dfdfd36..9a94c7ad623f4 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -202,8 +202,10 @@ jobs: libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) apt_dir="$RUNNER_TEMP/chromium-apt" - mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" - apt_options=(-o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) + mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" "$apt_dir/conf.d" + : > "$apt_dir/apt.conf" + apt_options=(-o "Dir::Etc::Main=$apt_dir/apt.conf" -o "Dir::Etc::Parts=$apt_dir/conf.d" \ + -o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) apt-get "${apt_options[@]}" update -qq apt-get "${apt_options[@]}" -qq install --download-only --no-install-recommends -y "${packages[@]}" for deb in "$apt_dir"/cache/archives/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done From 1f23ffff63bec9c681bb042b1a8493c752c3f3d0 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:49:24 +0000 Subject: [PATCH 11/11] ci: keep the latency gate off the image apt hooks apt applies -o Dir::Etc only after it has already read /etc/apt/apt.conf.d, so the runner image Post-Invoke still removes /var/cache/apt/archives/partial/*.deb and fails the 400 ms gate. APT_CONFIG is read first. Point it at an empty config under the job temp dir, keep the image dpkg status, and download only the Chromium libraries that image does not already have. Co-Authored-By: Claude Code --- .github/workflows/closura-arc-ci.yml | 48 +++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index 9a94c7ad623f4..f8339ecb831b1 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -201,20 +201,52 @@ jobs: packages=(libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2) + # -o Dir::Etc is applied after apt has already read /etc/apt/apt.conf.d, so the + # image Post-Invoke still runs and its rm of /var/cache/apt/archives/partial fails + # the step. APT_CONFIG is read first, which is what points Dir::Etc away from + # those hooks. Downloads stay under the job temp dir. Status stays the image + # dpkg database, so apt fetches only libraries the image does not already have + # and the extract does not replace the image libc. apt_dir="$RUNNER_TEMP/chromium-apt" - mkdir -p "$apt_dir/lists/partial" "$apt_dir/cache/archives/partial" "$apt_dir/root" "$apt_dir/conf.d" - : > "$apt_dir/apt.conf" - apt_options=(-o "Dir::Etc::Main=$apt_dir/apt.conf" -o "Dir::Etc::Parts=$apt_dir/conf.d" \ - -o "Dir::State::Lists=$apt_dir/lists" -o "Dir::Cache=$apt_dir/cache" -o Debug::NoLocking=1) - apt-get "${apt_options[@]}" update -qq - apt-get "${apt_options[@]}" -qq install --download-only --no-install-recommends -y "${packages[@]}" - for deb in "$apt_dir"/cache/archives/*.deb; do dpkg-deb -x "$deb" "$apt_dir/root"; done + mkdir -p "$apt_dir/etc/apt.conf.d" "$apt_dir/etc/sources.list.d" "$apt_dir/etc/preferences.d" \ + "$apt_dir/lists/partial" "$apt_dir/archives/partial" "$apt_dir/root" + printf '%s\n' \ + 'deb [arch=amd64 signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] https://archive.ubuntu.com/ubuntu noble main universe' \ + 'deb [arch=amd64 signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] https://archive.ubuntu.com/ubuntu noble-updates main universe' \ + 'deb [arch=amd64 signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] https://security.ubuntu.com/ubuntu noble-security main universe' \ + > "$apt_dir/etc/sources.list" + cat > "$apt_dir/apt.conf" <\n/usr/share/fonts%s%s\n' \ "$apt_dir/root/usr/share/fonts" "$RUNNER_TEMP/fontconfig-cache" > "$RUNNER_TEMP/fonts.conf" export FONTCONFIG_FILE="$RUNNER_TEMP/fonts.conf" - fonts=$(find /usr/share/fonts "$apt_dir/root/usr/share/fonts" -name '*.ttf' 2>/dev/null | wc -l) + fonts=0 + for font_dir in /usr/share/fonts "$apt_dir/root/usr/share/fonts"; do + if test -d "$font_dir"; then + fonts=$((fonts + $(find "$font_dir" -name '*.ttf' | wc -l))) + fi + done if test "$fonts" -eq 0; then echo "::error::No fonts for headless Chromium, so text has no size and is never visible." exit 1