Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion scripts/src/github-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import { isSuccessComment, isPRModificationFailureComment } from './github-api';
import { isSuccessComment, isPRModificationFailureComment, isBotComment, isStartWorkComment } from './github-api';
import type { GitHubComment } from './types';

describe('Comment detection', () => {
Expand All @@ -24,4 +24,37 @@ describe('Comment detection', () => {
};
expect(isPRModificationFailureComment(comment)).toBe(true);
});

it('should detect openhands-ai[bot] as a bot', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: 'Openhands is working, @neubig can click here to continue refining the PR',
};
expect(isBotComment(comment)).toBe(true);
});

it('should detect new start work format', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: 'Openhands is working, @neubig can click here to continue refining the PR',
};
expect(isStartWorkComment(comment)).toBe(true);
});

it('should detect new success format', () => {
const comment: GitHubComment = {
id: 1,
html_url: 'https://github.com/All-Hands-AI/OpenHands/issues/1#comment-1',
created_at: '2023-11-28T00:01:00Z',
user: { login: 'openhands-ai[bot]', type: 'Bot' },
body: '@neubig can click here to [continue refining the PR](https://app.all-hands.dev/conversations/e06b225de3a24fea97504511c80afc44)',
};
expect(isSuccessComment(comment)).toBe(true);
});
});
7 changes: 5 additions & 2 deletions scripts/src/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ async function fetchAllPages<T>(url: string): Promise<T[]> {

export function isBotComment(comment: GitHubComment): boolean {
return comment.user.login === 'openhands-agent' ||
comment.user.login === 'openhands-ai[bot]' ||
(comment.user.login === 'github-actions[bot]' && comment.user.type === 'Bot');
}

export function isStartWorkComment(comment: GitHubComment): boolean {
if (!isBotComment(comment)) return false;
const lowerBody = comment.body.toLowerCase();
return lowerBody.includes('started fixing the') ||
lowerBody.includes('openhands started fixing');
lowerBody.includes('openhands started fixing') ||
lowerBody.includes('openhands is working');
}

export function isSuccessComment(comment: GitHubComment): boolean {
Expand All @@ -122,7 +124,8 @@ export function isSuccessComment(comment: GitHubComment): boolean {
const isSuccess = lowerBody.includes('a potential fix has been generated') ||
lowerBody.includes('openhands made the following changes to resolve the issues') ||
lowerBody.includes('successfully fixed') ||
lowerBody.includes('updated pull request');
lowerBody.includes('updated pull request') ||
lowerBody.includes('can click here to [continue refining the pr]');
fs.appendFileSync('github-api.log', `[${new Date().toISOString()}] COMMENT CHECK: Bot comment - Success: ${String(isSuccess)}\nBody: ${comment.body}\n`);
return isSuccess;
}
Expand Down