From ebd605f9ee1dac4b5ba16b3849601cee81500a8c Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Fri, 6 Nov 2026 10:07:59 +0800 Subject: [PATCH] fix(models): unify connection editing and remove demo entry points --- AGENTS.md | 2 + CHANGELOG.md | 6 + docs/QA-UNIFIED-MODELS-1.25.7.md | 28 +++++ package-lock.json | 4 +- package.json | 2 +- scripts/verify-open-formal-ui.mjs | 13 ++- scripts/verify-unified-model-ui.mjs | 119 ++++++++++++++++++++ src/client/App.tsx | 55 ++------- src/client/ModelCenter.tsx | 52 +++++---- src/client/ModelWaitSettings.tsx | 2 +- src/core/models/model-hub.mjs | 32 ++++-- src/server/diagnostics.mjs | 2 +- tests/model-connection-unification.test.mjs | 68 +++++++++++ 13 files changed, 293 insertions(+), 92 deletions(-) create mode 100644 docs/QA-UNIFIED-MODELS-1.25.7.md create mode 100644 scripts/verify-unified-model-ui.mjs create mode 100644 tests/model-connection-unification.test.mjs diff --git a/AGENTS.md b/AGENTS.md index 6f6775e8..71655a66 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Agent Workbench项目执行规范 +1.25.7源码已统一模型连接:删除独立旧设置窗口和用户可选的离线演示,空占位不显示;既有连接按实际型号或保存名使用同一编辑/参数/启停契约,保留内部ID/凭据/当前模型池,历史原证据不改。构建、相关72/72、最终网页与实际Electron各5组通过;不可变发行/正式升级尚待,当前正式仍1.25.6/PID71628。见docs/QA-UNIFIED-MODELS-1.25.7.md;不委派/推送/触真实Key或续跑原项目,真实模型/网络/重复读取/缓存/预留/Purge未知保留。 + 1.25.6已正式交付:程序2a6554cd/候选20261106013126073,保留PID71628及原instance/Provider,85项目105会话全部原行/导出/工件/公开模型中心exact,9229关闭、空闲/窗口0。默认透传下逐型号只读展示上游最大上下文/输出,缺失时本地无限制;当前DeepSeek未存目录容量,不借手填旧值。源码发布独立于项目数据,原有证据不重打包;源码工具3494ae7a修正Git换行导出身份,1063项ZIP核对及711输入重建22/22通过,最终程序网页/Electron各4组、正式两端通过;首同名连接定位失败已保留并修正验证器。来源/阶段验证与历史失败见docs/QA-SOURCE-CAPACITY-1.25.6.md、docs/source-capacity-1.25.6-release-identity.json;不委派/推送,不触Key或续跑原项目,真实模型/网络/重复读取/缓存/预留/Purge未知保持。下文旧版说明按历史时点理解。 用户已澄清旧“等待审查/继续原任务”两张图来自1.25.4,不能代作1.25.5失败。1.25.5新图确实仍显示连接容量16000/2048;透传wire已不使用这些值,本轮1.25.6仅修正连接列表/编辑器/原连接的实际策略显示,并拆开源码发布与程序发布。源码导出不读服务/用户数据,不把正式数据对账当打包前置;npm run package:source为已提交Git源码,package/app默认只程序,历史证据需显式--with-evidence,原件不动。构建第二轮/相关25及网页11已过,Electron/独立包/实际升级仍待,不称已部署。见docs/QA-SOURCE-CAPACITY-1.25.6.md及docs/PACKAGING.md;下文1.25.5交付状态保持历史时点。 diff --git a/CHANGELOG.md b/CHANGELOG.md index 47881a5b..1b26de16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Agent Workbench 更新记录 +## 1.25.7 + +- 移除模型中心、主对话与侧栏的离线演示入口,以及独立的旧连接设置窗口;未配置时直接选择或获取上游模型,不再执行演示脚本。 +- 既有有效连接按实际型号或保存的名称显示,使用统一编辑、推理与能力、停用及选模流程;保留所属连接身份和凭据。编辑连接不再强制切换当前模型池。 +- 保留逐型号上游最大容量与默认无限制透传;空占位连接不再出现在列表、模型目录、模型池或凭据选择中。历史演示记录及真实失败仍保留原证据。 + ## 1.25.6 - 默认透传时,模型连接列表、编辑器与原连接设置统一显示“由上游决定”,不再把旧 16000/2048 等非活动容量声明显示成请求上限。逐型号只读显示上游目录声明的最大上下文/最大输出,缺失时显示本地无限制,由上游决定。 diff --git a/docs/QA-UNIFIED-MODELS-1.25.7.md b/docs/QA-UNIFIED-MODELS-1.25.7.md new file mode 100644 index 00000000..be989501 --- /dev/null +++ b/docs/QA-UNIFIED-MODELS-1.25.7.md @@ -0,0 +1,28 @@ +# 1.25.7:统一模型入口,移除旧连接与演示界面 + +状态:源码与相关72/72回归、最终实际网页/Electron各5组验证完成,准备冻结不可变程序。正式服务仍为1.25.6,不把源码修改当作已经部署。 + +用户截图指出,模型中心卡片的“原模型连接 → 编辑”会关闭模型中心,转到另一套早期“原连接与演示设置”。它含有离线演示切换、旧品牌预设、重复模型列表和独立预算表单,视觉与配置流程均与当前模型中心不一致。 + +本次集中修正: + +- 删除旧设置窗口、表单状态、获取/检测处理器和跳转回调,所有有效连接使用模型中心已有编辑器。 +- 移除默认模型选择、主对话、侧栏和欢迎页的演示入口。未配置模型时发送会打开模型中心,保留任务输入,不执行演示工具或发送请求。 +- 不再显示未配置过的占位连接;已有配置按实际型号显示,可保存连接名称。普通连接、既有连接共用保存/过期校验/停用/推理参数契约;保存不切换当前模型池,凭据留空仍保留。 +- 既有连接内部ID与凭据所属关系保持,修改时原子保存元数据及配置;协议可使用相同的Chat、Responses、Messages适配。旧Run及请求账本不回写,历史演示仍如实标识未调用模型。测试夹具使用的内部固定脚本不向普通用户提供选择入口。 +- 上游容量只读展示、完整透传、操作权限与Git回滚沿用1.25.6;并发0显示“不限”。源码发布继续独立于项目数据。 + +验证与原始记录: + +- 首构建与最终构建通过,日志`.qa/model-unification-build.txt`及`model-unification-build-final.txt`。 +- 新增3个关键回归通过:既有连接编辑/重新打开持久保存且不切换模型池;Responses原生推理/身份参数实际发送且保留原凭据、无输出上限;配置提交失败完整回滚元数据、配置和凭据。 +- 新增用例首轮1/3、第二轮2/3,均为验收夹具错误:受限夹具被断言为允许0并发、错误配置档ID,以及Responses的字符串status误当HTTP状态。原日志分别为`.qa/model-unification-tests-first-failure.txt`和`model-unification-tests-second-failure.txt`,修正后3/3,不改写原记录。 +- 首实际网页5组与真实Electron5组通过,均覆盖1440/390、无模型空状态、输入保留、统一窗口、保存及刷新、过期错误恢复、保留选中的模型池与启停。原结果在`.qa/model-unification/web-7d3b3688-263d-48f0-a3ed-77ed9e5d0288/`及`electron-9f39b4af-3435-4c90-bde9-b78058b0512e/`。追加凭据空状态/并发文案/版本后以最终发行验证为准。 + +回顾:原有连接能兼容旧配置,并不意味着应该继续保留两套面向用户的设置。仅改标题会留下不同的编辑与保存语义;本次同时统一了实际行为,并将只用于历史与夹具的脚本从用户入口移开。 + +最终实现验证:构建通过;连接、目录、路由、原生参数、凭据保存、容量与等待相关72/72通过(`.qa/model-unification-regression.txt`)。最终网页5组及真实Electron5组通过,目录分别为`.qa/model-unification/web-a0a30be5-7ad4-4d79-bd58-87d2e3666ae4/`及`electron-6b75059c-b1df-4afc-aa01-43bee5025814/`;每端6张原图,1440/390,同窗口、过期错误恢复和刷新保存均实际操作。 + +发行与源码专项18/18通过(`.qa/model-unification-release-tests.txt`),包括版本/安装完整性、操作连续性、并行复制、源码归档及Git换行后的实际ZIP身份。源码与程序来源将在冻结后另行记录。 + +本轮真实供应商请求0;不读取、复制、解密、转存或重存真实Key,不续跑用户项目或旧实验,不推送、不委派。历史真实模型交付、网络异常、普遍重复读取、缓存收益、真实预留边界、Purge AB/BA未验证事项完整保留。没有重跑全产品全量测试,原976轮958/18不因此改签。 diff --git a/package-lock.json b/package-lock.json index 2b94b7a2..57bdbedb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-agent-workbench", - "version": "1.25.6", + "version": "1.25.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "local-agent-workbench", - "version": "1.25.6", + "version": "1.25.7", "dependencies": { "@babel/parser": "7.29.11", "@peculiar/x509": "3.1.0", diff --git a/package.json b/package.json index c8eacfb5..8af7e610 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-agent-workbench", - "version": "1.25.6", + "version": "1.25.7", "private": true, "type": "module", "description": "A local coding workbench with explicit tool execution, reviewable changes and recoverable sessions.", diff --git a/scripts/verify-open-formal-ui.mjs b/scripts/verify-open-formal-ui.mjs index d1892321..be242e6b 100644 --- a/scripts/verify-open-formal-ui.mjs +++ b/scripts/verify-open-formal-ui.mjs @@ -44,13 +44,18 @@ try { const center = await (await fetch(url + '/api/model-center', { headers: { 'X-Workbench-Token': boot.token, Connection: 'close' } })).json(); const connection = center.connections.find(value => value.id === center.selected.id && value.id !== 'legacy-default' && value.enabled) ?? center.connections.find(value => value.id !== 'legacy-default' && value.enabled); - if (connection) { + const existing = center.connections.find(value => value.id === 'legacy-default' && value.model.trim()); + const targets = [...new Map([connection, existing].filter(Boolean).map(value => [value.id, value])).values()]; + await expect(dialog.locator('option[value="demo"]')).toHaveCount(0); + for (const connection of targets) { const cards = dialog.locator('.mc-connections > .mc-connection'); - await expect(cards).toHaveCount(center.connections.length); - const card = cards.nth(center.connections.findIndex(value => value.id === connection.id)); + await expect(cards).toHaveCount(center.connections.filter(value => value.id !== 'legacy-default' || value.model.trim()).length); + const card = dialog.locator('.mc-connections > [data-connection-id="' + connection.id + '"]'); await expect(card.getByRole('heading', { name: connection.name, exact: true })).toBeVisible(); await card.getByRole('button', { name: '编辑', exact: true }).click(); const editor = dialog.getByRole('form', { name: '编辑模型连接', exact: true }); + await expect(page.getByRole('dialog')).toHaveCount(1); + await expect(editor.getByLabel('连接名称', { exact: true })).toHaveValue(connection.name); await expect(editor.getByLabel('上下文上限', { exact: true })).toHaveCount(0); await expect(editor.getByLabel('输出上限', { exact: true })).toHaveCount(0); const upstream = connection.upstreamModel?.id === connection.model ? connection.upstreamModel : {}; @@ -58,7 +63,7 @@ try { await expect(editor.getByLabel(label, { exact: true })).toHaveText(upstream[field] ? Number(upstream[field]).toLocaleString() + ' tokens' : '本地无限制 · 由上游决定'); } await editor.getByLabel('连接容量策略', { exact: true }).scrollIntoViewIfNeeded(); - const capacityFile = path.join(root, 'model-capacity-390.png'); await page.screenshot({ path: capacityFile, fullPage: true }); screenshots.push(capacityFile); + const capacityFile = path.join(root, 'model-capacity-' + connection.id + '-390.png'); await page.screenshot({ path: capacityFile, fullPage: true }); screenshots.push(capacityFile); await editor.getByRole('button', { name: '取消', exact: true }).click(); } await dialog.getByRole('button', { name: '关闭窗口', exact: true }).click(); diff --git a/scripts/verify-unified-model-ui.mjs b/scripts/verify-unified-model-ui.mjs new file mode 100644 index 00000000..97f05a90 --- /dev/null +++ b/scripts/verify-unified-model-ui.mjs @@ -0,0 +1,119 @@ +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 { expect } from 'playwright/test'; +import { fixture, launchWorkbench, until } from '../tests/helpers.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'; + +if (process.argv.includes('--help')) { console.log('node scripts/verify-unified-model-ui.mjs [--desktop] — isolated empty/select/edit/save/stale/pool checks, no real credentials or model requests. AGENT_WORKBENCH_QA_APP_ROOT selects a built app.'); process.exit(0); } +assert.ok(process.argv.slice(2).every(value => value === '--desktop')); +const desktop = process.argv.includes('--desktop'), appRoot = path.resolve(process.env.AGENT_WORKBENCH_QA_APP_ROOT || '.'); +const directory = path.resolve('.qa/model-unification', (desktop ? 'electron-' : 'web-') + randomUUID()); +fs.mkdirSync(directory, { recursive: true }); console.log('EVIDENCE ' + directory); +const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t, { modernDefaults: true }); +f.store.close(); +const marks = [], screenshots = [], errors = [], launches = []; +let host, controller, browser, app, page, window, result; +const dialog = () => page.getByRole('dialog', { name: '模型中心', exact: true }); +const editor = () => dialog().getByRole('form', { name: '编辑模型连接', exact: true }); +const card = () => dialog().locator('[data-connection-id="legacy-default"]'); +const mark = message => { marks.push(message); console.log('PASS ' + message); }; +async function open() { await page.getByRole('button', { name: '打开模型中心', exact: true }).click(); await expect(dialog()).toBeVisible(); } +async function shot(name) { const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, fullPage: true }); screenshots.push(file); } +async function resize(width) { + if (window) { await window.evaluate((win, size) => win.setContentSize(size.width, size.height), { width, height: 1080 }); await until(() => page.evaluate(w => innerWidth === w, width)); } + else await page.setViewportSize({ width, height: 1080 }); + assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), 'page horizontal overflow'); +} +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 === undefined ? {} : { method: 'POST', input }), bootstrap: await controller.api('/bootstrap') }; + const executablePath = desktopExecutableIdentity(appRoot).path; + app = await _electron.launch({ executablePath, args: [...(executablePath.toLowerCase().endsWith('agentworkbench.exe') ? [] : [path.join(appRoot, 'dist-desktop/main.cjs')]), + '--app-root', appRoot, '--data-root', f.data, '--node', process.execPath, '--port', String(port)], env: projectEnvironment({ AGENT_WORKBENCH_QA: '1', AGENT_WORKBENCH_NODE: process.execPath }) }); + page = await app.firstWindow(); window = await app.browserWindow(page); + } 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(); await page.goto(host.url); + } + page.on('pageerror', error => errors.push(error.message)); + page.on('request', request => { if (/\/sessions\/[^/]+\/messages$/.test(request.url())) launches.push(request.url()); }); + await page.waitForLoadState('networkidle'); await resize(1440); + const goal = 'Keep my task text while I select a model.'; + await page.getByLabel('任务内容', { exact: true }).fill(goal); + await page.getByRole('button', { name: '发送任务', exact: true }).click(); + await expect(dialog()).toBeVisible(); await expect(dialog().locator('.mc-connections > .mc-connection')).toHaveCount(0); + await expect(dialog()).toContainText('还没有模型连接'); + await expect(dialog().getByLabel('新任务默认模型', { exact: true })).toHaveValue(''); + await expect(dialog().locator('option[value="demo"]')).toHaveCount(0); + assert.equal(launches.length, 0); assert.doesNotMatch(await page.locator('body').innerText(), /离线演示|原模型连接|原连接与演示设置/); + await shot('empty-1440'); + await dialog().getByRole('button', { name: '关闭窗口', exact: true }).click(); await expect(page.getByLabel('任务内容', { exact: true })).toHaveValue(goal); + mark('unconfigured install has no demo or placeholder connection; send opens model selection without executing or losing the task'); + + await host.api('/config', { ...host.bootstrap.config, mode: 'compatible', model: 'owned-existing-model', baseUrl: 'http://127.0.0.1:9/v1', apiKey: 'owned-ui-credential' }); + await page.reload(); await page.waitForLoadState('networkidle'); await open(); + await expect(card().getByRole('heading', { name: 'owned-existing-model', exact: true })).toBeVisible(); + await card().getByRole('button', { name: '编辑', exact: true }).click(); + await expect(editor()).toBeVisible(); await expect(page.getByRole('dialog')).toHaveCount(1); + await expect(editor().getByLabel('请求模型名称', { exact: true })).toHaveValue('owned-existing-model'); + await expect(editor().getByLabel('上下文上限', { exact: true })).toHaveCount(0); await expect(editor().getByLabel('输出上限', { exact: true })).toHaveCount(0); + await editor().getByLabel('连接名称', { exact: true }).fill('Owned upstream'); + await editor().getByLabel('并发请求数(0 为不限)', { exact: true }).fill('0'); + await shot('unified-editor-1440'); + await editor().getByRole('button', { name: '保存模型连接', exact: true }).click(); await expect(editor()).toHaveCount(0); + let center = await host.api('/model-center'); + assert.equal(center.connections.find(value => value.id === 'legacy-default').name, 'Owned upstream'); + assert.equal(center.connections.find(value => value.id === 'legacy-default').hasKey, true); + assert.equal(center.selected.id, 'legacy-default'); + assert.equal(JSON.stringify(center).includes('owned-ui-credential'), false); + mark('existing connection opens the shared editor in the same modal, saves zero concurrency and retains credential and identity'); + + await card().getByRole('button', { name: '编辑', exact: true }).click(); + await editor().getByLabel('连接名称', { exact: true }).fill('Keep my unsaved edit'); + const current = center.connections.find(value => value.id === 'legacy-default'); + await host.api('/model-center/connections', { ...current, name: 'Externally updated' }); + await editor().getByRole('button', { name: '保存模型连接', exact: true }).click(); + await expect(dialog().getByRole('status')).toContainText('模型连接已修改'); + await expect(editor().getByLabel('连接名称', { exact: true })).toHaveValue('Keep my unsaved edit'); + await editor().getByRole('button', { name: '取消', exact: true }).click(); + await dialog().getByRole('button', { name: '刷新模型中心', exact: true }).click(); + await expect(card()).toContainText('Externally updated'); + mark('stale save shows its actual error and preserves the unsaved draft; cancel and refresh recover the current connection'); + + const other = await host.api('/model-center/connections', { name: 'Owned pool member', model: 'owned-other', baseUrl: 'http://127.0.0.1:9/v1', requiresKey: false }); + const pool = await host.api('/model-center/pools', { name: 'Owned selected pool', members: [{ connectionId: other.id }] }); + await host.api('/model-center/select', { type: 'pool', id: pool.id }); + await dialog().getByRole('button', { name: '刷新模型中心', exact: true }).click(); + await expect(dialog().getByLabel('新任务默认模型', { exact: true })).toHaveValue('pool:' + pool.id); + await card().getByRole('button', { name: '编辑', exact: true }).click(); await editor().getByLabel('连接名称', { exact: true }).fill('Owned final name'); + await editor().getByRole('button', { name: '保存模型连接', exact: true }).click(); await expect(editor()).toHaveCount(0); + assert.equal((await host.api('/model-center')).selected.id, pool.id); + await card().getByRole('button', { name: '停用Owned final name', exact: true }).click(); await expect(card()).toContainText('已停用'); + await card().getByRole('button', { name: '启用Owned final name', exact: true }).click(); await expect(card()).toContainText('已配置'); + assert.equal((await host.api('/model-center')).selected.id, pool.id); + mark('edit and enable/disable behave like every other connection and keep the selected model pool'); + + await dialog().getByRole('button', { name: '关闭窗口', exact: true }).click(); await page.reload(); await page.waitForLoadState('networkidle'); await open(); + await expect(card()).toContainText('Owned final name'); await expect(dialog().getByLabel('新任务默认模型', { exact: true })).toHaveValue('pool:' + pool.id); + for (const width of [1440, 390]) { + await resize(width); await shot('connections-' + width); + await card().getByRole('button', { name: '编辑', exact: true }).click(); await expect(editor()).toBeVisible(); + await editor().getByLabel('连接名称', { exact: true }).scrollIntoViewIfNeeded(); + assert.equal(await page.getByRole('dialog').count(), 1); assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)); + assert.doesNotMatch(await page.locator('body').innerText(), /离线演示|原模型连接|原连接与演示设置/); + await shot('editor-' + width); await editor().getByRole('button', { name: '取消', exact: true }).click(); + } + mark('saved selection and connection survive reload; 1440px and 390px keep one consistent modal and no horizontal overflow'); + assert.deepEqual(errors, []); assert.equal(launches.length, 0); center = await host.api('/model-center'); assert.equal(center.attempts.length, 0); + result = { success: true, desktop, appRoot, marks, screenshots, errors, realModelRequests: 0, totalModelRequests: 0, userProjectsExecuted: 0 }; +} catch (error) { if (page) await shot('failure').catch(() => {}); result = { success: false, desktop, error: error.stack, marks, screenshots, errors }; } +finally { await app?.close(); await browser?.close(); 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/App.tsx b/src/client/App.tsx index 6ea5a72c..ddd17418 100644 --- a/src/client/App.tsx +++ b/src/client/App.tsx @@ -29,7 +29,7 @@ import { PermissionModeControl } from './PermissionModeControl'; const activeStates = ['running', 'awaiting_approval', 'stopping']; const activeMcpStates = ['queued', 'connecting', 'discovering', 'calling', 'closing', 'stopping']; -const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v1', model: '', contextLimit: 128000, maxSteps: 0, maxOutputTokens: 16384, executionMode: 'unrestricted', approvalMode: 'ask', capacityMode: 'passthrough', historyPolicy: 'preserve', hasKey: false, maxRunDurationMs: 0, maxRunTokens: 0, maxTaskTokens: 0, modelResponseTimeoutMs: 0, modelStreamIdleTimeoutMs: 0 }; +const defaultConfig: Config = { mode: 'compatible', baseUrl: 'http://127.0.0.1:11434/v1', model: '', contextLimit: 128000, maxSteps: 0, maxOutputTokens: 16384, executionMode: 'unrestricted', approvalMode: 'ask', capacityMode: 'passthrough', historyPolicy: 'preserve', hasKey: false, maxRunDurationMs: 0, maxRunTokens: 0, maxTaskTokens: 0, modelResponseTimeoutMs: 0, modelStreamIdleTimeoutMs: 0 }; export default function App() { const [token, setAccess] = useState(''); @@ -38,7 +38,6 @@ export default function App() { const [diagnostics, setDiagnostics] = useState(null); const [diagnosticsBusy, setDiagnosticsBusy] = useState(false); const [resuming, setResuming] = useState(false); - const [modelCheck, setModelCheck] = useState<{ kind: 'success' | 'error'; message: string } | null>(null); const [projects, setProjects] = useState([]); const [briefs, setBriefs] = useState([]); const [projectId, setProjectId] = useState(''); @@ -46,7 +45,7 @@ export default function App() { const [session, setSession] = useState(null); const [config, setConfig] = useState(defaultConfig); const [permissionSaving, setPermissionSaving] = useState(false); - const [modelSelection, setModelSelection] = useState({ type: "legacy", id: "legacy-default", name: "原模型连接" }); + const [modelSelection, setModelSelection] = useState({ type: "legacy", id: "legacy-default", name: "选择模型" }); const [exampleId, setExampleId] = useState(null); const [files, setFiles] = useState([]); const [filter, setFilter] = useState(''); @@ -77,12 +76,6 @@ export default function App() { const [viewportWidth,setViewportWidth]=useState(()=>window.innerWidth); const [mobile, setMobile] = useState(() => window.innerWidth <= 620); const [connected, setConnected] = useState(false); - const [settingsOpen, setSettingsOpen] = useState(false); - const [settings, setSettings] = useState(defaultConfig); - const [keyValue, setKeyValue] = useState(''); - const [clearKey, setClearKey] = useState(false); - const [models, setModels] = useState([]); - const [settingsBusy, setSettingsBusy] = useState(false); const [projectOpen, setProjectOpen] = useState(false); const [projectInput, setProjectInput] = useState(''); const [directoryPickerOpen, setDirectoryPickerOpen] = useState(false); @@ -267,7 +260,7 @@ export default function App() { async function submit() { if (!composer.trim() || sending || isRunning || (sessionId && !session)) return; if (restrictedWorker || session?.execution?.collaborations?.some(value => !['completed', 'discarded', 'resolved_external'].includes(value.status))) { setWorkersOpen(true); return; } - if (config.mode === 'compatible' && modelSelection.type === 'legacy' && !config.model) { setModelCenterOpen(true); notify('请先填写模型名称。'); return; } + if (config.mode === 'demo' || modelSelection.type === 'legacy' && !config.model) { setModelCenterOpen(true); notify('请先选择模型,或从上游添加连接。'); return; } setSending(true); const content = composer.trim(); try { @@ -369,24 +362,6 @@ export default function App() { notify('操作权限已保存,后续启动继续使用。'); } catch (error) { failure(error); } finally { setPermissionSaving(false); } } - function openSettings() { setSettings(config); setKeyValue(''); setClearKey(false); setModels([]); setModelCheck(null); setSettingsOpen(true); } - async function saveSettings() { - setSettingsBusy(true); - try { - const payload = { ...settings, ...(keyValue || clearKey ? { apiKey: clearKey ? '' : keyValue } : {}) }; - const saved = await api('/config', payload); setConfig(saved); setModelSelection({ type: "legacy", id: "legacy-default", name: "原模型连接" }); setSettingsOpen(false); - notify(saved.mode === 'demo' ? '已切换到离线演示。' : '模型连接已保存。API Key 仅在本次服务内存中使用。'); - } catch (error) { failure(error); } finally { setSettingsBusy(false); } - } - async function readModels() { - setSettingsBusy(true); - try { - const result = await api<{ models: string[] }>('/config/models', { baseUrl: settings.baseUrl, ...(keyValue || clearKey ? { apiKey: clearKey ? '' : keyValue } : {}) }); - setModels(result.models); - if (!settings.model && result.models[0]) setSettings(previous => ({ ...previous, model: result.models[0] })); - notify('读到 ' + result.models.length + ' 个模型。'); - } catch (error) { failure(error); } finally { setSettingsBusy(false); } - } async function openDiagnostics() { const targetId = sessionId; setDiagnosticsOpen(true); setDiagnosticsBusy(true); @@ -407,15 +382,6 @@ export default function App() { try { acceptSession(await api('/sessions/' + session.id + '/continue-reviewed', {})); } catch (error) { failure(error); } finally { setResuming(false); } } - async function testModel() { - setSettingsBusy(true); setModelCheck(null); - try { - const result = await api<{ ok: boolean; durationMs: number }>('/config/test', { baseUrl: settings.baseUrl, model: settings.model, - ...(keyValue || clearKey ? { apiKey: clearKey ? '' : keyValue } : {}) }); - setModelCheck({ kind: 'success', message: '模型响应验证通过,用时 ' + (result.durationMs / 1000).toFixed(1) + ' 秒。' }); - } catch (error) { setModelCheck({ kind: 'error', message: error instanceof Error ? error.message : String(error) }); } - finally { setSettingsBusy(false); } - } function failureForMessage(message: { id: string; content: string; createdAt: string }): RuntimeFailure | null { if (session?.failure?.messageId === message.id) return session.failure; const recorded = session?.events.filter(event => event.kind === 'error' && event.output === message.content && event.diagnostic).at(-1); @@ -446,7 +412,7 @@ export default function App() { let alive = true; api('/bootstrap').then(result => { if (!alive) return; - setToken(result.token); setAccess(result.token); setVersion(result.version); setProjects(result.projects); setBriefs(result.sessions); setConfig(result.config); if (result.modelSelection) setModelSelection(result.modelSelection); setSettings(result.config); setExampleId(result.exampleProjectId); + setToken(result.token); setAccess(result.token); setVersion(result.version); setProjects(result.projects); setBriefs(result.sessions); setConfig(result.config); if (result.modelSelection) setModelSelection(result.modelSelection); setExampleId(result.exampleProjectId); const savedCursor = Number(sessionStorage.getItem('awb-event-cursor:' + location.origin)); eventCursor.current = Number.isSafeInteger(savedCursor) && savedCursor >= 0 && savedCursor <= (result.eventCursor ?? 0) ? savedCursor : result.eventCursor ?? 0; for (const brief of result.sessions) revisions.current.set(brief.id, brief.revision); @@ -599,11 +565,11 @@ export default function App() { if (file.kind === 'directory') setCollapsed(previous => { const next = new Set(previous); if (next.has(file.path)) next.delete(file.path); else next.add(file.path); return next; }); else loadFile(file.path); }}>{file.kind === 'directory' ? <>{collapsed.has(file.path) ? : } : <>}{filter ? file.path : file.name})}{filter && !visibleFiles.length &&

没有匹配的文件。

} -
{ready ? '本地服务已连接' : '正在连接本地服务'}
+
{ready ? '本地服务已连接' : '正在连接本地服务'}
{(!sidebarOpen || mobile) && setSidebarOpen(true)}>}
{selectedProject?.name || '工作空间'} 任务

{session?.title || '让任务走到完成'}

-
{desktop && }
+
{desktop && }
本地项目{session ? : 等待新任务}
openDiagnostics()}> @@ -620,7 +586,7 @@ export default function App() { {!isRunning && pending.length === 0 && ['failed', 'paused'].includes(session.status) && }}
- {!session?.messages.length && !session?.events.length ?
从项目到结果

读懂项目。
把每一步做好。

给出一个任务,读取依据、工具执行和文件改动会在这里连成完整过程。

{['了解这个项目,并提出一项改进', '查找关键实现,解释调用关系', '检查项目,并准备可审查的修改'].map((prompt, index) => )}
{config.executionMode === 'unrestricted' ? '文件改动直接应用,可查看差异和回滚。命令按所选权限执行。' : '当前使用自定义额度;命令按所选权限执行。'}
{config.mode === 'demo' &&
演示固定脚本会调用真实本地工具,不进行模型推理。
}
:
+ {!session?.messages.length && !session?.events.length ?
从项目到结果

读懂项目。
把每一步做好。

给出一个任务,读取依据、工具执行和文件改动会在这里连成完整过程。

{['了解这个项目,并提出一项改进', '查找关键实现,解释调用关系', '检查项目,并准备可审查的修改'].map((prompt, index) => )}
{config.executionMode === 'unrestricted' ? '文件改动直接应用,可查看差异和回滚。命令按所选权限执行。' : '当前使用自定义额度;命令按所选权限执行。'}
:
{session?.recoveryNotice &&
已恢复会话记录

{session.recoveryNotice}

} {entries.map(entry => 'message' in entry && entry.message ?
{entry.message.role === 'user' ? '你' : entry.message.role === 'assistant' ? 'AW' : '·'}
{entry.message.role === 'user' ? '你的任务' : entry.message.role === 'assistant' ? session?.executionMode === 'demo' ? '演示执行器' : '编程助手' : '工作台'}
{entry.message.role === 'system' && failureForMessage(entry.message) ? openDiagnostics()} onRetry={session?.status === 'failed' && session?.failure?.messageId === entry.message.id ? () => resumeSession() : undefined} busy={resuming || isRunning} /> @@ -636,7 +602,7 @@ export default function App() { {canContinueReview && }
-