Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

Merge PR #139: 支持按状态和判定来源筛选审批记录

Autumn-277dfd5f3210c0
diff --cc web/src/components/approval-records.tsx
index eff3902,08c87e8..5b51322
--- a/web/src/components/approval-records.tsx
+++ b/web/src/components/approval-records.tsx
@@@ -24,7 -26,13 +26,14 @@@ import { Select, SelectContent, SelectG
import { Skeleton } from "@/components/ui/skeleton";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { api } from "@/lib/api";
- import type { InterceptApprovalRow, InterceptAudit, InterceptDetail, InterceptPending, InterceptReviewInput } from "@/lib/types";
+ import type {
+ InterceptApprovalFilter,
+ InterceptApprovalRow,
+ InterceptAudit,
+ InterceptDetail,
++ InterceptPending,
+ InterceptReviewInput,
+ } from "@/lib/types";
import { cn } from "@/lib/utils";
function fmtTime(value?: string) {
@@@ -665,26 -674,13 +677,27 @@@ export function ApprovalRecords({ taskI
const id = ++request.current;
if (manual) setRefreshing(true);
try {
- // The approval queue is independent of the current history page. Older
- // requests must remain actionable even when newer decisions fill it.
- const result = taskId
- ? await api.interceptTaskPage(taskId, page, pageSize, filter)
- : await api.interceptHistoryPage(page, pageSize, filter);
++ // The approval queue is independent of the current history page and its
++ // filter. Older requests must remain actionable even when newer decisions
++ // fill the page or a filter would hide them.
+ const [history, pending] = await Promise.allSettled([
- taskId ? api.interceptTaskPage(taskId, page, pageSize) : api.interceptHistoryPage(page, pageSize),
++ taskId ? api.interceptTaskPage(taskId, page, pageSize, filter) : api.interceptHistoryPage(page, pageSize, filter),
+ api.interceptPending(),
+ ]);
if (id !== request.current) return;
- setRows(result.items);
- setTotal(result.total);
- setError("");
+ if (history.status === "fulfilled") {
+ setRows(history.value.items);
+ setTotal(history.value.total);
+ setError("");
+ } else {
+ setError((history.reason as Error).message || "加载失败");
+ }
+ if (pending.status === "fulfilled") {
+ setPendingRows(pending.value);
+ setPendingError("");
+ } else {
+ setPendingError((pending.reason as Error).message || "加载失败");
+ }
if (manual) setRevision((v) => v + 1);
} catch (e) {
if (id === request.current) setError((e as Error).message || "加载失败");
@@@ -720,15 -729,13 +746,19 @@@
await api.interceptDecide(id, decision);
// Invalidate a list request started before this decision.
request.current++;
++ // Optimistically drop the decided item from the independent pending queue
++ // for instant feedback; the re-fetch below reconciles with server truth.
+ setRows((prev) =>
+ prev.map((row) => (row.id === id ? { ...row, status: decision, decided_at: new Date().toISOString() } : row)),
+ );
+ setPendingRows((prev) => prev.filter((row) => row.id !== id));
setRevision((v) => v + 1);
toast.success(decision === "allowed" ? "已允许执行" : "已拒绝执行");
+ // Re-fetch counts and rows: a decided item may no longer match the filter.
+ await latestLoad.current(true);
} catch (e) {
toast.error((e as Error).message);
- await load(true);
+ await latestLoad.current(true);
} finally {
decisionLock.current = false;
setDeciding(false);