From bcdc88b1a98e2f90c076746f3db58599164a5b72 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 13:07:19 +0800 Subject: [PATCH] auto-sync: 2026-05-17 13:07:19 --- src/frontend/src/store.ts | 81 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/frontend/src/store.ts b/src/frontend/src/store.ts index 51a3e0a..8f5df26 100644 --- a/src/frontend/src/store.ts +++ b/src/frontend/src/store.ts @@ -19,6 +19,44 @@ import { type TaskNode, } from './api'; +// ── v2.6 V2Task 类型(对齐后端 tasks 表)── +export interface V2Task { + id: string; + title: string; + description: string | null; + status: 'pending' | 'claimed' | 'working' | 'review' | 'done' | 'failed' | 'blocked' | 'cancelled'; + assignee: string | null; + assigned_by: string | null; + depends_on: string | null; + parent_task: string | null; + priority: number; + task_type: string | null; + created_at: string; + updated_at: string; + claimed_at: string | null; + completed_at: string | null; + started_at: string | null; + deadline: string | null; + retry_count: number; + max_retries: number; + must_haves: string | null; + risk_level: string | null; + estimated_duration_minutes: number | null; + escalated: number; + // API 聚合字段 + comments_count?: number; + outputs_count?: number; + review_status?: string | null; + latest_event_detail?: string | null; + // expand=all 时附加 + comments?: any[]; + outputs?: any[]; + reviews?: any[]; + decisions?: any[]; + events?: any[]; + experiences?: any[]; +} + // ── Pipeline Definition (PIPE) ── export const PIPE = [ @@ -329,6 +367,11 @@ interface AppStore { projects: Record; selectedProjectId: string | null; + // v2.6: 原生 V2Task + v2tasks: V2Task[]; + v2taskDetail: V2Task | null; + v2tasksLoading: boolean; + // UI State activeTab: TabKey; edictFilter: 'active' | 'archived' | 'all'; @@ -356,6 +399,10 @@ interface AppStore { setSelectedProjectId: (pid: string | null) => void; toast: (msg: string, type?: 'ok' | 'err') => void; + // v2.6 V2Task actions + loadV2Tasks: () => Promise; + loadV2TaskDetail: (taskId: string) => Promise; + // Data fetching loadLive: () => Promise; loadProjects: () => Promise; @@ -382,6 +429,11 @@ export const useStore = create((set, get) => ({ projects: {}, selectedProjectId: null, + // v2.6: 原生 V2Task + v2tasks: [], + v2taskDetail: null, + v2tasksLoading: false, + activeTab: 'tasks', edictFilter: 'active', statusFilter: 'all', @@ -415,6 +467,7 @@ export const useStore = create((set, get) => ({ setApiProjectId(pid); // 切换项目后重新加载 get().loadLive(); + get().loadV2Tasks(); }, toast: (msg, type = 'ok') => { @@ -425,6 +478,34 @@ export const useStore = create((set, get) => ({ }, 3000); }, + // v2.6: 加载项目任务列表 + loadV2Tasks: async () => { + const pid = get().selectedProjectId; + if (!pid) { set({ v2tasks: [] }); return; } + set({ v2tasksLoading: true }); + try { + const res = await fetch(`/api/projects/${pid}/tasks`); + if (res.ok) { + const data = await res.json(); + set({ v2tasks: data.tasks || [] }); + } + } catch { /* silently fail */ } + finally { set({ v2tasksLoading: false }); } + }, + + // v2.6: 加载任务详情(expand=all) + loadV2TaskDetail: async (taskId: string) => { + const pid = get().selectedProjectId; + if (!pid) return; + try { + const res = await fetch(`/api/projects/${pid}/tasks/${taskId}?expand=all`); + if (res.ok) { + const task = await res.json(); + set({ v2taskDetail: task }); + } + } catch { /* silently fail */ } + }, + loadLive: async () => { try { const data = await api.liveStatus();