已覆盖只允许正确或错误,未覆盖可待确认,缺引用不再阻止正确结论。 复用统一事务写入与不可变审计重评旧待确认,保留原问答和人工结论。 验证:全仓 make verify、真实隔离 PostgreSQL 全包与 race 回归通过。
This commit is contained in:
@@ -2,7 +2,13 @@ import { useEffect, useRef, useState } from 'react'
|
||||
import './qaPeriodInput.css'
|
||||
import type { QARecord } from './qaOps'
|
||||
import { qaColumns } from './qaOps'
|
||||
import { editableFieldKeys, editableFieldValue, fetchFieldOptions, saveInlineField } from './qaInlineFields'
|
||||
import {
|
||||
editableFieldKeys,
|
||||
editableFieldValue,
|
||||
fieldChoices,
|
||||
fetchFieldOptions,
|
||||
saveInlineField,
|
||||
} from './qaInlineFields'
|
||||
import type { EditableField, FieldOptions } from './qaInlineFields'
|
||||
import { newOperationID } from './operationKey'
|
||||
import { qaFieldColors } from './qaFieldColors'
|
||||
@@ -64,6 +70,7 @@ export function QAInlineFields({
|
||||
<div className="qa-detail-quality" aria-label="固定质量字段">
|
||||
{editableFieldKeys.map((field) => {
|
||||
const value = pending?.field === field ? pending.value : editableFieldValue(record, field)
|
||||
const choices = fieldChoices(field, options?.[field] ?? [], editableFieldValue(record, 'coverage'))
|
||||
const rootNotNeeded = field === 'root_cause' && editableFieldValue(record, 'is_correct') === '是'
|
||||
const downvoteLocked = field === 'is_correct' && record.quality?.feedback_rule === 'downvote-is-incorrect-v1'
|
||||
return (
|
||||
@@ -98,12 +105,12 @@ export function QAInlineFields({
|
||||
<option value="" disabled>
|
||||
{rootNotNeeded ? '无需根因' : '未设置'}
|
||||
</option>
|
||||
{value && !options?.[field].includes(value) ? (
|
||||
{value && !choices.includes(value) ? (
|
||||
<option value={value} disabled>
|
||||
{value}
|
||||
</option>
|
||||
) : null}
|
||||
{options?.[field].map((v) => (
|
||||
{choices.map((v) => (
|
||||
<option key={v} value={v}>
|
||||
{v}
|
||||
</option>
|
||||
|
||||
@@ -233,11 +233,13 @@ export function QAQualityEditor({ recordId, quality, onSaved, onReload, dataset
|
||||
onChange={(e) => change('correctness', e.target.value)}
|
||||
>
|
||||
<option value="">请选择</option>
|
||||
{['correct', 'incorrect', 'pending'].map((key) => (
|
||||
<option key={key} value={key}>
|
||||
{qualityLabels[key]}
|
||||
</option>
|
||||
))}
|
||||
{(fields.coverage === 'uncovered' ? ['correct', 'incorrect', 'pending'] : ['correct', 'incorrect']).map(
|
||||
(key) => (
|
||||
<option key={key} value={key}>
|
||||
{qualityLabels[key]}
|
||||
</option>
|
||||
)
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { fieldChoices } from './qaInlineFields'
|
||||
describe('correctness choices follow effective coverage', () => {
|
||||
it('allows pending only for uncovered, without changing coverage options', () => {
|
||||
for (const coverage of ['是', '部分覆盖', '待确认', '否但不计入', ''])
|
||||
expect(fieldChoices('is_correct', ['是', '否', '待确认'], coverage)).toEqual(['是', '否'])
|
||||
expect(fieldChoices('is_correct', ['是', '否', '待确认'], '否')).toEqual(['是', '否', '待确认'])
|
||||
expect(fieldChoices('coverage', ['是', '否', '待确认'], '是')).toEqual(['是', '否', '待确认'])
|
||||
})
|
||||
})
|
||||
@@ -3,6 +3,9 @@ import type { QARecord } from './qaOps'
|
||||
export const editableFieldKeys = ['coverage', 'is_correct', 'product_category', 'problem_type', 'root_cause'] as const
|
||||
export type EditableField = (typeof editableFieldKeys)[number]
|
||||
export type FieldOptions = Record<EditableField, string[]>
|
||||
export function fieldChoices(field: EditableField, choices: string[], coverage: string): string[] {
|
||||
return field === 'is_correct' && coverage !== '否' ? choices.filter((value) => value !== '待确认') : choices
|
||||
}
|
||||
export function parseFieldOptions(raw: unknown): FieldOptions {
|
||||
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw Error('主表选项读取失败')
|
||||
const v = raw as Record<string, unknown>
|
||||
|
||||
Reference in New Issue
Block a user