feat: exclude hidden (minimized) comments from GitHub Issues and PRs (#368)

* feat: ignore minimized comments

* fix tests
This commit is contained in:
atsushi-ishibashi
2025-07-30 23:18:34 +09:00
committed by GitHub
parent 5bdc533a52
commit fd012347a2
5 changed files with 221 additions and 3 deletions

View File

@@ -46,6 +46,7 @@ export const PR_QUERY = `
login
}
createdAt
isMinimized
}
}
reviews(first: 100) {
@@ -69,6 +70,7 @@ export const PR_QUERY = `
login
}
createdAt
isMinimized
}
}
}
@@ -98,6 +100,7 @@ export const ISSUE_QUERY = `
login
}
createdAt
isMinimized
}
}
}

View File

@@ -134,7 +134,7 @@ export async function fetchGitHubData({
// Prepare all comments for image processing
const issueComments: CommentWithImages[] = comments
.filter((c) => c.body)
.filter((c) => c.body && !c.isMinimized)
.map((c) => ({
type: "issue_comment" as const,
id: c.databaseId,
@@ -154,7 +154,7 @@ export async function fetchGitHubData({
const reviewComments: CommentWithImages[] =
reviewData?.nodes
?.flatMap((r) => r.comments?.nodes ?? [])
.filter((c) => c.body)
.filter((c) => c.body && !c.isMinimized)
.map((c) => ({
type: "review_comment" as const,
id: c.databaseId,

View File

@@ -50,6 +50,7 @@ export function formatComments(
imageUrlMap?: Map<string, string>,
): string {
return comments
.filter((comment) => !comment.isMinimized)
.map((comment) => {
let body = comment.body;
@@ -96,6 +97,7 @@ export function formatReviewComments(
review.comments.nodes.length > 0
) {
const comments = review.comments.nodes
.filter((comment) => !comment.isMinimized)
.map((comment) => {
let body = comment.body;
@@ -110,7 +112,9 @@ export function formatReviewComments(
return ` [Comment on ${comment.path}:${comment.line || "?"}]: ${body}`;
})
.join("\n");
reviewOutput += `\n${comments}`;
if (comments) {
reviewOutput += `\n${comments}`;
}
}
return reviewOutput;

View File

@@ -10,6 +10,7 @@ export type GitHubComment = {
body: string;
author: GitHubAuthor;
createdAt: string;
isMinimized?: boolean;
};
export type GitHubReviewComment = GitHubComment & {