feat(frontend): always show trigger source labels (手动/AI 助手/CLI)
Some checks failed
CI / test (push) Failing after 49s

运行列表、报告页运行下拉、仪表盘最近评测行不再隐藏手动标签;
报告头与对比 A/B 卡片新增"触发方式"(报告 payload 补 triggered_by)。
This commit is contained in:
sinohqb 2026-07-29 14:34:32 +08:00
parent 8e3cf82fcc
commit fbac28bc7e
4 changed files with 28 additions and 13 deletions

View File

@ -173,6 +173,7 @@ def generate_report(run_id: str, session=None) -> dict[str, Any]:
"scenario_id": run.scenario_id, "scenario_id": run.scenario_id,
"scenario_name": scenario.name if scenario else "未知", "scenario_name": scenario.name if scenario else "未知",
"scenario_version": run.scenario_version, "scenario_version": run.scenario_version,
"triggered_by": run.triggered_by.value,
"status": run.status.value, "status": run.status.value,
"started_at": iso_utc(run.started_at), "started_at": iso_utc(run.started_at),
"completed_at": iso_utc(run.completed_at), "completed_at": iso_utc(run.completed_at),
@ -249,6 +250,7 @@ def generate_compare_report(run_id_1: str, run_id_2: str, session=None) -> dict[
"target_name": report_a.get("target_name"), "target_name": report_a.get("target_name"),
"scenario_name": report_a.get("scenario_name"), "scenario_name": report_a.get("scenario_name"),
"scenario_version": report_a.get("scenario_version"), "scenario_version": report_a.get("scenario_version"),
"triggered_by": report_a.get("triggered_by"),
"status": report_a.get("status"), "status": report_a.get("status"),
"started_at": report_a.get("started_at"), "started_at": report_a.get("started_at"),
"summary": report_a["summary"], "summary": report_a["summary"],
@ -258,6 +260,7 @@ def generate_compare_report(run_id_1: str, run_id_2: str, session=None) -> dict[
"target_name": report_b.get("target_name"), "target_name": report_b.get("target_name"),
"scenario_name": report_b.get("scenario_name"), "scenario_name": report_b.get("scenario_name"),
"scenario_version": report_b.get("scenario_version"), "scenario_version": report_b.get("scenario_version"),
"triggered_by": report_b.get("triggered_by"),
"status": report_b.get("status"), "status": report_b.get("status"),
"started_at": report_b.get("started_at"), "started_at": report_b.get("started_at"),
"summary": report_b["summary"], "summary": report_b["summary"],

View File

@ -299,7 +299,7 @@ function RunRow({ r, selected, targetName, scenarioName, onSelect, onOpenReport,
</Tag> </Tag>
</Tooltip> </Tooltip>
)} )}
{r.triggered_by && r.triggered_by !== 'manual' && ( {r.triggered_by && (
<Tag <Tag
color={triggerColors[r.triggered_by] ?? 'default'} color={triggerColors[r.triggered_by] ?? 'default'}
style={{ marginLeft: 2, marginRight: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }} style={{ marginLeft: 2, marginRight: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }}

View File

@ -221,11 +221,9 @@ function RecentRunRow({ run, onOpen }: { run: Run; onOpen: () => void }) {
v{run.scenario_version} v{run.scenario_version}
</Tag> </Tag>
)} )}
{trigger !== 'manual' && ( <Tag color={triggerColors[trigger] ?? 'default'} style={{ margin: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }}>
<Tag color={triggerColors[trigger] ?? 'default'} style={{ margin: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }}> {triggerLabels[trigger] ?? trigger}
{triggerLabels[trigger] ?? trigger} </Tag>
</Tag>
)}
<span style={{ fontSize: 12, color: dotColor, width: 48, flexShrink: 0 }}>{statusLabels[run.status] ?? run.status}</span> <span style={{ fontSize: 12, color: dotColor, width: 48, flexShrink: 0 }}>{statusLabels[run.status] ?? run.status}</span>
<span style={{ <span style={{
fontSize: 12, fontWeight: 600, width: 44, textAlign: 'right', flexShrink: 0, fontSize: 12, fontWeight: 600, width: 44, textAlign: 'right', flexShrink: 0,

View File

@ -39,6 +39,7 @@ interface Report {
target_name: string target_name: string
scenario_name: string scenario_name: string
scenario_version?: number scenario_version?: number
triggered_by?: string
status: string status: string
started_at: string started_at: string
completed_at: string | null completed_at: string | null
@ -56,8 +57,8 @@ interface Report {
} }
interface CompareResult { interface CompareResult {
run_a: { run_id: string; target_name: string; scenario_name: string; scenario_version?: number; status: string; started_at: string; summary: Report['summary'] } run_a: { run_id: string; target_name: string; scenario_name: string; scenario_version?: number; triggered_by?: string; status: string; started_at: string; summary: Report['summary'] }
run_b: { run_id: string; target_name: string; scenario_name: string; scenario_version?: number; status: string; started_at: string; summary: Report['summary'] } run_b: { run_id: string; target_name: string; scenario_name: string; scenario_version?: number; triggered_by?: string; status: string; started_at: string; summary: Report['summary'] }
delta: { pass_rate: number; passed_cases: number; passed_rules: number } delta: { pass_rate: number; passed_cases: number; passed_rules: number }
cases: Array<{ cases: Array<{
case_id: string case_id: string
@ -207,11 +208,9 @@ export default function ReportsPage() {
color: passRate != null && passRate >= 0.8 ? '#3f8600' : '#cf1322', color: passRate != null && passRate >= 0.8 ? '#3f8600' : '#cf1322',
fontSize: 12, fontWeight: 600, fontSize: 12, fontWeight: 600,
}}>{pct}</span> }}>{pct}</span>
{trigger !== 'manual' && ( <Tag color={triggerColors[trigger] ?? 'default'} style={{ marginRight: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }}>
<Tag color={triggerColors[trigger] ?? 'default'} style={{ marginRight: 0, fontSize: 10, lineHeight: '16px', padding: '0 4px' }}> {triggerLabels[trigger] ?? trigger}
{triggerLabels[trigger] ?? trigger} </Tag>
</Tag>
)}
</span> </span>
), ),
} }
@ -404,6 +403,11 @@ function SingleReportView({ report }: { report: Report | null }) {
{report.scenario_version != null && <Tag color="geekblue">v{report.scenario_version}</Tag>} {report.scenario_version != null && <Tag color="geekblue">v{report.scenario_version}</Tag>}
</Space> </Space>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="触发方式">
<Tag color={triggerColors[report.triggered_by as keyof typeof triggerColors] ?? 'default'}>
{triggerLabels[report.triggered_by as keyof typeof triggerLabels] ?? report.triggered_by ?? '手动'}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="开始时间">{formatDateTime(report.started_at)}</Descriptions.Item> <Descriptions.Item label="开始时间">{formatDateTime(report.started_at)}</Descriptions.Item>
<Descriptions.Item label="完成时间">{report.completed_at ? formatDateTime(report.completed_at) : '-'}</Descriptions.Item> <Descriptions.Item label="完成时间">{report.completed_at ? formatDateTime(report.completed_at) : '-'}</Descriptions.Item>
</Descriptions> </Descriptions>
@ -502,6 +506,11 @@ function CompareView({ result }: { result: CompareResult | null }) {
{run_a.scenario_name} {run_a.scenario_name}
{run_a.scenario_version != null && <Tag color="geekblue" style={{ marginLeft: 6 }}>v{run_a.scenario_version}</Tag>} {run_a.scenario_version != null && <Tag color="geekblue" style={{ marginLeft: 6 }}>v{run_a.scenario_version}</Tag>}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="触发方式">
<Tag color={triggerColors[run_a.triggered_by as keyof typeof triggerColors] ?? 'default'}>
{triggerLabels[run_a.triggered_by as keyof typeof triggerLabels] ?? run_a.triggered_by ?? '手动'}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="时间">{formatDateTime(run_a.started_at)}</Descriptions.Item> <Descriptions.Item label="时间">{formatDateTime(run_a.started_at)}</Descriptions.Item>
<Descriptions.Item label="通过率">{(run_a.summary.pass_rate * 100).toFixed(1)}%</Descriptions.Item> <Descriptions.Item label="通过率">{(run_a.summary.pass_rate * 100).toFixed(1)}%</Descriptions.Item>
<Descriptions.Item label="用例">{run_a.summary.passed_cases}/{run_a.summary.total_cases}</Descriptions.Item> <Descriptions.Item label="用例">{run_a.summary.passed_cases}/{run_a.summary.total_cases}</Descriptions.Item>
@ -523,6 +532,11 @@ function CompareView({ result }: { result: CompareResult | null }) {
{run_b.scenario_name} {run_b.scenario_name}
{run_b.scenario_version != null && <Tag color="geekblue" style={{ marginLeft: 6 }}>v{run_b.scenario_version}</Tag>} {run_b.scenario_version != null && <Tag color="geekblue" style={{ marginLeft: 6 }}>v{run_b.scenario_version}</Tag>}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="触发方式">
<Tag color={triggerColors[run_b.triggered_by as keyof typeof triggerColors] ?? 'default'}>
{triggerLabels[run_b.triggered_by as keyof typeof triggerLabels] ?? run_b.triggered_by ?? '手动'}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="时间">{formatDateTime(run_b.started_at)}</Descriptions.Item> <Descriptions.Item label="时间">{formatDateTime(run_b.started_at)}</Descriptions.Item>
<Descriptions.Item label="通过率">{(run_b.summary.pass_rate * 100).toFixed(1)}%</Descriptions.Item> <Descriptions.Item label="通过率">{(run_b.summary.pass_rate * 100).toFixed(1)}%</Descriptions.Item>
<Descriptions.Item label="用例">{run_b.summary.passed_cases}/{run_b.summary.total_cases}</Descriptions.Item> <Descriptions.Item label="用例">{run_b.summary.passed_cases}/{run_b.summary.total_cases}</Descriptions.Item>