Skip to content

Commit fc5913e

Browse files
fix(plugin-chatbot): the build result card draws the checklist verification line and states a failed build once (#34858)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNgJrQDxaUNx2so1ektgf6A)_ Fixes #34627 repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:AI 搭建结果卡的核对清单现在会显示云端新增的 `verification` 行(红色,显示云端给的标签和问题数);清单失败时,搭建的草稿卡不再显示「N 处待修复」标签和红色的「fix the problems」提示,失败只在清单里说一次。清单里其它新种类的行(如之后的 `publish`)按其 `status` 和 `line` 原样显示,不必再改控制台。 - 为什么改:#34627(cloud#4799 的控制台一半)。以前控制台丢掉这一行,失败的搭建显示「核对通过 4/5」却只列 4 行,同一屏还重复说了两次失败。 - 风险与回滚:只改 `@object-ui/plugin-chatbot` 的映射和结果卡渲染,没有新的语言键,不动契约和服务端;已有三种行的显示与原来一致。回滚即 revert。 - 先看:`ui/packages/plugin-chatbot/src/mapMessages.ts` 的 `checklistLineOf`(哪些行保留、哪些丢弃);`ChatbotEnhanced.tsx` 的 `BuildChecklistRows`(红色行)和 `renderToolDetail` 的 `failureOnChecklist`(什么时候不画标签和红字)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.checklistVerification-34627.test.tsx`,预期 9 个测试全部通过。 - 需要你做的:无,席位落地。 ## What changes - **Mapper** (`mapMessages.ts`). `BuildResultChecklist.lines` is now a union, `BuildResultChecklistLine`. `detectBuildChecklist` reads each line through `checklistLineOf`: - `object` / `view` / `sampleData`: read as before (`status` + `line`). - `verification` (cloud `ChecklistVerificationLine`, `{ kind: 'verification', status: 'failed', label, count }`): kept only when `status` is `failed`, `label` is a non-empty string and `count` is a non-negative integer. Anything else under this kind is dropped; it is not read as a generic line. - Any other kind with a valid `status` and a non-empty string `line` is kept as `{ kind: 'other', servedKind, status, line }` (the claim's last paragraph, from cloud note 6941198748: cloud#4809's `publish` line is the next such kind). - **Result card** (`ChatbotEnhanced.tsx`, `BuildChecklistRows`). A `verification` row is drawn in red (`XCircle`, `text-red-600 dark:text-red-400`, `data-kind="verification"`). It shows the producer's `label`, then the count through the existing `chatbot.build.issuesCount` key (zh `3 处待修复`, en `3 to fix`). No new locale key, and no copy of the producer's wording. An `other` row is drawn like the existing rows, by `status` and `line`. Rows of the existing kinds keep their markup unchanged. The chip still reads the served `passed/total`. - **One statement of failure.** When the turn's result card shows a checklist whose `status` is `failed`, `renderToolDetail` gets `failureOnChecklist`. The build's draft card then draws neither its error-count chip (`draft-verification-chip`, "N to fix") nor the red `draft-issues-summary` ("fix the problems"). The findings stay behind its closed Technical details disclosure. A clean "Verified" chip and the amber warnings-only summary are not failure statements, so they draw as before. - Patch changeset for `@object-ui/plugin-chatbot`. `detectBuildChecklist` and its types are not exported from the package index, so no public type changes. ## Tests New `ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.checklistVerification-34627.test.tsx` (9 tests). Every message goes through the real `uiMessageToChatMessage`: - Mapper: a verification line is kept with label and count; malformed verification lines are dropped (empty label, `count: -1`, `count: '3'`, `status: 'passed'`, a `line` instead of `label`/`count`); a `publish` line is kept by `status` + `line`, and malformed ones are dropped. CONTROL: a checklist without the new line maps exactly as before. - Card: a failed build reads `核对通过 4/5` over 5 rows. Exactly one row is failed, and it reads `校验未通过 · 3 处待修复` in red. The draft card has no `draft-verification-chip` and no `draft-issues-summary`, and Technical details is still there. A new kind renders by its line. CONTROL: a passed checklist without the new line draws 7/7 over 7 rows with no `data-kind`, and the draft card keeps its chip and summary. CONTROL: no checklist (an older producer) keeps the chip and summary. <details><summary>Readings at head 61db196</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/` (lock VERDICT command-exit 0): `Test Files 102 passed (102)`, `Tests 1038 passed (1038)`. - `pnpm --filter @object-ui/plugin-chatbot run type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): VERDICT command-exit 0. - `eslint --no-inline-config` on the three touched files: exit 0, 0 errors (12 warnings, all `react-hooks` warnings outside this diff's hunks). - Ablation A: `checklistLineOf`'s `if (r.kind === 'verification') {` was replaced through `scripts/ablation-replace.mjs` (anchor 1 to 0, blob `4268370a3031` to `7f5534781a7a`). The new file went red: `3 failed | 6 passed (9)`. The mapper keep test, the malformed-drop test and the 4/5 card test failed. Restored: blob equals HEAD, and `git diff HEAD` is empty. - Ablation B: the call site's `{ failureOnChecklist: buildChecklist?.status === 'failed' }` was replaced with `{ failureOnChecklist: false }` (blob `af2d03d4e901` to `d75c90814fb0`). Result: `1 failed | 8 passed (9)`, and the failed test is the draft-card test. Restored: blob equals HEAD, and `git diff HEAD` is empty. - Gate families (`node scripts/pm/dispatch-gates.mjs --ran`): `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero — all 39 recorded an exit code and none of them is 3)`. This includes `pnpm --dir ui exec vitest run scripts/` (`Tests 5077 passed | 2 skipped`). `pnpm --dir ui run check:new-line-citations`: `0 new citation(s)`. - `node scripts/pm/overlap-check.mjs --branch=claude/issue-34627-checklist-verification-line`: `VERDICT clean exit 0` against origin/main 7752cac. </details> ## Acceptance notes - The vendored producer schema (`__tests__/fixtures/build-cards.schema.ts`, copied at cloud f0ecef3a) predates `ChecklistVerificationLine`. This session cannot read the cloud repository, so the copy was not refreshed. The new fixtures follow the shape the card and the claim name, and they are not routed through `buildCards.contract-12724.test.ts`. Refreshing the vendored copy at a cloud sha that carries the line would let the contract test check them. - Branch base is origin/main 0ad377c. origin/main has since moved to 7752cac. The one incoming plugin-chatbot commit touches `toolResultParsers.ts`, which this diff does not touch. Overlap-check reports a clean merge, and CI runs on the merge ref. ## Verification Run the new test file (command in 维护者速读). In a running console, a failed AI build's result card should read "Checks passed 4/5" over five rows, with one red row naming the issue count. The draft card under it should show no "N to fix" chip and no red "fix the problems" sentence. ## Human Minimum - [x] 1. No `packages/spec` change. - [x] 2. New names follow the casing for their kind. - [x] 3. No formatter ran. eslint on the touched files is clean of errors; repo-wide `pnpm lint` is CI's run. - [x] 4. One issue, one branch off `main`, one pull request. - [x] 5. Patch changeset with both declaration lines, here and in the changeset. - [x] 6. `packages/spec` not touched. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. (The 维护者速读 block is the seat's maintainer summary.) --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6e9d5d6 commit fc5913e

4 files changed

Lines changed: 262 additions & 25 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-chatbot': patch
3+
---
4+
5+
fix(plugin-chatbot): the AI build result card draws the checklist's verification line, and states a failed build once
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When an AI build fails verification, the result card's `checklist` now carries a `verification` line (`{ kind: 'verification', status: 'failed', label, count }`), and its `status` and `passed/total` follow the verdict. The console dropped that line, so a failed build read "Checks passed 4/5" over four rows. The card now draws it as a red row: the producer's label, then the issue count. A failed checklist is the one place the turn states the failure: the build's draft card no longer draws its "N to fix" chip or the red "fix the problems" sentence beside it. The findings stay behind its Technical details.
11+
12+
A checklist line of any other kind that carries a valid `status` and a string `line` is drawn by those two fields, so a new kind from the producer needs no console change. Lines of the existing kinds draw as before.

‎ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx‎

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,7 +3803,15 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
38033803
// (`has`) only, never as a dependency.
38043804
const supersededPlans = supersededPlanIds(messages);
38053805

3806-
const renderToolDetail = (tool: RenderedToolInvocation) => {
3806+
/**
3807+
* objectstack#34627 — `failureOnChecklist`: the turn's result card shows a
3808+
* failed checklist, which states the build's failure; this card then draws
3809+
* neither its issue-count chip nor the red summary beside it.
3810+
*/
3811+
const renderToolDetail = (
3812+
tool: RenderedToolInvocation,
3813+
{ failureOnChecklist = false }: { failureOnChecklist?: boolean } = {},
3814+
) => {
38073815
const state =
38083816
tool.state ??
38093817
(tool.errorText
@@ -4087,7 +4095,7 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
40874095
WHY a build did or didn't auto-publish without reading
40884096
tool JSON. Green = referentially clean; amber = blocking
40894097
issues, the build stays draft until the agent repairs. */}
4090-
{tool.draftReview.verification ? (
4098+
{tool.draftReview.verification && !(failureOnChecklist && tool.draftReview.verification.errors > 0) ? (
40914099
tool.draftReview.verification.errors > 0 ? (
40924100
<span
40934101
className="inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700"
@@ -4131,6 +4139,7 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
41314139
{(() => {
41324140
const issues = tool.draftReview!.issues!;
41334141
const errorCount = issues.filter((i) => i.severity === 'error').length;
4142+
if (errorCount > 0 && failureOnChecklist) return null;
41344143
return (
41354144
<div
41364145
className={cn(
@@ -5517,7 +5526,9 @@ const ChatbotEnhanced = React.forwardRef<HTMLDivElement, ChatbotEnhancedProps>(
55175526
</Reasoning>
55185527
) : null}
55195528
{!isUser && detailedTools.length > 0
5520-
? detailedTools.map(renderToolDetail)
5529+
? detailedTools.map((tool) =>
5530+
renderToolDetail(tool, { failureOnChecklist: buildChecklist?.status === 'failed' }),
5531+
)
55215532
: null}
55225533
{isUser ? (
55235534
message.content ? (
@@ -6539,28 +6550,51 @@ function PlanCardObjectRows({
65396550
* rows): every line the producer measured on the build, objects in one column
65406551
* and views and the sample data in the other, each with its own pass mark.
65416552
* The lines are the producer's words, read verbatim from `checklist.lines`.
6553+
* objectstack#34627 — a `verification` line states the build's failed verdict
6554+
* in red: the producer's `label`, then its issue `count`. A failed checklist is
6555+
* then the one place the card's turn states the failure.
65426556
*/
65436557
function BuildChecklistRows({ checklist }: { checklist: BuildResultChecklist }) {
6558+
const { t } = useObjectTranslation();
65446559
const objectLines = checklist.lines.filter((l) => l.kind === 'object');
65456560
const otherLines = checklist.lines.filter((l) => l.kind !== 'object');
65466561
const column = (lines: BuildResultChecklist['lines'], testId: string) =>
65476562
lines.length > 0 ? (
65486563
<ul className="flex flex-col" data-testid={testId}>
6549-
{lines.map((l, idx) => (
6550-
<li
6551-
key={idx}
6552-
className="flex items-start gap-2 py-1 text-xs text-foreground/90"
6553-
data-testid="build-checklist-line"
6554-
data-status={l.status}
6555-
>
6556-
{l.status === 'passed' ? (
6557-
<CheckCircle2 className="mt-0.5 size-3.5 shrink-0 text-emerald-600" />
6558-
) : (
6559-
<TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-600" />
6560-
)}
6561-
<span className="min-w-0">{l.line}</span>
6562-
</li>
6563-
))}
6564+
{lines.map((l, idx) =>
6565+
l.kind === 'verification' ? (
6566+
<li
6567+
key={idx}
6568+
className="flex items-start gap-2 py-1 text-xs text-red-600 dark:text-red-400"
6569+
data-testid="build-checklist-line"
6570+
data-status={l.status}
6571+
data-kind={l.kind}
6572+
>
6573+
<XCircle className="mt-0.5 size-3.5 shrink-0" />
6574+
<span className="min-w-0">
6575+
{l.label}
6576+
{' · '}
6577+
<span data-testid="build-checklist-verification-count">
6578+
{t('chatbot.build.issuesCount', { count: l.count, defaultValue: '{{count}} to fix' })}
6579+
</span>
6580+
</span>
6581+
</li>
6582+
) : (
6583+
<li
6584+
key={idx}
6585+
className="flex items-start gap-2 py-1 text-xs text-foreground/90"
6586+
data-testid="build-checklist-line"
6587+
data-status={l.status}
6588+
>
6589+
{l.status === 'passed' ? (
6590+
<CheckCircle2 className="mt-0.5 size-3.5 shrink-0 text-emerald-600" />
6591+
) : (
6592+
<TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-600" />
6593+
)}
6594+
<span className="min-w-0">{l.line}</span>
6595+
</li>
6596+
),
6597+
)}
65646598
</ul>
65656599
) : null;
65666600
return (
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
* objectstack#34627 — the result card's checklist gains cloud's
9+
* `ChecklistVerificationLine` (`{ kind: 'verification', status: 'failed',
10+
* label, count }`), appended when the build's verdict has errors, with
11+
* `status` and `passed/total` following the verdict. The console draws it as
12+
* a red row (the producer's label, then the issue count), and a failed
13+
* checklist is the one place the turn states the failure: the build's draft
14+
* card draws neither its issue-count chip nor the red summary beside it.
15+
*
16+
* A line of any other kind that carries a valid `status` and a string `line`
17+
* (cloud's `publish` line is the next one) is drawn by those two fields.
18+
*
19+
* The verification line's shape is the producer's `build-cards.schema.json`
20+
* as the card names it; the vendored copy in `fixtures/build-cards.schema.ts`
21+
* predates it, so these fixtures are not routed through the contract test.
22+
*
23+
* Each message goes through the real mapper (`uiMessageToChatMessage`) from a
24+
* raw tool part, so the lift is under test, not a hand-built invocation.
25+
*/
26+
import '@testing-library/jest-dom/vitest';
27+
import { describe, expect, it, vi } from 'vitest';
28+
import { render, screen, within } from '@testing-library/react';
29+
import { I18nProvider } from '@object-ui/i18n';
30+
import { ChatbotEnhanced } from '../ChatbotEnhanced';
31+
import { detectBuildChecklist, uiMessageToChatMessage } from '../mapMessages';
32+
import { applyEnvelope, checklistOf } from './fixtures/buildCards.fixtures';
33+
34+
const VERIFICATION = { kind: 'verification', status: 'failed', label: '校验未通过', count: 3 } as const;
35+
36+
/** Three objects and the board view, all passed, then the verification line: 4/5, failed. */
37+
function failedChecklist() {
38+
const base = checklistOf('zh');
39+
return { ...base, status: 'failed', passed: 4, total: 5, lines: [...base.lines.slice(0, 4), VERIFICATION] };
40+
}
41+
42+
const ISSUES = [
43+
{ severity: 'error', code: 'seed_column_empty', message: 'Seed "loan_sample" sets "due_date" on none of its rows.' },
44+
{ severity: 'error', code: 'view_filter_field', message: 'View "loan.overdue_loans" filters on an unknown field.' },
45+
{ severity: 'error', code: 'seed_lookup', message: 'Seed "loan_sample" points at a missing reader.' },
46+
];
47+
48+
/** `apply_blueprint`'s envelope with the verdict's errors, and the checklist given. */
49+
const failedBuild = (checklist: unknown) => {
50+
const { checklist: _served, ...envelope } = applyEnvelope('zh');
51+
return {
52+
...envelope,
53+
verification: { errors: 3, warnings: 0 },
54+
issues: ISSUES,
55+
...(checklist === undefined ? {} : { checklist }),
56+
};
57+
};
58+
59+
const turn = (output: unknown) =>
60+
uiMessageToChatMessage({
61+
id: 'built',
62+
role: 'assistant',
63+
parts: [{ type: 'tool-apply_blueprint', toolCallId: 'apply-1', state: 'output-available', input: {}, output }],
64+
});
65+
66+
const renderBuild = (output: unknown) =>
67+
render(
68+
<I18nProvider config={{ defaultLanguage: 'zh', detectBrowserLanguage: false }}>
69+
<ChatbotEnhanced messages={[turn(output)]} onOpenBuiltApp={vi.fn()} onReviewDraft={vi.fn()} />
70+
</I18nProvider>,
71+
);
72+
73+
describe('objectstack#34627 — detectBuildChecklist keeps the verification line and any new kind', () => {
74+
it('a verification line is kept with its label and count', () => {
75+
const checklist = detectBuildChecklist(failedBuild(failedChecklist()))!;
76+
expect([checklist.status, checklist.passed, checklist.total]).toEqual(['failed', 4, 5]);
77+
expect(checklist.lines).toHaveLength(5);
78+
expect(checklist.lines[4]).toEqual({ kind: 'verification', status: 'failed', label: '校验未通过', count: 3 });
79+
});
80+
81+
it('a verification line without its label or count, or not failed, is dropped', () => {
82+
for (const bad of [
83+
{ ...VERIFICATION, label: '' },
84+
{ ...VERIFICATION, count: -1 },
85+
{ ...VERIFICATION, count: '3' },
86+
{ ...VERIFICATION, status: 'passed' },
87+
{ kind: 'verification', status: 'failed', line: '校验未通过 · 3' },
88+
]) {
89+
const checklist = detectBuildChecklist(failedBuild({ ...failedChecklist(), lines: [bad] }))!;
90+
expect(checklist.lines).toEqual([]);
91+
}
92+
});
93+
94+
it('a line of another kind is kept by its status and line; one without them is dropped', () => {
95+
const publish = { kind: 'publish', status: 'failed', outcome: 'rolled_back', reason: 'x', line: '发布已回滚' };
96+
const checklist = detectBuildChecklist(
97+
failedBuild({ ...failedChecklist(), lines: [publish, { kind: 'publish', status: 'failed' }, { kind: 'publish', status: 'maybe', line: 'x' }] }),
98+
)!;
99+
expect(checklist.lines).toEqual([{ kind: 'other', servedKind: 'publish', status: 'failed', line: '发布已回滚' }]);
100+
});
101+
102+
it('CONTROL: a checklist without the new line maps as before', () => {
103+
expect(detectBuildChecklist(applyEnvelope('zh'))!.lines).toEqual(
104+
checklistOf('zh').lines.map((l) => ({ kind: l.kind, status: l.status, line: l.line })),
105+
);
106+
});
107+
});
108+
109+
describe('objectstack#34627 — a failed build: 4/5 over five rows, the failure stated once', () => {
110+
it('the chip reads 4/5, five rows, one red row with the label and the issue count', () => {
111+
renderBuild(failedBuild(failedChecklist()));
112+
const chip = screen.getByTestId('build-checklist-chip');
113+
expect(chip).toHaveTextContent(/^核对通过 4\/5$/);
114+
expect(chip).toHaveAttribute('data-status', 'failed');
115+
const rows = screen.getAllByTestId('build-checklist-line');
116+
expect(rows).toHaveLength(5);
117+
const failed = rows.filter((r) => r.getAttribute('data-status') === 'failed');
118+
expect(failed).toHaveLength(1);
119+
expect(failed[0]).toHaveAttribute('data-kind', 'verification');
120+
expect(failed[0]).toHaveTextContent(/^校验未通过 · 3 处待修复$/);
121+
expect(failed[0].className).toContain('text-red-600');
122+
expect(within(failed[0]).getByTestId('build-checklist-verification-count')).toHaveTextContent('3 处待修复');
123+
});
124+
125+
it('the draft card draws no issue-count chip and no red summary; the findings stay behind Technical details', () => {
126+
renderBuild(failedBuild(failedChecklist()));
127+
expect(screen.queryByTestId('draft-verification-chip')).not.toBeInTheDocument();
128+
expect(screen.queryByTestId('draft-issues-summary')).not.toBeInTheDocument();
129+
expect(screen.getByTestId('draft-issues-details')).toBeInTheDocument();
130+
});
131+
132+
it('a new kind renders by its status and line beside the others', () => {
133+
const publish = { kind: 'publish', status: 'failed', outcome: 'rolled_back', reason: 'x', line: '发布已回滚,应用保持原样' };
134+
const base = checklistOf('zh');
135+
renderBuild(failedBuild({ ...base, status: 'failed', passed: 7, total: 8, lines: [...base.lines, publish] }));
136+
const rows = screen.getAllByTestId('build-checklist-line');
137+
expect(rows).toHaveLength(8);
138+
expect(rows[7]).toHaveTextContent(/^发布已回滚,应用保持原样$/);
139+
expect(rows[7]).toHaveAttribute('data-status', 'failed');
140+
expect(rows[7]).not.toHaveAttribute('data-kind');
141+
});
142+
143+
it('CONTROL: a passed checklist without the new line draws as before, and the draft card keeps its chip and summary', () => {
144+
renderBuild(failedBuild(checklistOf('zh')));
145+
expect(screen.getByTestId('build-checklist-chip')).toHaveTextContent(/^核对通过 7\/7$/);
146+
const rows = screen.getAllByTestId('build-checklist-line');
147+
expect(rows).toHaveLength(7);
148+
for (const r of rows) expect(r).not.toHaveAttribute('data-kind');
149+
expect(screen.getByTestId('draft-verification-chip')).toHaveTextContent('3 处待修复');
150+
expect(screen.getByTestId('draft-issues-summary')).toBeInTheDocument();
151+
});
152+
153+
it('CONTROL: no checklist (an older producer): the draft card keeps its chip and summary', () => {
154+
renderBuild(failedBuild(undefined));
155+
expect(screen.queryByTestId('build-checklist')).not.toBeInTheDocument();
156+
expect(screen.getByTestId('draft-verification-chip')).toHaveTextContent('3 处待修复');
157+
expect(screen.getByTestId('draft-issues-summary')).toBeInTheDocument();
158+
});
159+
});

‎ui/packages/plugin-chatbot/src/mapMessages.ts‎

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ export interface ProposedPlanCard {
296296
posture?: { mode: 'publish' | 'draft'; line: string };
297297
}
298298

299+
/**
300+
* One row of the result card's checklist (cloud `build-cards.schema.json`).
301+
*
302+
* - `object` / `view` / `sampleData`: a measured line, drawn by `status` and
303+
* the producer's `line`.
304+
* - `verification` (`ChecklistVerificationLine`): appended when the build's
305+
* verdict has errors; always `failed`, and it carries the producer's `label`
306+
* and the issue `count` instead of a `line`.
307+
* - `other`: a line of a kind this console does not know yet, carrying a
308+
* valid `status` and a string `line`; `kind` is the producer's kind. It is
309+
* drawn by those two fields, so a new kind needs no console change.
310+
*/
311+
export type BuildResultChecklistLine =
312+
| { kind: 'object' | 'view' | 'sampleData'; status: 'passed' | 'failed'; line: string }
313+
| { kind: 'verification'; status: 'failed'; label: string; count: number }
314+
| { kind: 'other'; servedKind: string; status: 'passed' | 'failed'; line: string };
315+
299316
/**
300317
* objectui#12724 — the keys of the result card's `checklist` that the card
301318
* draws, from `apply_blueprint`'s and `verify_build`'s envelopes
@@ -306,7 +323,7 @@ export interface BuildResultChecklist {
306323
passed: number;
307324
total: number;
308325
/** Objects, then views, then the sample data, each measured on the build. */
309-
lines: Array<{ kind: 'object' | 'view' | 'sampleData'; status: 'passed' | 'failed'; line: string }>;
326+
lines: BuildResultChecklistLine[];
310327
/** The app 打开应用 opens. */
311328
app?: { name: string; label?: string };
312329
/** The package 在 Studio 中查看 opens. */
@@ -505,10 +522,29 @@ function liftPlanCard(raw: unknown): ProposedPlanCard | undefined {
505522
}
506523

507524
const isLineStatus = (v: unknown): v is 'passed' | 'failed' => v === 'passed' || v === 'failed';
508-
const isLineKind = (v: unknown): v is BuildResultChecklist['lines'][number]['kind'] =>
525+
const isMeasuredLineKind = (v: unknown): v is 'object' | 'view' | 'sampleData' =>
509526
v === 'object' || v === 'view' || v === 'sampleData';
510527
const isCount = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 0;
511528

529+
/**
530+
* One served checklist line, or none when it does not carry its kind's keys.
531+
* A known kind is read by its own shape only; a kind outside the known four is
532+
* kept when it carries a valid `status` and a string `line`.
533+
*/
534+
function checklistLineOf(l: unknown): BuildResultChecklistLine[] {
535+
const r = recordOf(l);
536+
if (!r || !isText(r.kind)) return [];
537+
if (r.kind === 'verification') {
538+
return r.status === 'failed' && isText(r.label) && isCount(r.count)
539+
? [{ kind: 'verification', status: 'failed', label: r.label, count: r.count }]
540+
: [];
541+
}
542+
if (!isLineStatus(r.status) || !isText(r.line)) return [];
543+
return isMeasuredLineKind(r.kind)
544+
? [{ kind: r.kind, status: r.status, line: r.line }]
545+
: [{ kind: 'other', servedKind: r.kind, status: r.status, line: r.line }];
546+
}
547+
512548
/**
513549
* objectui#12724 — the result card's `checklist`, on `apply_blueprint`'s
514550
* envelope (drafted, or published in-turn) and on `verify_build`'s, which
@@ -521,11 +557,7 @@ export function detectBuildChecklist(result: unknown): BuildResultChecklist | un
521557
if (!raw || !isLineStatus(raw.status) || !isCount(raw.passed) || !isCount(raw.total) || !Array.isArray(raw.lines)) {
522558
return undefined;
523559
}
524-
const lines = raw.lines.flatMap((l) => {
525-
const r = recordOf(l);
526-
if (!r || !isLineKind(r.kind) || !isLineStatus(r.status) || !isText(r.line)) return [];
527-
return [{ kind: r.kind, status: r.status, line: r.line }];
528-
});
560+
const lines = raw.lines.flatMap(checklistLineOf);
529561
const app = recordOf(raw.app);
530562
return {
531563
status: raw.status,

0 commit comments

Comments
 (0)