dsh-per-message-model 0.1.6 → 0.1.7

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 (2) hide show
  1. package/lib/client.js +1 -60
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -67,48 +67,6 @@ window.__ModuleLoader__.load({
67
67
  })
68
68
  ]);
69
69
  }
70
- /**
71
- * Per-message model badge as a small icon button. Missing projections
72
- * degrade to the same icon with an unknown title (fail-soft, verifiable).
73
- * @param value - a wire projection entry ({ provider, model, reasoningEffort, reasoningSource }).
74
- * @param t - locale seat bound to this plugin's namespace.
75
- */
76
- function modelBadge(value, t) {
77
- const known = value !== null && typeof value === "object";
78
- const provider = known && typeof value.provider === "string" ? value.provider : null;
79
- const model = known && typeof value.model === "string" ? value.model : null;
80
- const hasModel = provider !== null && model !== null;
81
- const label = hasModel
82
- ? `${provider} / ${model}${t("badge.separator")}${t("badge.effort")} ${known && typeof value.reasoningEffort === "string" && value.reasoningEffort.length > 0 ? value.reasoningEffort : t("badge.effort.default")}`
83
- : t("badge.unknown");
84
- const title = hasModel && known && value.reasoningSource === "adapter-default"
85
- ? `${label}(${t("badge.effort.adapterDefault")})`
86
- : hasModel ? label : t("badge.unknown.title");
87
- return createElement("span", {
88
- className: BADGE_PREFIX + "icon",
89
- "data-dsh-per-message-model": "true",
90
- "aria-label": label,
91
- title
92
- }, chipIcon());
93
- }
94
- /** Session-header occupant: current model badge (latest folded assistant message). */
95
- function SessionModelBadge({ useProjection, t }) {
96
- const value = useProjection("perMessageModel");
97
- const current = value === void 0 || value === null || typeof value !== "object" || value.current === void 0
98
- ? void 0
99
- : value.current;
100
- return modelBadge(current, t);
101
- }
102
- /** Assistant-actions occupant: per-message model icon, keyed by messageId
103
- * (renders inside the official per-message action row, reordered after the
104
- * branch button and before the time clock via CSS flex order). */
105
- function PerMessageModelBadge({ messageId, useProjection, t }) {
106
- const value = useProjection("perMessageModel");
107
- const entry = value === void 0 || value === null || typeof value !== "object" || value.messages === void 0
108
- ? void 0
109
- : value.messages[messageId];
110
- return modelBadge(entry, t);
111
- }
112
70
  //#endregion
113
71
  //#region client footer
114
72
  /**
@@ -304,12 +262,7 @@ window.__ModuleLoader__.load({
304
262
  const badgeStyle = document.createElement("style");
305
263
  badgeStyle.dataset.dshPerMessageModel = BADGE_PREFIX;
306
264
  badgeStyle.textContent = [
307
- // Per-message icon: small chip, full value in title/aria.
308
- `[data-dsh-per-message-model]{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin:0 2px;color:var(--dsw-alias-label-tertiary);border-radius:5px;cursor:default}`,
309
- `[data-dsh-per-message-model]:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base-2, var(--dsw-alias-bg-hover, rgba(128,128,128,.12)))}`,
310
- // Reorder inside the official action row: copy(0) branch(0) icon(3) clock(4)
311
- `[data-dsh-per-message-model]{order:3}`,
312
- `div[class*="actions"]:has([data-slot="conversation.chat.assistant-actions"]) [class*="timeEnd"]{order:4}`,
265
+
313
266
  // In-stream divider: full-width block, embeds in the message flow.
314
267
  // Label (模型切换:) and arrow are gray; model names are darker/bolder.
315
268
  `[data-dsh-model-switch]{display:flex;align-items:center;gap:8px;margin:10px 0 16px;padding:10px 14px;border:1.5px solid var(--dsw-alias-state-business-primary, #4f8cff);border-radius:10px;background:var(--dsw-alias-state-business-tertiary, rgba(79,140,255,.12));box-shadow:0 1px 3px rgba(0,0,0,.10);color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;user-select:none}`,
@@ -326,18 +279,6 @@ window.__ModuleLoader__.load({
326
279
  document.head.appendChild(badgeStyle);
327
280
  ctx.effect(() => () => badgeStyle.remove(), "per-message-model: css");
328
281
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "per-message-model: dictionaries");
329
- ctx.slots.inject("conversation.session.header.actions", () => ctx.slots.register({
330
- name: "conversation.session.header.actions",
331
- id: "dsh-per-message-model-header",
332
- locale: NS,
333
- order: 80
334
- }, SessionModelBadge));
335
- ctx.slots.inject("conversation.chat.assistant-actions", () => ctx.slots.register({
336
- name: "conversation.chat.assistant-actions",
337
- id: "dsh-per-message-model-badge",
338
- locale: NS,
339
- order: 40
340
- }, PerMessageModelBadge));
341
282
  ctx.slots.inject("conversation.session.header.actions", () => ctx.slots.register({
342
283
  name: "conversation.session.header.actions",
343
284
  id: "dsh-per-message-model-switch",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-per-message-model",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "在 DSH 主对话每条 assistant 回复旁展示该条回复实际使用的 provider / model 徽章(可选附带 reasoning effort)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",