auto-sync: 2026-05-17 13:07:19

This commit is contained in:
cfdaily
2026-05-17 13:07:19 +08:00
parent 1f7f554a0b
commit bcdc88b1a9
+81
View File
@@ -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<string, any>;
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<void>;
loadV2TaskDetail: (taskId: string) => Promise<void>;
// Data fetching
loadLive: () => Promise<void>;
loadProjects: () => Promise<void>;
@@ -382,6 +429,11 @@ export const useStore = create<AppStore>((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<AppStore>((set, get) => ({
setApiProjectId(pid);
// 切换项目后重新加载
get().loadLive();
get().loadV2Tasks();
},
toast: (msg, type = 'ok') => {
@@ -425,6 +478,34 @@ export const useStore = create<AppStore>((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();