Skip to content

Commit dee8e05

Browse files
committed
fix
1 parent 3ec2c93 commit dee8e05

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

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

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

520+
const getPullRequestReviewComments = 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+
// Extract repo from remote URL (format: owner/repo)
535+
const remoteUrl = await getRemoteUrl(directoryPath);
536+
if (!remoteUrl) {
537+
throw new Error("No remote URL found");
538+
}
539+
540+
// Parse repo from URL (handles both HTTPS and SSH formats)
541+
const repoMatch = remoteUrl.match(
542+
/github\.com[:/]([^/]+\/[^/]+?)(?:\.git)?$/,
543+
);
544+
if (!repoMatch) {
545+
throw new Error(`Cannot parse repository from URL: ${remoteUrl}`);
546+
}
547+
const repo = repoMatch[1];
548+
549+
// TODO: Paginate if many comments
550+
const { stdout } = await execAsync(
551+
`gh api repos/${repo}/pulls/${prNumber}/comments`,
552+
{ cwd: directoryPath },
553+
);
554+
return JSON.parse(stdout);
555+
} catch (error) {
556+
throw new Error(`Failed to fetch PR review comments: ${error}`);
557+
}
558+
};
559+
520560
export function registerGitIpc(
521561
getMainWindow: () => BrowserWindow | null,
522562
): void {
@@ -796,4 +836,15 @@ export function registerGitIpc(
796836
return discardFileChanges(directoryPath, filePath, fileStatus);
797837
},
798838
);
839+
840+
ipcMain.handle(
841+
"get-pr-review-comments",
842+
async (
843+
_event: IpcMainInvokeEvent,
844+
directoryPath: string,
845+
prNumber: number,
846+
): Promise<any> => {
847+
return getPullRequestReviewComments(directoryPath, prNumber);
848+
},
849+
);
799850
}

apps/array/src/main/services/session-manager.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,4 @@ export function registerAgentIpc(
648648
sessionManager.updateSessionToken(taskRunId, newToken);
649649
},
650650
);
651-
652-
ipcMain.handle(
653-
"agent-get-pr-review-comments",
654-
async (
655-
_event: IpcMainInvokeEvent,
656-
sessionId: string,
657-
prNumber: number,
658-
): Promise<any> => {
659-
const session = sessionManager.getSession(sessionId);
660-
if (!session) {
661-
throw new Error(`Session not found: ${sessionId}`);
662-
}
663-
return session.agent.getPullRequestReviewComments(prNumber);
664-
},
665-
);
666651
}

0 commit comments

Comments
 (0)