From 2f8a87048e32429d9dcd8c8312b6a2d416422493 Mon Sep 17 00:00:00 2001 From: RhenCloud Date: Sat, 15 Aug 2026 18:18:52 +0800 Subject: [PATCH] feat(formatters): add updateKey for suite/deployment/comment edit-in-place --- server/lib/formatters/check.ts | 2 ++ server/lib/formatters/comments.ts | 2 ++ server/lib/formatters/deployment.ts | 4 ++++ server/lib/formatters/review.ts | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/server/lib/formatters/check.ts b/server/lib/formatters/check.ts index f4551b0..05f1ad9 100644 --- a/server/lib/formatters/check.ts +++ b/server/lib/formatters/check.ts @@ -21,6 +21,7 @@ export function formatCheckSuite( showEmoji: boolean, ): NeutralMessage { const suite = payload.check_suite as { + id?: number; head_branch?: string; head_sha?: string; conclusion?: string; @@ -78,6 +79,7 @@ export function formatCheckSuite( suite.html_url ?? (baseUrl && suite.head_sha ? `${baseUrl}/commit/${suite.head_sha}/checks` : undefined), color: GITHUB_COLORS[colorKey], + updateKey: repo && suite.id != null ? `check_suite:${repo}:${suite.id}` : undefined, fields, }, t, diff --git a/server/lib/formatters/comments.ts b/server/lib/formatters/comments.ts index 05eb9ae..0ebf135 100644 --- a/server/lib/formatters/comments.ts +++ b/server/lib/formatters/comments.ts @@ -16,6 +16,7 @@ export function formatIssueComment( html_url?: string; }; const comment = payload.comment as { + id?: number; body?: string; html_url?: string; }; @@ -35,6 +36,7 @@ export function formatIssueComment( }), url: comment.html_url ?? issue.html_url, color: GITHUB_COLORS.issue_comment, + updateKey: repo && comment.id != null ? `issue_comment:${repo}:${comment.id}` : undefined, description: `${t("events.issue_comment.action_comment", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`, }, t, diff --git a/server/lib/formatters/deployment.ts b/server/lib/formatters/deployment.ts index 3fc7c50..3c813c9 100644 --- a/server/lib/formatters/deployment.ts +++ b/server/lib/formatters/deployment.ts @@ -42,6 +42,7 @@ export function formatDeployment( showEmoji: boolean, ): NeutralMessage { const deployment = payload.deployment as { + id?: number; environment?: string; ref?: string; sha?: string; @@ -88,6 +89,7 @@ export function formatDeployment( }), url: deployment.html_url ?? deployment.statuses_url, color: GITHUB_COLORS.deployment_pending, + updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined, fields, }, t, @@ -109,6 +111,7 @@ export function formatDeploymentStatus( description?: string; }; const deployment = payload.deployment as { + id?: number; sha?: string; ref?: string; environment?: string; @@ -163,6 +166,7 @@ export function formatDeploymentStatus( author, title: t("events.deployment.title", { repo: repo ?? t("common.repository"), env, state }), color: GITHUB_COLORS[colorKey], + updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined, fields, }, t, diff --git a/server/lib/formatters/review.ts b/server/lib/formatters/review.ts index de8138c..cae273a 100644 --- a/server/lib/formatters/review.ts +++ b/server/lib/formatters/review.ts @@ -11,6 +11,7 @@ export function formatPullRequestReview( ): NeutralMessage { const action = (payload.action as string) ?? "submitted"; const review = payload.review as { + id?: number; state?: string; body?: string; html_url?: string; @@ -50,6 +51,7 @@ export function formatPullRequestReview( }), url: review.html_url, color: GITHUB_COLORS[colorKey], + updateKey: repo && review.id != null ? `pull_request_review:${repo}:${review.id}` : undefined, description: descriptionParts.join("\n"), }, t, @@ -66,6 +68,7 @@ export function formatPullRequestReviewComment( ): NeutralMessage { const action = (payload.action as string) ?? "created"; const comment = payload.comment as { + id?: number; body?: string; path?: string; position?: number | null; @@ -105,6 +108,7 @@ export function formatPullRequestReviewComment( }), url: comment.html_url, color: GITHUB_COLORS.pull_request_review_commented, + updateKey: repo && comment.id != null ? `pull_request_review_comment:${repo}:${comment.id}` : undefined, description: `${t("events.pr_review_comment.action_inline", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`, fields: fields.length > 0 ? fields : undefined, },