docs: record workbench navigation authority

This commit is contained in:
lyon
2026-06-16 11:19:11 +08:00
parent 8ecf592b1b
commit 5f58e32f1c
+2
View File
@@ -21,6 +21,8 @@ Session rail 是该规则的高频区域。`/v1/agent/conversations` 还未返
Workbench 只能维护一条会话恢复与提交路径。首次打开、新建后继续、从左侧 session rail 切换、直接进入 `/workbench/sessions/<conversationId>` 恢复时,都必须以当前 route/active conversation id 作为会话真相,并通过同一条 conversation detail hydration 路径得到 messages、turn state、trace/status 和 markdown 渲染输入;不得另写只消费列表 snapshot、workspace stub 或 localStorage selected id 的恢复分支。
Workbench 的 URL 反射必须服从用户当前导航和组件生命周期。`activeConversationId`、hydrate、select conversation 或列表刷新等异步状态只能在当前 route 仍属于 Workbench section、路径仍是 `/workbench`/`/workspace` 系列且 Workbench 组件仍 active 时,才允许把 URL 反射到 `/workbench/sessions/<conversationId>`;用户已经点击 Dashboard、API Keys、Admin、Settings 或其他非 Workbench 导航后,晚到的 Workbench 响应只能更新 store,不得再调用 `router.replace`/`router.push` 把全局 route 拉回 Workbench。新增 session 恢复或 URL 反射入口时必须复用共享路由守卫,例如 `web/hwlab-cloud-web/src/router/workbench-navigation.ts`,不要在业务组件里各自手写跳转判断。
Workspace 中的 `selectedConversationId``selectedAgentSessionId` 和 selected snapshot 只能作为恢复线索。只有它们的 conversation id 与当前 active conversation id 完全一致,且已经拿到真实 detail 或真实 messages snapshot 时,才允许驱动 composer、message list、final response markdown 和 trace 入口。conversation id 不一致、detail 仍在加载、或 snapshot 只有 trace/session stub 时,不得覆盖当前消息、pending user message、pending agent message、final response markdown 或右上角运行详情入口。
提交消息必须形成新的 selection epoch。`submitMessage()` 开始后,前端应先把 workspace selection 对齐到当前 route/active conversation,再插入本轮 pending user message 和 pending agent message;任何更早的 hydrate/select/list 响应如果属于旧 epoch,不能再覆盖本轮消息、composer 所属会话或 final response 渲染结果。向 `/v1/agent/chat` 发起请求时,payload 中的 `conversationId` 必须等于当前 route/active conversation id;如果本地 workspace selected session 仍指向旧会话,应先对齐本地状态,而不是把提交落到旧会话。