- 审批卡尊重滚动意图,等长切换回底,排队超时按钮修活 - 带图编辑提示不静默丢,删除目标回写,切换文案消歧 - 会话键盘可达+搜索态重命名,筛选计数口径对齐 - 子任务提示正名,看板加载态 - 主题跟随系统,表单脏态拦截,密钥显隐留空提示
3.6 KiB
3.6 KiB
S4 TaskDrawer 查看会话跳转 — 只读勘察
1. 关联数据现状:无现成映射,audit 表可推导(零 schema 变更)
- spawn_agent 工具:src-tauri/src/commands/ai/tools/spawn_agent.rs(声明式注册 L164,handler L195)
- 父会话经 task-local CALLER_CONV 注入;子会话 id =
{parent}::agent-{n}(agentic/sub_agent.rs:215 next_child_id,父 id 内嵌可反推) - 子代理整轨迹落 ai_conversations,V44 origin='sub_agent' 标记(sub_agent.rs:76,452;侧栏/miniapp 按 origin 过滤,commands/conversation.rs:233)
- 父会话经 task-local CALLER_CONV 注入;子会话 id =
- 推导主链 = ai_tool_executions 审计表(V9 建,migrations.rs:1576):每笔工具执行记
conversation_id(发起会话) + tool_name + result(audit/record.rs:31 build_audit_record)
- create_task result =
{"id": task_id, "title", "status"}(tools/task.rs:128) - update/advance_task result =
{"id": task_id, "field", "updated"}(task.rs:167) - spawn_agent result 含 agent_id(即子会话 id,spawn_agent.rs:299)
- create_task result =
- project_events.conversation_id 列存在(models.rs:173 溯源链设计)但 IPC human 路径恒 None,不可依赖
- 最小落点:新增只读 IPC,从 ai_tool_executions 查
tool_name IN ('create_task','update_task','advance_task')且 result JSON 解析后 id 字段 == task_id(精确解析,勿 LIKE 防误命中);不需要 spawn 时写映射表
2. TaskDrawer 现状:src/components/task/TaskDrawer.vue
- Arco Drawer 640px,props { taskId, visible },仅 Tasks.vue:390 挂载
- 数据流:watch(taskId) → load()(L246)= taskApi.get + projectApi.list + ideaApi.list(防慢响应覆盖 L257)
- 挂点:「关联信息」panel L46-83——已有 parent/project/idea 三个 info-item + router-link 先例, 加「关联会话」info-item(v-if 有关联)最贴现状,零新 section
3. 会话跳转机制:无路由,面板 state + switchConversation
- AI 非路由视图:主窗口面板(state.panelOpen,v-show)或分离窗口(state.detached)
- 跳转 =
state.panelOpen = true(useAiPanel persistUiState)+switchConversation(id) - switchConversation(useAiConversations.ts:275)是唯一正规入口:aiApi.switchConversation → parse → activeConversationId → 持久化 df-ai-active-conv;自带"对话不存在"新建兜底/瞬态失败气泡/过期丢弃
- 既有先例:无跨视图跳会话(仅侧栏点击 ConversationSidebar.vue:353);panelOpen=true 写点全在 useAiPanel/useAiWindow 内部 → S4 需新增入口函数
- 坑:子会话(origin 非空)不在侧栏列表,switchConversation 数据面可用但侧栏不高亮;v1 建议只列主会话
- detached 状态主窗口无面板:openConversation 里判 state.detached 时仅 switchConversation 不动面板
4. S4 实施骨架(单代理一轮可完成,5 文件小改)
- 后端 IPC
list_task_conversations(task_id) -> Vec<{conversation_id, tool_name, requested_at}>: 放 src-tauri/src/commands/ai/audit/record.rs(与 list_tool_executions:207 同文件,复用 repo 读); 返回去重按 requested_at 倒序 - 注册:src-tauri/src/lib.rs invoke_handler(list_tool_executions 在 L475,紧邻追加)
- 前端 API:src/api/ai.ts 加 invoke 包装
- 跳转入口:src/composables/ai/useAiConversations.ts export
openConversation(id): if (!state.detached) { state.panelOpen = true; persistUiState() } + await switchConversation(id) - TaskDrawer.vue 关联信息 panel 加 info-item:load() 并行加 listTaskConversations,点击 router 语义改为 openConversation(非 router-link)
- i18n:taskDetail.relatedConversations(zh/en,src/i18n)
- 颗粒评估:后端 1+2 一体、前端 3-6 机械接线,单代理一轮内自证完成;唯一语义决策=result 精确解析 与 detached 分支,已在骨架内定死