Initial import of streamline

This commit is contained in:
2026-11-16 17:26:44 -08:00
commit 8e4aec1855
1221 changed files with 274256 additions and 0 deletions
+124
View File
@@ -0,0 +1,124 @@
/**
* The full `<category>:<kind>` → card map, built once from the shared fixtures.
* Used by both preview scripts so the name set can't drift between "render" and
* "send".
*
* Samples are STAGE-ACCURATE, not just status-relabelled: a real row has no
* mrUrl / fixedRisk / branchName until the fix run has actually produced them,
* and the card's field list is `.filter(value)`-driven, so previewing a
* `pending_confirmation` card with a populated MR would show a layout that can
* never occur in production — and hide the sparse one that will.
*/
import {
buildCard, buildFeatureCard, buildSecurityCard,
meta, featureMeta, securityMeta,
type NotifyKind, type FeatureNotifyKind, type SecurityNotifyKind,
} from "../control-server/src/notify_cards";
import { sampleTask, sampleFeature, sampleSecurity, FAILURE_REASON } from "./_notify-preview-fixtures";
/** How far along the lifecycle a status is, and therefore which fields exist. */
type Stage = "pre-eval" | "planned" | "running" | "done" | "failed";
const BUG_STAGE: Record<NotifyKind, Stage> = {
info_required: "pre-eval",
pending_confirmation: "planned",
dispatched: "running",
manual_review: "done",
fix_succeeded: "done",
awaiting_merge: "done",
fix_failed: "failed",
unreproducible: "failed",
};
const FEATURE_STAGE: Record<FeatureNotifyKind, Stage> = {
info_required: "pre-eval",
pending_confirmation: "planned",
dispatched: "running",
manual_review: "done",
completed: "done",
implementation_failed: "failed",
};
const SECURITY_STAGE: Record<SecurityNotifyKind, Stage> = {
info_required: "pre-eval",
dispatched: "running",
manual_review: "done",
completed: "done",
unreproducible: "failed",
security_failed: "failed",
};
/** Blank out everything a row of this stage would not yet have. */
function atStage<T extends Record<string, unknown>>(row: T, status: string, stage: Stage, reason: string): T {
const base = { ...row, status } as Record<string, unknown>;
if (stage === "pre-eval" || stage === "planned") {
Object.assign(base, {
mrUrl: null, branchName: null, fixedRisk: null, failureReason: null,
attempts: 0, durationMs: null, totalDurationMs: null,
// The eval claim stamps executorNodeId, so a planned row does have a node;
// an info_required row was bounced by that same eval, so it has one too.
executionPlan: stage === "planned" ? row.executionPlan : null,
});
} else if (stage === "running") {
Object.assign(base, { mrUrl: null, branchName: null, fixedRisk: null, failureReason: null, attempts: 1 });
} else if (stage === "failed") {
Object.assign(base, { fixedRisk: null, failureReason: reason, attempts: 6 });
}
return base as T;
}
export const CARDS: Record<string, () => unknown> = {};
for (const k of Object.keys(BUG_STAGE) as NotifyKind[]) {
const row = atStage(sampleTask, k, BUG_STAGE[k], FAILURE_REASON.bug);
CARDS[`bug:${k}`] = () => buildCard(row, meta(k));
}
for (const k of Object.keys(FEATURE_STAGE) as FeatureNotifyKind[]) {
const row = atStage(sampleFeature, k, FEATURE_STAGE[k], FAILURE_REASON.feature);
CARDS[`feature:${k}`] = () => buildFeatureCard(row, featureMeta(k));
}
for (const k of Object.keys(SECURITY_STAGE) as SecurityNotifyKind[]) {
const row = atStage(sampleSecurity, k, SECURITY_STAGE[k], FAILURE_REASON.security);
CARDS[`security:${k}`] = () => buildSecurityCard(row, securityMeta(k));
}
/**
* The ENRICHED review card — what a manual_review card becomes once the readable
* report lands and `refreshReviewCard` patches it: 大白话 up top, one button
* at the bottom.
*
* Worth its own fixture because it is the state nobody sees while developing:
* the plain version is what a fresh run produces, and the enriched one only
* appears minutes later on a task that happens to have mirrored evidence. It is
* also the layout most likely to break — the summary block is the only element
* that sits ABOVE the metadata grid.
*
*/
const PLAIN_SUMMARY =
"点赞按钮在深色模式下几乎看不见,是因为它一直用固定的浅色透明度,没有跟随主题切换。"
+ "改成读取当前主题的前景色后,深浅两种模式下都能看清,其它页面的按钮样式不受影响。";
CARDS["bug:manual_review:enriched"] = () => buildCard(
atStage(sampleTask, "manual_review", "done", FAILURE_REASON.bug),
meta("manual_review"),
{
plain: PLAIN_SUMMARY,
},
);
/** 开放平台建的单:顶部多一格「开放平台 · 申请人」,字段区多一行外部单号。 */
CARDS["bug:dispatched:openplatform"] = () => buildCard(
{
...atStage(sampleTask, "dispatched", BUG_STAGE.dispatched, FAILURE_REASON.bug),
meegoId: null, meegoUrl: null,
createdViaKeyId: "opk_preview", createdViaSource: "jira-crm", createdViaLabel: "CRM 工单同步",
createdViaOwner: "Yifan Jiang", externalId: "CRM-10293",
},
meta("dispatched"),
);
CARDS["feature:manual_review:enriched"] = () => buildFeatureCard(
atStage(sampleFeature, "manual_review", "done", FAILURE_REASON.feature),
featureMeta("manual_review"),
{
plain: "访客进入他人主页时,现在能直接看到「预览」入口并进入预览页;自己的主页不受影响,原有入口保持不变。",
},
);