feat(frontend): AI 对话核心——视图模型 + 数据/追加 hook + 抽屉(AC-3)

- lib/workbench/aiConversation.ts:纯视图模型(kind 标签/徽标、bubbleSide、
  按 thread 归组 (created_at,seq) 定序、按作用域分区、接受动作映射)+ 单测。
- lib/workbench/useAiConversation.ts:Workbench 级懒加载 + 批量 append(乐观插入 +
  正位对账 / 失败回滚),fail-soft 绝不 throw 进生成/HITL;silent 直投供工具箱页。
  renderHook 测试覆盖懒加载去重、对账、回滚、silent、项目切换复位。
- components/workbench/AiConversationDrawer.tsx:本章对话 + 项目级生成两段的气泡抽屉,
  克隆 ContextDrawer 的 a11y(role=dialog/log、Esc、focus trap、还原焦点);
  ai 气泡挂 DRAFT-only 再接受按钮(替换整章/插入正文/回填选段),不绕开验收事务。
- lib/api/types.ts:re-export AiMessage* 码生成名。
This commit is contained in:
Yaojia Wang
2026-07-09 17:11:09 +02:00
parent dce882ca91
commit ddf7fa061a
6 changed files with 1017 additions and 0 deletions

View File

@@ -125,3 +125,11 @@ export type OutlineSceneIngestView =
// F1拆书入库产物themes/archetypes/structure/hooks → 项目 rules 条目)。
export type TeardownIngestView =
components["schemas"]["TeardownIngestView"];
// AC-3 AI 对话聊天记录作者↔AI 五类往复留痕的 append/list 契约AC-2 C3 扩snake_case
export type AiMessageView = components["schemas"]["AiMessageView"];
export type AiMessageInput = components["schemas"]["AiMessageInput"];
export type AiMessageAppendRequest =
components["schemas"]["AiMessageAppendRequest"];
export type AiMessageListResponse =
components["schemas"]["AiMessageListResponse"];