feat(web): W3-3 site workbench, sources/feeds/snapshots, downloads with business timeline, organization records and agent sessions
- sites + /sites/:siteId: organized view with snapshot-first release list, inventory overlay, candidate reasons, volatile-field recheck, stale marking that keeps existing data, live search, unified download entry; origin view placeholder (M2) - sources: feed CRUD/enable/fetch/reset, cursor/health/gap hints; per-site snapshot history - tasks: download tasks with pause/resume (threshold pause cannot be bypassed), plans, cache volume thresholds and cleanup, business timeline (observation → plan → download → organization → agent/engine) - organize: record list/detail with file-level results, manual organize with dryRun preview - agent: session list/page and layout drawer with context prefix; streaming events, tool cards, rejection alerts, compaction, budget meters, model text vs server report; mock switch (?mock=1) until W2-D endpoints land Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6280d52ec3
commit
7103bc8f7c
35 files changed
+6134
-45
No files matched your search
@@ -0,0 +1,79 @@
|
||||
import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { AcquisitionPlan, type ResolutionStatus, WorkbenchReleaseDetail, WorkbenchReleasePage } from "@umt/contracts";
|
||||
import { apiMutate, apiParsed, cleanParams } from "./parse.ts";
|
||||
|
||||
// 站点工作台整理视图(W2-B:/sites/{id}/releases、/sites/{id}/releases/{rid})
|
||||
|
||||
export type ReleaseFilters = {
|
||||
q?: string;
|
||||
category?: string;
|
||||
promotion?: string;
|
||||
resolution?: ResolutionStatus;
|
||||
};
|
||||
|
||||
export const releaseKeys = {
|
||||
all: ["releases"] as const,
|
||||
list: (siteId: string, f: ReleaseFilters, live: boolean) => ["releases", "list", siteId, f, live] as const,
|
||||
detail: (siteId: string, rid: string) => ["releases", "detail", siteId, rid] as const,
|
||||
};
|
||||
|
||||
/**
|
||||
* 统一资源列表,游标分页。live=true 强制实时补查(只对第一页);否则让服务端按"本地无结果或快照过期"自行决定。
|
||||
* 翻页时保留上一次数据,避免"提取失败 = 空列表"。
|
||||
*/
|
||||
export function useSiteReleases(siteId: string | undefined, filters: ReleaseFilters, live = false) {
|
||||
return useInfiniteQuery({
|
||||
queryKey: releaseKeys.list(siteId ?? "", filters, live),
|
||||
enabled: !!siteId,
|
||||
initialPageParam: undefined as string | undefined,
|
||||
placeholderData: keepPreviousData,
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
apiParsed(WorkbenchReleasePage, "/api/v1/sites/:id/releases", {
|
||||
pathParams: { id: siteId ?? "" },
|
||||
params: cleanParams({
|
||||
...filters,
|
||||
cursor: pageParam,
|
||||
limit: 50,
|
||||
live: live && !pageParam ? "true" : undefined,
|
||||
}),
|
||||
signal,
|
||||
}),
|
||||
getNextPageParam: (last) => last.nextCursor ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
/** 资源详情;refresh=true 时实时复核(失败保留既有数据并带 refreshError) */
|
||||
export function useReleaseDetail(siteId: string | undefined, rid: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: releaseKeys.detail(siteId ?? "", rid ?? ""),
|
||||
enabled: !!siteId && !!rid,
|
||||
queryFn: ({ signal }) =>
|
||||
apiParsed(WorkbenchReleaseDetail, "/api/v1/sites/:id/releases/:rid", {
|
||||
pathParams: { id: siteId ?? "", rid: rid ?? "" },
|
||||
signal,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useRefreshReleaseDetail() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ siteId, rid }: { siteId: string; rid: string }) =>
|
||||
apiParsed(WorkbenchReleaseDetail, "/api/v1/sites/:id/releases/:rid", {
|
||||
pathParams: { id: siteId, rid },
|
||||
params: { refresh: "true" },
|
||||
}),
|
||||
onSuccess: (d, v) => qc.setQueryData(releaseKeys.detail(v.siteId, v.rid), d),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一下载入口:与自动收录同一条提交流程(计划 → 去重 → 缓存硬阈值 → 实例选择 → 管理标签)。
|
||||
* 后端对应端点 POST /acquisition-plans(sourceReleaseId + 可选 slotId);未提供时返回 not_found,页面给出说明。
|
||||
*/
|
||||
export function useSubmitRelease() {
|
||||
return useMutation({
|
||||
mutationFn: (body: { sourceReleaseId: string; slotId?: string; note?: string }) =>
|
||||
apiMutate("/api/v1/acquisition-plans", { body }).then((d) => AcquisitionPlan.parse(d)),
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user