mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Update Claude cleanup script to delete error comments
- Error comments are now deleted instead of collapsed - Only successful reviews and status comments are collapsed - This keeps the PR comments cleaner by removing failed attempts
This commit is contained in:
parent
dc646ae76e
commit
520c3ea443
1 changed files with 26 additions and 6 deletions
32
.github/scripts/cleanup-claude-comments.js
vendored
32
.github/scripts/cleanup-claude-comments.js
vendored
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Script to clean up multiple Claude bot comments on a PR
|
* Script to clean up multiple Claude bot comments on a PR
|
||||||
* Keeps only the most recent successful review and collapses others
|
* Keeps only the most recent successful review
|
||||||
|
* Deletes error comments and collapses other outdated comments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async function cleanupClaudeComments({ github, context, core }) {
|
async function cleanupClaudeComments({ github, context, core }) {
|
||||||
|
|
@ -62,6 +63,7 @@ async function cleanupClaudeComments({ github, context, core }) {
|
||||||
|
|
||||||
// Keep the most recent successful review visible
|
// Keep the most recent successful review visible
|
||||||
const commentsToCollapse = [];
|
const commentsToCollapse = [];
|
||||||
|
const commentsToDelete = [];
|
||||||
let keptReview = false;
|
let keptReview = false;
|
||||||
|
|
||||||
if (successfulReviews.length > 0) {
|
if (successfulReviews.length > 0) {
|
||||||
|
|
@ -70,12 +72,30 @@ async function cleanupClaudeComments({ github, context, core }) {
|
||||||
commentsToCollapse.push(...successfulReviews.slice(1));
|
commentsToCollapse.push(...successfulReviews.slice(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse all error and status comments
|
// Delete all error comments, collapse status comments
|
||||||
commentsToCollapse.push(...errorComments, ...statusComments);
|
commentsToDelete.push(...errorComments);
|
||||||
|
commentsToCollapse.push(...statusComments);
|
||||||
|
|
||||||
// If no successful review, keep the most recent comment of any type
|
// If no successful review, keep the most recent non-error comment
|
||||||
if (!keptReview && claudeComments.length > 0) {
|
if (!keptReview && claudeComments.length > 0) {
|
||||||
commentsToCollapse.push(...claudeComments.slice(1));
|
const nonErrorComments = claudeComments.filter(c => !errorComments.includes(c));
|
||||||
|
if (nonErrorComments.length > 0) {
|
||||||
|
commentsToCollapse.push(...nonErrorComments.slice(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process comments to delete
|
||||||
|
for (const comment of commentsToDelete) {
|
||||||
|
try {
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
comment_id: comment.id
|
||||||
|
});
|
||||||
|
core.info(`Deleted Claude error comment ${comment.id}`);
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(`Failed to delete error comment ${comment.id}: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process comments to collapse
|
// Process comments to collapse
|
||||||
|
|
@ -111,7 +131,7 @@ async function cleanupClaudeComments({ github, context, core }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Cleanup complete. Collapsed ${commentsToCollapse.length} comments`);
|
core.info(`Cleanup complete. Deleted ${commentsToDelete.length} error comments, collapsed ${commentsToCollapse.length} comments`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(`Failed to cleanup Claude comments: ${error.message}`);
|
core.error(`Failed to cleanup Claude comments: ${error.message}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue