Skip to content

Commit 3a3480f

Browse files
authored
feat: add "Create PR for local runs" setting (#79)
1 parent 219604f commit 3a3480f

File tree

8 files changed

+42
-8
lines changed

8 files changed

+42
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"dependencies": {
6363
"@ai-sdk/openai": "^2.0.52",
6464
"@phosphor-icons/react": "^2.1.10",
65-
"@posthog/agent": "1.15.0",
65+
"@posthog/agent": "1.16.0",
6666
"@radix-ui/react-icons": "^1.3.2",
6767
"@radix-ui/themes": "^3.2.1",
6868
"@recallai/desktop-sdk": "^1.3.0",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface AgentStartParams {
2121
model?: string;
2222
executionMode?: "plan";
2323
runMode?: "local" | "cloud";
24+
createPR?: boolean;
2425
}
2526

2627
contextBridge.exposeInMainWorld("electronAPI", {

src/main/services/agent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface AgentStartParams {
1616
model?: string;
1717
executionMode?: "plan";
1818
runMode?: "local" | "cloud";
19+
createPR?: boolean;
1920
}
2021

2122
export interface TaskController {
@@ -102,6 +103,7 @@ export function registerAgentIpc(
102103
autoProgress,
103104
model,
104105
runMode,
106+
createPR,
105107
}: AgentStartParams,
106108
): Promise<{ taskId: string; channel: string }> => {
107109
if (!posthogTaskId || !repoPath) {
@@ -231,6 +233,7 @@ export function registerAgentIpc(
231233
permissionMode: resolvedPermission,
232234
isCloudMode: runMode === "cloud",
233235
autoProgress: autoProgress ?? true,
236+
createPR: createPR ?? true,
234237
queryOverrides: {
235238
abortController,
236239
...(model ? { model } : {}),

src/renderer/features/settings/components/SettingsView.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ export function SettingsView() {
2828
} = useAuthStore();
2929
const isDarkMode = useThemeStore((state) => state.isDarkMode);
3030
const toggleDarkMode = useThemeStore((state) => state.toggleDarkMode);
31-
const { autoRunTasks, defaultRunMode, setAutoRunTasks, setDefaultRunMode } =
32-
useSettingsStore();
31+
const {
32+
autoRunTasks,
33+
defaultRunMode,
34+
createPR,
35+
setAutoRunTasks,
36+
setDefaultRunMode,
37+
setCreatePR,
38+
} = useSettingsStore();
3339
const [apiKey, setApiKey] = useState("");
3440
const [host, setHost] = useState(apiHost);
3541
const [initialHost] = useState(apiHost);
@@ -142,6 +148,23 @@ export function SettingsView() {
142148
Choose which environment to use when running tasks
143149
</Text>
144150
</Flex>
151+
152+
<Flex align="center" justify="between">
153+
<Flex direction="column" gap="1">
154+
<Text size="1" weight="medium">
155+
Create PR for local runs
156+
</Text>
157+
<Text size="1" color="gray">
158+
Automatically create a pull request when local tasks
159+
complete
160+
</Text>
161+
</Flex>
162+
<Switch
163+
checked={createPR}
164+
onCheckedChange={setCreatePR}
165+
size="1"
166+
/>
167+
</Flex>
145168
</Flex>
146169
</Card>
147170
</Flex>

src/renderer/features/settings/stores/settingsStore.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ interface SettingsStore {
77
autoRunTasks: boolean;
88
defaultRunMode: DefaultRunMode;
99
lastUsedRunMode: "local" | "cloud";
10+
createPR: boolean;
1011

1112
setAutoRunTasks: (autoRun: boolean) => void;
1213
setDefaultRunMode: (mode: DefaultRunMode) => void;
1314
setLastUsedRunMode: (mode: "local" | "cloud") => void;
15+
setCreatePR: (createPR: boolean) => void;
1416
}
1517

1618
export const useSettingsStore = create<SettingsStore>()(
@@ -19,10 +21,12 @@ export const useSettingsStore = create<SettingsStore>()(
1921
autoRunTasks: true,
2022
defaultRunMode: "last_used",
2123
lastUsedRunMode: "local",
24+
createPR: true,
2225

2326
setAutoRunTasks: (autoRun) => set({ autoRunTasks: autoRun }),
2427
setDefaultRunMode: (mode) => set({ defaultRunMode: mode }),
2528
setLastUsedRunMode: (mode) => set({ lastUsedRunMode: mode }),
29+
setCreatePR: (createPR) => set({ createPR }),
2630
}),
2731
{
2832
name: "settings-storage",

src/renderer/features/tasks/stores/taskExecutionStore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
437437
]);
438438

439439
try {
440+
const { createPR } = useSettingsStore.getState();
440441
const result = await window.electronAPI?.agentStart({
441442
taskId: task.id,
442443
repoPath: effectiveRepoPath,
@@ -446,6 +447,7 @@ export const useTaskExecutionStore = create<TaskExecutionStore>()(
446447
autoProgress: true,
447448
executionMode: taskState.executionMode,
448449
runMode: taskState.runMode,
450+
createPR,
449451
});
450452
if (!result) {
451453
store.addLog(taskId, {

src/renderer/types/electron.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface IElectronAPI {
4040
model?: string;
4141
executionMode?: "plan";
4242
runMode?: "local" | "cloud";
43+
createPR?: boolean;
4344
}) => Promise<{ taskId: string; channel: string }>;
4445
agentCancel: (taskId: string) => Promise<boolean>;
4546
onAgentEvent: (

0 commit comments

Comments
 (0)