cc-haha/desktop/src/stores/cliTaskStore.ts
程序员阿江(Relakkes) d059a8b487 feat: add Provider management UI, CLI Tasks page, and enhance NewTaskModal
- Settings: new Providers tab with full CRUD, activation, and connectivity
  test; Model tab shows active provider name; General tab simplified
- Tasks: new CLI Tasks page displaying task lists from ~/.claude/tasks/
  with status, owner, and dependency (blocks/blockedBy) visualization
- NewTaskModal: add Advanced options (model, permission mode, working dir)
- Backend: fix TaskService to parse CLI V2 task format; extend /api/tasks
  with /lists endpoint for grouped queries
- Fix ModelInfo.context type from number to string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:05:50 +08:00

46 lines
1.1 KiB
TypeScript

import { create } from 'zustand'
import { cliTasksApi } from '../api/cliTasks'
import type { CLITask, TaskListSummary } from '../types/cliTask'
type CLITaskStore = {
taskLists: TaskListSummary[]
selectedListId: string | null
tasks: CLITask[]
isLoading: boolean
fetchTaskLists: () => Promise<void>
selectTaskList: (id: string) => Promise<void>
clearSelection: () => void
}
export const useCLITaskStore = create<CLITaskStore>((set) => ({
taskLists: [],
selectedListId: null,
tasks: [],
isLoading: false,
fetchTaskLists: async () => {
set({ isLoading: true })
try {
const { lists } = await cliTasksApi.listTaskLists()
set({ taskLists: lists, isLoading: false })
} catch {
set({ isLoading: false })
}
},
selectTaskList: async (id) => {
set({ selectedListId: id, isLoading: true })
try {
const { tasks } = await cliTasksApi.getTasksForList(id)
set({ tasks, isLoading: false })
} catch {
set({ tasks: [], isLoading: false })
}
},
clearSelection: () => {
set({ selectedListId: null, tasks: [] })
},
}))