dsh-tidy-display 0.4.3 → 0.4.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4 — 2026-10-22
4
+
5
+ - **阅读视图放行 `render_ui`(与 dsh-genui 的硬冲突 B)**。`ResultView` 的绕过条件此前把 `render_ui` 与 `show_widget` 一起短路到通用结果行,GenUI 在阅读视图里永远只显示 JSON。现只保留 `show_widget` 绕过(它的 `html` 参数走 McpAppFrame,是 tidy 自有渲染),`render_ui` 交给官方 `tool.call.toolview` 镜像座位:装了 GenUI 时其注册胜出、卡片正常出现;未装 GenUI 或带 `html` 参数的 `render_ui` 仍由座位 fallback 落回原通用行,默认终态零变化。
6
+ - **阅读视图委托 `assistant-step` 影子接管(与 dsh-raw-html-v2 的硬冲突 A)**。新增单判据 `isShadowWinner`(`priority < 0`;宿主官方注册不写 priority)与 `acceptOfficialNode`:官方基线 `assistant-step` 仍被过滤、由 Reader 自渲染,而外部影子接管(如 raw-html-v2 开启渲染开关)会镜像进 `official.nodes` 座位,Reader 经 `AssistantStepDelegation` 委托其渲染;无影子时不挂载委托,默认路径 DOM 逐帧零漂移。开关关闭即不注册,行为与 0.4.3 完全一致。
7
+
3
8
  ## 0.4.3 — 2026-10-21
4
9
 
5
10
  - **对话轨「更早载入」箭头改为可连续点击**。原生「对话」视图的消息轨顶部箭头此前只能触发一次:嗅探宿主的 `加载更早` 按钮时,① 正则不认载入态文案(正在加载更早 / Loading earlier),箭头在加载瞬间塌掉;② `hasMore` 只在 prefs 变更时重算,宿主重新放出按钮后组件不重渲染,箭头再不回来——须切视图/改设置才能续点。改为:匹配同时覆盖空闲与载入态文案,并用 rAF 节流的 MutationObserver(作用域 `[data-conversation-scroll]`)驱动响应式重算;`loadOlder` 只点未禁用的按钮,载入中点击为无害 no-op。阅读视图轨本就走 `useSession(hasMore)` + `session().loadOlder()`,不受影响。
package/lib/client.js CHANGED
@@ -43886,6 +43886,31 @@ ${trimmed}
43886
43886
  "turn-tail",
43887
43887
  "turn-process"
43888
43888
  ]);
43889
+ /**
43890
+ * An external takeover registers the node with a negative priority. The host's own
43891
+ * assistant-step registration carries none (register-node-renderers.ts), so the
43892
+ * sign of the rank is the smallest sufficient signal that someone else renders it.
43893
+ */
43894
+ const isShadowWinner = (entry) => typeof entry.options.priority === "number" && entry.options.priority < 0;
43895
+ /**
43896
+ * Mirror only node kinds the Reader does not present itself. assistant-step stays
43897
+ * Reader-owned unless a shadow takeover wins its cell; then it must reach the
43898
+ * mirror seat so the Reader can delegate to it.
43899
+ */
43900
+ const acceptOfficialNode = (entry) => !READER_NODES.has(entry.options.key ?? "") || entry.options.key === "assistant-step" && isShadowWinner(entry);
43901
+ /** Registry captured at install; the Reader's delegation read needs election winners. */
43902
+ let installedSlots;
43903
+ /**
43904
+ * Reactive read for the Reader: does an external shadow takeover win the
43905
+ * assistant-step cell? Subscribes to the source slot so enabling the takeover
43906
+ * plugin after mount flips the answer.
43907
+ */
43908
+ function useAssistantStepShadow() {
43909
+ const registry = installedSlots;
43910
+ const subscribe = (0, react.useCallback)((notify) => registry?.subscribe(OFFICIAL_SLOTS.nodes, notify) ?? (() => {}), [registry]);
43911
+ const read = (0, react.useCallback)(() => registry?.entriesOfSlot(OFFICIAL_SLOTS.nodes).some((entry) => entry.options.key === "assistant-step" && isShadowWinner(entry)) ?? false, [registry]);
43912
+ return (0, react.useSyncExternalStore)(subscribe, read);
43913
+ }
43889
43914
  const EXPECTED = {
43890
43915
  actions: [{
43891
43916
  kind: "list",
@@ -44035,6 +44060,7 @@ ${trimmed}
44035
44060
  }
44036
44061
  function installOfficialSlots(ctx) {
44037
44062
  const slots = ctx.slots;
44063
+ installedSlots = slots;
44038
44064
  const disposers = [];
44039
44065
  try {
44040
44066
  for (const [name, source] of Object.entries(OFFICIAL_SLOTS)) {
@@ -44044,15 +44070,17 @@ ${trimmed}
44044
44070
  const target = officialSeat(family);
44045
44071
  const declared = slots.spec(target);
44046
44072
  if (spec.kind !== declared?.kind || spec.scope !== declared.scope) console.warn(`[dsh-tidy-display] official slot contract drift on mirror: ${source} (${spec.kind}/${spec.scope} vs ${declared?.kind ?? "none"}/${declared?.scope ?? "none"})`);
44047
- return mirrorOfficialSlot(slots, source, target, `dsh-tidy-display.official.${family}`, family === "nodes" ? (entry) => !READER_NODES.has(entry.options.key ?? "") : void 0);
44073
+ return mirrorOfficialSlot(slots, source, target, `dsh-tidy-display.official.${family}`, family === "nodes" ? acceptOfficialNode : void 0);
44048
44074
  }));
44049
44075
  }
44050
44076
  } catch (error) {
44051
44077
  for (const stop of disposers.reverse()) stop();
44078
+ if (installedSlots === slots) installedSlots = void 0;
44052
44079
  throw error;
44053
44080
  }
44054
44081
  return () => {
44055
44082
  for (const stop of disposers.splice(0).reverse()) stop();
44083
+ if (installedSlots === slots) installedSlots = void 0;
44056
44084
  };
44057
44085
  }
44058
44086
  //#endregion
@@ -44099,11 +44127,13 @@ ${trimmed}
44099
44127
  })
44100
44128
  });
44101
44129
  }
44102
- function OfficialNode({ node, fallback, ...render }) {
44103
- const official = render.official;
44104
- const [disclosureReset] = (0, react.useState)(() => createSnapshotStore(0));
44105
- if (!official) return fallback;
44106
- const owner = {
44130
+ /**
44131
+ * Owner currency for a keyed chat node. rc.1 dropped openSkill/renderMessageImages
44132
+ * from ChatNodeOwnerProps (message images moved to the images child slot); older
44133
+ * hosts still read both, so keep supplying them and cast past the new shape.
44134
+ */
44135
+ function officialNodeOwner(render, official) {
44136
+ return {
44107
44137
  cwd: render.cwd,
44108
44138
  openFile: render.openFile ?? (() => {}),
44109
44139
  openSkill: () => {},
@@ -44116,6 +44146,12 @@ ${trimmed}
44116
44146
  }),
44117
44147
  fileMentions: official.officialFileMentions
44118
44148
  };
44149
+ }
44150
+ function OfficialNode({ node, fallback, ...render }) {
44151
+ const official = render.official;
44152
+ const [disclosureReset] = (0, react.useState)(() => createSnapshotStore(0));
44153
+ if (!official) return fallback;
44154
+ const owner = officialNodeOwner(render, official);
44119
44155
  const turn = node.location.kind === "turn" || node.location.kind === "step" ? node.location.turn : void 0;
44120
44156
  const renderNode = official.renderSlot;
44121
44157
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -44135,6 +44171,36 @@ ${trimmed}
44135
44171
  })
44136
44172
  });
44137
44173
  }
44174
+ /**
44175
+ * Render one assistant-step node through the official mirror seat. Only an
44176
+ * external shadow takeover (negative priority) is mirrored there; the host's own
44177
+ * assistant-step entry is filtered out, so the default path renders nothing and
44178
+ * the Reader keeps its own segmentation.
44179
+ */
44180
+ function AssistantStepDelegation({ node, ...render }) {
44181
+ const official = render.official;
44182
+ const [disclosureReset] = (0, react.useState)(() => createSnapshotStore(0));
44183
+ if (!official) return null;
44184
+ const owner = officialNodeOwner(render, official);
44185
+ const turn = node.location.kind === "turn" || node.location.kind === "step" ? node.location.turn : void 0;
44186
+ const renderNode = official.renderSlot;
44187
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
44188
+ "data-reader-official-node": node.kind,
44189
+ "data-chat-anchor-key": node.key,
44190
+ "data-chat-flow-kind": node.kind,
44191
+ children: renderNode(OFFICIAL_SEATS.nodes, {
44192
+ ...owner,
44193
+ node
44194
+ }, {
44195
+ entryKey: "assistant-step",
44196
+ hookContext: {
44197
+ turnData: turn?.data,
44198
+ disclosureReset
44199
+ },
44200
+ fallback: null
44201
+ })
44202
+ });
44203
+ }
44138
44204
  function OfficialTail({ official, owner, produced }) {
44139
44205
  const tailOwner = owner && official ? {
44140
44206
  ...owner,
@@ -44998,7 +45064,7 @@ ${trimmed}
44998
45064
  function ResultView(props) {
44999
45065
  const { official, entry, model } = props;
45000
45066
  const fallback = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResultFallback, { ...props });
45001
- if (!official || !entry.block || model.name === "render_ui" || model.name === "show_widget") return fallback;
45067
+ if (!official || !entry.block || model.name === "show_widget") return fallback;
45002
45068
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OfficialTool, {
45003
45069
  ...props,
45004
45070
  official,
@@ -50279,9 +50345,17 @@ html:not([data-tidychat-hide-official-nav]) nav[class*="_frame"]:has([class*="_m
50279
50345
  });
50280
50346
  const AssistantNode = (0, react.memo)(function AssistantNode({ useChat, nodeKey, boundary, processOpen = false, pinned = false, folded = false, partStart, motion, pinBottom, onRead, returnFocusTo, ...render }) {
50281
50347
  const node = useChat((snapshot) => snapshot.nodes.get(nodeKey));
50348
+ const shadowStep = useAssistantStepShadow();
50282
50349
  if (!node || node.visibility === "hidden" || !isNode(node, "assistant-step")) return null;
50283
50350
  const data = node.data;
50284
50351
  const parts = assistantSegments(data.blocks);
50352
+ if (shadowStep && render.official) {
50353
+ if (partStart !== void 0 && parts.length > 0 && partStart !== parts[0].start) return null;
50354
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AssistantStepDelegation, {
50355
+ ...render,
50356
+ node
50357
+ }) });
50358
+ }
50285
50359
  const earlier = isEarlierNarration(data, boundary);
50286
50360
  const hasToolCalls = data.blocks.some((block) => block.kind === "tool-call");
50287
50361
  const isProcessStep = earlier || folded || hasToolCalls || boundary.latestStep > 0 && data.step < boundary.latestStep;
@@ -51164,8 +51238,8 @@ html:not([data-tidychat-hide-official-nav]) nav[class*="_frame"]:has([class*="_m
51164
51238
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
51165
51239
  ref: root,
51166
51240
  className: Reader_module_css_default.root,
51167
- "data-reader-build": "0.4.3",
51168
- "data-dsh-tidy-display": "0.4.3",
51241
+ "data-reader-build": "0.4.4",
51242
+ "data-dsh-tidy-display": "0.4.4",
51169
51243
  "data-reader-wait-clock-version": "input-v1",
51170
51244
  "data-reader-wait-start": waitAnchor.time ?? void 0,
51171
51245
  "data-motion": motion ? "on" : "off",