From d389b23c99b570c5710e2a67ad7cd46573a48e76 Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Wed, 4 Nov 2026 13:38:08 +0800 Subject: [PATCH] feat(ui): review original-text drafts and explicit task scope --- docs/TASK-AGREEMENT-C.md | 10 +++ findings.md | 2 + progress.md | 2 + scripts/verify-task-agreement-ui.mjs | 117 ++++++++++++++++++++++++++ src/client/RequirementDraftEditor.tsx | 69 +++++++++++++++ src/client/RequirementPanel.css | 9 +- src/client/RequirementPanel.tsx | 36 ++++---- src/client/types.ts | 9 +- task_plan.md | 4 +- 9 files changed, 235 insertions(+), 23 deletions(-) create mode 100644 scripts/verify-task-agreement-ui.mjs create mode 100644 src/client/RequirementDraftEditor.tsx diff --git a/docs/TASK-AGREEMENT-C.md b/docs/TASK-AGREEMENT-C.md index 00be8102..4f53d3b6 100644 --- a/docs/TASK-AGREEMENT-C.md +++ b/docs/TASK-AGREEMENT-C.md @@ -11,3 +11,13 @@ 首相关21项20通过/1失败:新HTTP用例在宿主尚未重建时返回旧“接口不存在”;原日志`.qa/task-agreement/backend-first.tap`保留。重建宿主后原测试/断言不变,21/21通过,含HTTP实际重启复用、跨Task、全来源变化、原工件篡改、截断、范围分类和旧证据保持。复验日志`backend-recheck.tap`,无真实模型请求。 阶段回顾:草案是用户审阅的起点,不是语义提取准确率或自主交付证明。禁止事项的文字记录不代表已经验证遵守,既有文件/检查/Git和审批硬门保持。下一完成实际审阅界面、诊断与报告,独立发行/安装/正式保持与最终证据另验。 + +## 阶段二:原文审阅界面 + +现有任务要求面板增加“从原文整理草案”。用户逐项选择业务要求、参考、禁止或待澄清,明确证据/体验/no-test方式并审阅保存;参考文件不自动填入输出路径。手动编辑与草案共用范围字段;切换用途时清除不适用的旧证据范围。未知继续阻止完成,用户确认与工程复核分别记录。并发保存拒绝旧修订且保留输入,迟到响应不打开其它Task的草案。 + +完整构建通过(`build-ui-recheck.log`),旧要求网页7组通过(`legacy-ui-first.log`);新网页6组与实际沙箱Electron6组通过,结果分别在`.qa/task-agreement/web-4d96bd78-7b95-4f8e-b015-3015365c28d6`及`electron-798aa49a-4438-4693-a65e-7abcbd8cca61`。实际1440/390px截图检查了原文、分类说明、可滚动审阅、保存后分类和并发冲突。页面没有意外横向溢出;390px只是桌面布局适配,不增加手机写权限。所有夹具hasKey=false、独立端口/数据,模型请求0,正式未触碰。 + +首网页末项因验收器先解除route再释放请求而失败;先等待原拦截处理结束再解除,保留原断言,复验6/6。实际Electron首轮隐藏窗口截图超时,改用既有showInactive后第二轮通过前4组,但验收器宿主适配未把写入传为POST而409;补齐适配后原6组全部通过。首日志`ui-first.log`、`ui-electron-first.log`、`ui-electron-recheck.log`与相应目录保留;没有重写失败、降低断言或修改正式配置。 + +阶段回顾:真实操作已证明本地草案可取消、审阅、保存、刷新、澄清及隔离迟到响应;不证明自动理解准确率、真实模型自主交付或禁止事项已经履行。下一补诊断原失败绑定和统一当前缺口/下一步,再独立发行及保留状态升级。 diff --git a/findings.md b/findings.md index 1294bf30..921c8bf3 100644 --- a/findings.md +++ b/findings.md @@ -1212,3 +1212,5 @@ Q验收复核:测试必须等待新修订的结果,不能只等待“通过 Q发行复核:源码ZIP独立560输入/22编译完全一致,555跟踪输入之外5份原示例dist经ZIP自身脚本独立重建逐SHA匹配;三载荷新界面各9组、三归档/便携、12实际安装和16+9文件操作通过。正式原生入口首launch窗口未及时返回,随后只读清单发现实际1.24.6,未重复启动。回看后全部原状态再次一致。677755ms操作历史明确出现重复full-manifest与directory-inventory,应单列优化,不移除核验。438份/89228582字节原材料离线通过。 V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。 + +草案阶段:Electron截图需先showInactive;HostController.api使用{method,input},与launchWorkbench的简化api不同。两处验收器错误在新结果修正,原失败保留。参考/边界只记录,unknown仍阻止复核;UI分类变化应清除残留paths等旧字段。恢复时两次已知文件路径不存在,已按实际清单定位,未将其记作验证通过。 diff --git a/progress.md b/progress.md index 405bcca4..c9c7ffa0 100644 --- a/progress.md +++ b/progress.md @@ -1765,3 +1765,5 @@ M最终发行与预检收尾:d62d03f9/20261103112054864的源码ZIP549输入 M最终Git索引核对:证据及manifest共746份/55074620字节,实际暂存blob逐项长度与SHA256全部一致。首cached diff发现原CRLF收据和供应商HTML尾空格,保留全部捕获字节,只补本轮证据属性;不把原字节格式当产品错误,也不改已安装包。 V调用前检查:新增11文件SHA断言首语法检查发现多一个右括号,已修正;此时尚无网络诊断/模型调用。保留首错误,语法检查通过后才冻结契约。 + +1.25草案界面阶段:完整构建、旧网页7组、新网页6组及实际Electron6组通过。首route释放次序/隐藏窗口截图/POST适配失败原日志与目录保留;实际1440/390px截图回看、保存刷新、并发拒绝/输入保留与迟到Task隔离完成。真实模型0,正式1.24.9/原PID36552/Provider保持。下一诊断与报告闭环。 diff --git a/scripts/verify-task-agreement-ui.mjs b/scripts/verify-task-agreement-ui.mjs new file mode 100644 index 00000000..d35992d6 --- /dev/null +++ b/scripts/verify-task-agreement-ui.mjs @@ -0,0 +1,117 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import net from 'node:net'; +import assert from 'node:assert/strict'; +import { randomUUID } from 'node:crypto'; +import { chromium, _electron } from 'playwright'; +import { fixture, launchWorkbench, until } from '../tests/helpers.mjs'; +import { beginPlanTask, completeRead } from '../tests/fixtures/task-plan-fixture.mjs'; +import { HostController } from '../src/core/desktop/host-controller.mjs'; +import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs'; +import { projectEnvironment } from '../src/core/process-environment.mjs'; + +const desktop = process.argv.includes('--desktop'), appRoot = path.resolve(process.env.AGENT_WORKBENCH_QA_APP_ROOT || '.'); +const directory = path.resolve('.qa/task-agreement', (desktop ? 'electron-' : 'web-') + randomUUID()); fs.mkdirSync(directory, { recursive: true }); +const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t); +beginPlanTask(f, '说明当前工程;参考 README.md;禁止修改原说明;后续范围待确认。无需测试。'); +const read = completeRead(f); f.session.title = '草案与范围审阅'; f.store.save(f.session); +const other = f.store.createSession(f.project.id), original = f.session; f.session = other; beginPlanTask(f, '另一独立目标'); other.title = '草案隔离的另一任务'; f.store.save(other); f.session = original; +const originalMessages = structuredClone(f.session.providerMessages); f.store.close(); +const passed = [], screenshots = [], errors = []; let browser, application, controller, host, page, window, result; +const mark = name => { passed.push(name); console.log('PASS ' + name); }; +const panel = () => page.getByLabel('要求与证据', { exact: true }); +const editor = () => page.getByRole('dialog', { name: '审阅原文草案', exact: true }); +async function select(session) { + if (!await page.getByLabel('当前项目').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click(); + await page.getByLabel('当前项目').selectOption(f.project.id); await page.locator('.session-list button').filter({ hasText: session.title }).click(); + if (!await panel().isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); + await until(() => panel().getByRole('button', { name: '从原文整理草案', exact: true }).isEnabled()); +} +async function resize(width, height) { + if (window) { await window.evaluate((win, size) => win.setContentSize(size.width, size.height), { width, height }); await until(() => page.evaluate(w => innerWidth === w, width)); } + else await page.setViewportSize({ width, height }); +} +async function shot(name) { + const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file); + fs.writeFileSync(path.join(directory, name + '.txt'), await page.locator('body').innerText()); +} +try { + if (desktop) { + const socket = net.createServer(); await new Promise(resolve => socket.listen(0, '127.0.0.1', resolve)); const port = socket.address().port; await new Promise(resolve => socket.close(resolve)); + assert.notEqual(port, 4318); controller = new HostController({ appRoot, dataRoot: f.data, port, nodePath: process.execPath, timeoutMs: 60000 }); await controller.start(); + host = { api: (route, input) => controller.api(route, input ? { method: 'POST', input } : {}), bootstrap: await controller.api('/bootstrap') }; + const executable = desktopExecutableIdentity(appRoot).path; + application = await _electron.launch({ executablePath: executable, args: [...(executable.toLowerCase().endsWith('agentworkbench.exe') ? [] : [path.join(appRoot, 'dist-desktop/main.cjs')]), + '--app-root', appRoot, '--data-root', f.data, '--node', process.execPath, '--port', String(port), '--hidden-window'], cwd: appRoot, env: projectEnvironment(), timeout: 60000 }); + page = await application.firstWindow(); window = await application.browserWindow(page); await window.evaluate(win => win.showInactive()); await resize(1440, 1080); + } else { host = await launchWorkbench(t, f.data, {}, { appRoot }); assert.notEqual(new URL(host.url).port, '4318'); browser = await chromium.launch({ channel: 'msedge', headless: true }); page = await browser.newPage({ viewport: { width: 1440, height: 1080 } }); await page.goto(host.url); } + page.on('pageerror', error => errors.push(error.message)); assert.equal(host.bootstrap.config.hasKey, false); + await page.locator('.connection.connected').waitFor(); await select(f.session); + await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor(); + assert.equal(await editor().getByLabel('草案1 内容用途', { exact: true }).inputValue(), 'unknown'); + assert.equal(await editor().getByRole('button', { name: '审阅并保存', exact: true }).isEnabled(), false); + await editor().getByRole('button', { name: '取消', exact: true }).click(); + assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).configured, false); + mark('generated and cancelled draft stays unconfigured, unresolved and independent of model history'); + await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor(); + const roles = ['requirement', 'reference', 'prohibition', 'unknown', 'requirement']; + for (const [i, role] of roles.entries()) await editor().getByLabel(`草案${i + 1} 内容用途`, { exact: true }).selectOption(role); + await editor().getByLabel('草案1 要求证据类别', { exact: true }).selectOption('results'); + assert.equal(await editor().getByLabel('草案1 要求文件范围', { exact: true }).inputValue(), ''); + await editor().getByLabel('草案1 要求证据类别', { exact: true }).selectOption('analysis'); + await editor().getByLabel('草案5 要求复核方式', { exact: true }).selectOption('not_requested'); + await shot('desktop-draft'); await resize(390, 844); + await editor().getByLabel('草案2 内容用途', { exact: true }).scrollIntoViewIfNeeded(); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true); await shot('narrow-draft'); + await editor().getByRole('checkbox').check(); await editor().getByRole('button', { name: '审阅并保存', exact: true }).click(); await editor().waitFor({ state: 'hidden' }); + await until(async () => await panel().locator('.requirement-list > li').count() === 5); + assert.deepEqual(await panel().locator('.requirement-state').allTextContents(), ['待复核', '参考已记录', '边界已记录', '范围待澄清', '按约定未执行']); + mark('reviewed classification preserves reference, boundary, unknown and no-test semantics without inferring file paths'); + await resize(1440, 1080); await page.reload(); await page.locator('.connection.connected').waitFor(); await select(f.session); + const rows = panel().locator('.requirement-list > li'); await rows.nth(0).getByRole('combobox').selectOption(read.id); + await rows.nth(0).getByRole('button', { name: '复核所选证据', exact: true }).click(); await until(async () => (await rows.nth(0).locator('.requirement-state').textContent()) === '所选证据已核对'); + assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).all_resolved, false); + mark('refresh restores saved scope, original read is separately verified and unknown still blocks resolution'); + await rows.nth(3).getByRole('button', { name: '修订此要求', exact: true }).click(); + const manual = page.getByRole('dialog', { name: '记录用户要求', exact: true }); + await manual.getByLabel('内容用途', { exact: true }).selectOption('requirement'); + await manual.getByLabel('要求复核方式', { exact: true }).selectOption('user'); + await manual.getByLabel('要求验收条件', { exact: true }).fill('用户实际体验后确认说明范围'); + await manual.getByRole('button', { name: '保存要求', exact: true }).click(); await manual.waitFor({ state: 'hidden' }); + await rows.nth(3).getByRole('textbox').fill('实际阅读了当前说明,确认范围符合本次原目标。'); + await rows.nth(3).getByRole('button', { name: '记录用户确认', exact: true }).click(); + await until(async () => (await rows.nth(3).locator('.requirement-state').textContent()) === '用户已确认'); + assert.equal((await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId)).all_resolved, true); + await panel().scrollIntoViewIfNeeded(); await shot('desktop-reviewed'); + mark('explicit clarification and actual user confirmation resolve only the selected revision'); + await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await editor().waitFor(); + const externalView = await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId); + const clean = row => ({ key: row.key, role: row.role, title: row.title, criterion: row.criterion, method: row.method, kind: row.kind, + source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end }, + ...(row.method === 'scope' ? {} : row.kind === 'analysis' ? { tools: row.tools } : { checks: row.checks }) }); + const externalRows = externalView.items.map(clean); externalRows[0].criterion += '(另一窗口追加)'; + await host.api('/sessions/' + f.session.id + '/requirements', { taskId: f.session.taskId, runId: f.session.runId, expected_revision: externalView.revision, requirements: externalRows }); + await editor().getByRole('checkbox').check(); await editor().getByRole('button', { name: '审阅并保存', exact: true }).click(); + await until(async () => /修订|旧来源/.test(await page.locator('body').innerText())); + assert.equal(await editor().isVisible(), true); await shot('desktop-stale-draft'); await editor().getByRole('button', { name: '取消', exact: true }).click(); + mark('concurrent revision rejects stale draft while preserving its review fields and original ledger'); + let release, finished, held = false; const handled = new Promise(resolve => { finished = resolve; }); + await page.route('**/requirement-drafts', async route => { + held = true; await new Promise(resolve => { release = resolve; }); + try { await route.continue(); } catch (error) { errors.push(error.message); } finally { finished(); } + }); + await panel().getByRole('button', { name: '从原文整理草案', exact: true }).click(); await until(() => held); await select(other); release(); await handled; await page.unroute('**/requirement-drafts'); + await until(async () => /尚未逐项记录/.test(await panel().textContent())); assert.equal(await editor().count(), 0); + mark('late draft response does not open a modal or overwrite another selected Task'); + assert.deepEqual(errors, []); + const exported = await host.api('/sessions/' + f.session.id + '/export'); assert.deepEqual(exported.session.providerMessages, originalMessages); + fs.writeFileSync(path.join(directory, 'session.json'), JSON.stringify(exported, null, 2)); + result = { success: true, version: host.bootstrap.version, appRoot, actualElectron: desktop, passed, screenshots, errors, realModelRequests: 0, officialServiceTouched: false }; +} catch (error) { + if (page) { await page.screenshot({ path: path.join(directory, 'failure.png') }).catch(() => {}); fs.writeFileSync(path.join(directory, 'failure.txt'), await page.locator('body').innerText().catch(() => 'Unavailable')); } + result = { success: false, passed, screenshots, errors, error: error.stack, realModelRequests: 0 }; +} finally { + if (application) await application.close(); if (browser) await browser.close(); if (controller && await controller.health()) await controller.stop(); + for (const dispose of disposers.reverse()) await dispose(); fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2)); +} +console.log(JSON.stringify({ directory, ...result })); if (!result.success) process.exitCode = 1; diff --git a/src/client/RequirementDraftEditor.tsx b/src/client/RequirementDraftEditor.tsx new file mode 100644 index 00000000..b405af4f --- /dev/null +++ b/src/client/RequirementDraftEditor.tsx @@ -0,0 +1,69 @@ +import { useState } from 'react'; +import { Modal } from './components'; +import type { RequirementDraft, RequirementItem, RequirementView, TaskPlanStep } from './types'; + +export const requirementRoles = { requirement: '业务要求', reference: '参考资料', prohibition: '禁止事项', unknown: '待澄清' }; +const kinds: Record = { analysis: '研究与读取', changes: '已应用改动', results: '当前文件', checks: '工程检查', browser: '页面断言' }; +export const requirementInput = (row: RequirementItem) => ({ key: row.key, title: row.title, criterion: row.criterion, + ...(row.role ? { role: row.role } : {}), kind: row.kind, method: row.method, + source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end }, + ...(row.method === 'scope' ? {} : row.kind === 'analysis' ? { tools: row.tools } : ['changes', 'results'].includes(row.kind) ? { paths: row.paths } + : row.kind === 'checks' ? { checks: row.checks } : { viewport_width: row.viewport_width, actions: row.actions }) }); +const evidenceScope = (kind: TaskPlanStep['kind']) => kind === 'analysis' ? { tools: ['read_file'] } : ['changes', 'results'].includes(kind) + ? { paths: [] } : kind === 'checks' ? { checks: ['test', 'build'] } : { viewport_width: 1280, actions: ['assert_visible'] }; +export function changeRequirementRole(row: RequirementItem, role: NonNullable): RequirementItem { + const { tools, paths, checks, actions, viewport_width, ...base } = row; + return role === 'requirement' ? { ...base, role, method: 'evidence', kind: 'analysis', tools: ['read_file'] } + : { ...base, role, kind: 'analysis', method: 'scope' }; +} +export function RequirementScopeFields({ row, change, prefix = '' }: { row: RequirementItem; change: (row: RequirementItem) => void; prefix?: string }) { + const updateKind = (kind: TaskPlanStep['kind']) => { + const { tools, paths, checks, actions, viewport_width, ...base } = row; + change({ ...base, kind, ...evidenceScope(kind) }); + }; + return <> + + {row.method === 'scope' ?

{row.role === 'unknown' ? '尚未确定用途,保存后仍阻止要求复核完成。' : row.role === 'reference' ? '只记录参考用途,不要求修改此文件,也不计为交付成果。' : '保留用户边界供执行和复核使用;记录边界不等于已证明遵守。既有操作审批仍保留。'}

: <> + + {row.method === 'evidence' && <> + {['results', 'changes'].includes(row.kind) &&