RSS/list releases that match no subscription or local work no longer hit
TMDB or open a pending item; they go to the identity pool as `unmatched`.
TMDB is queried only on a local alias hit, a published new-title rule whose
prefilter passes, manual/Agent retry, search results, or when the new
setting identity.eagerTmdbLookup (default off) is on. Mirrors MoviePilot:
torrents are recognised only when matched to a subscription or searched,
and recognition failures are logged, not alerted.
- Pending items only for related releases (ambiguous after lookup, or
related to a local work but unresolved); same source + normalized title
merge into one decision ("来源「X」的 N 条资源待识别"), resolve/dismiss
applies to the whole group, members detach as they get resolved.
- Pool governance: unmatched reviews capped (daily, 3x), title_alias
insert trigger wakes similar entries, stale unmatched entries archived
after identity.poolArchiveDays (30); review idempotency keys include the
due time.
- Migration 0047_identity_pool: reason/outcome `unmatched`,
identity_candidate.normalized_title (+trgm index), wake trigger, and
cleanup of open identity_unresolved items with no related work
(dismissed, resolution=moved_to_pool).
- Inbox: group by type + work/source with collapse, hide info-only items
by default (minSeverity=warning), badge counts warning+ only; pool sheet
gets manual TMDB/local-work assign and dismiss; settings card for the
new identity settings.
- Runbook docs/runbook/identity.md.
Requires rebuild/restart (migration runs on start).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.3 KiB
TypeScript
61 lines
2.3 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, minSeverity?: MinSeverity) =>
|
|
["decisions", "summary", status ?? "open", minSeverity ?? "info"] as const,
|
|
};
|
|
|
|
/** 只看不低于此级别的事项;收件箱缺省 warning(隐藏"仅信息"类) */
|
|
export type MinSeverity = "info" | "warning" | "critical";
|
|
export type DecisionFilters = { status?: DecisionStatus; kind?: DecisionKind; minSeverity?: MinSeverity };
|
|
|
|
/** /decisions/summary(合同 DecisionSummary) */
|
|
export { DecisionSummary };
|
|
|
|
const Page = cursorPage(Decision);
|
|
|
|
export function useDecisions(filters: DecisionFilters, enabled = true) {
|
|
return useInfiniteQuery({
|
|
enabled,
|
|
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, minSeverity?: MinSeverity) {
|
|
return useQuery({
|
|
queryKey: decisionKeys.summary(status, minSeverity),
|
|
queryFn: ({ signal }) => getParsed(DecisionSummary, "/decisions/summary", { status, minSeverity }, 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"] });
|
|
},
|
|
});
|
|
}
|