Skip to content

fix: render dsh-ui fences when the host row lacks data-chat-anchor-key (Safari) - #2

Merged
taekchef merged 1 commit into
mainfrom
fix/safari-fence-anchor-fallback
Aug 14, 2026
Merged

fix: render dsh-ui fences when the host row lacks data-chat-anchor-key (Safari)#2
taekchef merged 1 commit into
mainfrom
fix/safari-fence-anchor-fallback

Conversation

@taekchef

Copy link
Copy Markdown
Collaborator

Closes #1 — Safari 下 dsh-ui 围栏全部静默丢失。

根因

宿主把 data-chat-anchor-key 渲染为 React key 派生属性(routedNode.key);Safari 的渲染路径里该 key 为 undefined 时 React 直接省略属性 → rowOf 落空 → DOM 通道在静默 return 点放弃每个围栏(无 UI、无报错、无日志)。Chrome 同页 14 个代码块全有锚点、Safari 0 个,与 issue 排查一致。

修复(src/client/dom-fence.tsx

  • 行解析降级链[data-chat-anchor-key][data-chat-flow-key]/[data-chat-flow-kind](宿主同一行 div 的路由属性,kind 独立于 key、可幸存)→ 代码块自身(身份降级为 dom:unknown:<序数>
  • fenceIndexOf:无行兜底时按全文档已落定 dsh-ui 块序数计数,兄弟围栏不会撞同一个 dom:unknown:N
  • anchorSeqOf:文档序兜底改用联合选择器,无锚点行仍得单调 seq 估计
  • 诊断:所有静默 return 点加一次性 console.warn[dsh-genui] 前缀,WeakSet 每块一次,1s sweep 不刷屏):无锚点降级 / 落定空体 / 落定不可修复体

验证

  • 新增 5 个 Safari 回归测试(无锚点行渲染、无行直接挂 body、同无锚点行兄弟围栏身份不折叠、无锚点一次告警、落定坏体一次告警)
  • 全量 360 项:258 passed / 102 skipped(skip 为原有 registry 通道门控),0 失败
  • lib/client.js 已重建并提交

…y (Safari)

Safari (and any host render path that drops the routed node's React key)
omits `data-chat-anchor-key` from message rows — Chrome renders the same
page with it. `rowOf` returned null there and the DOM channel silently
abandoned every fence: no UI, no error, no log.

- rowOf fallback chain: [data-chat-anchor-key] → [data-chat-flow-key]/
  [data-chat-flow-kind] (the same row div's routing attributes; kind is a
  separate value that survives an undefined key) → the code block itself,
  with identity degrading to dom:unknown:<ordinal>.
- fenceIndexOf: when the chain bottoms out at the block, count settled
  dsh-ui blocks in document order so sibling fences never collide on one
  dom:unknown:N identity.
- anchorSeqOf: document-order fallback now counts flow rows too, so
  anchor-less rows keep a monotonic seq estimate.
- Diagnostics: every silent return point warns once per block
  (`[dsh-genui]` prefix, WeakSet-guarded against the 1s sweep) — missing
  anchor, settled empty body, settled unrepairable body.

Closes #1
@taekchef
taekchef merged commit ceab0ed into main Aug 14, 2026
2 checks passed
@taekchef
taekchef deleted the fix/safari-fence-anchor-fallback branch August 14, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacOS 下 Chrome 正常渲染但是 Safari JS报错无法正常使用

1 participant