dsh-subagent-default-model 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/client.js +178 -36
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.2 (2026-09-25)
4
+
5
+ ### Fixed
6
+
7
+ - **对话流里的「当前/切换/恢复模型」上下文行不可见(P0):0.1.7 宿主把内置 `context` kind 行从可见对话流里过滤掉了**。`lib/client.js` 的 `chatModelDefinition` 原本写成 `kind: "context"`,复用宿主内置注入行。但 `dsh-client-ui-chat` 的可见性规则 `isVisibleChatNode()` 硬排除 `node.kind === "context"`(注释明写「Exclude system prompts, ordinary Context …」),且分类逻辑对插件注入消息直接归为 `context`。结果:轨迹里能看到那一行,但**对话流主视图里永远不出现**——用户可感的正是「切换/恢复模型提示消失」。
8
+ 已把节点 `kind` 改为**自有值** `chat-subagent-model-notice`(`CHAT_MODEL_NODE_KIND`)。该可见性黑名单只列 `system-prompt` / `context` / `permission` 三项,自定义 `kind` 默认可见;`source.kind`(消息来源标识,仍是 `plugin:dsh-subagent-default-model`)与节点 `kind` 是两件事,保持不动。
9
+ 注意:光改 `kind` **不够**。宿主按 `entryKey = node.kind` 在 `conversation.chat.node` 这个 **keyed 槽位**运行时分派渲染器;没有占用者的 `kind` 会落到 `ChatNodeSeat` 传入的 `fallback`——一个 `JsonBlock`(标签「unknown surface」+ 节点数据原样 JSON)。也就是说,不配渲染器的话,不可见会变成**对话流里出现一行原始 JSON**,比不可见更糟。
10
+ 故同步新增自有渲染器 `SubagentModelNoticeRow`(经 `registerSubagentModelNotice()` 注册到 `conversation.chat.node`,`key: CHAT_MODEL_NODE_KIND`,并声明 `locale:` 以收到字典):折叠态只显示行头(圆点 + 「上下文注入 · dsh-subagent-default-model」+ summary),点开才渲染 `<pre>` 完整内容;新增 `.dsm-notice-*` 样式与 zh/en 的 `row.noticeLabel`;`trajectory` 侧不受此影响(该黑名单只在 ui-chat)。
11
+ 旧注释曾写「复用内置注入行(ContextMessageNodeView)」——其复用目标在 0.1.7 已不存在,已一并勘正。
12
+
13
+ ### Testing
14
+
15
+ - 新增 3 个契约用例(`plugin/test/client-trajectory.test.mjs`):① `buildViewNode` 产出的 `kind` 必须是自有值、绝不能是宿主的 `"context"`,且 `source.kind` 保持 `plugin:dsh-subagent-default-model`;② `conversation.chat.node` 槽位恰好注册一个渲染器、`key` 必须等于节点 `kind`、组件必须是函数;③ 渲染器表现——折叠态只显示 summary、不挂载 `<pre>`,点击 toggle 后展开出完整文本且 `aria-expanded` 跟随,并对缺 `content`/`summary` 的节点容错不抛错(此时标签退化为字典 key)。
16
+ - 因 `slotRegistrations` 不再只含两张设置卡(又多了聊天渲染器),把原先按位置索引 `slotRegistrations[0]` 的断言改为 `cardRegistrations()` 按槽位名(`plugins.`)过滤,避免断言错认贡献。
17
+ - 均**变异验证**过:把 `kind` 改回 `"context"`、或把渲染器注册删掉,上面三条立刻变红,还原即全绿。全量 **90 项通过**。
18
+
19
+ ## 2.0.1 (2026-09-25)
20
+
21
+ ### Fixed
22
+
23
+ - **设置卡的「保存」按钮永久灰着、点不动(P0):命名空间在 `apply` 期只探测一次,落空后永不重探**。`lib/client.js` 原本写作 `subagentScope = forms.get(subagentEntryIdOf(forms))` —— 一次性的 `get()`。但 `configForms` 的 describe mirror 是**异步加载**的(`mirror.ensure()`),`apply` 跑的时候 `view` 往往还不存在;此时 `subagentEntryIdOf` 看不到任何命名空间,只能回落到**声明条目 id** `dsh-subagent-default-model`,而桌面宿主实际服务的是 **`include:dsh-subagent-default-model`**。
24
+ 绑定错命名空间后,宿主的 `ConfigFormController.derive()` 找不到对应 `view`,把表单停在 `status: 'unavailable'`(**静默,不报错**),而 `derive()` 只在 mirror 变化时重跑——**而作用域早已被捕获,于是永远停在 unavailable**。卡片的 `saveDisabled` 含 `snap.status !== "ready"`,因此保存按钮**永久禁用**;同时因 `value` 为 undefined,卡片还会退化成「尚未指定默认模型」的空态。
25
+ 已改为 0.1.7 的官方范式 **`configForms.whileServed([...], (served) => …)`**:命名空间**进入 mirror 时**才注册贡献,并把宿主实际服务的命名空间集合交给回调,据此解析并绑定;命名空间消失时自动卸载贡献。`subagentEntryIdOf(forms, servedNamespaces)` 现优先使用该集合(它正是判定「该注册了」的依据,mirror 可能仍在折叠中),mirror 快照退居其次。
26
+ 这是 `remote.session` 那条的**同类第三次**:**「取一次就捕获」在异步就绪的服务上必然出错**。
27
+ 诊断与验证(不依赖 Electron):以宿主 `derive()` 的真实语义构造两类作用域,渲染同一张卡片并触发改动 —— 正确绑定(`ready`)→ `Save disabled = false`(可保存);错误绑定(`unavailable`)→ `Save disabled = true`(永久禁用)。修复前用一次性 `get()` 恰是后者。
28
+
29
+ ### Testing
30
+
31
+ - 新增 1 个 **行为级**用例 `cards bind to the namespace the host actually serves when the mirror is late`:mirror 为空时 `apply` 必须**不**绑定任何命名空间、**不**注册卡片;待宿主服务的命名空间出现后,绑定必须落在 `include:<条目 id>` 上并注册两个放置点。
32
+ - 改写 `resolves the served settings namespace instead of assuming the bare id`,使其断言 `whileServed` 契约(含 `servedNamespaces.has` 优先与逐次绑定),而不再固定旧的一次性 `get()` 形状。
33
+ - 两者均**变异验证**过:把实现改回「`apply` 期一次性探测」后立刻变红,还原即全绿。全量 **86 项通过**。
34
+
3
35
  ## 2.0.0 (2026-09-25)
4
36
 
5
37
  ### Breaking
package/lib/client.js CHANGED
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
23
23
 
24
24
  // ── plugin icon (LD brand logo, 64px) ────────────────────────────────
25
25
  var DSM_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAXGUlEQVR4nH1bC7BdVXn+1tr7nHPvzb3JvUloSAQp0JHWoAMttKOCFrWU8irQSbCTQYG21IahnTJUUTsM0FJ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JVmfOsuxdifg03U9vUZHrPz0fl7p5caGjNkiEmTFUXBooUDbjWGs5TE+Pdyy6vjqijO+MPYACb+efjwdiYsqIewMk+d8tbro1b1uXXehPrYahmn+hZmGgtefqsalNFvU1BpAhM8QXhUlCmgCmihAUnBUQixk6J2eSYqwvM9Iz5sfrApM7LDF7W651oILbef3Tky0Nk2vcfeed0dxp3Nu7h6EYr2sgOL/Aa5OuMdnE5sWAAAAAElFTkSuQmCC";
26
- var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}";
26
+ var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-notice-row{display:flex;flex-direction:column;gap:4px;margin:6px 0;font-size:12px}.dsm-notice-toggle{appearance:none;font:inherit;cursor:pointer;background:transparent;border:0;padding:2px 0;display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-tertiary,#9a9a9a);text-align:left;min-width:0}.dsm-notice-toggle:hover{color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;border-radius:3px}.dsm-notice-dot{flex:none;width:5px;height:5px;border-radius:50%;background:var(--dsw-alias-label-caption,#777)}.dsm-notice-label{flex:none;font-weight:500}.dsm-notice-summary{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-summary:before{content:'·';margin-right:6px;color:var(--dsw-alias-label-caption,#777)}.dsm-notice-body{margin:0;padding:8px 10px;border-left:2px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-1,#1b1b1d);color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:420px;overflow:auto}";
27
27
 
28
28
  if (typeof document !== "undefined") {
29
29
  var cssId = "dsh-subagent-default-model/client.css";
@@ -38,6 +38,23 @@ window.__ModuleLoader__.load({
38
38
 
39
39
  // ── locale ───────────────────────────────────────────────────────────
40
40
  var SUBAGENT_ROW_LOCALE = "settings.subagentModel";
41
+
42
+ // ── 对话流注入行的自有节点 kind(2026-09-25)─────────────────────────
43
+ //
44
+ // 宿主 0.1.7 起,插件注入消息在**对话流不可见**:`dsh-client-ui-chat` 的分类
45
+ // 逻辑是 `if (event.data.source.kind !== "user") → kind: "context"`(与 form
46
+ // 无关),而可见性规则 `isVisibleChatNode()` 硬排除 `node.kind !== "context"`
47
+ // (注释明写「Exclude system prompts, ordinary Context, and permission
48
+ // commands from visible Chat rows」)。故本插件的注入只进轨迹。
49
+ //
50
+ // 绕开方式是注册**自有节点 kind**:该可见性黑名单只列 system-prompt /
51
+ // context / permission 三项,自定义 kind 默认可见;渲染器经
52
+ // `conversation.chat.node` 槽位按 `entryKey = node.kind` 运行时分派。
53
+ //
54
+ // 注意:`source.kind`(消息来源标识,仍是 "plugin:dsh-subagent-default-model")
55
+ // 与这里的**节点 kind** 是两件事,不要混改。trajectory 侧不受此影响
56
+ // (isVisibleChatNode 只在 ui-chat),故 trajectory definition 保持原样。
57
+ var CHAT_MODEL_NODE_KIND = "chat-subagent-model-notice";
41
58
  var SUBAGENT_ROW_ZH = {
42
59
  "row.title": "子代理默认模型(dsh-subagent-default-model)",
43
60
  "row.desc": "为 subagent / subagent_fork 选择一个或多个默认路由;清空后子代理继承父会话路由。",
@@ -69,7 +86,8 @@ window.__ModuleLoader__.load({
69
86
  "row.trajectoryModel": "当前供应商/模型",
70
87
  "row.chatModelInitial": "当前供应商/模型",
71
88
  "row.chatModelChange": "已切换到",
72
- "row.chatModelResume": "继续使用"
89
+ "row.chatModelResume": "继续使用",
90
+ "row.noticeLabel": "上下文注入 · dsh-subagent-default-model"
73
91
  };
74
92
  var SUBAGENT_ROW_EN = {
75
93
  "row.title": "Subagent default model (dsh-subagent-default-model)",
@@ -102,7 +120,8 @@ window.__ModuleLoader__.load({
102
120
  "row.trajectoryModel": "Current provider/model",
103
121
  "row.chatModelInitial": "Current provider/model",
104
122
  "row.chatModelChange": "Switched to",
105
- "row.chatModelResume": "Resumed on"
123
+ "row.chatModelResume": "Resumed on",
124
+ "row.noticeLabel": "Context injection · dsh-subagent-default-model"
106
125
  };
107
126
 
108
127
  // ── helpers ──────────────────────────────────────────────────────────
@@ -126,20 +145,33 @@ window.__ModuleLoader__.load({
126
145
  * while the mirror is not ready.
127
146
  *
128
147
  * @param {object} forms - the `configForms` client service.
148
+ * @param {Set<string>} [servedNamespaces] - authoritative served-namespace set
149
+ * handed over by `configForms.whileServed(...)`. When present it is preferred
150
+ * over the mirror snapshot, because it is the very set that decided the
151
+ * registration was due — the mirror may still be mid-fold.
129
152
  * @returns {string} the namespace to pass to `forms.get()`.
130
153
  */
131
- function subagentEntryIdOf(forms) {
154
+ function subagentEntryIdOf(forms, servedNamespaces) {
155
+ var pick = function (names) {
156
+ return names.find(function (ns) {
157
+ return ns === SUBAGENT_MODEL_SETTINGS_NS;
158
+ }) ?? names.find(function (ns) {
159
+ return ns === "include:" + SUBAGENT_MODEL_SETTINGS_NS;
160
+ }) ?? names.find(function (ns) {
161
+ return /subagent-default-model/i.test(ns || "");
162
+ });
163
+ };
132
164
  try {
165
+ if (servedNamespaces && typeof servedNamespaces.has === "function") {
166
+ var fromServed = pick(Array.from(servedNamespaces));
167
+ if (typeof fromServed === "string" && fromServed !== "") return fromServed;
168
+ }
133
169
  var view = forms.describe().getSnapshot().view;
134
- var namespaces = (view && view.namespaces) || [];
135
- var served = namespaces.find(function (entry) {
136
- return entry.ns === SUBAGENT_MODEL_SETTINGS_NS;
137
- }) ?? namespaces.find(function (entry) {
138
- return entry.ns === "include:" + SUBAGENT_MODEL_SETTINGS_NS;
139
- }) ?? namespaces.find(function (entry) {
140
- return /subagent-default-model/i.test((entry && entry.ns) || "");
170
+ var namespaces = ((view && view.namespaces) || []).map(function (entry) {
171
+ return entry && entry.ns;
141
172
  });
142
- if (served !== undefined && typeof served.ns === "string" && served.ns !== "") return served.ns;
173
+ var served = pick(namespaces);
174
+ if (typeof served === "string" && served !== "") return served;
143
175
  } catch (_e) { /* mirror not ready: the declared id is still the right guess */ }
144
176
  return SUBAGENT_MODEL_SETTINGS_NS;
145
177
  }
@@ -526,6 +558,63 @@ window.__ModuleLoader__.load({
526
558
  );
527
559
  }
528
560
 
561
+ // ── 对话流注入行的渲染器(自有节点 kind)─────────────────────────────
562
+ //
563
+ // 宿主按 `entryKey = node.kind` 从 `conversation.chat.node` 槽位**运行时分派**
564
+ // 渲染器(`ChatNodeSeat` 传 `entryKey: routedNode.kind`)。该分派是 keyed 槽位:
565
+ // 没有占用者的 kind 走 `ChatNodeSeat` 传入的 `fallback`——一个 `JsonBlock`
566
+ // (标签 "unknown surface" + 节点数据原样 JSON)。所以只改 kind 而不注册渲染器
567
+ // 不是「行消失」,而是**对话流里出现一行原始 JSON**(比不可见更糟)。
568
+ //
569
+ // 渲染器收到的是 `{ node }`(`ChatNodeOwnerProps`),节点数据即 `start()` 的
570
+ // state(`buildViewNode` 把它放进 `data`)。这里只读 content / source.summary,
571
+ // 不依赖任何宿主内部工具。
572
+ function SubagentModelNoticeRow(props) {
573
+ var node = props.node;
574
+ var data = node && node.data ? node.data : {};
575
+ // `t` is the framework-injected locale seat: this registration declares
576
+ // `locale:`, so the renderer receives it. Keep the label in the
577
+ // dictionary rather than inlining one language (the plugin ships zh+en).
578
+ var t = props.t || function (key) { return key; };
579
+ var openState = React.useState(false);
580
+ var open = openState[0];
581
+ var setOpen = openState[1];
582
+ var blocks = Array.isArray(data.content) ? data.content : [];
583
+ var text = blocks.map(function (block) {
584
+ return block && typeof block.text === "string" ? block.text : "";
585
+ }).join("\n");
586
+ var summary = data.source && typeof data.source.summary === "string" ? data.source.summary : "";
587
+ return React.createElement("div", { className: "dsm-notice-row" },
588
+ React.createElement("button", {
589
+ type: "button",
590
+ className: "dsm-notice-toggle",
591
+ "aria-expanded": open,
592
+ onClick: function () { setOpen(!open); }
593
+ },
594
+ React.createElement("span", { className: "dsm-notice-dot", "aria-hidden": "true" }),
595
+ React.createElement("span", { className: "dsm-notice-label" }, t("row.noticeLabel")),
596
+ summary ? React.createElement("span", { className: "dsm-notice-summary" }, summary) : null
597
+ ),
598
+ open ? React.createElement("pre", { className: "dsm-notice-body" }, text) : null
599
+ );
600
+ }
601
+
602
+ /** 注册自有 kind 的渲染器;返回卸载函数。槽位缺失时静默跳过。 */
603
+ function registerSubagentModelNotice(ctx) {
604
+ try {
605
+ return ctx.slots.inject("conversation.chat.node", function () {
606
+ return ctx.slots.register({
607
+ name: "conversation.chat.node",
608
+ key: CHAT_MODEL_NODE_KIND,
609
+ locale: SUBAGENT_ROW_LOCALE
610
+ }, SubagentModelNoticeRow);
611
+ });
612
+ } catch (error) {
613
+ console.error("[dsh-subagent-default-model] notice renderer failed to register (chat row absent):", error);
614
+ return function () { };
615
+ }
616
+ }
617
+
529
618
  // ── apply: inject settings row ───────────────────────────────────────
530
619
  // `settingsScope` service was REMOVED in DSH 0.1.7 (settings moved to
531
620
  // `configForms` + the plugin's own `Config`). Hard-injecting it would keep
@@ -659,8 +748,12 @@ window.__ModuleLoader__.load({
659
748
  // persisted session resumes ("resume"). The frame header carries the
660
749
  // full config (provider/model), so the conversation can show exactly
661
750
  // which route is in use — no host-side changes required.
662
- // The chat view renders `kind: "context"` nodes via ContextMessageNodeView
663
- // (content/source/provenance/form), reusing the built-in injection row.
751
+ // 节点 kind 用**自有值**(`CHAT_MODEL_NODE_KIND`),不复用内置 `context`。
752
+ // 旧注释曾写「复用内置注入行(ContextMessageNodeView)」——该复用目标在
753
+ // 宿主 0.1.7 已不存在:`dsh-client-ui-chat` 的 `isVisibleChatNode()` 明确
754
+ // 排除 `node.kind === "context"`(除非含 tool-addition/removal 块),故
755
+ // 复用 `context` 的结果是**行永远不可见**。自有 kind 不在黑名单内,配一个
756
+ // 自有渲染器即可见。trajectory 侧不受影响(该黑名单只在 ui-chat)。
664
757
  var chatT = ctx.locale.bind(SUBAGENT_ROW_LOCALE);
665
758
  var chatModelDefinition = {
666
759
  kind: "chat-subagent-model",
@@ -682,7 +775,7 @@ window.__ModuleLoader__.load({
682
775
  var reason = data.reason === "change" ? "row.chatModelChange" : data.reason === "resume" ? "row.chatModelResume" : "row.chatModelInitial";
683
776
  var label = chatT(reason) + ":" + (config.provider ? config.provider + (config.model ? "/" + config.model : "") : (config.model || ""));
684
777
  return {
685
- kind: "context",
778
+ kind: CHAT_MODEL_NODE_KIND,
686
779
  seq: event.seq,
687
780
  time: event.time,
688
781
  content: [{ type: "text", text: label }],
@@ -699,7 +792,7 @@ window.__ModuleLoader__.load({
699
792
  if (context.state === void 0) return null;
700
793
  return {
701
794
  key: context.key,
702
- kind: "context",
795
+ kind: CHAT_MODEL_NODE_KIND,
703
796
  id: context.id,
704
797
  target: "chat",
705
798
  anchorSeq: context.state.seq,
@@ -712,6 +805,13 @@ window.__ModuleLoader__.load({
712
805
  ctx.effect(function () {
713
806
  return ctx.uiConversation.events.register(chatModelDefinition);
714
807
  }, "dsh-subagent-default-model: chat model row");
808
+
809
+ // 自有节点 kind 必须配自己的渲染器(宿主按 `entryKey = node.kind` 分派)。
810
+ // 缺这一步,该行会落到 `ChatNodeSeat` 的 `fallback`(JsonBlock)——用户看到
811
+ // 的不是「模型行」,而是一坨原始 JSON。
812
+ ctx.effect(function () {
813
+ return registerSubagentModelNotice(ctx);
814
+ }, "dsh-subagent-default-model: chat notice row");
715
815
  }
716
816
 
717
817
  // Resolve the settings scope for this plugin. On DSH 0.1.7+ the settings
@@ -734,30 +834,72 @@ window.__ModuleLoader__.load({
734
834
 
735
835
  // `configForms` is the 0.1.7 client settings surface; soft-inject it so the
736
836
  // card simply stays absent when the service is unavailable, instead of
737
- // blocking the whole client plugin. The served namespace is probed (see
738
- // `subagentEntryIdOf`) rather than assumed — see that function.
837
+ // blocking the whole client plugin.
838
+ //
839
+ // Register through `whileServed`, NOT a one-shot `forms.get(...)`.
840
+ // The describe mirror loads ASYNCHRONOUSLY (`mirror.ensure()`), so a probe
841
+ // run during `apply` can execute before `view` exists. `subagentEntryIdOf`
842
+ // then sees zero namespaces and falls back to the declared entry id
843
+ // (`dsh-subagent-default-model`) while the Desktop host actually serves
844
+ // `include:dsh-subagent-default-model`. The mismatch makes the host's
845
+ // `ConfigFormController.derive()` park the form at `status: 'unavailable'`
846
+ // — silently, with no error — and `derive()` only re-runs on a mirror
847
+ // change. Because the scope was already captured, the card stayed
848
+ // unavailable FOREVER and its Save button was permanently disabled
849
+ // (`saveDisabled` includes `snap.status !== 'ready'`).
850
+ //
851
+ // `whileServed` re-invokes the registration each time one of the watched
852
+ // namespaces enters the mirror, and hands it the served set — so the
853
+ // namespace is resolved from the authoritative directory at the moment it
854
+ // actually exists. It also disposes the contribution when the namespace
855
+ // goes away. Every official consumer registers this way.
739
856
  ctx.inject(["configForms"], function (formsCtx) {
740
857
  var forms = formsCtx.configForms;
741
- subagentScope = forms.get(subagentEntryIdOf(forms));
742
858
 
743
- var registerCard = function (slotName, key) {
744
- try {
745
- ctx.slots.inject(slotName, function () {
746
- return ctx.slots.register({
747
- name: slotName,
748
- key: key,
749
- locale: SUBAGENT_ROW_LOCALE,
750
- inject: subagentRowInjected
751
- }, SubagentModelCard);
752
- });
753
- } catch (error) {
754
- console.error('[dsh-subagent-default-model] settings card slot "' + slotName + '" failed to register (host provider unaffected):', error);
755
- }
859
+ var registerCards = function (namespace) {
860
+ subagentScope = forms.get(namespace);
861
+ var disposers = [];
862
+ var registerCard = function (slotName, key) {
863
+ try {
864
+ disposers.push(ctx.slots.inject(slotName, function () {
865
+ return ctx.slots.register({
866
+ name: slotName,
867
+ key: key,
868
+ locale: SUBAGENT_ROW_LOCALE,
869
+ inject: subagentRowInjected
870
+ }, SubagentModelCard);
871
+ }));
872
+ } catch (error) {
873
+ console.error('[dsh-subagent-default-model] settings card slot "' + slotName + '" failed to register (host provider unaffected):', error);
874
+ }
875
+ };
876
+ // 0.1.7 placement: register under Plugins config surfaces (the old
877
+ // `settings.plugin.item` slot was removed in 0.1.7).
878
+ registerCard("plugins.bundle.config", "dsh-subagent-default-model");
879
+ registerCard("plugins.row.config", "dsh-subagent-default-model#dsh-subagent-default-model");
880
+ return function () {
881
+ while (disposers.length) {
882
+ var off = disposers.pop();
883
+ if (typeof off === "function") off();
884
+ }
885
+ subagentScope = null;
886
+ };
756
887
  };
757
- // 0.1.7 placement: register under Plugins config surfaces (the old
758
- // `settings.plugin.item` slot was removed in 0.1.7).
759
- registerCard("plugins.bundle.config", "dsh-subagent-default-model");
760
- registerCard("plugins.row.config", "dsh-subagent-default-model#dsh-subagent-default-model");
888
+
889
+ // `whileServed` is the 0.1.7 contract. Fall back to a direct registration
890
+ // only if a host somehow lacks it, so the card still appears.
891
+ if (typeof forms.whileServed === "function") {
892
+ ctx.effect(function () {
893
+ return forms.whileServed(
894
+ [SUBAGENT_MODEL_SETTINGS_NS, "include:" + SUBAGENT_MODEL_SETTINGS_NS],
895
+ function (served) {
896
+ return registerCards(subagentEntryIdOf(forms, served));
897
+ }
898
+ );
899
+ }, "dsh-subagent-default-model: settings cards follow the served namespace");
900
+ } else {
901
+ registerCards(subagentEntryIdOf(forms));
902
+ }
761
903
  });
762
904
  }
763
905
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Configure default model routes for DeepSeek Harness subagents, with single-model, round-robin, random, and per-route reasoning-effort options.",
5
5
  "keywords": [
6
6
  "deepseek-harness",