合入期 4 整合 J4:质询回答工件在记录页有名字和说明;问答串在审批列表取失败时不再漏条目;运行对比的默认基准与定时任务自动对比用同一条规则(同一任务、同一工作流、比这次先发起的上一次成功并封存的运行),触发历史在基准不是紧挨着的上一次时写明「与上一次成功的运行对比」

This commit is contained in:
ThearchyHelios
2026-10-06 16:23:40 +08:00
17 changed files with 886 additions and 148 deletions
+66 -1
View File
@@ -1,5 +1,5 @@
{
"//": "审批质询预览用例与 check-inquiry 共用的夹具(frontend/src/dev/fixtures/inquiry.tsx)。报告文档和回答文档由后端 evidence.build_catalog + compose_doc 真实组装(虚构的超市、片区、金额),查询快照照质询工件接口的样子给:遮罩列的值写「已遮罩」,另带 masked。生成脚本不在仓库里:改了文档的形状,照这个思路按后端的输出重新生成",
"//": "审批质询预览用例与 check-inquiry 共用的夹具(frontend/src/dev/fixtures/inquiry.tsx)。报告文档和回答文档由后端 evidence.build_catalog + compose_doc 真实组装(虚构的超市、片区、金额),查询快照照质询工件接口的样子给:遮罩列的值写「已遮罩」,另带 masked。生成脚本不在仓库里:改了文档的形状,照这个思路按后端的输出重新生成。run_artifacts 是探索运行的工件列表(照 GET /api/runs/{id}/artifacts 的样子手写,质询回答的 meta 同 engine/inquiry.py 写的 {report, unit, question: 问题的前 40 字}),给运行详情「工件」页签的用例",
"runs": {
"approve": "run-inq-approve",
"formal": "run-inq-formal",
@@ -4278,5 +4278,70 @@
"masked": []
}
},
"run_artifacts": [
{
"id": "8cb677489bbaafcafd3b0f0df1939c1ca57cccaa3c065e14c4efe2991a3dd9a9",
"kind": "report_doc",
"node_id": "write",
"size": 18234,
"meta": {},
"created_at": "2026-10-05T06:30:00"
},
{
"id": "02ca8aeabca59d785d982b321d22ff889cb2da5a037cd4a080407e9044356434",
"kind": "query_snapshot",
"node_id": null,
"size": 1460,
"meta": {},
"created_at": "2026-10-05T06:44:30"
},
{
"id": "911780ed990217a2a2e7e3424a9408d23b53a524ba5d1812ec677b7d6b5b80aa",
"kind": "inquiry_answer",
"node_id": null,
"size": 2140,
"meta": {
"report": "write",
"unit": "u2",
"question": "退款率怎么算的?"
},
"created_at": "2026-10-05T06:45:00"
},
{
"id": "4ed3d62d2af13bbea40195283f3caf63462ca76bb5d4f7ddf1216d36dd5e0463",
"kind": "inquiry_answer",
"node_id": null,
"size": 2510,
"meta": {
"report": "write",
"unit": null,
"question": "枫岭区的销售额是否包含线上订单?如果包含,线上订单按下单门店还是按收货地址归到片"
},
"created_at": "2026-10-05T06:52:00"
},
{
"id": "1c66d590eac155dec35e2215e20c6e7497e96d0b2d73894eff1dea3fb641bb51",
"kind": "inquiry_answer",
"node_id": null,
"size": 1980,
"meta": {
"report": "write",
"unit": "u2"
},
"created_at": "2026-10-05T06:58:00"
},
{
"id": "ab8f8dbfb139d3be461bd9b5f4024cc161be5588a2eea9275a47eac160bfc885",
"kind": "inquiry_answer",
"node_id": null,
"size": 2380,
"meta": {
"report": "write",
"unit": "u3",
"question": "本周枫岭片区 GMV 环比下降了多少?下降的主要原因是不是 SKU 结构的变化 "
},
"created_at": "2026-10-05T07:04:00"
}
],
"card_artifact": "757e03414694c3b3480236718d32082ba449e7712d9ce99f4aee39ffdc5c3f4e"
}
+62 -2
View File
@@ -1,7 +1,10 @@
import { useState, type JSX } from 'react'
import { useMemo, useState, type JSX } from 'react'
import { createPortal } from 'react-dom'
import { parseServerTime } from '../../lib/format'
import { ArtifactsPane, useRunArtifacts } from '../../pages/runs/ArtifactsPane'
import { EvidencePane } from '../../pages/runs/EvidencePane'
import { ApprovalCard } from '../../run/RunPanel'
import { emptyTrace } from '../../run/trace'
import type { Approval, ApprovalReport, Run } from '../../types'
import fx from './inquiry.json'
@@ -20,12 +23,18 @@ import fx from './inquiry.json'
* React 树里排在前面)和右栏;「收起浮层」按钮开关浮层
* - ?syn=inquiry-approval-steps:同一份报告先后两张审批(主管审批 → 总监审批),「处理掉这张」换下一张;卡按审批 id
* 重新挂(同右栏)。?syn=inquiry-approval-steps-same:同一个卡片实例换审批(同画布的审批浮层,不按 id 重新挂)
* - ?syn=inquiry-approval-two:一张卡审两份报告(写月报、写周报),两份报告的问答串各自挂着、共用这次运行的审批列表
*
* 运行详情的「证据」页签(pages/runs/EvidencePane,是否可问由它按运行状态判断):
* - ?syn=inquiry-run-explore:封存了的探索运行,报告上给入口,问答追加在封存之后
* - ?syn=inquiry-run-formal:封存了的正式运行,不给入口,审批时问过的照列
* - ?syn=inquiry-run-waiting:停在审批上的运行,同运行详情直接打开「证据」页签:时间线里的待审批卡和证据页签同时挂着
* 同一份报告的问答串(卡上这张审批里问的直接认,证据页签哪张审批都要对一下)
* - ?syn=inquiry-run-artifacts:运行详情的「工件」页签(pages/runs/ArtifactsPane),工件列表里有封存后追加的质询回答
* (运行期间产出的能跳到航迹,封存后追加的不能)
*
* 列表、提问、质询工件、报告文档、证据图、审批列表、设置都由检查脚本用 page.route 伪造;直接打开时问答串照实说无法读取。
* 列表、提问、质询工件、报告文档、证据图、审批列表、工件列表、设置都由检查脚本用 page.route 伪造;直接打开时问答串照实说
* 无法读取。
*/
const RUNS = fx.runs
@@ -115,6 +124,45 @@ function RunEvidence({ run, name }: { run: Run; name: string }) {
)
}
/**
* 停在审批上的运行,同运行详情直接打开「证据」页签:时间线(一直挂着)里的待审批卡在上,证据页签在下,两处挂着同一份
* 报告的问答串。卡上的问答串认得这张审批,证据页签不认任何审批(cardId 为空),两处要为不同的几张审批取审批列表
*/
function Waiting({ approval, run }: { approval: Approval; run: Run }) {
return (
<div className="flex min-h-screen min-w-0 flex-col" data-fixture="inquiry-run-waiting">
<div className="mx-auto w-full max-w-3xl p-4" data-fixture-card="">
<div className="overflow-hidden rounded-lg border" style={{ borderColor: 'var(--warn)' }}>
<ApprovalCard approval={approval} onResolved={() => undefined} showWorkflow={false} />
</div>
</div>
<div className="h-[80vh] min-w-0 border-t" data-fixture-evidence="">
<EvidencePane run={run} output={null} labelOf={(id) => (id ? LABELS[id] : undefined)} refreshKey="0" />
</div>
</div>
)
}
/**
* 运行详情的「工件」页签:工件列表由检查脚本按 inquiry.json 的 run_artifacts 答。航迹的起止照这次运行的开始、结束时间
* 给(同运行详情):运行期间产出的工件能跳到航迹里那一刻,封存后追加的质询回答和它的查询快照不给跳转。点过的跳转记在
* data-fixture-moment 上
*/
function RunArtifacts({ run }: { run: Run }) {
const list = useRunArtifacts(run.id, '0')
const trace = useMemo(() => ({
...emptyTrace(), phase: 'succeeded' as const,
startedAt: parseServerTime(run.started_at ?? null)?.getTime(), endedAt: parseServerTime(run.finished_at ?? null)?.getTime(),
}), [run.started_at, run.finished_at])
const [moment, setMoment] = useState<number | null>(null)
return (
<div className="h-screen min-w-0" data-fixture="inquiry-run-artifacts" data-fixture-moment={moment ?? ''}>
<ArtifactsPane list={list} graph={null} trace={trace} labelOf={(id) => (id ? LABELS[id] : undefined)}
onMoment={(at) => setMoment(at)} />
</div>
)
}
export const cases: Record<string, () => JSX.Element> = {
'inquiry-approval': () => (
<Card name="inquiry-approval" approval={approvalOf(fx.approval_id, RUNS.approve, 'exploratory', reports.approve)} />
@@ -138,6 +186,18 @@ export const cases: Record<string, () => JSX.Element> = {
),
'inquiry-approval-steps': () => <Steps name="inquiry-approval-steps" keyed />,
'inquiry-approval-steps-same': () => <Steps name="inquiry-approval-steps-same" keyed={false} />,
'inquiry-approval-two': () => (
<Card name="inquiry-approval-two" approval={{
...approvalOf(fx.approval_id, RUNS.approve, 'exploratory', reports.approve),
payload: { kind: 'human_node', message: '请审核 9 月月报和第 39 周周报。',
reports: [reports.approve, { ...reports.approve, node_id: 'write2', label: '写周报' }] },
}} />
),
'inquiry-run-explore': () => <RunEvidence name="inquiry-run-explore" run={runOf(RUNS.explore, 'exploratory')} />,
'inquiry-run-formal': () => <RunEvidence name="inquiry-run-formal" run={runOf(RUNS.sealed, 'formal')} />,
'inquiry-run-waiting': () => (
<Waiting approval={approvalOf(fx.approval_id, RUNS.approve, 'exploratory', reports.approve)}
run={{ ...runOf(RUNS.approve, 'exploratory'), status: 'interrupted', manifest_hash: null, manifest_seq: null, finished_at: null }} />
),
'inquiry-run-artifacts': () => <RunArtifacts run={runOf(RUNS.explore, 'exploratory')} />,
}
+47 -11
View File
@@ -3085,10 +3085,16 @@ export const SCHEDULE_TEXT = {
// ---- 触发历史里的对比:运行成功结束后,服务端自动和同一定时任务上一次成功的运行比一次
/**
* 和运行详情「更多」菜单里的入口是同一件事,用同一个叫法。RUN_COMPARE_TEXT 定义在本对象之后,模块初始化时还取不到,
* 写成 getter 用到时再取
* 和运行详情「更多」菜单里的入口是同一件事(服务端用同一个函数挑基准,两处比的是同一对运行),基准就是紧挨着的上一次
* 时用同一个叫法。RUN_COMPARE_TEXT 定义在本对象之后,模块初始化时还取不到,写成 getter 用到时再取
*/
get compareLink() { return RUN_COMPARE_TEXT.menu },
/**
* 基准不是紧挨着的上一次(上一次失败了、取消了,比的是再往前成功的那一次)时链接上看得见的叫法:触屏没有悬停,
* 键盘聚焦时也不显示 title,只在悬停里说明会让人以为比的就是上一次。运行详情「更多」里的菜单项点之前还不知道基准
* 是哪一次,这时仍叫「与上一次对比」,两处叫法不同;进了对比页都写「默认基准:同一定时任务上一次成功的运行」
*/
compareLinkLastOk: '与上一次成功的运行对比',
/**
* 悬停写各类指标的个数,和 Webhook 通知里那一行同一个写法(服务端 scheduler/auto_compare.py 的 summary_text):
* 变化三分法的三类总写上,0 个也写;其余各类有才写,次序同对比页;两边都没有指标时不写一串 0 个。只有个数,
@@ -3160,7 +3166,7 @@ export const RUN_COMPARE_TEXT = {
menuSealedOnly: '运行结束并封存后才能对比',
/** 没有 workflow_id 的运行:画布、问数据里没保存就运行的,或者工作流删掉之后被置空的。服务端只比同一个已保存的工作流 */
menuNoWorkflow: '工作流未保存或已删除,无法对比',
menuFinding: '正在查找上一次运行…',
menuFinding: '正在查找上一次成功的运行…',
pickManually: '手动选择基准',
retry: '重试',
// 顶部的两次运行
@@ -3175,12 +3181,17 @@ export const RUN_COMPARE_TEXT = {
runFailed: '无法读取这次运行',
runMissing: '运行记录不存在',
noBase: '未选择',
/**
* 默认基准是怎么选的,照服务端(api/compare.py 的 pick_base)的规则写:只挑比本次先发起、成功结束并封存的运行。
* 上一次失败、取消了时基准是再往前成功的那一次,所以不能写成「上一次运行」
*/
reason: {
same_schedule: '默认基准:同一定时任务的上一次运行',
same_workflow: '默认基准:同一工作流、同一运行类别的上一次运行',
same_schedule: '默认基准:同一定时任务上一次成功的运行',
same_workflow: '默认基准:同一工作流、同一运行类别上一次成功的运行',
} as Record<string, string>,
pickBase: '更换基准',
pickHint: '同一工作流最近的运行,未封存的不能作为基准',
/** 默认基准只取成功结束的运行(pick_base),手动选不限:失败、取消的也能选,下拉和基准卡上写明它的状态 */
pickHint: '同一工作流最近的运行,未封存的不能作为基准;默认基准只取成功结束的运行',
pickLoading: '正在读取同一工作流的运行…',
pickFailed: '无法读取同一工作流的运行',
pickNone: '同一工作流没有其他运行',
@@ -3188,14 +3199,17 @@ export const RUN_COMPARE_TEXT = {
pickTargetGone: '本次运行的记录不存在,无法列出同一工作流的运行',
pickUnsaved: '工作流未保存或已删除,没有可对比的运行',
pickPlaceholder: '选择一次运行作为基准',
/** 下拉里的一次运行:时间 · 类别和版本 · 短 id,没封存的另标 */
pickOption: (time: string, cls: string, id: string, sealed: boolean) =>
`${time} · ${cls} · ${id}${sealed ? '' : '(未封存)'}`,
/**
* 下拉里的一次运行:时间 · 类别和版本 · 短 id,没有成功结束的写上状态(失败、已取消),没封存的另标。默认基准跳过的
* 正是这几种,手动挑时也得看得出哪次没成功
*/
pickOption: (time: string, cls: string, id: string, sealed: boolean, status?: string | null) =>
`${time} · ${cls} · ${id}${status ? ` · ${status}` : ''}${sealed ? '' : '(未封存)'}`,
/** 当前的基准读不到时下拉里的那一项(短 id):如实显示选的是哪一次 */
pickGone: (id: string, missing: boolean) => `${id}(${missing ? '记录不存在' : '无法读取'})`,
// 页面状态
noTarget: '未指定要对比的运行',
noTargetHint: '在运行详情的「更多」菜单中选择「与上一次对比」,即可对照本次与上一次运行',
noTargetHint: '在运行详情的「更多」菜单中选择「与上一次对比」,即可对照本次与上一次成功的运行',
toRuns: '前往记录',
finding: '正在查找基准运行…',
loading: '正在对比两次运行…',
@@ -3213,7 +3227,11 @@ export const RUN_COMPARE_TEXT = {
errMissingHint: '链接可能已失效,请从记录页重新打开',
/** 本次的记录读得到、对比却回 404:缺的是基准 */
errBaseMissingHint: '可在上方选择另一次运行作为基准',
errNoBase: '未找到可作为基准的运行',
/**
* 找不到默认基准:标题只说没有默认基准,原因(服务端的 NO_BASE_TEXT:没有找到上一次成功的运行、要什么条件)跟在后面。
* 不能写成「没有可作为基准的运行」:失败、取消但封存了的运行不当默认基准,却照样能在上方手动选
*/
errNoBase: '没有默认基准',
errNoBaseHint: '可在上方选择同一工作流的其他运行作为基准',
/** 下拉里一次能选的都没有(只有本次、或者都没封存) */
errNoBaseNone: '同一工作流还没有其他已封存的运行',
@@ -3424,6 +3442,12 @@ export const INQUIRY_TEXT = {
/** 之前几轮审批里问的、报告后来改写过(句子编号对不上),或者对不上是哪一稿:单独一组 */
otherDoc: '报告其他版本上的质询',
otherDocHint: '提问时的报告与当前显示的版本不同,或无法确认是否相同,所以不挂到当前报告的句子下面',
/**
* 别的审批里问的、审批列表又没取到:不知道提问时审的是哪一稿,不能说成「其他版本」(审批人会以为报告换过稿)。
* 单独一组照实说没能确认,给重试
*/
unsureDoc: '无法确认提问时的报告版本',
unsureDocHint: '审批记录读取失败,暂不挂到当前报告的句子下面',
loadFailed: '无法读取之前的质询记录',
retry: '重试',
q: '问',
@@ -3491,6 +3515,18 @@ export const INQUIRY_TEXT = {
snapshotLoading: '正在读取查询结果…',
snapshotFailed: '无法读取这次查询的结果',
masked: (columns: string) => `${columns} 在数据源中设置了遮罩,不显示原值`,
// ---- 运行详情「工件」页签:回答文档按工件种类 inquiry_answer 记在运行名下(pages/runs/model.ts 的工件名和说明) ----
artifactKind: '质询回答',
/**
* 服务端在工件的 meta 里只记问题的前 40 字(engine/inquiry.py 的 QUESTION_BRIEF):满 40 字的多半截断过,末尾补省略号,
* 免得半句话读成整个问题。字数按原样数、显示时才去掉首尾空白:服务端截之前已经去过整个问题的首尾空白,摘要以空格、
* 换行结尾只会是截断截在了空白上,先去空白再数就少了一个字、漏掉省略号
*/
artifactAbout: (question: string) =>
`质询「${question.trim()}${[...question].length >= 40 ? '…' : ''}」的回答`,
/** meta 里没有问题摘要时的说法(服务端照理都会记,这里兜底):照报告文档那一句写装的是什么 */
artifactAboutNone: '审批质询的回答:逐段的片段和每个数字的出处',
}
/**
+7 -3
View File
@@ -136,6 +136,8 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
}
const t0 = trace.timed ? trace.startedAt : undefined
// 运行结束之后才写下的(封存后追加的质询回答和它查询的快照):航迹里没有那一刻,不给跳转,只写时间
const t1 = trace.timed ? trace.endedAt : undefined
let budget = all ? Infinity : FIRST_ROWS
const hidden = Math.max(0, groups.reduce((n, [, g]) => n + g.length, 0) - FIRST_ROWS)
@@ -174,7 +176,7 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
budget -= take.length
return (
<Group key={nodeId || '—'} nodeId={nodeId} rows={take} total={rows.length} graph={graph} trace={trace}
labelOf={labelOf} t0={t0} onOpen={setOpen} onMoment={onMoment} />
labelOf={labelOf} t0={t0} t1={t1} onOpen={setOpen} onMoment={onMoment} />
)
})}
{!all && hidden > 0 && (
@@ -190,7 +192,7 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
)
}
function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMoment }: {
function Group({ nodeId, rows, total, graph, trace, labelOf, t0, t1, onOpen, onMoment }: {
nodeId: string
rows: RunArtifact[]
total: number
@@ -198,6 +200,8 @@ function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMomen
trace: Trace
labelOf: (id?: string | null) => string | undefined
t0?: number
/** 运行结束的时刻(还没结束的为空):晚于它的工件不给跳转 */
t1?: number
onOpen: (v: { id: string; title: string }) => void
onMoment?: (at: number, nodeId: string | null) => void
}) {
@@ -226,7 +230,7 @@ function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMomen
const kind = artifactKindLabel(a.kind)
const attempt = Number(a.meta?.attempt)
const created = parseServerTime(a.created_at ?? null)?.getTime()
const at = t0 != null && created != null && created >= t0 ? created : null
const at = t0 != null && created != null && created >= t0 && (t1 == null || created <= t1) ? created : null
const numbered = (perKind.get(a.kind) ?? 0) > 1
const title = `${label} · ${kind}${numbered ? ` #${n}` : ''}`
return (
+16 -4
View File
@@ -1,8 +1,9 @@
import { useId, type ReactNode } from 'react'
import { Link } from 'react-router-dom'
import { ArrowLeftRight, CalendarClock, RotateCw } from 'lucide-react'
import { Skeleton, useTicker } from '../../../components/ui'
import { Skeleton, StatusPill, useTicker } from '../../../components/ui'
import { formatDateTime, formatTime, shortId } from '../../../lib/format'
import { statusLabel } from '../../../lib/status'
import { RUN_COMPARE_TEXT as T, runClassLabel, runName } from '../../../lib/terms'
import type { RunWithSchedule } from '../../../types'
import { ClassChip as RunClassChip } from '../parts'
@@ -11,7 +12,8 @@ import { isGone } from './model'
/**
* 顶部的两次运行:左边基准、右边本次(窄屏上下排),中间「互换」。每张卡写名字、时间、类别和版本,点名字进各自的
* 运行详情;没封存的标出来(对比会因此被拒)。基准卡底下是换基准的下拉:同一工作流最近的运行,没封存的不能选。
* 运行详情;没封存的标出来(对比会因此被拒),失败、取消的标出状态。基准卡底下是换基准的下拉:同一工作流最近的运行,
* 没封存的不能选。
*/
export function RunPair({ target, base, targetRun, baseRun, candidates, unsaved, reason, onPick, onSwap }: {
target: string
@@ -49,6 +51,12 @@ export function RunPair({ target, base, targetRun, baseRun, candidates, unsaved,
)
}
/**
* 封存了、却没有成功结束的(失败、已取消):能手动选作基准,默认基准却跳过它(拿它当基准,口径卡没执行的指标都成了
* 「新增」「移除」)。下拉和卡上写明状态,人读懂「上一次成功的运行」之后自己挑得出成功的那一次
*/
const unsuccessful = (status: string | null | undefined) => status === 'failed' || status === 'cancelled'
function RunCard({ role, id, run, children }: {
role: 'base' | 'target'; id: string | null; run: Loaded<RunWithSchedule>; children?: ReactNode
}) {
@@ -63,6 +71,9 @@ function RunCard({ role, id, run, children }: {
{r?.schedule_id && (
<span className="chip" title={T.scheduled}><CalendarClock size={10} aria-hidden /> {T.scheduled}</span>
)}
{r && unsuccessful(r.status) && (
<span className="inline-flex" data-compare-run-status={r.status}><StatusPill status={r.status} /></span>
)}
{r && !r.manifest_hash && (
<span className="chip" title={T.unsealedHint} data-compare-unsealed=""
style={{ color: 'var(--warn)', borderColor: 'color-mix(in srgb, var(--warn) 40%, transparent)' }}>
@@ -113,7 +124,8 @@ function RetryButton({ onClick }: { onClick: () => void }) {
}
/**
* 换基准。列的是运行列表接口按工作流取回的最近几次(新的在前),去掉本次;没封存的列出来但不能选,写明原因。
* 换基准。列的是运行列表接口按工作流取回的最近几次(新的在前),去掉本次;没封存的列出来但不能选,写明原因;失败、
* 取消的能选,写明状态(默认基准不取它们)。
*
* 当前的基准不在这几次里(更早、属于别的工作流、读不到)时也单列一项:受控的下拉值对不上任何选项时浏览器会选中
* 第一项,看着像另一次运行被选中,而原生下拉再选当前显示的那一项不触发 change,最自然的补救点了没反应。读不到的
@@ -146,7 +158,7 @@ function BasePicker({ target, base, baseRun, targetRun, candidates, unsaved, onP
const list = (candidates.data ?? []).filter((r) => r.id !== target)
if (!loading && !list.length) return <p className="mt-2 text-2xs text-faint" data-compare-pick-note="none">{T.pickNone}</p>
const label = (r: RunWithSchedule) => T.pickOption(formatTime(r.started_at ?? r.created_at ?? null, new Date(now)),
runClassLabel(r.run_class, r.version), shortId(r.id), !!r.manifest_hash)
runClassLabel(r.run_class, r.version), shortId(r.id), !!r.manifest_hash, unsuccessful(r.status) ? statusLabel(r.status) : null)
const current = base && !list.some((r) => r.id === base) ? base : null
const currentLabel = (b: string) => (baseRun.data ? label(baseRun.data)
: baseRun.state === 'error' ? T.pickGone(shortId(b), isGone(baseRun.error)) : shortId(b))
+3 -2
View File
@@ -17,8 +17,9 @@ export const comparePath = (target: string, base?: string | null) =>
const NOTE_DELAY_MS = 300
/**
* 运行详情「更多」菜单里的「与上一次对比」。先问服务端默认的基准(同一定时任务的上一次,没有就同一工作流、同一类别的
* 上一次),找到了再跳到对比页;找不到时留在原页,提示服务端给的原因,并给「手动选择基准」去对比页自己挑。
* 运行详情「更多」菜单里的「与上一次对比」。先问服务端默认的基准(同一定时任务上一次成功的运行,没有就同一工作流、
* 同一类别上一次成功的运行;定时任务触发历史里同名的入口由服务端用同一个函数挑,两处比的是同一对运行),找到了再跳到
* 对比页;找不到时留在原页,提示服务端给的原因,并给「手动选择基准」去对比页自己挑。
* 这几种不给点,点了也只会被拒:没封存、还在运行的(对比只认已封存的运行,409);不属于已保存工作流的——画布、问数据
* 里没保存就运行的,和工作流删掉之后 workflow_id 被置空的(服务端找不到同一工作流的运行,手动选也是 422)。
*
+5
View File
@@ -10,6 +10,7 @@ import {
RUN_STATUS_ORDER, STATUS, resolveStatus, serverStatusOf, type StatusCode,
} from '../../lib/status'
import { formatSpan, parseServerTime } from '../../lib/format'
import { INQUIRY_TEXT } from '../../lib/terms'
import { hasPendingApproval } from '../../store/catalog'
// -------------------------------------------------------------------------
@@ -334,6 +335,7 @@ export const ARTIFACT_KIND_LABEL: Record<string, string> = {
schema_snapshot: '表结构快照',
dual_check: '双盲复算对照',
challenge: '反方审稿记录',
inquiry_answer: INQUIRY_TEXT.artifactKind,
}
export const artifactKindLabel = (kind: string): string => ARTIFACT_KIND_LABEL[kind] ?? kind
@@ -356,6 +358,9 @@ export function artifactDescription(kind: string, meta?: Record<string, any> | n
? `双盲复算:${meta.metrics} 个指标两边的 SQL、取值与差异说明` : '双盲复算:两边的 SQL、取值与差异说明'
// 反方审稿的完整记录(工件行的 meta 里有 {report: 审的报告节点})
case 'challenge': return '反方审稿:每句结论的判断、理由和反方执行的查询'
// 审批质询的回答文档(工件行的 meta 里有 {report, unit, question: 问题的前 40 字}):不挂在节点上,靠问题认出是哪一条
case 'inquiry_answer': return typeof meta?.question === 'string' && meta.question.trim()
? INQUIRY_TEXT.artifactAbout(meta.question) : INQUIRY_TEXT.artifactAboutNone
default: return '工件'
}
}
+11 -7
View File
@@ -14,7 +14,8 @@ const PAGE = 20
/**
* 触发历史:每次触发一行,新的在前,20 条一页、「加载更多」往后接。计划时间按定时任务的时区写;跳过、发起失败
* 写原因;发起了的链到那次运行、写运行现在的状态;运行成功结束后服务端和同一任务上一次成功的运行比过的,另给
* 「与上一次对比」;发出去的通知逐条写结果。refreshKey 变了(立即运行之后)从头重取
* 「与上一次对比」(基准不是紧挨着的上一次时写「与上一次成功的运行对比」);发出去的通知逐条写结果。refreshKey 变了
* (立即运行之后)从头重取
*/
export function FireHistory({ schedule, refreshKey }: { schedule: Schedule; refreshKey: number }) {
const [items, setItems] = useState<ScheduleFire[] | null>(null)
@@ -142,14 +143,17 @@ function FireRow({ fire: f, tz, now }: { fire: ScheduleFire; tz: string; now: nu
}
/**
* 「与上一次对比」:去对比页,本次是这次触发的运行、基准是服务端自动对比时取的同一任务上一次成功的运行。旁边写有几个
* 指标有变化(触屏没有悬停,键盘聚焦也不显示悬停),悬停写各类指标的个数(和通知里那一行同一个写法),读屏把它当
* 说明念。基准就是紧挨着的上一次时带上来历,对比页据此写「默认基准:同一定时任务的上一次运行」;不是(上一次失败了、
* 取消了)时不带,免得说错,悬停写明比的是哪一次
* 「与上一次对比」:去对比页,本次是这次触发的运行、基准是服务端自动对比时取的同一任务上一次成功的运行——和运行详情
* 「更多」里同名入口的默认基准是同一个挑法(服务端 api/compare.py 的 pick_base),两处进去比的是同一对运行。旁边写有
* 几个指标有变化(触屏没有悬停,键盘聚焦也不显示悬停),悬停写各类指标的个数(和通知里那一行同一个写法),读屏把它
* 当说明念。
*
* 基准不是紧挨着的上一次(上一次失败了、取消了)时,链接上看得见的字就写「与上一次成功的运行对比」,悬停另写是哪一次。
* 两种都带上来历:对比页据此写「默认基准:同一定时任务上一次成功的运行」,和从运行详情进去时一字不差
*/
function CompareLink({ runId, compare }: { runId: string; compare: ScheduleFireCompare }) {
const previous = compare.previous !== false
const via: CompareVia | undefined = previous ? { base: compare.base_run_id, reason: 'same_schedule' } : undefined
const via: CompareVia = { base: compare.base_run_id, reason: 'same_schedule' }
const count = T.compareCount(compare.summary)
return (
<Link
@@ -160,7 +164,7 @@ function CompareLink({ runId, compare }: { runId: string; compare: ScheduleFireC
className="inline-flex shrink-0 items-center gap-1 rounded-sm text-2xs text-dim outline-none hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-[var(--accent)]"
>
<GitCompareArrows size={11} aria-hidden />
<span data-fire-compare-label="">{T.compareLink}</span>
<span data-fire-compare-label="">{previous ? T.compareLink : T.compareLinkLastOk}</span>
{count && (
<>
<span aria-hidden>·</span>
+45 -9
View File
@@ -308,7 +308,17 @@ export const useInquiry = create<InquiryState>((set, get) => ({
},
loadApprovalDocs: async (runId, ids) => {
if (get().approvalDocs[runId]?.status === 'loading') return
const inflight = get().approvalDocs[runId]
if (inflight?.status === 'loading') {
// 别处已经在取(同一张卡审两份报告;运行详情的待审批卡和证据页签同时挂着,两处要对的审批不同):不再另取,但这一处
// 要对的也记成取过——列表按运行取、不按审批,在路上的那一份本来就带着全部审批。只是提前返回的话,这一处的 unknown
// 在请求回来之后不变、effect 不再执行,settled 一直为假:头上写着「· N 次」,别的审批里问的那几条一直不显示
const asked = [...new Set([...inflight.asked, ...ids])]
if (asked.length > inflight.asked.length) {
set((s) => ({ approvalDocs: { ...s.approvalDocs, [runId]: { ...s.approvalDocs[runId]!, asked } } }))
}
return
}
set((s) => {
const cur = s.approvalDocs[runId]
return { approvalDocs: { ...s.approvalDocs, [runId]: {
@@ -503,6 +513,13 @@ const groupKey = (t: { unit: string | null; quote: string | null }) =>
/** 问的不是眼前这一稿报告的那几条:单独一组,排在最后 */
const OTHER = 'other'
/** 别的审批里问的、审批列表又没取到,不知道是不是眼前这一稿:也单独一组,排在最后,给重试 */
const UNSURE = 'unsure'
/**
* 不按句子挂的两组:句子编号对不上(或者不知道对不对得上),回答引用报告已有的出处时不在眼前这一稿里找;正在回答的、
* 提问框也不挂进来
*/
const offDoc = (key: string) => key === OTHER || key === UNSURE
interface Group {
key: string
@@ -600,6 +617,10 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
if (a === (cardId ?? null)) return true
return !!a && !!docArtifact && docsSlot?.map[a]?.[report] === docArtifact
}, [cardId, docArtifact, docsSlot, report])
// 审批列表没取到时,别的审批里问的、那张审批又不在之前取到的列表里:不知道是不是眼前这一稿,不能算「其他版本」。
// 取到了列表却没有那张审批的(审批记录没了)、这份报告没有报告文档(拿什么都对不上)的,重取也一样,照旧算对不上
const unsure = useCallback((x: Inquiry) => !!docArtifact && docsSlot?.status === 'error' && !!x.approval_id
&& !(x.approval_id in docsSlot.map), [docArtifact, docsSlot])
const groups = useMemo(() => {
const out = new Map<string, Group>()
@@ -609,9 +630,10 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
return out.get(k)!
}
const others: InquiryEntry[] = []
const unsures: InquiryEntry[] = []
for (const e of entries) {
if (sameDoc(e.inquiry)) add(e.inquiry.unit, e.inquiry.quote).entries.push(e)
else if (settled) others.push(e)
else if (settled) (unsure(e.inquiry) ? unsures : others).push(e)
}
// 正在回答的、没问成的、开着的提问框挂在它们问的那一句下面(按先后):那句还没有问答时另起一组
if (mine) add(mine.target.unit, mine.target.quote)
@@ -619,8 +641,11 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
if (draft) add(draft.target.unit, draft.target.quote)
const list = [...out.values()]
if (others.length) list.push({ key: OTHER, unit: null, quote: null, entries: others })
if (unsures.length) list.push({ key: UNSURE, unit: null, quote: null, entries: unsures })
return list
}, [entries, sameDoc, settled, mine, draft, failed])
}, [entries, sameDoc, unsure, settled, mine, draft, failed])
// 重取审批列表:列表按运行取,一份里各张审批都有。取的时候这两组先收起(同第一次取),取回来按结果重新归拢
const retryDocs = useCallback(() => { void loadApprovalDocs(runId, foreign) }, [loadApprovalDocs, runId, foreign])
// 提交之后提问框拿掉了,焦点接到「正在回答」那一条上;回答回来那一条换掉了,再接到回答上。焦点已经去了别处的不抢;
// 没问成(提问框带着报错重新打开)时焦点由提问框自己接。都只在问的那一处:同一张卡挂在两处时另一处不动
@@ -687,15 +712,15 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
<div className="mt-1.5 space-y-2">
{groups.map((g) => (
<div key={g.key} className="min-w-0"
data-inquiry-group={g.key === OTHER ? OTHER : g.unit ?? (g.quote ? 'quote' : 'report')}>
<GroupHead group={g} units={units} />
data-inquiry-group={offDoc(g.key) ? g.key : g.unit ?? (g.quote ? 'quote' : 'report')}>
<GroupHead group={g} units={units} onRetry={retryDocs} />
<div className="mt-1 space-y-2 border-l pl-2">
{g.entries.map((e) => (
<EntryView key={e.id} runId={runId} entry={e} groupQuote={g.unit ? null : g.quote}
otherDoc={g.key === OTHER} onLocate={g.key === OTHER ? undefined : onLocate}
otherDoc={offDoc(g.key)} onLocate={offDoc(g.key) ? undefined : onLocate}
focusRef={e.id === latest ? (el) => { lastRef.current = el } : undefined} />
))}
{g.key !== OTHER && (
{!offDoc(g.key) && (
<>
{mine && groupKey(mine.target) === g.key && (
<PendingView pending={mine} focusRef={(el) => { pendingRef.current = el }} />
@@ -730,9 +755,9 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
/**
* 一组的抬头:问的是哪一句(原文从报告文档取,取不到写「报告中的一句」)、哪段原文,或者整份报告。问的不是眼前这一稿的
* 那一组只写明这一点:句子编号对不上,不去取原文
* 那一组只写明这一点:句子编号对不上,不去取原文。审批列表没取到、不知道是哪一稿的那一组照实说,给重试(onRetry)
*/
function GroupHead({ group, units }: { group: Group; units: Map<string, string> }) {
function GroupHead({ group, units, onRetry }: { group: Group; units: Map<string, string>; onRetry: () => void }) {
if (group.key === OTHER) {
return (
<div className="min-w-0 text-2xs leading-relaxed" data-inquiry-about="">
@@ -741,6 +766,17 @@ function GroupHead({ group, units }: { group: Group; units: Map<string, string>
</div>
)
}
if (group.key === UNSURE) {
return (
<div className="flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 text-2xs leading-relaxed" data-inquiry-about="">
<span className="min-w-0 flex-1">
<span className="font-medium" style={{ color: 'var(--st-waiting)' }} data-inquiry-about-text="">{INQUIRY_TEXT.unsureDoc}</span>
<span className="block text-faint">{INQUIRY_TEXT.unsureDocHint}</span>
</span>
<button type="button" className="btn btn-xs shrink-0" data-inquiry-docs-retry="" onClick={onRetry}>{INQUIRY_TEXT.retry}</button>
</div>
)
}
const text = group.unit ? units.get(group.unit) || group.entries.find((e) => e.inquiry.quote)?.inquiry.quote || ''
: group.quote ?? ''
return (