Add Cloud Console cancel action and cancelled status

- Widen TaskStatus to include "cancelled"; add it to TasksView's
  STATUSES filter dropdown.
- Add TaskCancellationResponse type and cancelTask(taskId) to api.ts.
- Add a Cancel button to TasksView's task detail panel, gated on
  tasks:submit and a non-terminal task status; updates the displayed
  status on success and surfaces errors via the existing error path.
- Extract the cancellability rule into a pure taskCancellation.ts
  module (mirroring taskProgress.ts/plannerHistory.ts) with unit
  tests, since the project has no Vue component-mounting test setup.

Task 6/9 of task-cancellation change.
This commit is contained in:
2026-07-15 18:43:55 +08:00
parent 6776ac2f2d
commit 4d04d7ac83
6 changed files with 94 additions and 5 deletions
+8
View File
@@ -13,6 +13,7 @@ import type {
PluginRecord,
PluginRegistrationPayload,
TaskAttempt,
TaskCancellationResponse,
TaskListResponse,
TaskSubmissionPayload,
TaskStatus,
@@ -239,6 +240,13 @@ export function getTaskAttempts(taskId: string): Promise<TaskAttempt[]> {
return request<TaskAttempt[]>(`/v1/tasks/${encodeURIComponent(taskId)}/attempts`);
}
export function cancelTask(taskId: string): Promise<TaskCancellationResponse> {
return request<TaskCancellationResponse>(
`/v1/tasks/${encodeURIComponent(taskId)}/cancel`,
{ method: "POST" },
);
}
export function getTaskPlannerDecisions(
taskId: string,
attempt: number,