Merge PR #139: 支持按状态和判定来源筛选审批记录
合并 codex/approval-record-filters,解决与 #133 在 web/src/components/approval-records.tsx 的冲突: - 导入同时保留 InterceptApprovalFilter 与 InterceptPending。 - load() 采用 #133 的独立待审批队列(Promise.allSettled 拉取 /intercept/pending),并把 #139 的 filter 参数透传给历史分页调用; 筛选只作用于历史记录,待处理队列不受 filter 影响,保证跨页/被筛 记录仍可审批。 - decide() 保留 #133 的乐观更新(移除 pendingRows 对应项)叠加 #139 决策后重新拉取以对齐筛选后的计数与行。 验证:前端 tsc 通过、Biome 仅剩预存告警;go build/vet 通过; db TestInterceptApprovalFilters(8 子用例)与 server TestInterceptFilterHTTP 在本地 dev 库均通过。 Closes #139
This commit is contained in:
commit
13ce2ea6e3
8 files changed
+436
-45
No files matched your search
+12
-4
@@ -43,6 +43,7 @@ import type {
|
||||
FindingTraffic,
|
||||
FindingTrafficDetail,
|
||||
IntentAsset,
|
||||
InterceptApprovalFilter,
|
||||
InterceptApprovalRow,
|
||||
InterceptDetail,
|
||||
InterceptPending,
|
||||
@@ -205,6 +206,13 @@ function findingFilterParams(q: Omit<FindingQuery, "page" | "pageSize">): URLSea
|
||||
return p;
|
||||
}
|
||||
|
||||
function interceptPageQuery(page: number, size: number, filter: InterceptApprovalFilter) {
|
||||
const query = new URLSearchParams({ page: String(page), size: String(size) });
|
||||
if (filter.status) query.set("status", filter.status);
|
||||
if (filter.decision_source) query.set("decision_source", filter.decision_source);
|
||||
return query.toString();
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// 后端应用版本号(release 时由 ldflags 注入,默认 "dev")。
|
||||
health: () => get<{ ok: boolean; service: string; version: string }>("/health"),
|
||||
@@ -1068,8 +1076,8 @@ export const api = {
|
||||
get<import("@/lib/types").InterceptExecution>(`/intercept/history/${id}/execution${conversationId ? `?conversation=${conversationId}` : ""}`),
|
||||
interceptDetail: (id: number) => get<InterceptDetail>(`/intercept/history/${id}`),
|
||||
interceptHistory: () => get<{ items: InterceptApprovalRow[] }>("/intercept/history").then((r) => arr(r.items)),
|
||||
interceptHistoryPage: (page = 1, size = 20) =>
|
||||
get<{ items: InterceptApprovalRow[]; total?: number }>(`/intercept/history?page=${page}&size=${size}`).then(
|
||||
interceptHistoryPage: (page = 1, size = 20, filter: InterceptApprovalFilter = {}) =>
|
||||
get<{ items: InterceptApprovalRow[]; total?: number }>(`/intercept/history?${interceptPageQuery(page, size, filter)}`).then(
|
||||
(r) => ({
|
||||
items: arr(r.items),
|
||||
total: r.total ?? r.items?.length ?? 0,
|
||||
@@ -1077,9 +1085,9 @@ export const api = {
|
||||
),
|
||||
interceptTask: (taskId: string) =>
|
||||
get<{ items: InterceptApprovalRow[] }>(`/intercept/task/${taskId}`).then((r) => arr(r.items)),
|
||||
interceptTaskPage: (taskId: string, page = 1, size = 20) =>
|
||||
interceptTaskPage: (taskId: string, page = 1, size = 20, filter: InterceptApprovalFilter = {}) =>
|
||||
get<{ items: InterceptApprovalRow[]; total?: number }>(
|
||||
`/intercept/task/${encodeURIComponent(taskId)}?page=${page}&size=${size}`,
|
||||
`/intercept/task/${encodeURIComponent(taskId)}?${interceptPageQuery(page, size, filter)}`,
|
||||
).then((r) => ({
|
||||
items: arr(r.items),
|
||||
total: r.total ?? r.items?.length ?? 0,
|
||||
|
||||
Reference in new issue
Block a user