Skip to content

Commit 2cfa089

Browse files
committed
feat: render rich tauri agent replies
1 parent 4a02f15 commit 2cfa089

21 files changed

Lines changed: 1378 additions & 143 deletions

docs/diataxis/en/explanation/agent-conversation-focus-mode-plan.md

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,31 @@ This is the current product-facing priority because it connects the existing lea
1313
single, discoverable interaction loop instead of leaving tutor, path, and focus behaviors split
1414
across separate UI surfaces.
1515

16-
## 2026-05-27 Tauri-First Reply Direction
16+
## 2026-05-27 Tauri-First Reply Delivery
1717

18-
Current branch reality is now asymmetric:
18+
The Tauri-first reply-rendering baseline is now implemented.
1919

20-
- the conversation contract is real,
21-
- the knowledge-point/action shell is real,
22-
- Tauri reader hardening is real,
23-
- scoped knowledge-workspace hydration is real,
24-
- but assistant reply rendering is still not real in the same sense.
20+
Delivered now:
2521

26-
If Tauri is temporarily allowed to lead and Godot is treated as a later adaptation target, the
27-
correct architecture center shifts:
28-
29-
- Tauri becomes the rich-render baseline,
30-
- the Reader markdown/math/mermaid pipeline becomes the render substrate,
31-
- Godot later consumes downgraded/materialized output instead of constraining Tauri-first UX now.
32-
33-
### Current code gap
34-
35-
The current backend/frontend contract is only partially product-complete:
36-
37-
- `src/learning/KnowledgeLearningPlatform.ts` returns `assistantMessage`, `citations`, `knowledgePoints`, memory signals, and trace data.
38-
- `src/frontend/agent_workspace.js` still consumes `assistantMessage` as a flat string.
39-
- `src/frontend/workspace_panes.js` still mounts conversation messages through plain `textContent`.
22+
- `src/learning/types.ts` and `src/learning/KnowledgeLearningPlatform.ts` now expose backward-compatible `assistantBlocks` beside legacy `assistantMessage`,
23+
- `src/frontend/markdown_runtime.js` now provides a shared markdown/math/mermaid runtime extracted from the Reader-side logic,
24+
- `src/frontend/workspace_panes.js` now mounts structured assistant replies through typed blocks instead of only plain text when structured payloads are present,
25+
- `src/frontend/agent_workspace.js` keeps the legacy fallback path so older `assistantMessage`-only responses still work,
26+
- `html_artifact` rendering now has a sandboxed preview path instead of requiring arbitrary full-HTML injection into the main chat DOM.
4027

41-
That means:
28+
If Tauri is temporarily allowed to lead and Godot is treated as a later adaptation target, the
29+
architecture center is now aligned as intended:
4230

43-
- grounded retrieval works,
44-
- action orchestration works,
45-
- but markdown, KaTeX, Mermaid, and structured HTML do not yet reach the agent reply surface.
31+
- Tauri is the rich-render baseline,
32+
- the Reader markdown/math/mermaid pipeline is the render substrate,
33+
- Godot can later consume downgraded/materialized output instead of constraining Tauri-first UX now.
4634

47-
### Tauri-first implementation program
35+
### Delivered implementation program
4836

4937
1. **Response contract evolution**
50-
- Keep `assistantMessage` as a compatibility fallback.
51-
- Add an `assistantBlocks` shape for typed reply rendering.
52-
- Start with:
38+
- `assistantMessage` remains as a compatibility fallback.
39+
- `assistantBlocks` is now present for typed reply rendering.
40+
- Current block baseline:
5341
- `main_markdown`
5442
- `citations`
5543
- `knowledge_actions`
@@ -62,34 +50,39 @@ That means:
6250
- `src/server.ts`
6351

6452
2. **Shared render runtime extraction**
65-
- Reuse the mature Reader pipeline instead of creating a fourth markdown path.
66-
- Extract the reusable markdown/math/mermaid runtime from:
53+
- The mature Reader pipeline is now reused instead of creating a fourth markdown path.
54+
- The reusable markdown/math/mermaid runtime is extracted from:
6755
- `src/frontend/reader.js`
6856
- `src/frontend/app.js`
6957
- `src/reader_renderer.ts`
7058
- `src/routes/render.ts`
71-
- The shared runtime should remain browser/Tauri-friendly and later support Godot materialization without being designed around it now.
59+
- The shared runtime remains browser/Tauri-friendly and preserves a later Godot materialization boundary.
7260

7361
3. **Message block renderer in the agent workspace**
74-
- Replace plain message mounting with a typed block renderer.
75-
- Keep conversation-card/result-presentation registries intact.
76-
- Introduce a dedicated assistant-reply renderer in:
62+
- Plain message mounting is now replaced by a typed block renderer where structured payloads are present.
63+
- Conversation-card/result-presentation registries remain intact.
64+
- Assistant-reply rendering now lives in:
7765
- `src/frontend/agent_workspace.js`
7866
- `src/frontend/workspace_panes.js`
7967
- `src/frontend/index.html`
8068
- `src/frontend/styles.css`
8169

8270
4. **HTML artifact path**
83-
- Do not inject arbitrary full HTML into the main chat DOM.
84-
- Treat large HTML payloads as artifacts with a sandboxed preview flow.
85-
- This should mirror the existing product direction already proven in external references like Cherry Studio, while staying stack-native to NoteConnection.
71+
- Arbitrary full HTML is not injected into the main chat DOM.
72+
- Large HTML payloads are treated as artifacts with a sandboxed preview flow.
8673

8774
5. **Streaming and transition safety**
88-
- Keep current SSE + sync fallback behavior.
89-
- Stream into `main_markdown` blocks rather than directly mutating plain-text message nodes.
90-
- Preserve current `knowledgePoints` and capability execution behavior during the transition so the upgrade is forward-compatible rather than a rewrite.
75+
- SSE + sync fallback behavior is preserved.
76+
- Structured replies now flow through `main_markdown` blocks while legacy replies still fall back cleanly.
77+
- Current `knowledgePoints` and capability execution behavior stays forward-compatible.
78+
79+
### Remaining follow-up
80+
81+
- expand block usage where future endpoints emit richer assistant payloads,
82+
- keep the new render substrate honest through real browser/Tauri verification,
83+
- decide later whether Reader itself should delegate more of its internal rendering helpers to the shared runtime rather than only sharing extracted logic.
9184

92-
### Acceptance criteria for this next slice
85+
### Acceptance criteria for this delivered slice
9386

9487
1. Tauri agent replies can render markdown headings, lists, tables, KaTeX, and Mermaid without leaving persistent error overlays in the visible chat surface.
9588
2. The reply surface still works when only legacy `assistantMessage` is present.

docs/diataxis/en/explanation/development-progress-dashboard.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ Implemented now at current HEAD:
3333
- Debug and evidence tooling:
3434
- the repository now ships runtime/webview/window capture helpers plus Mermaid stage/export tooling under `scripts/`, so live Tauri failures can be inspected with first-party evidence commands instead of one-off manual probing.
3535

36-
Current Tauri product gap:
36+
Tauri-first reply rendering baseline delivered:
3737

38-
- The agent reply area is still plain-text oriented.
39-
- `src/frontend/agent_workspace.js` still consumes `assistantMessage` as a flat string, and `src/frontend/workspace_panes.js` still mounts conversation messages via `node.textContent = message`.
40-
- This means the current Tauri chat shell can issue grounded requests and action cards, but it still does not reuse the mature Reader markdown/math/mermaid rendering path for assistant replies.
41-
- The next delivery step is therefore not another generic shell expansion. It is a Tauri-first reply-rendering upgrade that preserves the current contract while introducing a richer message model.
38+
- `src/learning/types.ts` and `src/learning/KnowledgeLearningPlatform.ts` now expose backward-compatible `assistantBlocks` alongside legacy `assistantMessage`,
39+
- `src/frontend/markdown_runtime.js` now carries a shared markdown/math/mermaid runtime extracted from the Reader-side logic,
40+
- `src/frontend/workspace_panes.js` now mounts assistant replies through typed blocks instead of only plain text when structured payloads are present,
41+
- `src/frontend/agent_workspace.js` keeps legacy fallback behavior intact, so older `assistantMessage`-only flows still render.
42+
43+
The next gap is narrower now:
44+
45+
- broaden block coverage where future endpoints emit richer assistant payloads,
46+
- keep the new render substrate honest under real browser/Tauri runtime verification,
47+
- preserve a clean downgrade/materialization boundary for later Godot reuse.
4248

4349
Code-vs-plan reality for this slice:
4450

@@ -48,7 +54,7 @@ Code-vs-plan reality for this slice:
4854
| Tauri markdown reader parity | markdown, math, and Mermaid should survive real runtime conditions without persistent error overlays | reader/runtime paths now render Mermaid with frontend-first + backend-PNG fallback and suppress leaked error artifacts | Operational |
4955
| Provider settings | provider/model/API-key controls should be isolated and write durable TOML configuration | dedicated agent/provider settings surface plus preset/TOML template helpers are now present | Operational |
5056
| Conversation retry transport | turn/replay headers should survive browser/Tauri preflight | CORS now allows both conversation turn headers | Closed |
51-
| Tauri agent reply rendering | assistant replies should render rich markdown instead of plain text | reply area still uses `assistantMessage` + `textContent` and therefore remains rendering-incomplete | Open |
57+
| Tauri agent reply rendering | assistant replies should render rich markdown instead of plain text | backward-compatible `assistantBlocks` plus shared markdown runtime now power rich assistant replies, while legacy `assistantMessage` remains supported | Operational |
5258

5359
## 2026-05-26 Program F Closure
5460

@@ -169,8 +175,8 @@ Current branch status for this slice:
169175
- graph-focus fullscreen now promotes the real graph workspace instead of only enlarging a metadata card (`src/frontend/workspace_panes.js`, `src/frontend/styles.css`),
170176
- the scoped-knowledge conversation flow is now materially more honest about corpus readiness: active folder target flows into the request contract, the server selectively hydrates likely title-matching documents into the workspace, and conversation traces now include readiness + miss diagnostics instead of only returning an empty top-k result (`src/frontend/source_manager.js`, `src/frontend/agent_workspace.js`, `src/server.ts`, `src/routes/data.ts`, `src/learning/KnowledgeLearningPlatform.ts`),
171177
- the new agent workspace shell now has i18n coverage for static shell strings plus runtime button/empty-state messaging, existing knowledge-card actions / localized system messages now re-render on language change instead of staying in the previous locale, conversation card rerender is now centralized through a card-kind renderer registry, and a source-level parity guard now checks append-kind vs registry alignment (`src/frontend/index.html`, `src/frontend/locales/en.json`, `src/frontend/locales/zh.json`, `src/frontend/workspace_panes.js`, `src/frontend/agent_workspace.js`, `src/agent_workspace.frontend.test.ts`),
172-
- provider/model/API-key settings are now isolated into a dedicated agent settings page with preset-template and TOML-template flows, but reply rendering in that same workspace still remains plain-text and is therefore the next obvious Tauri-first closure item (`src/frontend/index.html`, `src/frontend/settings.js`, `src/notemd/AppConfigToml.ts`, `src/notemd/providerTemplates.ts`),
173-
- the reader/runtime render stack is now substantially more robust for Tauri markdown usage: raw markdown, KaTeX, Mermaid frontend render, Mermaid backend PNG fallback, and leaked Mermaid error suppression are all present; the missing step is to reuse that stack inside the agent reply surface instead of keeping it isolated to the Reader (`src/frontend/reader.js`, `src/frontend/app.js`, `src/reader_renderer.ts`, `src/routes/render.ts`, `src/notemd/MermaidProcessor.ts`),
178+
- provider/model/API-key settings are now isolated into a dedicated agent settings page with preset-template and TOML-template flows, and the same agent workspace now also has a typed rich-reply baseline instead of staying plain-text-only (`src/frontend/index.html`, `src/frontend/settings.js`, `src/notemd/AppConfigToml.ts`, `src/notemd/providerTemplates.ts`, `src/frontend/markdown_runtime.js`, `src/frontend/workspace_panes.js`, `src/frontend/agent_workspace.js`),
179+
- the reader/runtime render stack is now substantially more robust for Tauri markdown usage: raw markdown, KaTeX, Mermaid frontend render, Mermaid backend PNG fallback, leaked Mermaid error suppression, and a shared markdown runtime for agent replies are all present (`src/frontend/reader.js`, `src/frontend/app.js`, `src/frontend/markdown_runtime.js`, `src/reader_renderer.ts`, `src/routes/render.ts`, `src/notemd/MermaidProcessor.ts`),
174180
- locale governance now includes backend-to-frontend capability label-key parity blocking: emitted conversation capability `labelKey` values must resolve to non-empty bilingual `agentWorkspace.actions.*` entries (`src/learning/KnowledgeLearningPlatform.ts`, `src/frontend/locales/en.json`, `src/frontend/locales/zh.json`, `src/agent_workspace.locale.contract.test.ts`),
175181
- modular knowledge-route closure now includes live browser strict proof instead of snapshot-only recovery: conversation response wiring, capability-triggered request routes, card-title localization, and graph-focus compatibility now pass `STRICT`, `UI_STRICT`, and `UI_DYNAMIC_STRICT` against real browser/network traces (`src/routes/knowledge.ts`, `src/learning/KnowledgeLearningPlatform.ts`, `src/frontend/app.js`, `src/frontend/locales/en.json`, `src/frontend/locales/zh.json`, `scripts/verify-agent-workspace-browser.js`),
176182
- locale governance now also blocks capability failure-message drift: emitted `failure.messageKey` values must resolve to bilingual `agentWorkspace.messages.*` entries with aligned interpolation placeholders and stable fallback placeholder sets (`src/learning/KnowledgeLearningPlatform.ts`, `src/frontend/locales/en.json`, `src/frontend/locales/zh.json`, `src/agent_workspace.locale.contract.test.ts`),

docs/diataxis/zh/explanation/agent-conversation-focus-mode-plan.md

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,30 @@
99
- `focus mode``学习路径` 两个 pane 可以并排共存,
1010
- 两个 pane 都支持各自独立提升为全屏。
1111

12-
## 2026-05-27 Tauri-first 回复渲染方向
12+
## 2026-05-27 Tauri-first 回复渲染交付
1313

14-
当前分支现实已经出现明显不对称:
14+
Tauri-first reply-rendering baseline 现已实现。
1515

16-
- conversation contract 已经是真实的,
17-
- knowledge-point / action shell 已经是真实的,
18-
- Tauri Reader 渲染加固已经是真实的,
19-
- scoped knowledge workspace hydration 已经是真实的,
20-
- 但 assistant reply rendering 还没有以同样强度变成“真实产品能力”。
16+
当前已交付:
2117

22-
如果暂时允许 Tauri 优先、把 Godot 视为后续适配目标,那么正确的架构重心应调整为:
18+
- `src/learning/types.ts``src/learning/KnowledgeLearningPlatform.ts` 现已在保留 legacy `assistantMessage` 的同时返回向前兼容的 `assistantBlocks`
19+
- `src/frontend/markdown_runtime.js` 现已提供一套从 Reader 侧逻辑抽取出来的共享 markdown / math / mermaid runtime,
20+
- `src/frontend/workspace_panes.js` 现已在结构化载荷存在时通过 typed blocks 挂载 assistant reply,而不再只走纯文本,
21+
- `src/frontend/agent_workspace.js` 继续保留 legacy fallback,因此旧的 `assistantMessage`-only 响应仍可显示,
22+
- `html_artifact` 现已具备 sandboxed preview 路径,而不再需要把任意完整 HTML 直接注入主聊天 DOM。
2323

24-
- 以 Tauri 作为 rich-render baseline,
25-
- 以 Reader 的 markdown / math / mermaid 渲染链作为主渲染 substrate,
26-
- Godot 未来消费的是降级 / 物化后的输出,而不是反过来在当前阶段约束 Tauri 的交互体验。
24+
如果暂时允许 Tauri 优先、把 Godot 视为后续适配目标,那么架构重心现在已经按预期对齐:
2725

28-
### 当前代码缺口
26+
- Tauri 是 rich-render baseline,
27+
- Reader 的 markdown / math / mermaid 管线是主渲染 substrate,
28+
- Godot 未来消费的是降级 / 物化后的输出,而不是继续反向约束当前 Tauri UX。
2929

30-
目前后端 / 前端契约只完成了一半:
31-
32-
- `src/learning/KnowledgeLearningPlatform.ts` 已返回 `assistantMessage``citations``knowledgePoints`、memory signals 与 trace data,
33-
- `src/frontend/agent_workspace.js` 仍把 `assistantMessage` 当作平铺字符串消费,
34-
- `src/frontend/workspace_panes.js` 仍通过普通 `textContent` 挂载 conversation 消息。
35-
36-
这意味着:
37-
38-
- grounded retrieval 已经成立,
39-
- action orchestration 已经成立,
40-
- 但 markdown、KaTeX、Mermaid 与结构化 HTML 还没有真正进入 agent reply surface。
41-
42-
### Tauri-first 实施方案
30+
### 已交付实施方案
4331

4432
1. **响应契约演进**
45-
- 保留 `assistantMessage` 作为兼容回退字段
46-
- 增加 `assistantBlocks` 作为 typed reply rendering 载体
47-
- 第一批 block 类型建议至少包含
33+
- `assistantMessage` 继续作为兼容回退字段保留
34+
- `assistantBlocks` 已作为 typed reply rendering 载体落地
35+
- 当前 block 基线包含
4836
- `main_markdown`
4937
- `citations`
5038
- `knowledge_actions`
@@ -57,32 +45,37 @@
5745
- `src/server.ts`
5846

5947
2. **共享渲染运行时抽取**
60-
- 直接复用 Reader 成熟链路,而不是再造第四套 markdown 路径,
61-
- 从以下位置抽取可复用的 markdown / math / mermaid runtime:
48+
- 已直接复用 Reader 成熟链路,而不是再造第四套 markdown 路径,
49+
- 可复用的 markdown / math / mermaid runtime 已从以下位置抽取
6250
- `src/frontend/reader.js`
6351
- `src/frontend/app.js`
6452
- `src/reader_renderer.ts`
6553
- `src/routes/render.ts`
66-
- 该共享 runtime 需要首先服务 browser/Tauri,同时保留未来为 Godot 做物化输出的能力,但当前不应被 Godot-first 设计反向约束
54+
- 这套共享 runtime 现已首先服务 browser/Tauri,同时保留未来为 Godot 做物化输出的边界
6755

6856
3. **agent workspace 中的消息块渲染器**
69-
- typed block renderer 替换当前的 plain message mounting,
70-
- 保持现有 conversation-card / result-presentation registry 继续可用
71-
- 在以下文件中引入专用 assistant-reply renderer:
57+
- 结构化载荷存在时,已用 typed block renderer 替换当前的 plain message mounting,
58+
- 现有 conversation-card / result-presentation registry 继续保持可用
59+
- assistant-reply renderer 现已落在以下文件中
7260
- `src/frontend/agent_workspace.js`
7361
- `src/frontend/workspace_panes.js`
7462
- `src/frontend/index.html`
7563
- `src/frontend/styles.css`
7664

7765
4. **HTML artifact 路径**
78-
- 不要把任意完整 HTML 直接注入主聊天 DOM,
79-
- 对较大 HTML 结果采用 artifact 语义,并通过 sandboxed preview 路径展示,
80-
- 这条产品方向可以参考 Cherry Studio 的思路,但实现必须保持 NoteConnection 当前栈内生,而不是复制外部架构。
66+
- 任意完整 HTML 不会直接注入主聊天 DOM,
67+
- 较大 HTML 输出会通过 artifact 语义与 sandboxed preview 路径展示。
8168

8269
5. **流式输出与迁移安全**
83-
- 保留当前 SSE + sync fallback 行为,
84-
- 将流式内容写入 `main_markdown` block,而不是直接操作纯文本消息节点,
85-
- 在迁移期间保持现有 `knowledgePoints` 与 capability execution 行为不变,使这次升级成为 forward-compatible 演进,而不是推倒重来。
70+
- 当前 SSE + sync fallback 行为已保留,
71+
- 结构化回复现已通过 `main_markdown` block 进入渲染链,而 legacy 回复仍能平滑回退,
72+
- 现有 `knowledgePoints` 与 capability execution 行为保持向前兼容。
73+
74+
### 剩余跟进项
75+
76+
- 当更多端点开始返回 richer assistant payload 时,继续扩充 block 覆盖面,
77+
- 让新的共享 render substrate 在真实 browser/Tauri 运行时下持续经受验证,
78+
- 后续再决定是否让 Reader 本体进一步委托更多内部 helper 给这套共享 runtime,而不是只共享已抽取逻辑。
8679

8780
### 本阶段验收标准
8881

0 commit comments

Comments
 (0)