feat: ship isolated workspace review and navigation in 1.6.0

This commit is contained in:
Agent Workbench Dev
2026-10-29 23:45:32 +08:00
parent 7d9bfb85da
commit bb48f69f25
39 changed files with 841 additions and 35 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
if (!fs.existsSync(originalScript) || !fs.existsSync(upgradeScript) || !fs.existsSync(path.join(next, 'dist-client', 'index.html'))) throw new Error('Upgrade bundles are incomplete.');
if (!Number.isInteger(pid) || pid < 1 || pid === process.pid) throw new Error('Invalid target process.');
const before = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (before.sessions.some(session => ['running', 'awaiting_approval', 'stopping'].includes(session.status))) throw new Error('Wait for existing tasks and approvals before upgrading.');
let protocol, socket, enabledHere = false, paused = false;
const breakpoints = [];
+74
View File
@@ -0,0 +1,74 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import { gitEnvironment } from '../src/core/git-process.mjs';
import { randomUUID } from 'node:crypto';
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
assert.equal(version, '1.6.0', 'Review evidence paths when introducing the next release.');
const prefix = 'workspaces', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
const cases = [
['verify-ui.mjs', '.qa/ui-validation.json'], ['verify-diagnostics-ui.mjs', '.qa/diagnostics-ui-validation.json'],
['verify-execution-ui.mjs', '.qa/execution-ui-validation.json'], ['verify-delivery-ui.mjs', '.qa/delivery-ui-validation.json'],
['verify-index-ui.mjs', '.qa/index-ui-result.json'], ['verify-change-sets-ui.mjs', 'docs/workspaces-batch-ui-validation.json'],
['verify-context-ui.mjs', '.qa/workspaces-context-ui-validation.json'], ['verify-workspaces-ui.mjs', 'docs/workspaces-ui-validation.json'],
];
fs.mkdirSync('.qa', { recursive: true });
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
async function startHost(script) {
const data = path.resolve('.qa', 'ui-host-' + script.replace('.mjs', '') + '-' + randomUUID());
fs.mkdirSync(data, { recursive: true });
const child = spawn(process.execPath, ['dist-server/server.mjs'], { cwd: process.cwd(), env: { ...gitEnvironment(),
AGENT_WORKBENCH_APP_DIR: process.cwd(), AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: '0' }, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
let url = '', output = '', errors = '';
child.stdout.on('data', bytes => { output += bytes.toString('utf8'); for (const line of output.split('\n')) { try { const value = JSON.parse(line); if (value.ready) url = value.url; } catch {} } });
child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
const deadline = Date.now() + 10000;
while (!url && child.exitCode === null && Date.now() < deadline) await new Promise(resolve => setTimeout(resolve, 30));
if (!url) { child.kill(); throw new Error('Independent UI host failed: ' + errors); }
const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
assert.equal(bootstrap.version, version); assert.equal(bootstrap.config.hasKey, false); assert.equal(bootstrap.config.mode, 'demo');
return { url, data, async close() {
try {
await fetch(url + '/api/shutdown', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' }, body: '{}' });
const stopDeadline = Date.now() + 10000;
while (child.exitCode === null && child.signalCode === null && Date.now() < stopDeadline) await new Promise(resolve => setTimeout(resolve, 30));
} finally { if (child.exitCode === null && child.signalCode === null) child.kill(); }
} };
}
for (const [script, proof] of cases) {
console.log('UI regression: ' + script); const started = Date.now(), log = `.qa/${prefix}-${script.replace('.mjs', '')}.log`;
const stream = fs.createWriteStream(log);
let host;
try {
if (externalHost.has(script)) host = await startHost(script);
await new Promise((resolve, reject) => {
const child = spawn(process.execPath, [path.join('scripts', script)], { cwd: process.cwd(), env: { ...gitEnvironment(), ...(host ? { AGENT_WORKBENCH_URL: host.url } : {}) }, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
let tail = ''; const capture = bytes => { stream.write(bytes); tail = (tail + bytes.toString('utf8')).slice(-10000); };
child.stdout.on('data', capture); child.stderr.on('data', capture);
const timer = setTimeout(() => child.kill(), 240000);
child.once('error', error => { clearTimeout(timer); reject(error); });
child.once('close', code => { clearTimeout(timer); code === 0 ? resolve() : reject(new Error(script + ' failed (' + code + '): ' + tail)); });
});
stream.end(); const evidence = JSON.parse(fs.readFileSync(proof, 'utf8'));
assert.notEqual(evidence.success, false); if (evidence.version) assert.equal(evidence.version, version);
const passed = evidence.passed ?? evidence.cases;
assert.ok(Array.isArray(passed) && passed.length > 0);
const errors = evidence.pageErrors ?? [], failures = evidence.requestFailures ?? [];
assert.equal(errors.length, 0); assert.equal(failures.length, 0);
const saved = script === 'verify-ui.mjs' ? `docs/${prefix}-basic-ui-validation.json`
: script === 'verify-workspaces-ui.mjs' ? proof
: `docs/${prefix}-${script.replace('verify-', '').replace('.mjs', '')}-validation.json`;
if (path.resolve(saved) !== path.resolve(proof)) fs.copyFileSync(proof, saved);
results.push({ script, success: true, groups: passed.length, durationMs: Date.now() - started, evidence: saved, log });
console.log('PASS ' + script + ': ' + passed.length + ' groups');
} catch (error) {
stream.end(); fs.writeFileSync(resultFile, JSON.stringify({ success: false, version, at: new Date().toISOString(), results, error: error.message, script, log }, null, 2) + '\n');
throw error;
} finally { await host?.close(); }
}
const result = { success: true, version, at: new Date().toISOString(), groups: results.reduce((sum, item) => sum + item.groups, 0), results,
scope: 'Every verifier owns an independent port and synthetic data directory. Synthetic provider fixtures verify protocols; configured-model acceptance is separate. No production service or real key read/copied.' };
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2) + '\n');
fs.copyFileSync(resultFile, 'docs/' + prefix + '-all-ui-validation.json'); console.log(JSON.stringify(result, null, 2));
+2 -2
View File
@@ -33,8 +33,8 @@ child.stdout.on('data', value => { output += value; for (const line of output.sp
child.stderr.on('data', value => { errors += value; });
const wait = async predicate => { const deadline = Date.now() + 15000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('UI fixture timed out: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
await wait(() => url); const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
assert.ok(['1.4.0', '1.5.0', '1.5.1'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : 'context-fix-batch';
assert.ok(['1.4.0', '1.5.0', '1.5.1', '1.6.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : bootstrap.version === '1.5.1' ? 'context-fix-batch' : 'workspaces-batch';
const screenshotPrefix = bootstrap.version === '1.4.0' ? '1.4-batch' : proofPrefix;
const api = async (route, input) => { const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' },
...(input === undefined ? {} : { body: JSON.stringify(input) }) }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
+2 -2
View File
@@ -60,9 +60,9 @@ child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
const until = async predicate => { const deadline = Date.now() + 20000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('Context UI fixture timeout: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
await until(() => url || child.exitCode !== null); assert.ok(url, errors);
const bootstrap = await (await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' } })).json();
assert.ok(['1.5.0', '1.5.1'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
assert.ok(['1.5.0', '1.5.1', '1.6.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' } }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : 'context-fix';
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : 'workspaces-context';
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
const passed = [], pageErrors = [], requestFailures = [], screenshots = [];
page.on('pageerror', error => pageErrors.push(error.message));
+147
View File
@@ -0,0 +1,147 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { spawn } from 'node:child_process';
import { chromium, expect } from 'playwright/test';
import { Store } from '../src/server/store.mjs';
import { WorkspaceManager } from '../src/core/workspaces/git-workspaces.mjs';
import { createDeliveryProject } from '../tests/fixtures/delivery-project.mjs';
import { captureWorkspaceSource, assertWorkspaceSource } from '../tests/fixtures/workspace-project.mjs';
// Every host/project is synthetic and independently owned. Never uses 4318.
const root = path.resolve('.qa', 'workspace-ui-' + randomUUID()), data = path.join(root, 'data');
fs.mkdirSync(root, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
const store = new Store(data), cases = {}, passed = [], pageErrors = [], requestFailures = [], screenshots = [], createPosts = [];
for (const name of ['normal', 'mobile', 'recovery', 'late-success', 'late-failure']) {
const projectRoot = path.join(root, '独立工作区验收-' + name); fs.mkdirSync(projectRoot); fs.writeFileSync(path.join(projectRoot, 'README.md'), '# Workspace UI fixture\n');
const project = store.addProject(projectRoot), session = store.createSession(project.id), f = { root, data, projectRoot, project, session, store };
createDeliveryProject(f); session.title = '工作区验收 ' + name; store.save(session);
const before = captureWorkspaceSource(f); cases[name] = { ...f, before };
if (name === 'recovery') {
const manager = new WorkspaceManager(store, { faultInjector: (phase, record) => {
if (phase === 'git_finished') fs.writeFileSync(path.join(record.root, 'src/add.mjs'), 'Owner registration recovery content\n');
} });
const record = await manager.prepare(session, '创建中断核对'); await (await manager.start(session, record.id, record.fingerprint)).promise;
assert.equal(record.status, 'unknown'); cases[name].record = structuredClone(record);
}
}
const peer = store.createSession(cases.normal.project.id, '同项目其他会话'); store.close();
const env = { ...process.env, AGENT_WORKBENCH_APP_DIR: process.cwd(), AGENT_WORKBENCH_DATA_DIR: data, AGENT_WORKBENCH_PORT: '0' }; delete env.AGENT_WORKBENCH_API_KEY;
const host = spawn(process.execPath, ['dist-server/server.mjs'], { cwd: process.cwd(), env, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
let url = '', output = '', errors = '';
host.stdout.on('data', bytes => { output += bytes.toString('utf8'); for (const line of output.split('\n')) { try { const value = JSON.parse(line); if (value.ready) url = value.url; } catch {} } });
host.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
const wait = async predicate => { const deadline = Date.now() + 30000; while (!(await predicate())) { if (Date.now() > deadline) throw new Error('Workspace UI state timed out: ' + errors); await new Promise(resolve => setTimeout(resolve, 30)); } };
await wait(() => url || host.exitCode !== null); assert.ok(url, errors); assert.notEqual(new URL(url).port, '4318');
const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
assert.equal(bootstrap.config.hasKey, false); assert.equal(bootstrap.config.mode, 'demo');
const api = async (route, input) => {
const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' }, ...(input === undefined ? {} : { body: JSON.stringify(input) }) });
const value = await response.json(); assert.ok(response.ok, value.error); return value;
};
const browser = await chromium.launch({ executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
page.on('pageerror', error => pageErrors.push(error.message));
page.on('requestfailed', request => { if (request.resourceType() !== 'eventsource') requestFailures.push(request.url() + ': ' + request.failure()?.errorText); });
page.on('request', request => { if (request.method() === 'POST' && /\/workspaces\/[^/]+\/create$/.test(new URL(request.url()).pathname)) createPosts.push(new URL(request.url()).pathname); });
const panel = () => page.getByLabel('独立开发工作区', { exact: true });
const review = () => page.getByRole('dialog', { name: '创建独立工作区', exact: true });
const mark = value => { passed.push(value); console.log('PASS ' + value); };
const records = f => api('/sessions/' + f.session.id + '/workspaces');
const latest = async f => (await records(f)).at(-1);
async function choose(name) {
const f = cases[name];
if (!await page.locator('.project-sidebar').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
await page.getByLabel('当前项目', { exact: true }).selectOption(f.project.id);
if (!await page.locator('.session-item.selected').filter({ hasText: f.session.title }).count()) await page.locator('.session-select').filter({ hasText: f.session.title }).click();
if (page.viewportSize().width <= 620 && await page.locator('.project-sidebar').isVisible()) await page.getByRole('button', { name: '收起项目栏', exact: true }).click();
await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); await expect(panel()).toBeVisible(); return f;
}
async function fit(name) {
const size = await page.evaluate(() => {
const modal = document.querySelector('[role="dialog"]'), close = modal?.querySelector('[aria-label="关闭窗口"]');
const rect = modal?.getBoundingClientRect(), closeRect = close?.getBoundingClientRect();
return { width: innerWidth, height: innerHeight, scrollWidth: document.documentElement.scrollWidth, top: rect?.top, bottom: rect?.bottom, left: rect?.left, right: rect?.right, closeBottom: closeRect?.bottom };
});
assert.ok(size.scrollWidth <= size.width + 1, name + ' page horizontal overflow');
if (size.top !== undefined) { assert.ok(size.top >= 0 && size.left >= 0 && size.right <= size.width + 1 && size.bottom <= size.height + 1, name + ' modal bounds'); assert.ok(size.closeBottom <= size.height); }
const file = '.qa/screenshots/1.6-workspace-' + name + '.png'; await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file);
}
try {
await page.goto(url); await page.waitForLoadState('networkidle');
const normal = await choose('normal');
await panel().getByLabel('工作区名称').fill('桌面独立开发'); await panel().getByRole('button', { name: '准备独立工作区', exact: true }).click();
await expect(review()).toBeVisible(); await expect(review()).toContainText('3 项未提交改动'); await review().getByText('查看来源已有改动', { exact: true }).click();
await expect(review()).toContainText('owner-staged.txt'); const planned = await latest(normal); assert.equal(planned.status, 'prepared'); assert.equal(fs.existsSync(planned.root), false);
await fit('review-desktop'); mark('desktop preview seals the committed version and shows existing staged/unstaged/untracked source changes');
await review().getByRole('button', { name: '确认创建工作区', exact: true }).evaluate(button => { button.click(); button.click(); });
await expect(review()).toBeHidden(); await wait(async () => (await latest(normal)).status === 'ready');
await expect(panel()).toContainText('可以开始开发'); assert.equal(createPosts.filter(route => route.includes(planned.id)).length, 1);
assertWorkspaceSource(assert, normal, normal.before, planned.branch); await fit('ready-desktop'); mark('repeated create clicks execute once and preserve the exact source index and owner files');
await panel().getByRole('button', { name: '打开此工作区', exact: true }).click();
await expect(page.getByLabel('当前项目', { exact: true })).toHaveValue(planned.childProjectId); await expect(panel()).toContainText('当前独立分支');
await expect(panel()).toContainText(planned.branch); await panel().getByRole('button', { name: '返回来源会话', exact: true }).click();
await expect(page.getByLabel('当前项目', { exact: true })).toHaveValue(normal.project.id); await expect(panel()).toContainText('桌面独立开发');
await page.reload(); await page.waitForLoadState('networkidle'); await page.getByRole('button', { name: '查看任务记录', exact: true }).click();
await expect(panel()).toContainText('可以开始开发'); mark('opening the child, returning to the source and reloading retain stable project/session identity');
await page.locator('.session-select').filter({ hasText: peer.title }).click(); await expect(panel()).toContainText('转到所属会话');
await panel().getByRole('button', { name: '转到所属会话', exact: true }).click(); await expect(page.locator('.session-item.selected')).toContainText(normal.session.title);
mark('a record owned by another session navigates to that saved owner instead of accepting its actions');
const recovery = await choose('recovery'); await expect(panel()).toContainText('创建结果需要核对');
await panel().getByRole('button', { name: '核对创建结果', exact: true }).click();
await expect(panel().getByRole('button', { name: '核对创建结果', exact: true })).toBeEnabled();
assert.equal((await latest(recovery)).status, 'unknown'); await fit('recovery-desktop');
await panel().getByRole('button', { name: '保留当前外部状态', exact: true }).click();
await page.getByRole('dialog', { name: '保留当前外部状态', exact: true }).getByRole('button', { name: '确认保留当前状态', exact: true }).click();
await expect(panel()).toContainText('已保留外部状态'); assert.equal((await latest(recovery)).status, 'resolved_external');
assert.equal(fs.readFileSync(path.join(recovery.record.root, 'src/add.mjs'), 'utf8'), 'Owner registration recovery content\n');
mark('explicit recovery preserves outside content and acknowledgement does not report successful creation');
await page.setViewportSize({ width: 390, height: 844 }); await expect(page.locator('.project-sidebar')).toBeHidden(); const mobile = await choose('mobile');
await panel().getByLabel('工作区名称').fill('手机审查工作区'); await panel().getByRole('button', { name: '准备独立工作区', exact: true }).click();
await expect(review()).toBeVisible(); await fit('review-mobile');
await review().getByRole('button', { name: '确认创建工作区', exact: true }).click(); await expect(review()).toBeHidden();
await wait(async () => (await latest(mobile)).status === 'ready'); const mobileRecord = await latest(mobile);
await panel().getByRole('button', { name: '打开此工作区', exact: true }).click(); await expect(panel()).toContainText(mobileRecord.branch); await fit('child-mobile');
await panel().getByRole('button', { name: '返回来源会话', exact: true }).click(); await expect(panel()).toContainText('手机审查工作区');
assertWorkspaceSource(assert, mobile, mobile.before, mobileRecord.branch); mark('390×844 preview/create/open/return stays within viewport and preserves source ownership');
await page.setViewportSize({ width: 1440, height: 1000 });
for (const kind of ['late-failure', 'late-success']) {
const f = await choose(kind), pattern = '**/api/sessions/' + f.session.id + '/workspaces';
let release, held, recorded;
const heldPromise = new Promise(resolve => { held = resolve; }), releasePromise = new Promise(resolve => { release = resolve; });
await page.route(pattern, async route => {
if (route.request().method() !== 'POST') return route.continue();
const response = kind === 'late-success' ? await route.fetch() : null;
if (response) recorded = await response.json(); held(); await releasePromise;
if (response) await route.fulfill({ response }); else await route.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ error: 'OLD-SOURCE-ONLY delayed failure' }) });
});
await panel().getByLabel('工作区名称').fill(kind); await panel().getByRole('button', { name: '准备独立工作区', exact: true }).click(); await heldPromise;
await choose('normal'); release(); await page.waitForResponse(response => response.url().endsWith('/sessions/' + f.session.id + '/workspaces') && response.request().method() === 'POST');
await expect(review()).toBeHidden(); await expect(page.locator('.toast').filter({ hasText: 'OLD-SOURCE-ONLY' })).toHaveCount(0);
await expect(page.getByLabel('当前项目', { exact: true })).toHaveValue(normal.project.id);
if (recorded) { assert.equal((await latest(f)).id, recorded.id); assert.equal((await latest(f)).status, 'prepared'); assert.equal(fs.existsSync(recorded.root), false); }
await page.unroute(pattern); mark(kind + ' stays with the original session after project switching');
}
await choose('normal'); let releaseNavigation, heldNavigation;
const navHeld = new Promise(resolve => { heldNavigation = resolve; }), navRelease = new Promise(resolve => { releaseNavigation = resolve; });
await page.route('**/api/bootstrap', async route => { const response = await route.fetch(); heldNavigation(); await navRelease; await route.fulfill({ response }); });
await panel().getByRole('button', { name: '打开此工作区', exact: true }).click(); await navHeld;
await page.locator('.inspector-tabs').getByRole('button', { name: /^文件/ }).click(); releaseNavigation();
await page.waitForResponse(response => response.url().endsWith('/api/bootstrap'));
await expect(page.getByLabel('当前项目', { exact: true })).toHaveValue(normal.project.id); await expect(panel()).toBeHidden();
await page.unroute('**/api/bootstrap'); mark('a delayed bootstrap cannot navigate after the task panel has unmounted');
assert.equal(pageErrors.length, 0, pageErrors.join('\n')); assert.equal(requestFailures.length, 0, requestFailures.join('\n'));
const result = { success: true, version: bootstrap.version, at: new Date().toISOString(), browser: browser.version(), passed, pageErrors, requestFailures, screenshots, projectRoot: root,
scope: 'Independent synthetic Git projects and real browser flows. Desktop/390×844, actual worktree creation, source preservation, explicit external recovery, ownership navigation, delayed success/error/navigation. No production service or real model credential used.' };
fs.writeFileSync('docs/workspaces-ui-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
} catch (error) {
await page.screenshot({ path: '.qa/screenshots/1.6-workspace-failure.png', scale: 'css' });
fs.writeFileSync('.qa/workspaces-ui-failure.json', JSON.stringify({ success: false, message: error.message, passed, pageErrors, requestFailures }, null, 2)); throw error;
} finally {
await browser.close(); try { await api('/shutdown', {}); await wait(() => host.exitCode !== null); } catch { if (host.exitCode === null) host.kill(); }
}