- Agent page uses contracts (AgentRun/AgentRunDetail/AgentGoalReport) instead of a local mirror; ?mock=1 stays as an explicit demo switch; run snapshot refreshes on agent.run_status; stream auto-follow only while the user stays near the bottom (abort stays reachable) - settings: Pi provider select incl. fake, new Agent runtime card (budgets, fakeScript) - download trace uses /tasks?subjectId= and /organization-records?downloadTaskId= instead of time-window engine run matching and path matching; new business-task tab with cancel/retry - workbench download dialog posts /acquisition-plans and shows per-slot rejection reasons - preference tag revision history; subscription search by title/kind; identity/alias/subscription lists show entity titles; slot cards show current asset summary; policy preview sample titles - DecisionSummary / IdentityRevisionList / ReleaseIdentityResult / TaskAccepted / PolicyPreviewSummary / OrganizePlanArtifactContent taken from contracts - docs: SSE for console (cookie) vs GET /events?after=&limit= JSON replay for API keys Co-Authored-By: Claude Opus 5.5 <[email protected]>
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import {
|
|
cursorPage,
|
|
Decision,
|
|
type DecisionKind,
|
|
type DecisionResolveInput,
|
|
type DecisionStatus,
|
|
DecisionSummary,
|
|
} from "@umt/contracts";
|
|
import { api } from "~/lib/api.ts";
|
|
import { getParsed, parseOrThrow } from "./library.ts";
|
|
|
|
// 待处理中心:按作品与问题类型聚合(summary),条目带证据/建议/影响范围,resolve 选项来自 decision.options。
|
|
|
|
export const decisionKeys = {
|
|
all: ["decisions"] as const,
|
|
list: (f: DecisionFilters) => ["decisions", "list", f] as const,
|
|
summary: (status?: DecisionStatus) => ["decisions", "summary", status ?? "open"] as const,
|
|
};
|
|
|
|
export type DecisionFilters = { status?: DecisionStatus; kind?: DecisionKind };
|
|
|
|
/** /decisions/summary(合同 DecisionSummary) */
|
|
export { DecisionSummary };
|
|
|
|
const Page = cursorPage(Decision);
|
|
|
|
export function useDecisions(filters: DecisionFilters) {
|
|
return useInfiniteQuery({
|
|
queryKey: decisionKeys.list(filters),
|
|
initialPageParam: undefined as string | undefined,
|
|
queryFn: ({ pageParam, signal }) =>
|
|
getParsed(Page, "/decisions", { ...filters, cursor: pageParam, limit: 100 }, signal),
|
|
getNextPageParam: (last) => last.nextCursor ?? undefined,
|
|
placeholderData: keepPreviousData,
|
|
});
|
|
}
|
|
|
|
export function useDecisionSummary(status?: DecisionStatus) {
|
|
return useQuery({
|
|
queryKey: decisionKeys.summary(status),
|
|
queryFn: ({ signal }) => getParsed(DecisionSummary, "/decisions/summary", { status }, signal),
|
|
});
|
|
}
|
|
|
|
export function useResolveDecision() {
|
|
const qc = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, ...body }: DecisionResolveInput & { id: string }) =>
|
|
api.post<unknown>(`/decisions/${id}/resolve`, body).then((d) => parseOrThrow(Decision, d, "/decisions")),
|
|
onSuccess: () => {
|
|
void qc.invalidateQueries({ queryKey: decisionKeys.all });
|
|
void qc.invalidateQueries({ queryKey: ["identity"] });
|
|
},
|
|
});
|
|
}
|