diff --git a/CHANGELOG.md b/CHANGELOG.md
index a32ce9b..79f3ff4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
### Added
+- 问答记录新增“本周”快捷查询,默认展示北京时间本周数据;所选范围自动读取全部记录,校验完整数量后展示,不再需要分页或加载更多。固定展示完整字段,空列不再隐藏,中文原文直接展示、外语未翻译明确标记;保留源端有界传输、取消和失败保护。
+
- 问答记录新增年份与自然周选择,周次展示起止日期,支持跨年及每年实际周数;按北京时间周一至周日填入查询范围,默认本周且仅查询截至当前的数据。保留自定义时间与原查询按钮,浏览器时区不改变查询边界。
- 问答运营按已确认口径显示知识覆盖率、回答正确率及原始分子/分母、排除数量与构成。使用完整筛选范围和当前有效人工优先结论,精确规则命中的未覆盖可进入覆盖分母;部分覆盖不算完全覆盖,待确认/未评估/失效/不计入按对应指标排除,零分母显示“暂无可计算数据”。返回独立规则版本,AI 模型与绩效范围仍未接入。
diff --git a/web/src/QAOperations.test.tsx b/web/src/QAOperations.test.tsx
index 5c9907b..1307e88 100644
--- a/web/src/QAOperations.test.tsx
+++ b/web/src/QAOperations.test.tsx
@@ -50,17 +50,40 @@ const props = {
}
describe('QA operations workbench', () => {
- it('shows populated columns in required order and keeps false/downvotes visible', () => {
+ it('shows all required columns even when empty and keeps false/downvotes visible', () => {
const html = renderToStaticMarkup()
expect(html).toContain('原始问题')
expect(html.indexOf('AI答案')).toBeLessThan(html.indexOf('是否覆盖'))
expect(html.indexOf('是否正确')).toBeLessThan(html.indexOf('提问时间'))
expect(html).toContain('否(点踩)')
expect(html).toContain('是否正确')
- expect(html).not.toContain('
部门 | ')
- expect(html).not.toContain('产品分类 | ')
+ expect(html).toContain('部门 | ')
+ expect([...html.matchAll(/(.*?)<\/th>/g)].slice(0, 14).map((match) => match[1])).toEqual([
+ '中文问题',
+ 'AI答案',
+ '是否覆盖',
+ '是否正确',
+ '产品分类',
+ '问题类型',
+ '根因分析',
+ '提问时间',
+ '提问人',
+ '原始问题',
+ '语言',
+ '流程触发人员信息',
+ '部门',
+ '区域',
+ ])
+ expect(html).toContain(' | 产品分类 | ')
expect(html).not.toContain('')
})
+ it('never shows a load-more control for the all-records table', () => {
+ const html = renderToStaticMarkup(
+
+ )
+ expect(html).not.toContain('加载更多')
+ expect(html).not.toContain('空列按整个筛选结果隐藏')
+ })
it('distinguishes an unavailable source from a successful empty query', () => {
const html = renderToStaticMarkup()
expect(html).toContain('role="alert"')
diff --git a/web/src/QAOperations.tsx b/web/src/QAOperations.tsx
index 7118e61..165b466 100644
--- a/web/src/QAOperations.tsx
+++ b/web/src/QAOperations.tsx
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react'
import type { FormEvent } from 'react'
import { useOptionalAuth } from './auth'
-import { fetchQARecord, fetchQARecords, fetchQAStatus, mergeQAPages, qaCellValue, qaColumns } from './qaOps'
+import { fetchQARecord, fetchAllQARecords, fetchQAStatus, qaCellValue, qaColumns } from './qaOps'
import type { QAQuery, QARecord, QARecordPage, QAStatus } from './qaOps'
import './qaOps.css'
import { QARegions } from './QARegions'
@@ -25,7 +25,7 @@ interface ViewProps {
detailError: string | null
onSelect: (id: string) => void
onCloseDetail: () => void
- onLoadMore: () => void
+ progress?: { loaded: number; total: number }
onRetry: () => void
}
const stateLabels = { disabled: '未配置', unavailable: '连接不可用', blocked: '接入被阻断', connected: '已连接' }
@@ -44,14 +44,18 @@ const sourceCoverageLabels: Record = { covered: '已覆盖', unc
export function QAOperationsView(props: ViewProps) {
const page = props.page
- const columns = qaColumns.filter(({ key }) => page?.columns.includes(key))
+ const columns = qaColumns
const detail = props.detail
const showDrawer = Boolean(detail || props.detailLoading || props.detailError)
return (
- {props.loading ? '正在读取…' : page ? `共 ${page.total} 条 · 已显示 ${page.items.length} 条` : '尚未读取问答'}
+ {props.loading
+ ? `正在读取全部问答…${props.progress ? `(${props.progress.loaded} / ${props.progress.total})` : ''}`
+ : page
+ ? `共 ${page.total} 条 · 已展示 ${page.items.length} 条`
+ : '尚未读取问答'}
DobotAI 2.0 / 钉钉 · 独立只读连接{props.status ? ` · ${stateLabels[props.status.state]}` : ''}
@@ -134,14 +138,8 @@ export function QAOperationsView(props: ViewProps) {
) : null}
{page ? (
) : null}
{showDrawer ? (
@@ -314,9 +312,8 @@ export function QAOperations() {
const [detail, setDetail] = useState(null)
const [detailLoading, setDetailLoading] = useState(false)
const [detailError, setDetailError] = useState(null)
- const generation = useRef(0)
+ const [progress, setProgress] = useState<{ loaded: number; total: number } | undefined>()
const detailRequest = useRef(null)
- const moreRequest = useRef(null)
const returnFocus = useRef(null)
useEffect(() => {
@@ -333,18 +330,16 @@ export function QAOperations() {
if (!query || !canRead) return
if (view !== 'records') {
setLoading(false)
- moreRequest.current?.abort()
detailRequest.current?.abort()
setDetail(null)
return
}
const controller = new AbortController()
- generation.current += 1
- moreRequest.current?.abort()
detailRequest.current?.abort()
setLoading(true)
setError(null)
setPage(null)
+ setProgress(undefined)
setDetail(null)
setDetailError(null)
setDetailLoading(false)
@@ -353,7 +348,9 @@ export function QAOperations() {
.catch(() => {
if (!controller.signal.aborted) setStatus(null)
})
- void fetchQARecords(query, controller.signal)
+ void fetchAllQARecords(query, controller.signal, (loaded, total) => {
+ if (!controller.signal.aborted) setProgress({ loaded, total })
+ })
.then((result) => {
if (!controller.signal.aborted) setPage(result)
})
@@ -369,7 +366,6 @@ export function QAOperations() {
useEffect(
() => () => {
detailRequest.current?.abort()
- moreRequest.current?.abort()
},
[]
)
@@ -410,25 +406,6 @@ export function QAOperations() {
setDetailLoading(false)
returnFocus.current?.focus()
}
- const loadMore = async () => {
- if (!query || !page?.has_more || loading) return
- const currentGeneration = generation.current
- const controller = new AbortController()
- moreRequest.current = controller
- setLoading(true)
- setError(null)
- try {
- const result = await fetchQARecords({ ...query, cursor: page.next_cursor }, controller.signal)
- if (!controller.signal.aborted && currentGeneration === generation.current) {
- setPage(mergeQAPages(page, result))
- }
- } catch (reason) {
- if (!controller.signal.aborted && currentGeneration === generation.current)
- setError(reason instanceof Error ? reason.message : '翻页失败')
- } finally {
- if (!controller.signal.aborted && currentGeneration === generation.current) setLoading(false)
- }
- }
return (
@@ -475,6 +452,16 @@ export function QAOperations() {
{
+ const current = initialDraft()
+ setDraft({ ...current, keyword: draft.keyword })
+ setQuery({
+ start: qaDateTimeToISO(current.start),
+ end: qaDateTimeToISO(current.end),
+ keyword: draft.keyword,
+ cursor: '',
+ })
+ }}
onChange={(year, week) => {
setDraft((old) => {
if (week === null) return { ...old, year, week }
@@ -557,7 +544,7 @@ export function QAOperations() {
}}
onSelect={(id) => void select(id)}
onCloseDetail={close}
- onLoadMore={() => void loadMore()}
+ progress={progress}
onRetry={() => setRevision((value) => value + 1)}
/>
)}
diff --git a/web/src/QAWeekPicker.test.tsx b/web/src/QAWeekPicker.test.tsx
index 8683dd1..9a99a17 100644
--- a/web/src/QAWeekPicker.test.tsx
+++ b/web/src/QAWeekPicker.test.tsx
@@ -3,6 +3,10 @@ import { describe, expect, it, vi } from 'vitest'
import { QAWeekPicker } from './QAWeekPicker'
describe('QA week picker', () => {
+ it('offers a one-click current-week shortcut', () => {
+ const html = renderToStaticMarkup()
+ expect(html).toContain('>本周')
+ })
it('shows a year and numbered weeks with visible inclusive date ranges', () => {
const html = renderToStaticMarkup()
expect(html).toContain('aria-label="年份"')
diff --git a/web/src/QAWeekPicker.tsx b/web/src/QAWeekPicker.tsx
index beb646e..49d3579 100644
--- a/web/src/QAWeekPicker.tsx
+++ b/web/src/QAWeekPicker.tsx
@@ -4,9 +4,10 @@ interface Props {
year: number
week: number | null
onChange: (year: number, week: number | null) => void
+ onCurrentWeek?: () => void
}
-export function QAWeekPicker({ year, week, onChange }: Props) {
+export function QAWeekPicker({ year, week, onChange, onCurrentWeek }: Props) {
const currentYear = currentQAWeek().year
const firstYear = Math.min(currentYear - 5, year)
const lastYear = Math.max(currentYear + 1, year)
@@ -46,6 +47,9 @@ export function QAWeekPicker({ year, week, onChange }: Props) {
))}
+
北京时间 · 周一至周日 · 本周截至当前
)
diff --git a/web/src/qaAllRecords.test.ts b/web/src/qaAllRecords.test.ts
new file mode 100644
index 0000000..ba75a61
--- /dev/null
+++ b/web/src/qaAllRecords.test.ts
@@ -0,0 +1,88 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { fetchAllQARecords } from './qaOps'
+const row = (id: string) => ({
+ id,
+ status: 'succeeded',
+ question: '明确合成问题',
+ answer: '明确合成答案',
+ asked_at: '2026-10-14T03:00:00Z',
+ time_source: 'request_message.created_at',
+ asker: '合成夹具',
+ trigger_person: '',
+ department: '',
+ region: '',
+ references: [],
+ media: [],
+ source_coverage: { verdict: '', reason_code: '', evaluator_version: '' },
+ feedback: { asker_value: '', up: 0, down: 0 },
+ coverage: { state: 'pending', rule_version: 'fixture-rule' },
+})
+const page = (ids: string[], total: number, cursor = '') => ({
+ items: ids.map(row),
+ columns: [],
+ total,
+ has_more: Boolean(cursor),
+ next_cursor: cursor,
+ as_of: '2026-10-14T04:00:00Z',
+})
+const query = { start: '2026-10-11T16:00:00Z', end: '2026-10-18T08:00:00Z', keyword: '%_原文', cursor: 'stale-cursor' }
+const respond = (data: unknown) => new Response(JSON.stringify({ data }), { status: 200 })
+afterEach(() => vi.unstubAllGlobals())
+describe('all QA records without manual pagination', () => {
+ it('rejects incomplete, duplicate, drifting and cycling batches', async () => {
+ const cases = [
+ [page(['a'], 2)],
+ [page(['a'], 2, 'n'), page(['a'], 2)],
+ [page(['a'], 2, 'n'), page(['b'], 3)],
+ [page(['a'], 3, 'n'), page(['b'], 3, 'n')],
+ ]
+ for (const pages of cases) {
+ const fetcher = vi.fn()
+ pages.forEach((data) => fetcher.mockResolvedValueOnce(respond(data)))
+ vi.stubGlobal('fetch', fetcher)
+ await expect(fetchAllQARecords(query)).rejects.toThrow()
+ }
+ })
+ it('surfaces a later source failure instead of returning the first batch', async () => {
+ const fetcher = vi
+ .fn()
+ .mockResolvedValueOnce(respond(page(['a'], 2, 'n')))
+ .mockResolvedValueOnce(new Response(JSON.stringify({ error: '明确合成源不可用' }), { status: 503 }))
+ vi.stubGlobal('fetch', fetcher)
+ await expect(fetchAllQARecords(query)).rejects.toThrow('明确合成源不可用')
+ })
+ it('accepts a genuinely empty complete scope', async () => {
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(respond(page([], 0))))
+ expect((await fetchAllQARecords(query)).items).toEqual([])
+ })
+ it('does not start or continue requests after cancellation', async () => {
+ const controller = new AbortController()
+ controller.abort()
+ const fetcher = vi.fn().mockResolvedValue(respond(page([], 0)))
+ vi.stubGlobal('fetch', fetcher)
+ await expect(fetchAllQARecords(query, controller.signal)).rejects.toMatchObject({ name: 'AbortError' })
+ expect(fetcher).not.toHaveBeenCalled()
+ })
+
+ it('reads every transport batch and verifies final count before returning', async () => {
+ const fetcher = vi
+ .fn()
+ .mockResolvedValueOnce(respond(page(['a', 'b'], 3, 'next')))
+ .mockResolvedValueOnce(respond(page(['c'], 3)))
+ vi.stubGlobal('fetch', fetcher)
+ const progress = vi.fn()
+ const result = await fetchAllQARecords(query, undefined, progress)
+ expect(result.items.map((r) => r.id)).toEqual(['a', 'b', 'c'])
+ expect(result.has_more).toBe(false)
+ expect(result.total).toBe(3)
+ expect(progress.mock.calls).toEqual([
+ [2, 3],
+ [3, 3],
+ ])
+ const urls = fetcher.mock.calls.map((call) => new URL(String(call[0]), 'http://localhost'))
+ expect(urls.map((url) => url.searchParams.get('cursor'))).toEqual(['', 'next'])
+ expect(
+ urls.every((url) => url.searchParams.get('limit') === '100' && url.searchParams.get('keyword') === query.keyword)
+ ).toBe(true)
+ })
+})
diff --git a/web/src/qaOps.css b/web/src/qaOps.css
index bced1ca..c9b80ed 100644
--- a/web/src/qaOps.css
+++ b/web/src/qaOps.css
@@ -202,6 +202,14 @@
background: var(--c-run);
border: 1px solid var(--c-run);
}
+.qa-ops-query .qa-week-current {
+ color: var(--ink-strong);
+ background: var(--bg-panel);
+ border-color: var(--border-strong);
+}
+.qa-ops-query .qa-week-current:hover {
+ background: var(--bg-soft);
+}
.qa-ops button:focus-visible,
.qa-ops input:focus-visible,
.qa-ops select:focus-visible,
diff --git a/web/src/qaOps.ts b/web/src/qaOps.ts
index c0b6b38..2daaed8 100644
--- a/web/src/qaOps.ts
+++ b/web/src/qaOps.ts
@@ -259,6 +259,35 @@ export async function fetchQARecords(query: QAQuery, signal?: AbortSignal): Prom
})
return parseQARecordPage(await getPayload(`/api/v1/qa-ops/records?${parameters}`, signal))
}
+export async function fetchAllQARecords(
+ query: QAQuery,
+ signal?: AbortSignal,
+ onProgress?: (loaded: number, total: number) => void
+): Promise {
+ if (signal?.aborted) throw new DOMException('读取已取消', 'AbortError')
+ let page = await fetchQARecords({ ...query, cursor: '', limit: 100 }, signal)
+ const total = page.total
+ const ids = new Set(page.items.map((item) => item.id))
+ const cursors = new Set()
+ onProgress?.(ids.size, total)
+ while (page.has_more) {
+ if (signal?.aborted) throw new DOMException('读取已取消', 'AbortError')
+ const cursor = page.next_cursor
+ if (cursors.has(cursor) || ids.size >= total) throw new Error('全量读取游标异常,请重新查询')
+ cursors.add(cursor)
+ const next = await fetchQARecords({ ...query, cursor, limit: 100 }, signal)
+ if (next.total !== total) throw new Error('查询总数已变化,请重新查询,未将部分记录当作全部结果')
+ for (const item of next.items) {
+ if (ids.has(item.id)) throw new Error('全量读取出现重复记录,请重新查询')
+ ids.add(item.id)
+ }
+ page = mergeQAPages(page, next)
+ onProgress?.(ids.size, total)
+ }
+ if (ids.size !== total) throw new Error('全量读取数量不完整,请重试,未将部分记录当作全部结果')
+ return page
+}
+
export async function fetchQARecord(id: string, signal?: AbortSignal): Promise {
return parseQARecord(await getPayload(`/api/v1/qa-ops/records/${encodeURIComponent(id)}`, signal))
}
@@ -283,6 +312,9 @@ export async function fetchQAStatus(signal?: AbortSignal): Promise {
}
export function qaCellValue(item: QARecord, column: QAColumn): string | null {
+ if (column === 'question_chinese')
+ return item.question_chinese || (/\p{Script=Han}/u.test(item.question) ? item.question : '待翻译')
+ if (column === 'language') return item.language || '未识别'
const f = item.quality?.effective
if (f) {
if (column === 'coverage')
@@ -309,6 +341,7 @@ export function qaCellValue(item: QARecord, column: QAColumn): string | null {
if (item.feedback.up || item.feedback.down) return `其他人:赞 ${item.feedback.up} / 踩 ${item.feedback.down}`
return null
}
- if (column === 'asked_at') return new Date(item.asked_at).toLocaleString('zh-CN', { hour12: false })
+ if (column === 'asked_at')
+ return new Date(item.asked_at).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false })
return item[column] || null
}