From 76380ff1c01637f348460a9cc6da9261cd4a2e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:22:04 +0800 Subject: [PATCH] fix(check): isolate updates by check suite Same-named checks from different suites must not edit one message. Include the suite or app identity and retain the former key for controlled adoption of existing tracked messages. --- server/lib/formatters/check.ts | 13 ++++++++++++- server/lib/types.ts | 5 +++++ tests/formatter.test.ts | 21 ++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/server/lib/formatters/check.ts b/server/lib/formatters/check.ts index ef2f55e..9bf3fb5 100644 --- a/server/lib/formatters/check.ts +++ b/server/lib/formatters/check.ts @@ -184,7 +184,13 @@ export function formatCheckRun( details_url?: string; status?: string; output?: { title?: string; summary?: string }; + check_suite?: { id?: number }; + app?: { id?: number }; }; + // Phases of one check (a fresh run id each, as Cloudflare Pages sends them) + // share a suite; two checks of the same name from different workflows or + // apps do not — they never share a message. + const owner = checkRun.check_suite?.id ?? checkRun.app?.id; const status = workflowStatus(checkRun.status, checkRun.conclusion); const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳"; @@ -226,9 +232,14 @@ export function formatCheckRun( url: checkRun.html_url, color: GITHUB_COLORS[colorKey], fields, + // Chains tracked before the suite joined the key. + legacyUpdateKey: + repo && checkRun.name && checkRun.head_sha && owner != null + ? `check_run:${repo}:${checkRun.name}:${checkRun.head_sha}` + : undefined, updateKey: repo && checkRun.name && checkRun.head_sha - ? `check_run:${repo}:${checkRun.name}:${checkRun.head_sha}` + ? `check_run:${repo}:${owner != null ? `${owner}:` : ""}${checkRun.name}:${checkRun.head_sha}` : repo && checkRun.id != null ? `check_run:${repo}:${checkRun.id}` : undefined, diff --git a/server/lib/types.ts b/server/lib/types.ts index 4b3aebb..5cf1f45 100644 --- a/server/lib/types.ts +++ b/server/lib/types.ts @@ -321,6 +321,11 @@ export interface NeutralMessage { * previously sent message instead of sending a new one. */ updateKey?: string; + /** + * The chain key this message had before `updateKey` changed shape, used + * only to find a message tracked under the old key (then re-keyed). + */ + legacyUpdateKey?: string; /** * Discord role ids to mention in the message content (set by dispatch from * the route's `discordRoleIds`). Only used by the Discord driver. diff --git a/tests/formatter.test.ts b/tests/formatter.test.ts index 7199907..a17e36c 100644 --- a/tests/formatter.test.ts +++ b/tests/formatter.test.ts @@ -317,6 +317,7 @@ describe("message title spec", () => { head_sha: "abc123def456", status: "in_progress", conclusion: null, + check_suite: { id: 7 }, }, repository: repo, sender, @@ -331,13 +332,31 @@ describe("message title spec", () => { head_sha: "abc123def456", status: "completed", conclusion: "failure", + check_suite: { id: 7 }, }, repository: repo, sender, }), ); - expect(running.updateKey).toBe("check_run:acme/widget:Cloudflare Pages:abc123def456"); + expect(running.updateKey).toBe("check_run:acme/widget:7:Cloudflare Pages:abc123def456"); expect(failed.updateKey).toBe(running.updateKey); + // A same-named check of another suite (workflow / app) has its own message. + const other = formatEvent( + route, + event("check_run", { + check_run: { + id: 44, + name: "Cloudflare Pages", + head_sha: "abc123def456", + status: "completed", + conclusion: "success", + check_suite: { id: 8 }, + }, + repository: repo, + sender, + }), + ); + expect(other.updateKey).not.toBe(running.updateKey); }); it("check_suite shows conclusion, service, branch and commit", () => {