From 98eb9436a1c02ee36f0c5b623b850b1b6608dd43 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Tue, 6 Oct 2026 07:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E8=B4=A8=E8=AF=A2=EF=BC=88?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=EF=BC=89=E6=94=B6=E5=B0=BE=EF=BC=9A=E9=97=AE?= =?UTF-8?q?=E7=AD=94=E4=B8=B2=E7=9A=84=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=B8=8E=E7=84=A6=E7=82=B9=E4=BA=A4=E6=8E=A5=E6=94=B9=E7=A8=B3?= =?UTF-8?q?=EF=BC=8Ccheck-inquiry=20=E7=9A=84=E8=80=97=E6=97=B6=E6=8C=89?= =?UTF-8?q?=E5=AE=9E=E6=B5=8B=E7=99=BB=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 问答串按提问时间排序改用 lib/format 的 parseServerTime(不带时区的服务端时间按 UTC 认,秒级时间戳照认),不再自己拼一套 - 焦点交接改成按「这一次提问」记:提交时焦点丢了才接到正在回答的那一条,回答回来、条数确实多了才播报并接到回答上;没问成(提问框带着报错重新打开)不抢焦点,列表重新取回来也不误报「已收到回答」 - 报告文档在有问答、开着提问框或正在回答时就取:回答引用报告已有出处时要靠它在报告里找到那一处,不再只在问答带句子时取 - check-all 的 ESTIMATE 里 inquiry 按四道并行的实测改成 22 秒 --- frontend/src/run/Inquiry.tsx | 41 ++++++++++++++++++------------------ scripts/check-all.mjs | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/frontend/src/run/Inquiry.tsx b/frontend/src/run/Inquiry.tsx index 4d1cae3f..dd146636 100644 --- a/frontend/src/run/Inquiry.tsx +++ b/frontend/src/run/Inquiry.tsx @@ -8,7 +8,7 @@ import { ApiError, api } from '../api/client' import { Spinner, isComposing, useTicker } from '../components/ui' import { EVIDENCE_STATE, segmentLabel, segmentState, sourceOf, unitText, type EvidenceStateCode } from '../lib/evidence' import { humanizeError } from '../lib/errors' -import { formatCost, formatDateTime, formatNumber, formatTime } from '../lib/format' +import { formatCost, formatDateTime, formatTime, parseServerTime } from '../lib/format' import { EVIDENCE_STATE_LABEL, EVIDENCE_TEXT, INQUIRY_TEXT } from '../lib/terms' import { useEvidence } from '../store/evidence' import type { @@ -294,11 +294,7 @@ function entriesOf(thread: Thread | undefined): InquiryEntry[] { })) const seen = new Set(thread.listed.map((x) => x.seq).filter((s) => s != null)) const local = thread.local.filter((e) => e.inquiry.seq == null || !seen.has(e.inquiry.seq)) - const at = (e: InquiryEntry) => { - const t = typeof e.inquiry.at === 'number' ? e.inquiry.at * (e.inquiry.at < 1e12 ? 1000 : 1) - : e.inquiry.at ? Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(e.inquiry.at) ? e.inquiry.at : `${e.inquiry.at}Z`) : NaN - return Number.isFinite(t) ? t : Infinity - } + const at = (e: InquiryEntry) => parseServerTime(e.inquiry.at)?.getTime() ?? Infinity // 稳定排序:时间相同、没有时间的保持原来的先后(列表在前,刚问的在后) return [...listed, ...local].map((e, i) => ({ e, i, t: at(e) })) .sort((a, b) => (a.t === b.t ? a.i - b.i : a.t - b.t)).map((x) => x.e) @@ -348,10 +344,11 @@ export function ReportInquiry({ runId, report, docArtifact, access, onLocate, po const entries = useMemo(() => entriesOf(thread), [thread]) const mine = pending?.key === key ? pending : undefined - // 句子的原文从报告文档取(审批卡上逐段证据没展开时也要取:问答串得写出问的是哪一句) + // 句子的原文从报告文档取(审批卡上逐段证据没展开时也要取:问答串得写出问的是哪一句;回答引用了报告已有的出处时, + // 也要靠它在报告里找到那一处)。文档按工件 id 缓存,同一份只取一次 const docSlot = useEvidence((s) => (docArtifact ? s.docs[docArtifact] : undefined)) const loadDoc = useEvidence((s) => s.loadDoc) - const needDoc = !!docArtifact && (entries.some((e) => e.inquiry.unit) || !!draft?.target.unit || !!mine?.target.unit) + const needDoc = !!docArtifact && (entries.length > 0 || !!draft || !!mine) useEffect(() => { if (needDoc && docArtifact) void loadDoc(docArtifact) }, [needDoc, docArtifact, loadDoc]) const units = useMemo(() => { const map = new Map() @@ -374,24 +371,28 @@ export function ReportInquiry({ runId, report, docArtifact, access, onLocate, po return [...out.values()] }, [entries, mine, draft]) - // 提交之后提问框拿掉了,焦点接到「正在回答」那一条上;回答回来那一条换掉了,再接到回答上 + // 提交之后提问框拿掉了,焦点接到「正在回答」那一条上;回答回来那一条换掉了,再接到回答上。焦点已经去了别处的不抢; + // 没问成(提问框带着报错重新打开)时焦点由提问框自己接 const pendingRef = useRef(null) const lastRef = useRef(null) - const held = useRef(false) - useLayoutEffect(() => { - if (mine && focusLost()) { pendingRef.current?.focus({ preventScroll: true }); held.current = true } - }, [mine]) const count = entries.length const [heard, setHeard] = useState('') - const seen = useRef(count) + const asking = useRef<{ count: number; held: boolean } | null>(null) useLayoutEffect(() => { - if (count > seen.current) { - setHeard(INQUIRY_TEXT.arrived) - if (held.current && focusLost()) lastRef.current?.focus({ preventScroll: true }) + if (mine) { + if (!asking.current) { + const held = focusLost() + if (held) pendingRef.current?.focus({ preventScroll: true }) + asking.current = { count, held } + } + return } - held.current = false - seen.current = count - }, [count]) + const was = asking.current + asking.current = null + if (!was || count <= was.count) return + setHeard(INQUIRY_TEXT.arrived) + if (was.held && focusLost()) lastRef.current?.focus({ preventScroll: true }) + }, [mine, count]) const reportBtn = useRef(null) if (!access && !entries.length && thread?.status !== 'error') return null diff --git a/scripts/check-all.mjs b/scripts/check-all.mjs index be969cad..e9b3b25a 100644 --- a/scripts/check-all.mjs +++ b/scripts/check-all.mjs @@ -98,7 +98,7 @@ const ESTIMATE = { stream: 173, chat: 160, studio: 149, manage: 145, runs: 112, publish: 92, shell: 87, evidence: 91, versions: 60, catalog: 45, 'ui-kit': 70, ui: 61, guards: 8, 'canvas-layout': 2, copy: 2, tokens: 1, trace: 1, decode: 1, // 占位,换成真检查时按实测改 - schedules: 60, compare: 45, verify: 71, inquiry: 1, bundle: 16, whatif: 33, + schedules: 60, compare: 45, verify: 71, inquiry: 22, bundle: 16, whatif: 33, } // 最慢的两项按段拆成几份。用的是它们自己的段过滤:最后一份用 *_SKIP 兜住「其余全部」,以后新加的段 // 不用改这里也跑得到(拆出去的那几份要是一段都没对上,那一份会报「一项都没跑」)。