按当前筛选后的完整已载入顺序切换,边界自动禁用,后台续页到达后自动开放。 独立保存选中目标以支持加载及失败时切换,沿用取消/迟到响应隔离,关闭返回原表格焦点。 验证:详情首中尾/未知目标、加载/失败、100到101续页先红后绿;既有流水和看板范围回归、完整门禁及原生备份恢复通过。
This commit is contained in:
@@ -76,6 +76,12 @@
|
||||
> `0.1.12`),由 `scripts/version.py` 从 git **算出来**;开发交付的独立说明写入本文件“开发快照”章节,并打 `snapshot/vX.Y.Z` 注释标签 ⇒ 每次开发交付均可追溯,
|
||||
> 但"发布版本"仍然只能由人定(CI 不会自动升版本、不会打 tag)。
|
||||
|
||||
## 开发快照 snapshot/v0.1.60 - 2026-10-25
|
||||
|
||||
### Added
|
||||
|
||||
- 右侧问答详情顶部增加上一条、下一条,沿当前筛选后的完整已载入表格顺序切换;首尾自动禁用,后续页载入后自动开放下一条,读取中或失败仍能切换,关闭保留原表格焦点。
|
||||
|
||||
## 开发快照 snapshot/v0.1.59 - 2026-10-25
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -52,6 +52,58 @@ const props = {
|
||||
}
|
||||
|
||||
describe('QA operations workbench', () => {
|
||||
it('puts previous/next in the detail header and follows the entire filtered result, including loading and error states', () => {
|
||||
const items = Array.from({ length: 101 }, (_, index) => ({ ...item, id: 'filtered-' + index }))
|
||||
const cases = [
|
||||
{ index: 0, previous: false, next: true },
|
||||
{ index: 50, previous: true, next: true },
|
||||
{ index: 100, previous: true, next: false },
|
||||
{ index: -1, previous: false, next: false },
|
||||
]
|
||||
for (const state of ['ready', 'loading', 'failed']) {
|
||||
for (const value of cases) {
|
||||
const selected = items[value.index] ?? { ...item, id: 'not-in-this-filter' }
|
||||
const html = renderToStaticMarkup(
|
||||
<QAOperationsView
|
||||
{...props}
|
||||
page={{ ...page, items, total: items.length }}
|
||||
detailID={selected.id}
|
||||
detail={state === 'ready' ? selected : null}
|
||||
detailLoading={state === 'loading'}
|
||||
detailError={state === 'failed' ? '详情读取失败' : null}
|
||||
/>
|
||||
)
|
||||
const drawer = html.slice(html.indexOf('<aside'))
|
||||
const header = drawer.slice(0, drawer.indexOf('</header>'))
|
||||
for (const [label, enabled] of [
|
||||
['上一条', value.previous],
|
||||
['下一条', value.next],
|
||||
] as const) {
|
||||
const button = header.match(new RegExp('<button([^>]*)>' + label + '</button>'))
|
||||
expect(button, state + ': ' + selected.id + ': ' + label).not.toBeNull()
|
||||
expect(button?.[1].includes('disabled=""')).toBe(!enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
it('enables next automatically when the background reader appends the next page', () => {
|
||||
const items = Array.from({ length: 101 }, (_, index) => ({ ...item, id: 'filtered-' + index }))
|
||||
for (const loaded of [100, 101]) {
|
||||
const html = renderToStaticMarkup(
|
||||
<QAOperationsView
|
||||
{...props}
|
||||
page={{ ...page, items: items.slice(0, loaded), total: 101, has_more: loaded < 101 }}
|
||||
detail={items[99]}
|
||||
loading={loaded < 101}
|
||||
/>
|
||||
)
|
||||
const drawer = html.slice(html.indexOf('<aside'))
|
||||
const button = drawer.slice(0, drawer.indexOf('</header>')).match(/<button([^>]*)>下一条<\/button>/)
|
||||
expect(button).not.toBeNull()
|
||||
expect(button?.[1].includes('disabled=""')).toBe(loaded === 100)
|
||||
}
|
||||
})
|
||||
|
||||
it('puts all five selectors in their own table header cells, including empty filtered results', () => {
|
||||
const filtering = { filters: { coverage: '否' }, onFiltersChange: vi.fn() }
|
||||
for (const value of [page, { ...page, items: [], total: 0, has_more: false }]) {
|
||||
|
||||
@@ -52,6 +52,7 @@ interface ViewProps {
|
||||
loading: boolean
|
||||
error: string | null
|
||||
detail: QARecord | null
|
||||
detailID?: string | null
|
||||
detailLoading: boolean
|
||||
detailError: string | null
|
||||
onSelect: (id: string) => void
|
||||
@@ -176,6 +177,9 @@ export function QAOperationsView(props: ViewProps) {
|
||||
return map
|
||||
}, [props.taskUpdates])
|
||||
const detail = props.detail
|
||||
const detailIndex = page?.items.findIndex((item) => item.id === (props.detailID ?? detail?.id)) ?? -1
|
||||
const previous = detailIndex > 0 ? page?.items[detailIndex - 1] : undefined
|
||||
const next = detailIndex >= 0 ? page?.items[detailIndex + 1] : undefined
|
||||
const showDrawer = Boolean(detail || props.detailLoading || props.detailError)
|
||||
return (
|
||||
<section className="qa-ops-results" aria-label="问答记录">
|
||||
@@ -320,9 +324,17 @@ export function QAOperationsView(props: ViewProps) {
|
||||
>
|
||||
<header>
|
||||
<h3>问答详情</h3>
|
||||
<button type="button" autoFocus onClick={props.onCloseDetail}>
|
||||
关闭详情
|
||||
</button>
|
||||
<div className="qa-detail-actions">
|
||||
<button type="button" disabled={!previous} onClick={() => previous && props.onSelect(previous.id)}>
|
||||
上一条
|
||||
</button>
|
||||
<button type="button" disabled={!next} onClick={() => next && props.onSelect(next.id)}>
|
||||
下一条
|
||||
</button>
|
||||
<button type="button" autoFocus onClick={props.onCloseDetail}>
|
||||
关闭详情
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
{detail ? (
|
||||
<QAInlineFields
|
||||
@@ -431,6 +443,7 @@ export function QAOperations() {
|
||||
viewRef.current = view
|
||||
const [mirrorChanged, setMirrorChanged] = useState(false)
|
||||
const [detail, setDetail] = useState<QARecord | null>(null)
|
||||
const [detailID, setDetailID] = useState<string | null>(null)
|
||||
const [detailLoading, setDetailLoading] = useState(false)
|
||||
const [detailError, setDetailError] = useState<string | null>(null)
|
||||
const [progress, setProgress] = useState<{ loaded: number; total: number } | undefined>()
|
||||
@@ -454,6 +467,7 @@ export function QAOperations() {
|
||||
setError(null)
|
||||
detailRequest.current?.abort()
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
return
|
||||
}
|
||||
const controller = new AbortController()
|
||||
@@ -465,6 +479,7 @@ export function QAOperations() {
|
||||
setPage(null)
|
||||
setProgress(undefined)
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(false)
|
||||
void fetchQAStatus(controller.signal)
|
||||
@@ -547,9 +562,11 @@ export function QAOperations() {
|
||||
}, [])
|
||||
const select = useCallback(async (id: string) => {
|
||||
detailRequest.current?.abort()
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
if (!document.activeElement?.closest('.qa-ops-drawer'))
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
const controller = new AbortController()
|
||||
detailRequest.current = controller
|
||||
setDetailID(id)
|
||||
setDetail(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(true)
|
||||
@@ -585,6 +602,7 @@ export function QAOperations() {
|
||||
}
|
||||
detailRequest.current?.abort()
|
||||
setDetail(null)
|
||||
setDetailID(null)
|
||||
setDetailError(null)
|
||||
setDetailLoading(false)
|
||||
returnFocus.current?.focus()
|
||||
@@ -728,6 +746,7 @@ export function QAOperations() {
|
||||
error={error}
|
||||
loading={loading}
|
||||
detail={detail}
|
||||
detailID={detailID}
|
||||
detailLoading={detailLoading}
|
||||
detailError={detailError}
|
||||
onReloadDetail={() => {
|
||||
|
||||
@@ -366,6 +366,7 @@
|
||||
}
|
||||
.qa-ops-drawer > header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
@@ -374,6 +375,11 @@
|
||||
background: var(--bg-panel);
|
||||
border-bottom: 1px solid var(--border-base);
|
||||
}
|
||||
.qa-detail-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.qa-detail-quality {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
|
||||
Reference in New Issue
Block a user