From a806acda9c1225b2f5e50db53150230c40a03b2c Mon Sep 17 00:00:00 2001 From: qyh15 Date: Sun, 8 Nov 2026 23:45:14 +0800 Subject: [PATCH] =?UTF-8?q?0.7.1=EF=BC=9A=E5=8D=81=E4=B8=AA=E5=B8=AD?= =?UTF-8?q?=E4=BD=8D=E9=83=BD=E8=83=BD=E8=AE=BE=E7=BD=AE=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E5=8F=AC=E8=A7=81=E7=9A=84=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E5=85=88=E9=80=89=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 +++++++++- package.json | 2 +- panel/lib/client.js | 29 ++++++++++++++++------------- panel/package.json | 2 +- panel/test/client.test.js | 19 +++++++++++++++++++ scripts/preview.mjs | 17 +++++++++++------ 6 files changed, 57 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd879d..12b3ffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Changelog -> 版本号以 `package.json` 为准(当前 0.7.0)。更早的 0.6.x 条目沿用旧编号,保留作历史。 +> 版本号以 `package.json` 为准(当前 0.7.1)。更早的 0.6.x 条目沿用旧编号,保留作历史。 + +## 0.7.1 — 十个席位都有模型设置,没召见的也能先选好 + +- 面板「模型设置」原来只在 `seat.present` 时渲染,没召见的部门连入口都没有。现在绑定的是席位本身:未召见的部门也能选模型,保存时同样下发 `/dept-model <角色> [推理等级]`,并注明「召见后生效」。 +- 未召见的席位读清单时不再传会话 id:直接读全局清单,当前值取面板里固定过的那条;保存后脚注写「该部门还没召见;保存后在召见时生效」。 +- 顺带修掉一个由缺席席位暴露的 bug:`activeSeat` 在 `activeChildId` 为空时会撞上「没有会话 id 的缺席席位」(`undefined === undefined`),把标题写成「正在与吏部对话」。现在只有存在子会话时才去找席位。 +- 预览脚本新增 `--absent=<角色,...>`,可以直接截「未召见的部门」这一态;演示数据补上全局清单的 `default` 字段,缺席席位才有默认可选模型。 +- 测试新增「还没召见的部门也能先选好模型,保存走 /dept-model」;`node --test` 49 项全过。 ## 0.7.0 — 每个部门可以单独固定模型 diff --git a/package.json b/package.json index fdca2a2..b63dab6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-sansheng-liubu-mode", - "version": "0.7.0", + "version": "0.7.1", "private": true, "description": "上朝:丞相统筹的三省六部多 Agent 模式", "type": "module", diff --git a/panel/lib/client.js b/panel/lib/client.js index 66a4fd6..6904e62 100644 --- a/panel/lib/client.js +++ b/panel/lib/client.js @@ -699,7 +699,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s React.useEffect(() => { if (catalog.status === "loading") return undefined; - if (!targetId) { setCatalog({ status: "idle", options: [], error: null, current: undefined, subagent: false }); return undefined; } + if (!targetId && !(seat && seat.role)) { setCatalog({ status: "idle", options: [], error: null, current: undefined, subagent: false }); return undefined; } let alive = true; setCatalog((prev) => ({ ...prev, status: "loading", error: null })); host.loadCatalog(targetId, seat && seat.role).then((result) => { @@ -721,15 +721,15 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s const currentModelValue = catalog.current ? catalog.current.provider + "/" + catalog.current.model : ""; const currentEffortValue = (catalog.current && catalog.current.reasoningEffort) || ""; const modelDirty = draftModel !== currentModelValue || draftEffort !== currentEffortValue; - const canSaveModel = Boolean(chosenOption && seat && seat.id && modelDirty && !busy); + const canSaveModel = Boolean(chosenOption && seat && modelDirty && !busy); const applyModel = () => { - if (!chosenOption || !seat || !seat.id) return; + if (!chosenOption || !seat) return; const plan = modelSwitchPlan(catalog.current, { provider: chosenOption.provider, model: chosenOption.model, reasoningEffort: draftEffort || undefined, - }, catalog.subagent); + }, catalog.subagent || !seat.id); if (!plan.ok) { setNotice({ kind: "error", text: plan.reason }); return; } setBusy(true); const request = plan.via === "command" @@ -750,7 +750,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s const activeChildId = activeAddress && activeAddress.childSessionId ? activeAddress.childSessionId : focusedSessionId !== leadSessionId ? focusedSessionId : undefined; - const activeSeat = seats.find((entry) => entry.id === activeChildId); + const activeSeat = activeChildId ? seats.find((entry) => entry.id === activeChildId) : undefined; const previousChildRef = React.useRef(null); React.useEffect(() => { const previousChild = previousChildRef.current; @@ -926,12 +926,12 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s seatInfo.lastText ? h("small", { children: shortText(seatInfo.lastText, 46) }) : null, ]), seat && !seat.present ? h("div", { className: "sl-hint", children: "该部门尚未设立。让丞相按流程组建后再进入会话。" }) : null, - seat && seat.present ? h("div", { className: "sl-setting-block" }, [ + seat ? h("div", { className: "sl-setting-block" }, [ h("div", { className: "sl-setting-head" }, [ h("h3", { children: "模型设置" }), - h("small", { children: catalog.subagent ? "按部门固定" : "只影响该部门" }), + h("small", { children: catalog.subagent ? (seat.present ? "按部门固定" : "召见后生效") : "只影响该部门" }), ]), - catalog.subagent ? h("div", { className: "sl-hint", children: "部门是子会话,宿主不允许事后单独改;这里选好后由模式把它固定下来,下一轮开工即用。" }) : null, + catalog.subagent ? h("div", { className: "sl-hint", children: seat.present ? "部门是子会话,宿主不允许事后单独改;这里选好后由模式把它固定下来,下一轮开工即用。" : "该部门还没召见。这里选好的模型由模式记下来,召见时直接按它开工。" }) : null, h(React.Fragment, null, [ h("div", { className: "sl-model-grid" }, [ h("label", { className: "sl-control" }, [ @@ -977,7 +977,9 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s ? "有未保存的更改" : catalog.fixed ? "该部门固定使用此模型" - : catalog.inherited + : !seat.present + ? "该部门还没召见;保存后在召见时生效" + : catalog.inherited ? (catalog.unresolved ? "该部门会话未在本页打开,选好保存后直接生效" : "当前:跟随默认(" + modelLabel(catalog.current) + ")") : "当前:" + (catalog.current ? modelLabel(catalog.current) : "未设置") }), ]), @@ -1383,18 +1385,19 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s }, loadCatalog(sessionId, role) { const subagentOf = (id) => (typeof sessions.subagentAddress === "function" ? sessions.subagentAddress(id) !== undefined : false); - const isSubagent = subagentOf(sessionId); - const fixed = isSubagent ? readSeatRoute(role) : undefined; + // 还没召见的部门没有会话:清单照样给,当前值取面板里固定过的那条。 + const isSubagent = sessionId ? subagentOf(sessionId) : true; + const fixed = isSubagent && role ? readSeatRoute(role) : undefined; // 模型清单是全局的:宿主同时只维护一份,任何会话都能读到;会话只决定「当前选的是哪个」。 const global = modelCatalogOf(); if (global.service === false) { return Promise.resolve({ options: [], current: undefined, inherited: false, error: "当前宿主没有模型目录服务(modelDirectories)", subagent: false, unresolved: false }); } if (!global.catalog) { - return Promise.resolve({ options: [], current: undefined, inherited: false, error: global.error, subagent: subagentOf(sessionId), unresolved: false }); + return Promise.resolve({ options: [], current: undefined, inherited: false, error: global.error, subagent: isSubagent, unresolved: false }); } const catalog = global.catalog; - const resolved = modelDirectoryOf(sessionId); + const resolved = sessionId ? modelDirectoryOf(sessionId) : { service: true, directory: undefined }; const directory = resolved.directory; /** 该会话自己的当前模型;没在本页登记时为 undefined。 */ const ownCurrent = () => { diff --git a/panel/package.json b/panel/package.json index 449c927..122d0f5 100644 --- a/panel/package.json +++ b/panel/package.json @@ -1,6 +1,6 @@ { "name": "dsh-sansheng-liubu-panel", - "version": "0.7.0", + "version": "0.7.1", "private": true, "description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent", "type": "module", diff --git a/panel/test/client.test.js b/panel/test/client.test.js index a8e40da..c4bc2d6 100644 --- a/panel/test/client.test.js +++ b/panel/test/client.test.js @@ -962,3 +962,22 @@ test('子会话的固定路由从面板记录里读出来当「当前模型」', assert.equal(result.current.model, 'deepseek-reasoner') assert.equal(result.current.reasoningEffort, 'high') }) + +test('还没召见的部门也能先选好模型,保存走 /dept-model', async () => { + const { exports } = loadPlugin() + const { ctx } = mockContext() + exports.apply(ctx) + const host = exports.createHost(ctx) + + const catalog = await host.loadCatalog(undefined, 'libu') + assert.equal(catalog.options.length, 2, '没有会话也能拿到全局模型清单') + assert.equal(catalog.subagent, true, '未召见的部门同样按子会话处理') + assert.equal(catalog.error, null) + + const routed = await host.routeModel('libu', { provider: 'deepseek', model: 'deepseek-chat' }) + assert.equal(routed.ok, true) + assert.match(routed.text, /^\/dept-model libu deepseek deepseek-chat$/) + + // 详情区的模型设置对缺席席位也要渲染出来(不再是 seat.present 才给)。 + assert.match(source, /seat \? h\("div", \{ className: "sl-setting-block" \}, \[/, '模型设置绑定席位,而不是绑定「已召见」') +}) diff --git a/scripts/preview.mjs b/scripts/preview.mjs index abd0eff..a01b68c 100644 --- a/scripts/preview.mjs +++ b/scripts/preview.mjs @@ -44,6 +44,7 @@ const DEFAULTS = { chrome: null, htmlOnly: false, viewport: 0, + absent: '', } /** 页面左侧留出的「会话区」宽度,让预览看起来是右侧栏而不是整页。 */ @@ -67,6 +68,7 @@ function printHelp() { --width=<像素> 侧栏容器宽度 320-900(默认 ${DEFAULTS.width}) --view= 渲染页签(默认 ${DEFAULTS.view}) --seat=<角色> 选中哪个席位,如 gongbu(默认 ${DEFAULTS.seat}) + --absent=<角色,...> 让这些部门还没召见(用于预览「召见后生效」) --theme= 主题(默认 ${DEFAULTS.theme}) --name=<文件名> 输出文件名,不含扩展名(默认 ${DEFAULTS.name}) --source=<路径> 要渲染的 client.js(默认 ${DEFAULTS.source},A/B 对比用) @@ -649,8 +651,10 @@ const DEMO_NODES = new Map([ ['demo-1', { kind: 'assistant', anchorSeq: 1, data: { blocks: [{ kind: 'text', text: DEMO_STATUS_TEXT }] } }], ]) -function createDemoContext() { - const members = DEMO_ROLES.map((role) => ({ id: `sess-${role}`, name: role, phase: 'active' })) +function createDemoContext(options = {}) { + const absent = new Set(String(options.absent || '').split(',').map((entry) => entry.trim()).filter(Boolean)) + const members = DEMO_ROLES.filter((role) => !absent.has(role)).map((role) => ({ id: `sess-${role}`, name: role, phase: 'active' })) + const roles = DEMO_ROLES.filter((role) => !absent.has(role)) const tasks = [ { id: 'task-1', subject: '拆解 0.5.1 侧栏验收清单', status: 'in_progress', ownerName: 'zhongshu' }, { id: 'task-2', subject: '复算朝堂统计投影', status: 'in_progress', ownerName: 'hubu' }, @@ -662,13 +666,13 @@ function createDemoContext() { const byId = {} const ids = [] - for (const role of DEMO_ROLES) { + for (const role of roles) { const id = `sess-${role}` ids.push(id) byId[id] = { id, name: DEMO_LABELS[role], - updatedAt: 1_760_000_000_000 + DEMO_ROLES.indexOf(role), + updatedAt: 1_760_000_000_000 + roles.indexOf(role), running: DEMO_RUNNING.has(role), workspaceId: 'demo-workspace', } @@ -696,7 +700,7 @@ function createDemoContext() { } const statuses = new Map() - for (const role of DEMO_ROLES) { + for (const role of roles) { statuses.set(`sess-${role}`, { running: DEMO_RUNNING.has(role) }) } const statusStore = { @@ -708,6 +712,7 @@ function createDemoContext() { status: 'ready', error: null, current: { provider: 'openai', model: 'gpt-6-astra', reasoningEffort: 'high' }, + default: { provider: 'openai', model: 'gpt-6-astra', reasoningEffort: 'high' }, groups: [ { id: 'openai', @@ -1004,7 +1009,7 @@ async function main() { } const { React } = hooks - const { ctx } = createDemoContext() + const { ctx } = createDemoContext(options) const host = bundle.exports.createHost(ctx) const rootVNode = React.createElement(bundle.exports.SanshengPanel, { host,