Skip to content

Commit 36c02a5

Browse files
committed
fix
1 parent dee8e05 commit 36c02a5

File tree

3 files changed

+35
-52
lines changed

3 files changed

+35
-52
lines changed

apps/array/src/main/services/git.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,30 @@ export const detectSSHError = (output: string): string | undefined => {
517517
return `SSH test failed: ${output.substring(0, 200)}`;
518518
};
519519

520+
const getAllPullRequestComments = async (
521+
directoryPath: string,
522+
prNumber: number,
523+
): Promise<any> => {
524+
// Validate prNumber: must be a positive integer
525+
if (
526+
typeof prNumber !== "number" ||
527+
!Number.isInteger(prNumber) ||
528+
prNumber < 1
529+
) {
530+
throw new Error(`Invalid pull request number: ${prNumber}`);
531+
}
532+
533+
try {
534+
const { stdout } = await execAsync(
535+
`gh pr view ${prNumber} --json comments`,
536+
{ cwd: directoryPath },
537+
);
538+
return JSON.parse(stdout);
539+
} catch (error) {
540+
throw new Error(`Failed to fetch PR comments: ${error}`);
541+
}
542+
};
543+
520544
const getPullRequestReviewComments = async (
521545
directoryPath: string,
522546
prNumber: number,
@@ -837,6 +861,17 @@ export function registerGitIpc(
837861
},
838862
);
839863

864+
ipcMain.handle(
865+
"get-pr-comments",
866+
async (
867+
_event: IpcMainInvokeEvent,
868+
directoryPath: string,
869+
prNumber: number,
870+
): Promise<any> => {
871+
return getAllPullRequestComments(directoryPath, prNumber);
872+
},
873+
);
874+
840875
ipcMain.handle(
841876
"get-pr-review-comments",
842877
async (

packages/agent/src/agent.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,6 @@ Generated by PostHog Agent`;
418418
});
419419
}
420420

421-
async getPullRequestReviewComments(prNumber: number): Promise<any> {
422-
this.logger.debug("Fetching PR review comments", { prNumber });
423-
return this.gitManager.getPullRequestReviewComments(prNumber);
424-
}
425-
426421
async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
427422
this.logger.info("Updating task run branch", { taskId, branchName });
428423

packages/agent/src/git-manager.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -592,51 +592,4 @@ Generated by PostHog Agent`;
592592
return false;
593593
}
594594
}
595-
596-
async getAllPullRequestComments(prNumber: number): Promise<any> {
597-
try {
598-
const output = await this.runCommand(
599-
`gh pr view ${prNumber} --json comments`,
600-
);
601-
return JSON.parse(output);
602-
} catch (error) {
603-
throw new Error(`Failed to fetch PR comments: ${error}`);
604-
}
605-
}
606-
607-
async getPullRequestReviewComments(prNumber: number): Promise<any> {
608-
// Validate prNumber: must be a positive integer
609-
if (
610-
typeof prNumber !== "number" ||
611-
!Number.isInteger(prNumber) ||
612-
prNumber < 1
613-
) {
614-
throw new Error(`Invalid pull request number: ${prNumber}`);
615-
}
616-
617-
try {
618-
// Extract repo from remote URL (format: owner/repo)
619-
const remoteUrl = await this.getRemoteUrl();
620-
if (!remoteUrl) {
621-
throw new Error("No remote URL found");
622-
}
623-
624-
// Parse repo from URL (handles both HTTPS and SSH formats)
625-
const repoMatch = remoteUrl.match(
626-
/github\.com[:/]([^/]+\/[^/]+?)(?:\.git)?$/,
627-
);
628-
if (!repoMatch) {
629-
throw new Error(`Cannot parse repository from URL: ${remoteUrl}`);
630-
}
631-
const repo = repoMatch[1];
632-
633-
// TODO: Paginate if many comments
634-
const output = await this.runCommand(
635-
`gh api repos/${repo}/pulls/${prNumber}/comments`,
636-
);
637-
return JSON.parse(output);
638-
} catch (error) {
639-
throw new Error(`Failed to fetch PR review comments: ${error}`);
640-
}
641-
}
642595
}

0 commit comments

Comments
 (0)