Files
cc-web/.trellis/tasks/08-18-goal-mode-title/research/goal-message-title-chain.md

23 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Goal 消息与标题链路
## 已确认入口
- `public/app.js`:`buildMsgElement()` 把完整消息对象作为 `meta` 传给 `createMsgElement()`,适合直接读取 `ccwebGoalCommand`,同时覆盖实时和历史消息。
- `server.js`:`persistCodexAppGoalDisplayMessage()` 创建 `role: user`、`ccwebDisplayOnly: true`、带 `ccwebGoalCommand.action: 'set'` 的持久消息,并统一保存会话。
- `server.js`:`handleCodexAppGoalSlashCommand()` 在普通消息运行时之前处理 `/goal`,因此不会触发模型主动调用 `ccweb_set_title`。
- `server.js`:`ensureCodexAppGoalThread()` 复用 `codexAppThreadParams()`;`codexAppThreadConfig()` 会从 runtime MCP 配置写入 `mcp_servers.ccweb`。因此底层 Goal thread 已注册 ccweb MCP,缺口是 `thread/goal/set` 本身不是模型工具调用。
- `server.js`:普通消息只在标题为 `New Chat`/`Untitled` 时取正文前 60 字并设置 `titleSource: 'derived'`。
- `server.js`:`setCurrentConversationTitle()` 展示了 `session_renamed`、`publicTitleMetadata()` 和 `broadcastSessionList()` 的实时通知契约;该 MCP 路径使用 `titleSource: 'llm'`,不能直接复用其来源语义。
- `server.js`:`handleRenameSession()` 将用户标题写为 `titleSource: 'manual'`;`isTitleLockedByUser()` 可阻止自动覆盖。
- `server.js`:`normalizeTitleHistory()` 只保留 `source: 'llm'`,普通 `derived` 标题不进入标题历史。
## 视觉与缓存边界
- 暗金荒野主题 ID 为 `wasteland`。
- Goal 标签只应命中专用 Goal user message selector,不能扩大到普通 `.msg.user`。
- `app.js` 使用动态 `__CC_WEB_FRONTEND_ASSET_VERSION__`;`style.css` 使用固定 query,CSS 变化后需要推进版本并同步回归断言。
## 并行工作边界
当前工作树另有 Codex App 重试修复,涉及 `lib/codex-app-runtime.js`、`scripts/mock-codex-app-server.js`、`scripts/regression.js` 及 Trellis 规范文件。实现可在 `scripts/regression.js` 的 Goal 场景追加断言,但必须保留并发改动,不得重排或还原整文件。