feat(web): unified task stream with plan tab, task detail drawer and audit links (FE-1)

Tasks page merges engine runs (with W9-I business fields) into one stream:
all / active / failed / plan tabs, filters for source, business kind, status
and time; detail drawer with business summary, timeline, collapsed engine
steps, cancel/retry and related audit links. The schedule board moves into
the plan tab; card history jumps to the stream filtered by schedule key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-28 16:10:29 +08:00
1 parent f8362a3f4c
commit d8b9bd9662
10 files changed
+1189 -30

No files matched your search

+29 -3
View File
@@ -1,15 +1,24 @@
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { CursorPage, EngineRun, EngineRunDetail, EngineStats } from "@umt/contracts";
import type { CursorPage, EngineBusinessKind, EngineRun, EngineRunDetail, EngineStats } from "@umt/contracts";
import { apiData } from "~/lib/api.ts";
import { qk } from "~/lib/query-keys.ts";
import { errorCode } from "./parse.ts";
export type EngineRunFilters = { status?: string; workflowName?: string };
export type EngineRunFilters = {
status?: string;
workflowName?: string;
businessKind?: EngineBusinessKind;
businessRefId?: string;
/** created_at 下界(ISO) */
from?: string;
};
/** 终态:不能再 cancel */
export const ENGINE_TERMINAL = new Set(["completed", "succeeded", "failed", "canceled"]);
export function useEngineRuns(filters: EngineRunFilters) {
export function useEngineRuns(filters: EngineRunFilters, enabled = true) {
return useInfiniteQuery({
enabled,
queryKey: qk.list("engine", filters),
initialPageParam: undefined as string | undefined,
queryFn: ({ pageParam, signal }) =>
@@ -18,11 +27,28 @@ export function useEngineRuns(filters: EngineRunFilters) {
});
}
/** 只取第一页(首页区块、进行中合并用) */
export function useEngineRunsPage(
filters: EngineRunFilters,
limit = 20,
refetchMs: number | false = 30_000,
enabled = true,
) {
return useQuery({
enabled,
queryKey: qk.list("engine", { ...filters, limit, page: 1 }),
queryFn: ({ signal }) => apiData<CursorPage<EngineRun>>("/engine/runs", { params: { ...filters, limit }, signal }),
refetchInterval: refetchMs,
});
}
export function useEngineRun(id: string | undefined) {
return useQuery({
queryKey: qk.detail("engine", id ?? ""),
queryFn: ({ signal }) => apiData<EngineRunDetail>("/engine/runs/{id}", { pathParams: { id: id ?? "" }, signal }),
enabled: !!id,
// 不存在的 id(旧链接探测)不重试
retry: (count, err) => errorCode(err) !== "not_found" && count < 2,
// 非终态每 5 秒兜底刷新(SSE 事件驱动是主路径)
refetchInterval: (q) => (q.state.data && !ENGINE_TERMINAL.has(q.state.data.status) ? 5_000 : false),
});