重构: P0前端架构(useAiSend/useAiEvents/useToolCard拆分+status union全)

squash合并:
- P0-1 useAiSend审批抽离(useAiApproval)
- P0-2 useAiEvents switch拆3域handler
- P0-3 useToolCard formatToolResult策略表
- P0-4 status union(Idea+Task+Project+Workflow+AiToolCall)
This commit is contained in:
2026-06-19 15:04:04 +08:00
parent 998a2f243d
commit 5feeaa6cb0
6 changed files with 435 additions and 262 deletions

View File

@@ -36,11 +36,17 @@ export interface CreateIdeaInput {
// 项目
// ============================================================
// ProjectRecord.status union 类型 — 值集对齐后端 ProjectStatus serde (df-types/src/types.rs:90)
// snake_case: planning | in_progress | testing | releasing | completed | paused | cancelled
// 注:前端 constants/dashboard 的 'active' 是 UI 虚拟派生态(非 record 落库值),不进此 union。
export type ProjectStatus =
| 'planning' | 'in_progress' | 'testing' | 'releasing' | 'completed' | 'paused' | 'cancelled'
export interface ProjectRecord {
id: string
name: string
description: string
status: string // planning | in_progress | testing | releasing | completed | paused
status: ProjectStatus
idea_id: string | null
/** 绑定的本地代码目录绝对路径(null=未绑定) */
path: string | null
@@ -84,12 +90,19 @@ export interface PromotionResult {
// 任务
// ============================================================
// TaskRecord.status union 类型 — 值集对齐后端 TaskStatus serde (df-types/src/types.rs:131)
// snake_case: todo | in_progress | in_review | testing | done | blocked | cancelled
// 注:constants/project.ts 的 mapLegacyStatus 兜底老 DB 旧态(completed/review_ready/merged/abandoned),
// 仅在 taskStatusLabel/taskStatusClass 辅助函数内映射,record.status 本身经后端 is_valid 拦截无旧态。
export type TaskStatus =
| 'todo' | 'in_progress' | 'in_review' | 'testing' | 'done' | 'blocked' | 'cancelled'
export interface TaskRecord {
id: string
project_id: string
title: string
description: string
status: string // todo | in_progress | in_review | testing | done | blocked | cancelled
status: TaskStatus
priority: number // 0=critical, 1=high, 2=medium, 3=low
branch_name: string | null
assignee: string | null
@@ -121,11 +134,16 @@ export interface CreateTaskInput {
// 工作流
// ============================================================
// WorkflowRecord.status union 类型 — 值集对齐后端 WorkflowStatus serde (df-types/src/types.rs:195)
// snake_case: pending | running | paused | completed | failed | cancelled
export type WorkflowStatus =
| 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled'
export interface WorkflowRecord {
id: string
name: string
dag_json: string
status: string // running | completed | failed | cancelled
status: WorkflowStatus
triggered_by: string | null
project_id: string | null
task_id: string | null
@@ -320,12 +338,17 @@ export interface AiMessage {
timestamp: number
}
// AiToolCallInfo.status union 类型 — 前端构建(后端无对应 struct,经 audit log/stream event 组装)。
// 值集核验:grep src/composables/ai + src/components 实际使用点 = {running,pending_approval,completed,rejected}。
// 前端为权威源(无后端 enum 约束),保持现状仅抽 alias 便于复用。
export type AiToolCallStatus = 'running' | 'pending_approval' | 'completed' | 'rejected'
/** 工具调用信息 */
export interface AiToolCallInfo {
id: string
name: string
args: unknown
status: 'running' | 'pending_approval' | 'completed' | 'rejected'
status: AiToolCallStatus
result?: unknown
/** 审批风险说明AiApprovalRequired 时填充) */
reason?: string