0.7.1:十个席位都能设置模型,没召见的部门也能先选好

This commit is contained in:
qyh15 2026-11-08 23:45:14 +08:00
parent cfd4b0957a
commit a806acda9c
6 changed files with 57 additions and 22 deletions

View File

@ -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 <角色> <provider> <model> [推理等级]`,并注明「召见后生效」。
- 未召见的席位读清单时不再传会话 id:直接读全局清单,当前值取面板里固定过的那条;保存后脚注写「该部门还没召见;保存后在召见时生效」。
- 顺带修掉一个由缺席席位暴露的 bug:`activeSeat` 在 `activeChildId` 为空时会撞上「没有会话 id 的缺席席位」(`undefined === undefined`),把标题写成「正在与吏部对话」。现在只有存在子会话时才去找席位。
- 预览脚本新增 `--absent=<角色,...>`,可以直接截「未召见的部门」这一态;演示数据补上全局清单的 `default` 字段,缺席席位才有默认可选模型。
- 测试新增「还没召见的部门也能先选好模型,保存走 /dept-model」;`node --test` 49 项全过。
## 0.7.0 — 每个部门可以单独固定模型

View File

@ -1,6 +1,6 @@
{
"name": "dsh-sansheng-liubu-mode",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
"type": "module",

View File

@ -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 = () => {

View File

@ -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",

View File

@ -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" \}, \[/, '模型设置绑定席位,而不是绑定「已召见」')
})

View File

@ -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=<court|tasks> 渲染页签(默认 ${DEFAULTS.view})
--seat=<角色> 选中哪个席位,如 gongbu(默认 ${DEFAULTS.seat})
--absent=<角色,...> 让这些部门还没召见(用于预览「召见后生效」)
--theme=<light|dark> 主题(默认 ${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,