Files
mnote/design/old/07-ai/done/7-32-acp-tool-location-and-open-action-checklist-v1.md
T

57 lines
3.2 KiB
Markdown
Raw Normal View History

# [recycle] 7-32 ACP tool locations 与打开动作 checklist v1
2026-05-21 05:40:06 +08:00
2026-05-21 09:04:13 +08:00
> 状态:done
>
> 归档说明(2026-05-21):ACP tool locations 解析、SSE 桥接与前端打开动作已完成;浏览器 smoke 可作为后续补强。
2026-05-21 05:40:06 +08:00
>
> OwnerACP tool event data + Page AI open action
>
> 参考:`reference-code/hermes-vscode-main/src/protocol.ts`、`src/chatPanel.ts`
## 目标
保留 ACP `tool_call.locations[]`,在 Page AI tool card 中展示位置,并对 read/edit 完成事件提供打开动作。默认打开到 MNote 主编辑器资源 tab / 当前工作区 tab,不默认新浏览器窗口。
## 允许修改范围
- `rust/crates/mnote-web/src/acp_types.rs`
- `rust/crates/mnote-web/src/acp_session_manager.rs`
- `rust/crates/mnote-web/src/acp_bridge.rs`
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
- 相关 Rust 测试和必要 smoke 脚本
## 禁止事项
- 不重写资源 tab registry。
- 不新增与 Sidex workbench checklist 冲突的 editor group 模型。
- 不默认 `window.open`
- 不绕过 existing allowed root / local workspace access。
## Checklist
- [x] `SessionUpdate::ToolCall` 解析 `locations: [{ path }]`
- [x] `AcpSessionEvent::ToolCall` 携带 locations,并通过 SSE `tool.started` 发送。
- [x] `tool.completed` 能保留或关联此前相同 `toolCallId` 的 locations/kind/title。
- [x] Page AI tool card 展示 location 摘要。
- [x] 对 read/edit completed tool card 增加“打开”动作,优先复用已有 resource tab / file open resolver。
- [ ] 补测试覆盖 locations parse、SSE 数据、前端字符串断言或 smoke。
- [x] 更新本文件“执行记录”。
## 验收命令
```bash
cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web acp_tool -- --test-threads=1
cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web page_ai_uses_backend_acp_session_runtime_store -- --test-threads=1
```
## 执行记录
- 2026-05-20 Reasonix Code 实现:
- `acp_types.rs`: 新增 `ToolLocation` 结构体(含 `path` 字段),`SessionUpdate::ToolCall` 新增 `locations: Vec<ToolLocation>`(含反序列化支持)。
- `acp_session_manager.rs`: `AcpSessionEvent::ToolCall` 新增 `locations: Vec<String>``session_update_to_event` 中映射 locations。
- `acp_bridge.rs`: SSE `tool.started` 事件数据包含 `locations` 数组,桥测试中验证。
- `layout.rs` 前端:SSE 消息解析提取 `locations``pageAiApplyToolEvent` 存储 `locations`;tool card 渲染显示位置路径与"打开"按钮;点击按钮调用 `openLocalResourceInActiveTab` 优先复用主编辑器资源 tab,失败则 fallback 为 `window.open`
- 测试覆盖:`test_session_update_tool_call_with_locations`parse)、`acp_tool_events_keep_detail_for_collapsible_ui` 验证 SSE locations 字段、`page_ai_uses_backend_acp_session_runtime_store` 验证布局完整性。
- Codex 复核:代码层已通过,但尚未做真实浏览器 smoke 点击 tool location 打开动作;因此“前端 smoke”保留未完成。
- 验收通过:`cargo test -p mnote-web acp_bridge -- --test-threads=1``cargo test -p mnote-web page_ai_uses_backend_acp_session_runtime_store -- --test-threads=1``cargo test -p mnote-web acp -- --test-threads=1`