mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-18 13:23:33 +08:00
Completed desktop task bars were only being dismissed locally, which let the persisted task list resurface on refresh or bleed into the next user turn. This wires the existing server-side reset path into the desktop stores and session flow so a finished task cycle is summarized once, cleared locally, and removed remotely before the next round starts. Constraint: Existing task persistence already lives behind the server task-list API and must stay compatible with persisted JSON task files Rejected: Only hide the completed task bar in UI state | left stale persisted tasks behind and reintroduced them on reload Rejected: Clear desktop state without a task summary | dropped useful completion context from the chat transcript Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep desktop task dismissal and task-list persistence behavior aligned; do not reintroduce local-only clearing without covering reload and next-turn flows Tested: `cd desktop && bun run lint` Tested: `cd desktop && bun run test src/stores/cliTaskStore.test.ts src/stores/chatStore.test.ts src/components/chat/SessionTaskBar.test.tsx src/components/chat/ComputerUsePermissionModal.test.tsx` Tested: `bun test src/server/__tests__/e2e/business-flow.test.ts --test-name-pattern "Task Lists API"` Not-tested: Full `bun test src/server/__tests__/e2e/business-flow.test.ts` suite still has unrelated pre-existing failures in Models and Sessions sections
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { api } from './client'
|
|
import type { CLITask, TaskListSummary } from '../types/cliTask'
|
|
|
|
type TaskListsResponse = { lists: TaskListSummary[] }
|
|
type TasksResponse = { tasks: CLITask[] }
|
|
type TaskResponse = { task: CLITask }
|
|
|
|
export const cliTasksApi = {
|
|
/** List all task lists with summaries */
|
|
listTaskLists() {
|
|
return api.get<TaskListsResponse>('/api/tasks/lists')
|
|
},
|
|
|
|
/** Get all tasks for a specific task list */
|
|
getTasksForList(taskListId: string) {
|
|
return api.get<TasksResponse>(`/api/tasks/lists/${encodeURIComponent(taskListId)}`)
|
|
},
|
|
|
|
/** Get a single task */
|
|
getTask(taskListId: string, taskId: string) {
|
|
return api.get<TaskResponse>(`/api/tasks/lists/${encodeURIComponent(taskListId)}/${taskId}`)
|
|
},
|
|
|
|
/** Clear all persisted tasks for a completed task list */
|
|
resetTaskList(taskListId: string) {
|
|
return api.post<{ ok: true }>(`/api/tasks/lists/${encodeURIComponent(taskListId)}/reset`)
|
|
},
|
|
|
|
/** List all tasks across all task lists */
|
|
listAll() {
|
|
return api.get<TasksResponse>('/api/tasks')
|
|
},
|
|
}
|