mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 08:41:59 +00:00
审阅队列成批审阅之后列表头的「N 项待确认」跟着变:总数减掉列表里已经不是推断的项(成批审阅、表详情里改过的),撤销审阅回到推断的、冲突的照算,和视图标签、按表筛选的计数同一个口径;载入下一页的偏移用同一个算法;check-catalog-loop 补纯函数和成批确认、撤销审阅、单项确认、刷新之后的计数检查
This commit is contained in:
@@ -10,15 +10,16 @@ import { errorMessage } from '../../lib/errors'
|
||||
import { CATALOG_REVIEW_TEXT as RT } from '../../lib/terms'
|
||||
import { StatusChip } from './parts'
|
||||
import {
|
||||
REVIEW_BATCH_MAX, REVIEW_KINDS, REVIEW_PAGE, applyResults, batchTargets, confirmProgress, itemKey, reviewWhere, statusOf,
|
||||
syncFromDetail,
|
||||
REVIEW_BATCH_MAX, REVIEW_KINDS, REVIEW_PAGE, applyResults, batchTargets, confirmProgress, itemKey, pendingTotal, reviewWhere,
|
||||
reviewedCount, statusOf, syncFromDetail,
|
||||
} from './review'
|
||||
import type { ItemOutcome } from './review'
|
||||
|
||||
// ===========================================================================
|
||||
// 审阅队列(数据目录页的「审阅队列」视图,左栏):跨表列出推断项,顺序由服务端排好(所在表的使用次数 × 这一项对数字的
|
||||
// 影响 × 来源),每一项写为什么排在这里。可以按项(影响数字的项 / 名称和含义)和表筛选;多选后成批确认、驳回,审阅过的
|
||||
// 原地标出结果(冲突的标出来),选中可以撤销审阅;刷新队列后审阅过的才移除。顶上是审阅进度:常用表(使用次数最多、
|
||||
// 原地标出结果(冲突的标出来),选中可以撤销审阅;刷新队列后审阅过的才移除,列表头的「N 项待确认」审阅成功一项就少一项
|
||||
// (pendingTotal,和视图标签、按表筛选的计数同一个口径)。顶上是审阅进度:常用表(使用次数最多、
|
||||
// 被运行用过的前 20 张)、全部表、影响数字的项各确认了多少,三行同一个口径。点开一项,右栏是所在表的详情(滚到那一项、
|
||||
// 标出来)和用过这张表的运行。
|
||||
// ===========================================================================
|
||||
@@ -96,7 +97,7 @@ export function ReviewQueue({ sourceId, rows, kind, table, activeKey, detailSync
|
||||
const loadMore = async () => {
|
||||
const list = itemsRef.current
|
||||
if (!list || loadingMore) return
|
||||
const gone = list.filter((i) => statusOf(i, outcomes.get(itemKey(i))) !== 'proposed').length
|
||||
const gone = reviewedCount(list, outcomes)
|
||||
setLoadingMore(true)
|
||||
try {
|
||||
const q = await api.dataCatalog.reviewQueue(sourceId, { limit: REVIEW_PAGE, offset: list.length - gone, kind, table: table || null })
|
||||
@@ -193,7 +194,9 @@ export function ReviewQueue({ sourceId, rows, kind, table, activeKey, detailSync
|
||||
reset: batchTargets(loaded, selected, 'reset', outcomes).length,
|
||||
}
|
||||
const filtered = kind !== 'all' || !!table
|
||||
// 还没载入的项(total 里含列表里审阅过、刷新前还留着的项);列表头写的是还待确认的(审阅过的减掉)
|
||||
const remaining = Math.max(0, total - loaded.length)
|
||||
const pending = pendingTotal(total, loaded, outcomes)
|
||||
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 flex-col" data-review-queue="" aria-label={RT.queueLabel}>
|
||||
@@ -228,7 +231,7 @@ export function ReviewQueue({ sourceId, rows, kind, table, activeKey, detailSync
|
||||
<input ref={allRef} type="checkbox" checked={all} onChange={toggleAll} disabled={!loaded.length}
|
||||
aria-label={RT.selectAll} title={RT.selectAll} data-review-select-all="" />
|
||||
<span className="tnum min-w-0 flex-1 truncate" data-review-total="">
|
||||
{selected.size ? RT.selected(selected.size) : items ? RT.total(total) : RT.loading}
|
||||
{selected.size ? RT.selected(selected.size) : items ? RT.total(pending) : RT.loading}
|
||||
</span>
|
||||
{selected.size > 0 && (
|
||||
<button type="button" className="inline-flex items-center gap-0.5 rounded px-1 hover:bg-hover hover:text-fg"
|
||||
|
||||
@@ -100,6 +100,21 @@ export function statusOf(item: CatalogReviewItem, outcome: ItemOutcome | undefin
|
||||
return outcome?.kind === 'ok' ? outcome.status : item.status
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表里已经不是推断的项(审阅成功过:成批审阅、表详情里改过)。它们还留在列表里、刷新后才移除,服务端的队列里已经没有了。
|
||||
* 撤销审阅回到推断的、冲突的不算
|
||||
*/
|
||||
export const reviewedCount = (items: readonly CatalogReviewItem[], outcomes: ReadonlyMap<string, ItemOutcome>): number =>
|
||||
items.filter((i) => statusOf(i, outcomes.get(itemKey(i))) !== 'proposed').length
|
||||
|
||||
/**
|
||||
* 列表头「N 项待确认」:总数减掉列表里已经不是推断的项。total 是「列表里的项 + 服务端还没载入的项」(载入下一页时按
|
||||
* 服务端的新总数加回列表里审阅过的项,见 ReviewQueue),所以减完就是服务端现在的待确认项数,和视图标签、按表筛选的计数
|
||||
* 同一个口径。以前只在载入时设一次,成批审阅之后还写着审阅前的数
|
||||
*/
|
||||
export const pendingTotal = (total: number, items: readonly CatalogReviewItem[], outcomes: ReadonlyMap<string, ItemOutcome>): number =>
|
||||
Math.max(0, total - reviewedCount(items, outcomes))
|
||||
|
||||
/**
|
||||
* 一批选中的项里,这个动作要发哪几条:确认发还不是已确认的,驳回发还不是已驳回的,撤销审阅只发这一页上审阅成功过的
|
||||
* (队列里本来都是推断,没审阅过的撤销了也没有变化)。冲突过的照旧可以再发
|
||||
|
||||
@@ -625,6 +625,9 @@ await section('纯函数 · 对话怎么截、待保存的修改怎么累积、
|
||||
dedup: { value: 'y', source: 'llm', status: 'rejected' } }, 4, res.outcomes, res.versions)
|
||||
out.sync = { grain: synced.outcomes.get(rv.itemKey(items[0])), dedup: synced.outcomes.get(rv.itemKey(items[1]))?.status, v: synced.versions.get('t1') }
|
||||
out.pct = [rv.percentOf(120, 286), rv.percentOf(0, 0)]
|
||||
// 列表头「N 项待确认」:这一页上审阅成功、不再是推断的项从总数里减掉;撤销审阅回到推断的、冲突的照算
|
||||
out.pendingTotal = [rv.pendingTotal(57, items, new Map()), rv.pendingTotal(57, items, res.outcomes),
|
||||
rv.pendingTotal(57, items, synced.outcomes), rv.pendingTotal(1, items, res.outcomes)]
|
||||
// 提案的改前:被驳回的原值也写出来(同导入预览「目标里这一项已经驳回」)
|
||||
const cp = await import('/src/run/catalogPatch.ts')
|
||||
out.before = [
|
||||
@@ -696,6 +699,8 @@ await section('纯函数 · 对话怎么截、待保存的修改怎么累积、
|
||||
check('表详情改过之后:回到推断的记成撤销审阅,驳回的记成已驳回,版本换成最新的', r.sync.grain?.action === 'reset' && r.sync.dedup === 'rejected' && r.sync.v === 4,
|
||||
JSON.stringify(r.sync))
|
||||
check('进度的百分比四舍五入,分母为 0 时不写', r.pct[0] === 42 && r.pct[1] === null, JSON.stringify(r.pct))
|
||||
check('列表头的待确认项数:这一页上审阅成功的从总数里减掉,撤销审阅、冲突的照算,不会减成负数',
|
||||
JSON.stringify(r.pendingTotal) === JSON.stringify([57, 55, 56, 0]), JSON.stringify(r.pendingTotal))
|
||||
check('提案的改前:被驳回的写「已驳回:原值」(值按界面上的说法),别的照原样,没有值写「未填写」',
|
||||
JSON.stringify(r.before) === JSON.stringify(['已驳回:元', '元', '未填写', '已驳回:明细表', '已驳回:1=有效']), JSON.stringify(r.before))
|
||||
check('队列一项的位置写到列:列 status 的码值、表的有效记录条件、指向 parks 的关联关系;列名里有句点、认不出的路径也说得通',
|
||||
@@ -1253,6 +1258,11 @@ await section('审阅队列 · 成批确认、冲突、撤销审阅、打开所
|
||||
const { page, sent, errors, natives, close } = await open(`/data/catalog/${S1}?view=review`, { handlers: loopHandlers(state) })
|
||||
const queue = page.locator('[data-review-queue]')
|
||||
await until(async () => (await queue.locator('[data-review-item]').count()) === 50)
|
||||
// 列表头的「N 项待确认」和视图标签上的计数(清单里各表的推断项):成批审阅之后一起变
|
||||
const headTotal = () => textOf(queue.locator('[data-review-total]'))
|
||||
const tabCount = async () => Number((await textOf(page.locator('[data-catalog-view-tab="review"]'))).replace(/\D/g, ''))
|
||||
const tab0 = await tabCount()
|
||||
check('还没审阅:列表头写「57 项待确认」', (await headTotal()) === '57 项待确认' && tab0 > 0, `${await headTotal()} · 标签 ${tab0}`)
|
||||
const sel = (k) => queue.locator(`[data-review-item="${k}"] [data-review-select]`)
|
||||
await sel('visits::valid_filter').check()
|
||||
await sel('visits::dedup').check()
|
||||
@@ -1280,6 +1290,9 @@ await section('审阅队列 · 成批确认、冲突、撤销审阅、打开所
|
||||
check('……汇总:已确认 2 项;1 项未生效(所在表刚被修改过),请刷新队列后再审阅', summary.includes('已确认 2 项') && summary.includes('1 项未生效(所在表刚被修改过)'), summary)
|
||||
check('……清单里那张表的计数跟着重取', await until(async () => count(sent, /^GET \/datasources\/check-loop-scenic\/catalog$/) >= 2))
|
||||
check('……审阅进度跟着重取', count(sent, /review-progress$/) >= 2)
|
||||
check('……列表头跟着减:确认了的 2 项不再待确认、冲突的那项照算(57 → 55),和视图标签上的计数一起少 2',
|
||||
await until(async () => (await headTotal()) === '55 项待确认') && await until(async () => (await tabCount()) === tab0 - 2),
|
||||
`${await headTotal()} · 标签 ${tab0} → ${await tabCount()}`)
|
||||
// 撤销审阅:只发这一页上审阅成功的,带这张表写入后的版本
|
||||
await sel('visits::valid_filter').check()
|
||||
await sel('visits::dedup').check()
|
||||
@@ -1290,6 +1303,8 @@ await section('审阅队列 · 成批确认、冲突、撤销审阅、打开所
|
||||
{ table_name: 'visits', path: 'dedup', action: 'reset', if_version: 3 },
|
||||
] }), JSON.stringify(undo))
|
||||
check('……回到推断,标「已撤销审阅」', await until(async () => (await textOf(queue.locator('[data-review-item="visits::dedup"] [data-review-outcome]'))).includes('已撤销审阅')))
|
||||
check('……列表头加回去:又是「57 项待确认」,视图标签也回到原来的数', await until(async () => (await headTotal()) === '57 项待确认')
|
||||
&& await until(async () => (await tabCount()) === tab0), `${await headTotal()} · 标签 ${await tabCount()}`)
|
||||
|
||||
// 打开所在表:右栏是这张表的详情,滚到那一项、标出来,并列出用过这张表的运行
|
||||
await queue.locator('[data-review-item="visits::dedup"] [data-review-open]').click()
|
||||
@@ -1310,9 +1325,11 @@ await section('审阅队列 · 成批确认、冲突、撤销审阅、打开所
|
||||
await page.locator('[data-item-mark="dedup"]').first().click()
|
||||
await page.locator('[data-item-panel] [data-review-action="confirm"]').click()
|
||||
check('在详情里确认那一项:队列里跟着标「已确认」', await until(async () => (await textOf(queue.locator('[data-review-item="visits::dedup"] [data-review-outcome]'))).includes('已确认')))
|
||||
check('……列表头跟着少一项:「56 项待确认」', await until(async () => (await headTotal()) === '56 项待确认'), await headTotal())
|
||||
// 刷新:审阅过的移除
|
||||
await queue.locator('[data-review-refresh]').click()
|
||||
check('刷新队列:已确认的那一项移除', await until(async () => (await queue.locator('[data-review-item="visits::dedup"]').count()) === 0))
|
||||
check('……服务端的总数和刷新前列表头写的一样:「56 项待确认」', (await headTotal()) === '56 项待确认', await headTotal())
|
||||
await cleanCopy(page, '成批审阅')
|
||||
check('只发过成批审阅、单项审阅的写请求', writes(sent).every((s) => /\/review(\/batch)?$/.test(s.key)), JSON.stringify(writes(sent).map((s) => s.key)))
|
||||
check('没有原生对话框', natives.length === 0, natives.join(' | '))
|
||||
|
||||
Reference in New Issue
Block a user