Skip to content

fix: DOM 通道多表面兼容——rc.6 异形宿主不再静默丢围栏 (issue #6) - #7

Merged
taekchef merged 1 commit into
mainfrom
fix/dom-channel-multi-surface-rc6
Aug 14, 2026
Merged

fix: DOM 通道多表面兼容——rc.6 异形宿主不再静默丢围栏 (issue #6)#7
taekchef merged 1 commit into
mainfrom
fix/dom-channel-multi-surface-rc6

Conversation

@taekchef

Copy link
Copy Markdown
Collaborator

解决的问题

Closes #6 —— dsh-ui 围栏在 DSH 0.1.0-rc.6 的部分部署上静默不渲染:保持为代码块、控制台零报错。

根因

DOM 渲染通道的围栏发现依赖单一表面契约

契约 旧实现 异形宿主(deepsuite 风格渲染栈)
表面类名 只认 .md-code-block 渲染为 .code-block / .code-block-small
语言标签 只认 banner 里的叶子 div 标签是 span
正文结构 <pre> 直接在表面下 可能被 content div 包裹

→ 插件在异形宿主上完全找不到围栏:renderBlock 根本不会被调用,无任何日志(与报告「静默失败」完全一致)。

修复(0.8.3)

多表面发现,三层递进:

  1. 选择器并集.md-code-block, .code-block, .code-block-small(最外层去重——修饰类子元素不会双计);
  2. 结构兜底:任何 banner 叶子元素文本恰为 dsh-ui(div/span 均可,且必须在 <pre> 正文之外——代码体里出现 dsh-ui 字面量不得误判)且含 <pre> 的元素都被识别为围栏表面——未来任何宿主类名漂移都照常渲染;
  3. 漂移诊断:结构兜底命中未知类名时一次性 console.warn(每次安装一条),「静默失败」从此有迹可查。

已知类名表面保留完整流式能力(按内容流式接管 + 落定标签复核);未知类名表面在标签出现(落定)后立即渲染,不丢内容。

验证

  • 新增 7 个多表面回归测试(.code-block 接管 / .code-block-small / 结构兜底 + 一次性漂移告警 / 代码体含 dsh-ui 字面量不误判 / 嵌套修饰去重 / 同行兄弟围栏 / 异形表面流式接管与落定复核),370 测试全绿
  • 真实环境端到端验证:在运行中的 DSH 0.1.0-rc.6 页面(headless Chrome)注入 .code-block + span 标签 + 包裹正文的异形围栏 → 新 client.js 正确接管并渲染出组件内容;旧 bundle 同样注入则无任何反应。
  • README / README.zh-CN 双通道段落同步说明多表面兼容。

…k surfaces (issue #6)

Fence discovery relied on a single-surface contract: the selector only
matched .md-code-block and the language label only matched a leaf <div>.
DSH 0.1.0-rc.6 deployments with a deepsuite-style render stack paint
fences as .code-block / .code-block-small with a <span> label and a
wrapped body — the channel found nothing, so every dsh-ui fence stayed
a plain code block with zero console output (exactly the report).

Discovery is now multi-surface:
- selector union .md-code-block, .code-block, .code-block-small with
  outermost-element dedup (modifier children never double-count);
- structural backstop: any element whose banner labels it dsh-ui (leaf
  div/span outside the <pre> body — a code body literally containing
  'dsh-ui' must not self-identify) and contains a <pre> is a fence
  surface, so unlisted host classes still render;
- drift diagnostic: a one-time console.warn when the backstop matches
  an unknown surface class, so host DOM drift is never silent again;
- known surfaces keep full streaming takeover (content-identified,
  label-verified at settle); unlisted surfaces render the moment the
  label materialises.

Docs: README/README.zh-CN dual-channel section + CHANGELOG 0.8.3.
Tests: +7 multi-surface regressions (code-block / code-block-small /
structural backstop + one-shot drift warning / body-literal dsh-ui
non-false-positive / nested modifier dedup / sibling surfaces / alien
surface streaming takeover). 370 total, all green.
@taekchef
taekchef merged commit 0e756ef into main Aug 14, 2026
2 checks passed
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.

[Bug] dsh-ui 围栏在 DSH 0.1.0-rc.6 上静默不渲染

1 participant