Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
perf(ui): type-check browser suites beside Playwright and lint on worker threads (#3026)
Call Whiteb29ea067e6c9
diff --git a/ui/package.json b/ui/package.jsonindex 116ead1c3..c0cf60af3 100644--- a/ui/package.json+++ b/ui/package.json@@ -19,23 +19,23 @@"test:crypto": "vitest run src/lib/vaultCrypto.test.ts","e2e": "playwright test","e2e:headed": "playwright test --headed",- "test:chat-interactions": "tsc -p e2e/chat-interactions/tsconfig.json --noEmit && playwright test --config playwright.chat-interactions.config.ts",- "test:chat-paging": "tsc -p e2e/chat-paging/tsconfig.json --noEmit && playwright test --config playwright.chat-paging.config.ts",- "test:citations": "tsc -p e2e/citations/tsconfig.json --noEmit && playwright test --config playwright.citations.config.ts",- "test:chat-selection": "tsc -p e2e/chat-selection/tsconfig.json --noEmit && playwright test --config playwright.chat-selection.config.ts",- "test:inbox-return": "tsc -p e2e/inbox-return/tsconfig.json --noEmit && playwright test --config playwright.inbox-return.config.ts",- "test:home-media": "tsc -p e2e/home-media/tsconfig.json --noEmit && playwright test --config playwright.home-media.config.ts",- "test:badge-triggers": "tsc -p e2e/badge-triggers/tsconfig.json --noEmit && playwright test --config playwright.badge-triggers.config.ts",- "test:project-order": "tsc -p e2e/project-order/tsconfig.json --noEmit && playwright test --config playwright.project-order.config.ts",- "test:session-dot": "tsc -p e2e/session-dot/tsconfig.json --noEmit && playwright test --config playwright.session-dot.config.ts",- "test:queue-attachments": "tsc -p e2e/queue-attachments/tsconfig.json --noEmit && playwright test --config playwright.queue-attachments.config.ts",- "test:pdf-preview": "tsc -p e2e/pdf-preview/tsconfig.json --noEmit && playwright test --config playwright.pdf-preview.config.ts",- "test:model-catalog": "tsc -p e2e/model-catalog/tsconfig.json --noEmit && playwright test --config playwright.model-catalog.config.ts",- "test:model-provider": "tsc -p e2e/model-provider/tsconfig.json --noEmit && playwright test --config playwright.model-provider.config.ts",- "test:onboarding-fidelity": "tsc -p e2e/onboarding-fidelity/tsconfig.json --noEmit && playwright test --config playwright.onboarding-fidelity.config.ts",- "test:workbench-general": "tsc -p e2e/workbench-general/tsconfig.json --noEmit && playwright test --config playwright.workbench-general.config.ts",- "test:workbench-general-build": "tsc -p e2e/workbench-general/tsconfig.json --noEmit && playwright test --config playwright.workbench-general-build.config.ts",- "test:voice-shortcut": "tsc -p e2e/voice-shortcut/tsconfig.json --noEmit && playwright test --config playwright.voice-shortcut.config.ts",+ "test:chat-interactions": "node scripts/e2e-suite.mjs e2e/chat-interactions/tsconfig.json playwright.chat-interactions.config.ts",+ "test:chat-paging": "node scripts/e2e-suite.mjs e2e/chat-paging/tsconfig.json playwright.chat-paging.config.ts",+ "test:citations": "node scripts/e2e-suite.mjs e2e/citations/tsconfig.json playwright.citations.config.ts",+ "test:chat-selection": "node scripts/e2e-suite.mjs e2e/chat-selection/tsconfig.json playwright.chat-selection.config.ts",+ "test:inbox-return": "node scripts/e2e-suite.mjs e2e/inbox-return/tsconfig.json playwright.inbox-return.config.ts",+ "test:home-media": "node scripts/e2e-suite.mjs e2e/home-media/tsconfig.json playwright.home-media.config.ts",+ "test:badge-triggers": "node scripts/e2e-suite.mjs e2e/badge-triggers/tsconfig.json playwright.badge-triggers.config.ts",+ "test:project-order": "node scripts/e2e-suite.mjs e2e/project-order/tsconfig.json playwright.project-order.config.ts",+ "test:session-dot": "node scripts/e2e-suite.mjs e2e/session-dot/tsconfig.json playwright.session-dot.config.ts",+ "test:queue-attachments": "node scripts/e2e-suite.mjs e2e/queue-attachments/tsconfig.json playwright.queue-attachments.config.ts",+ "test:pdf-preview": "node scripts/e2e-suite.mjs e2e/pdf-preview/tsconfig.json playwright.pdf-preview.config.ts",+ "test:model-catalog": "node scripts/e2e-suite.mjs e2e/model-catalog/tsconfig.json playwright.model-catalog.config.ts",+ "test:model-provider": "node scripts/e2e-suite.mjs e2e/model-provider/tsconfig.json playwright.model-provider.config.ts",+ "test:onboarding-fidelity": "node scripts/e2e-suite.mjs e2e/onboarding-fidelity/tsconfig.json playwright.onboarding-fidelity.config.ts",+ "test:workbench-general": "node scripts/e2e-suite.mjs e2e/workbench-general/tsconfig.json playwright.workbench-general.config.ts",+ "test:workbench-general-build": "node scripts/e2e-suite.mjs e2e/workbench-general/tsconfig.json playwright.workbench-general-build.config.ts",+ "test:voice-shortcut": "node scripts/e2e-suite.mjs e2e/voice-shortcut/tsconfig.json playwright.voice-shortcut.config.ts","test:pet-mini": "playwright test --config playwright.pet-mini.config.ts","validate:catalog": "node scripts/validate-scenario-catalog.mjs","validate:theme": "node scripts/validate-theme.mjs"diff --git a/ui/scripts/e2e-suite.mjs b/ui/scripts/e2e-suite.mjsnew file mode 100644index 000000000..56e6e9b2c--- /dev/null+++ b/ui/scripts/e2e-suite.mjs@@ -0,0 +1,76 @@+// Runs one Playwright suite and its TypeScript check side by side.+//+// node scripts/e2e-suite.mjs <tsconfig> <playwright config> [playwright args...]+//+// Each `npm run test:<suite>` used to run `tsc -p <tsconfig> --noEmit &&+// playwright test --config <config>`: the browser run waited for a type check it+// shares nothing with. Checking a suite's specs, fixtures and the app sources they+// import takes 20 to 35 seconds on a CI runner, once per suite. Both now start+// together and the suite fails when either one fails, so the same two checks run+// in the time of the longer one.+//+// The type checker runs at a lower scheduling priority. On a four-vCPU runner it+// otherwise slowed the first browser cases by 10 to 13 seconds per suite. Those+// cases compile the app in the dev server at the same time.+//+// Playwright's output streams as it runs. The type checker's is held and printed+// once both have finished, so the two never interleave. Arguments after the config+// go to Playwright, as `npm run test:<suite> -- <spec files>` did before.+import { spawn } from 'node:child_process';+import { createRequire } from 'node:module';+import os from 'node:os';++const require = createRequire(import.meta.url);+const [tsconfig, config, ...forwarded] = process.argv.slice(2);+if (!tsconfig || !config) {+ console.error('usage: node scripts/e2e-suite.mjs <tsconfig> <playwright config> [playwright args...]');+ process.exit(2);+}++const children = new Set();+for (const signal of ['SIGINT', 'SIGTERM']) {+ process.on(signal, () => {+ for (const child of children) child.kill(signal);+ });+}++function run(script, args, { capture, background = false }) {+ return new Promise((resolve) => {+ const child = spawn(process.execPath, [script, ...args], {+ stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',+ });+ children.add(child);+ if (background && child.pid !== undefined) {+ try {+ os.setPriority(child.pid, 10);+ } catch {+ // Only scheduling is lost; the check itself still runs.+ }+ }+ let output = '';+ if (capture) {+ child.stdout.on('data', (chunk) => (output += chunk));+ child.stderr.on('data', (chunk) => (output += chunk));+ }+ child.on('error', (error) => {+ children.delete(child);+ resolve({ code: 1, output: `${output}${error.message}\n` });+ });+ child.on('close', (code) => {+ children.delete(child);+ resolve({ code: code ?? 1, output });+ });+ });+}++const [typecheck, suite] = await Promise.all([+ run(require.resolve('typescript/bin/tsc'), ['-p', tsconfig, '--noEmit'], { capture: true, background: true }),+ run(require.resolve('@playwright/test/cli'), ['test', '--config', config, ...forwarded], { capture: false }),+]);++if (typecheck.code === 0) {+ console.log(`tsc -p ${tsconfig}: no type errors`);+} else {+ console.error(`\ntsc -p ${tsconfig} failed:\n${typecheck.output}`);+}+process.exitCode = suite.code || typecheck.code;diff --git a/ui/scripts/e2e-suite.test.mjs b/ui/scripts/e2e-suite.test.mjsnew file mode 100644index 000000000..c8f997399--- /dev/null+++ b/ui/scripts/e2e-suite.test.mjs@@ -0,0 +1,52 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { spawnSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { afterAll, describe, expect, it } from 'vitest';++const RUNNER = fileURLToPath(new URL('./e2e-suite.mjs', import.meta.url));+const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'e2e-suite-'));+afterAll(() => fs.rmSync(directory, { recursive: true, force: true }));++const write = (name, value) => {+ fs.writeFileSync(path.join(directory, name), value);+ return path.join(directory, name);+};+const project = (name, source) => {+ write(`${name}.ts`, source);+ return write(`${name}.tsconfig.json`, JSON.stringify({ compilerOptions: { strict: true, noEmit: true }, files: [`${name}.ts`] }));+};+const broken = project('broken', "export const count: number = 'one';\n");+const clean = project('clean', 'export const count: number = 1;\n');+// No spec files: `--list --pass-with-no-tests` makes Playwright succeed without a browser,+// and only when the runner forwards the arguments after the config.+const emptySuite = write('empty.config.mjs', 'export default { testDir: "." };\n');+const listOnly = ['--list', '--pass-with-no-tests'];++function suite(...args) {+ const result = spawnSync(process.execPath, [RUNNER, ...args], { encoding: 'utf8', timeout: 30000 });+ if (result.error) throw result.error;+ return { status: result.status, output: `${result.stdout}\n${result.stderr}` };+}++// The type check now runs beside the browser run instead of gating it, so its+// verdict reaches the exit code only through the runner.+describe('one browser suite and its type check', () => {+ it('fails on a type error even when every browser case passes, and prints the error', () => {+ const result = suite(broken, emptySuite, ...listOnly);+ expect(result.output).toContain('Total: 0 tests in 0 files');+ expect(result.output).toContain("Type 'string' is not assignable to type 'number'");+ expect(result.status).not.toBe(0);+ });++ it('fails when the browser run fails even though the types check', () => {+ const result = suite(clean, path.join(directory, 'missing.config.mjs'), ...listOnly);+ expect(result.output).toContain('no type errors');+ expect(result.status).not.toBe(0);+ });++ it('passes only when both pass', () => {+ expect(suite(clean, emptySuite, ...listOnly).status).toBe(0);+ });+});diff --git a/ui/scripts/lint-baseline.mjs b/ui/scripts/lint-baseline.mjsindex 50207c4b3..a1bf732e4 100644--- a/ui/scripts/lint-baseline.mjs+++ b/ui/scripts/lint-baseline.mjs@@ -276,7 +276,10 @@ async function measureIntegrity(eslint, results) {async function main() {const update = process.argv.includes('--update');- const eslint = new ESLint();+ // `auto` lints in worker threads when there are enough files to pay for them+ // (ESLint's own heuristic: about one worker per 50 files, at most half the+ // cores). The results are the same as a single-threaded run's.+ const eslint = new ESLint({ concurrency: 'auto' });const results = await eslint.lintFiles(['.']);// Unconditional, and first: an incomplete or bypassed measurement can neither