From d2e147c0197e868baca1c5fe8677df830c0247cc Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Sat, 20 Jun 2026 13:49:10 +0800 Subject: [PATCH] fix: align performance summary problem counts (#1703) --- internal/cloud/web-performance.test.ts | 23 +++++++++++++++++++++++ internal/cloud/web-performance.ts | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/cloud/web-performance.test.ts b/internal/cloud/web-performance.test.ts index 4701b17d..ec4eb792 100644 --- a/internal/cloud/web-performance.test.ts +++ b/internal/cloud/web-performance.test.ts @@ -251,6 +251,29 @@ test("web performance summary exposes Workbench p75 and low-sample diagnostics w assert.doesNotMatch(json, /trc_secret|ses_secret|run_secret|cmd_secret|traceId|sessionId|runId|commandId|conversationId|prompt|api key/iu); }); +test("web performance summary does not count low-sample Workbench errors as performance problems", () => { + const store = createWebPerformanceStore({ env: { HWLAB_METRICS_NAMESPACE: "hwlab-v03", HWLAB_GITOPS_TARGET: "v03" } }); + store.record({ + schemaVersion: "hwlab-web-performance-v2", + page: "/workbench/sessions/ses_secret", + events: [ + { kind: "workbench_journey", journey: "session_switch_first_visible", route: "/workbench/sessions/ses_secret", source: "deeplink", targetState: "unknown", cache: "cold", outcome: "ok", valueMs: 560, sessionId: "ses_secret" }, + { kind: "workbench_journey", journey: "session_switch_full_load", route: "/workbench/sessions/ses_secret", source: "deeplink", targetState: "unknown", cache: "cold", outcome: "error", valueMs: 620, sessionId: "ses_secret" } + ] + } as Record); + + const summary = store.summary(); + const fullLoad = summary.workbenchJourneys.find((row) => row.metric === "session_switch_full_load"); + const problemCard = summary.dashboard.cards.find((card) => card.id === "problems"); + + assert.equal(fullLoad?.sampleState, "low-sample"); + assert.equal(fullLoad?.tone, "source"); + assert.equal(fullLoad?.problem, "low-sample"); + assert.equal(summary.summary.problemCount, 0); + assert.equal(summary.problems.length, 0); + assert.equal(problemCard?.value, 0); +}); + test("web performance collection health only requires backend attribution for backend-scoped Workbench series", () => { const frontendOnly = createWebPerformanceStore({ env: { HWLAB_METRICS_NAMESPACE: "hwlab-v03", HWLAB_GITOPS_TARGET: "v03" } }); frontendOnly.record({ diff --git a/internal/cloud/web-performance.ts b/internal/cloud/web-performance.ts index 948f0bc5..931fff7c 100644 --- a/internal/cloud/web-performance.ts +++ b/internal/cloud/web-performance.ts @@ -1298,6 +1298,7 @@ function summaryProblemForRow(row: PerformanceSummaryRow, p95: number, count: nu } function isPerformanceProblemRow(row: PerformanceSummaryRow) { + if ((row.kind === "workbench_journey" || row.kind === "workbench_event_phase" || row.kind === "workbench_backend_event_visible") && row.sampleState !== "ok") return false; return row.tone === "blocked" || row.tone === "warn" || row.outcome !== "ok" || row.statusClass === "network" || row.statusClass === "5xx" || row.statusClass === "4xx"; } @@ -1508,8 +1509,8 @@ function performanceProblem(labels: Record, p95: number, count: function workbenchProblem(outcome: string, metric: string, count: number, tone: string) { if (count <= 0) return "no-sample"; - if (outcome !== "ok") return outcome; if (count < LOW_SAMPLE_THRESHOLD) return "low-sample"; + if (outcome !== "ok") return outcome; if (tone === "blocked" || tone === "warn") return `slow-${metric}`; return "ok"; }