feat: preserve bounded model requests and complete task history

This commit is contained in:
Agent Workbench Dev
2026-10-29 21:09:50 +08:00
parent 19b738b468
commit 8f32dec6cc
58 changed files with 1269 additions and 108 deletions
+7 -5
View File
@@ -33,7 +33,9 @@ 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.equal(bootstrap.version, '1.4.0'); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
assert.ok(['1.4.0', '1.5.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' : 'context-batch';
const screenshotPrefix = bootstrap.version === '1.4.0' ? '1.4-batch' : 'context-batch';
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({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
@@ -67,7 +69,7 @@ async function viewport(name) {
});
assert.equal(bounds.scrollY, 0); assert.ok(bounds.scrollWidth <= bounds.width + 1 && bounds.scrollHeight <= bounds.height + 1, JSON.stringify(bounds));
if (bounds.modal) assert.ok(bounds.modal.top >= 0 && bounds.modal.bottom <= bounds.height + 1 && bounds.modal.scrollWidth <= bounds.modal.width + 1 && bounds.close.bottom <= bounds.height, JSON.stringify(bounds));
const destination = '.qa/screenshots/1.4-batch-' + name + '.png'; await page.screenshot({ path: destination, scale: 'css' }); screenshots.push(destination);
const destination = '.qa/screenshots/' + screenshotPrefix + '-' + name + '.png'; await page.screenshot({ path: destination, scale: 'css' }); screenshots.push(destination);
}
try {
await page.goto(url, { waitUntil: 'networkidle' });
@@ -126,11 +128,11 @@ try {
await expect(page.locator('.toast')).toHaveCount(0); await expect(dialog()).toHaveCount(0); await expect(page.locator('.session-item.selected')).toContainText('批次验收 normal');
passed.push('A failed batch response after its component unmounts cannot display an error in the newly selected project');
assert.equal(pageErrors.length, 0, pageErrors.join('\n')); assert.equal(requestFailures.length, 0, requestFailures.join('\n'));
const result = { success: true, version: '1.4.0', testedAt: new Date().toISOString(), cases: passed, pageErrors, requestFailures, screenshots, projectRoot: root,
const result = { success: true, version: bootstrap.version, testedAt: new Date().toISOString(), cases: passed, pageErrors, requestFailures, screenshots, projectRoot: root,
scope: 'Real independent demo host and durable batch states; UI fixtures include actual owner conflict/rollback results. No real model credentials or user project were used.' };
fs.writeFileSync('docs/m2-batch-ui-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
fs.writeFileSync('docs/' + proofPrefix + '-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.4-batch-failure.png', scale: 'css' }); fs.writeFileSync('.qa/batch-ui-failure.json', JSON.stringify({ passed, message: error.message, pageErrors, requestFailures }, null, 2)); throw error;
await page.screenshot({ path: '.qa/screenshots/' + screenshotPrefix + '-failure.png', scale: 'css' }); fs.writeFileSync('.qa/' + proofPrefix + '-ui-failure.json', JSON.stringify({ passed, message: error.message, pageErrors, requestFailures }, null, 2)); throw error;
} finally {
await browser.close(); try { await api('/shutdown', {}); await wait(() => child.exitCode !== null); } catch { if (child.exitCode === null) child.kill(); }
}