fix: align performance summary analysis

This commit is contained in:
Codex
2026-06-20 05:56:48 +00:00
parent 39af2ce600
commit d2205de467
+17 -4
View File
@@ -887,15 +887,18 @@ function nodePerformanceArray(value: unknown): Record<string, unknown>[] {
}
function nodePerformanceAnalysis(performance: Record<string, unknown>, rows: Record<string, unknown>[]): Record<string, unknown> {
const networkErrors = rows.filter((row) => nodePerformanceString(row.outcome) === "network_error" || nodePerformanceString(row.problem) === "network_error" || nodePerformanceString(row.problem) === "network error");
const blockedRows = rows.filter((row) => nodePerformanceString(row.tone) === "blocked" || nodePerformanceString(row.status) === "blocked");
const actionableRows = rows.filter(nodePerformanceActionableProblem);
const networkErrors = actionableRows.filter((row) => nodePerformanceString(row.outcome) === "network_error" || nodePerformanceString(row.problem) === "network_error" || nodePerformanceString(row.problem) === "network error");
const blockedRows = actionableRows.filter((row) => nodePerformanceString(row.tone) === "blocked" || nodePerformanceString(row.status) === "blocked");
const slowApiRows = rows.filter((row) => {
const source = nodePerformanceString(row.source) ?? "";
const metric = nodePerformanceString(row.metric) ?? "";
const p95Seconds = nodePerformanceNumber(row.p95Seconds);
return (source.includes("api") || metric.includes("api") || (nodePerformanceString(row.route) ?? "").startsWith("/v1") || (nodePerformanceString(row.route) ?? "").startsWith("/health")) && (p95Seconds === null || p95Seconds >= 5);
return nodePerformanceActionableProblem(row)
&& (source.includes("api") || metric.includes("api") || (nodePerformanceString(row.route) ?? "").startsWith("/v1") || (nodePerformanceString(row.route) ?? "").startsWith("/health"))
&& (p95Seconds === null || p95Seconds >= 5);
});
const lcpRows = rows.filter((row) => {
const lcpRows = actionableRows.filter((row) => {
const metric = `${nodePerformanceString(row.metric) ?? ""} ${nodePerformanceString(row.problem) ?? ""}`.toLowerCase();
return metric.includes("lcp") || metric.includes("largest contentful") || metric.includes("最大内容");
});
@@ -955,6 +958,16 @@ function nodePerformanceAnalysis(performance: Record<string, unknown>, rows: Rec
};
}
function nodePerformanceActionableProblem(row: Record<string, unknown>): boolean {
const tone = nodePerformanceString(row.tone) ?? "";
const status = nodePerformanceString(row.status) ?? "";
if (tone === "blocked" || tone === "warn" || status === "blocked" || status === "warn") return true;
const sampleState = nodePerformanceString(row.sampleState) ?? "";
if (sampleState && sampleState !== "ok") return false;
const problem = (nodePerformanceString(row.problem) ?? "").trim().toLowerCase();
return Boolean(problem && problem !== "ok" && problem !== "low-sample" && problem !== "no-sample");
}
function nodePerformanceEvidence(rows: Record<string, unknown>[]): Record<string, unknown>[] {
return rows.slice(0, 8).map((row) => ({
source: nodePerformanceString(row.source),