Skip to content
Merged
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
11 changes: 9 additions & 2 deletions src/main/ipc/githubIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as fs from 'fs';
import * as crypto from 'crypto';
import { homedir } from 'os';
import { quoteShellArg } from '../utils/shellEscape';
import { getAppSettings } from '../settings';

const execAsync = promisify(exec);
const githubService = new GitHubService();
Expand Down Expand Up @@ -285,13 +286,15 @@ export function registerGithubIpc() {
? args.taskName.trim()
: `pr-${prNumber}-${defaultSlug}`;
const branchName = args.branchName || `pr/${prNumber}`;
const reviewProvider = getAppSettings().defaultProvider || 'claude';
const buildTaskInfo = (taskPath: string, name: string) => ({
id: crypto.randomUUID(),
projectId,
name,
branch: branchName,
path: taskPath,
status: 'active' as const,
agentId: reviewProvider,
useWorktree: true,
metadata: {
prNumber,
Expand All @@ -305,9 +308,13 @@ export function registerGithubIpc() {

if (existing) {
const persistedTask = await databaseService.getTaskByPath(existing.path);
const existingTask = persistedTask ?? buildTaskInfo(existing.path, existing.name);
let existingTask = persistedTask ?? buildTaskInfo(existing.path, existing.name);

if (!persistedTask) {
if (persistedTask && !persistedTask.agentId) {
existingTask = { ...persistedTask, agentId: reviewProvider };
}

if (!persistedTask || !persistedTask.agentId) {
try {
await databaseService.saveTask(existingTask);
} catch (dbError) {
Expand Down
1 change: 1 addition & 0 deletions src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ export interface ElectronAPI {
branch: string;
projectId: string;
status: string;
agentId: string;
metadata?: { prNumber?: number; prTitle?: string | null };
};
error?: string;
Expand Down
14 changes: 1 addition & 13 deletions src/renderer/components/OpenPrsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,11 @@ const OpenPrsSection: React.FC<OpenPrsSectionProps> = ({ projectPath, projectId,
branch: result.task.branch,
path: result.task.path,
status: result.task.status as Task['status'],
agentId: result.task.agentId,
useWorktree: true,
metadata: result.task.metadata,
};
onReviewPr(task);
} else if (result.success && result.worktree) {
// Fallback: worktree was created but task came from an existing match
const task: Task = {
id: result.worktree.id || crypto.randomUUID(),
projectId,
name: result.taskName || `PR #${pr.number}`,
branch: result.branchName || '',
path: result.worktree.path || '',
status: 'active',
useWorktree: true,
metadata: { prNumber: pr.number, prTitle: pr.title },
};
onReviewPr(task);
} else {
toast({
title: 'Failed to create review task',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/types/electron-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ declare global {
branch: string;
projectId: string;
status: string;
agentId: string;
metadata?: { prNumber?: number; prTitle?: string | null };
};
error?: string;
Expand Down Expand Up @@ -1696,6 +1697,7 @@ export interface ElectronAPI {
branch: string;
projectId: string;
status: string;
agentId: string;
metadata?: { prNumber?: number; prTitle?: string | null };
};
error?: string;
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ declare global {
worktree?: any;
branchName?: string;
taskName?: string;
task?: {
id: string;
name: string;
path: string;
branch: string;
projectId: string;
status: string;
agentId: string;
metadata?: { prNumber?: number; prTitle?: string | null };
};
error?: string;
}>;
githubLogout: () => Promise<void>;
Expand Down
Loading