Files
goodbuddy/docs/features/conversation-html-rendering/prd.md
T
mesalogo a4b64a1641 feat: preview Agent HTML in conversations and unblock long replies
Agent replies that produced HTML could only be read as source, so users had
to copy the markup into an external file to see the result. Completed Agent
and Subagent output now renders complete HTML documents, single-root HTML
replies, and `html` / `htm` code blocks as an isolated static preview in
place. Each preview keeps a persistent notice that scripts and network are
disabled and offers the same icon actions as Mermaid diagrams: a source
toggle and a full-screen preview. The new "render HTML in conversations"
switch under Platform Features / General is on by default, applies to the
open conversation immediately, and falls back to HTML source when disabled.
Previews cannot run scripts, reach the network, submit forms, open windows,
or load remote media; author stylesheets and inline styles are preserved so
the intended layout survives, and remote resource loading is refused by the
preview CSP instead.

Direct-model replies no longer fail once they grow large. The byte caps on
streaming responses, single stream blocks, non-streaming replies, model tool
arguments, tool request context, aggregate tool results, and accumulated
answer text are removed, so users stop seeing "模型接口流式响应超过安全限制"
on long answers. Response length is now governed by the request timeout,
cancellation, and context compression. Image generation responses keep their
decodable-image validation.

A message sent after a failed or interrupted run stayed in the pending queue
instead of running. The conversation is now released whenever a run reaches
any terminal state, not only when the renderer reports readiness again, and a
dispatched queue item whose run never starts releases its reservation and
returns to pending. Later messages dispatch without extra user action.

Release note: Agent 回复中的 HTML 现在可直接在会话内预览,支持查看源码和全屏预览,默认开启并可在“平台功能 / 通用设置”关闭;直连模型的长回复不再因大小限制中断;上一次运行失败或被中断后,新发送的消息会立即执行而不再排队等待。
2026-09-05 09:10:44 +08:00

3.0 KiB

会话 HTML 渲染产品需求

用户问题

Agent 可以生成网页、报告和交互原型的 HTML,但此前会话只能显示源码或忽略原始标签。 用户必须把内容复制到外部文件后才能查看结果,打断了会话内的阅读和迭代流程。

目标

  • 让 Agent 生成的 HTML 在回复完成后直接显示为网页预览。
  • 保留一键查看原始 HTML 的能力。
  • 允许用户通过平台功能开关恢复为只看源码。
  • 预览不取得 GoodBuddy Renderer 或外部网络能力。

非目标

  • 不执行 Agent 提供的 JavaScript。
  • 不提供联网网页、表单、弹窗或 Electron webview。
  • 不在流式输出中反复加载不完整页面。
  • 不自动把普通会话回复保存为成果。

功能需求

FR-1 默认设置

“会话 HTML 渲染”是应用级持久设置,默认开启。用户可在“设置 > 平台功能 > 通用设置”中立即关闭或重新开启;保存失败时保留最后确认的状态并显示错误。

FR-2 可识别输出

开启后,已完成 Agent 回复中的以下内容显示为静态预览:

  1. 完整 HTML 文档。
  2. 由单一 HTML 根元素构成的完整回复。
  3. Markdown 中标记为 html 或 htm 的代码块。

普通 Markdown 继续按原有规则显示。一个回复中的多个 HTML 代码块各自保持原有位置。

FR-3 回复状态和角色

  • 已完成的主 Agent 正文和已完成的子 Agent 输出可以预览 HTML。
  • 用户消息和 Agent 推理只显示文本或源码。
  • 流式 Agent 正文在完成前显示源码,完成后原位切换为预览。

FR-4 源码、全屏与关闭行为

每个预览持续显示“静态安全预览,脚本和网络已禁用”,并在标题右侧提供两个图标操作:

  1. 源码按钮,就地展开或收起原始 HTML。
  2. 全屏按钮,在应用级 Modal 中查看同一份预览文档。

嵌入预览使用固定高度并在框内滚动,需要更大画面时使用全屏预览。全屏预览可通过关闭 按钮、Escape 或点击遮罩退出,退出后焦点回到全屏按钮。关闭平台功能后,完整 HTML 回复 和 HTML 代码块继续显示源码,不能变成空白。

FR-5 静态隔离

预览必须禁用脚本、网络请求、表单提交、嵌套页面、插件对象和窗口操作。远程链接和远程 媒体不得从预览加载;内联样式和有界的内联位图可用于还原静态视觉。

产品验收

  • 新安装和从旧设置升级后,开关均为开启。
  • 完整 HTML 和 fenced HTML 在已完成的 Agent 回复中显示预览。
  • 关闭开关后,当前会话立即恢复显示源码,重启后选择仍保留。
  • 流式回复、推理和用户消息从不执行 HTML。
  • 预览可通过键盘访问源码和全屏按钮,并具有明确的 iframe 标题。
  • 全屏预览隔离背景、初始聚焦关闭按钮,Escape 退出后焦点回到全屏按钮。
  • 恶意脚本、事件属性、远程资源、表单和嵌套 frame 不进入可执行预览。