aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/ipc/handlers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/ipc/handlers.ts')
-rw-r--r--src/main/ipc/handlers.ts45
1 files changed, 4 insertions, 41 deletions
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts
index bc0d024..2d5e3d3 100644
--- a/src/main/ipc/handlers.ts
+++ b/src/main/ipc/handlers.ts
@@ -3,7 +3,6 @@ import * as projects from "../db/projects";
3import * as sessions from "../db/sessions"; 3import * as sessions from "../db/sessions";
4import * as claude from "../claude"; 4import * as claude from "../claude";
5import type { UserPermissionMode } from "../claude/phases"; 5import type { UserPermissionMode } from "../claude/phases";
6import * as git from "../git/worktree";
7 6
8export function registerIpcHandlers(mainWindow: BrowserWindow): void { 7export function registerIpcHandlers(mainWindow: BrowserWindow): void {
9 // Projects 8 // Projects
@@ -19,35 +18,16 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void {
19 ipcMain.handle("sessions:list", (_, projectId: string) => 18 ipcMain.handle("sessions:list", (_, projectId: string) =>
20 sessions.listSessions(projectId) 19 sessions.listSessions(projectId)
21 ); 20 );
22 21
23 ipcMain.handle("sessions:create", async (_, projectId: string, name: string) => { 22 ipcMain.handle("sessions:create", (_, projectId: string, name: string) =>
24 const session = sessions.createSession(projectId, name); 23 sessions.createSession(projectId, name)
25 const project = projects.getProject(projectId); 24 );
26
27 if (project && git.isGitRepo(project.path)) {
28 try {
29 // Create git worktree for this session
30 git.createWorktree(project.path, session.id);
31 } catch (error) {
32 console.error("Failed to create worktree:", error);
33 // Continue without worktree - not fatal
34 }
35 }
36
37 return session;
38 });
39 25
40 ipcMain.handle("sessions:delete", (_, id: string) => { 26 ipcMain.handle("sessions:delete", (_, id: string) => {
41 const session = sessions.getSession(id); 27 const session = sessions.getSession(id);
42 if (session) { 28 if (session) {
43 const project = projects.getProject(session.project_id); 29 const project = projects.getProject(session.project_id);
44 if (project) { 30 if (project) {
45 // Clean up worktree if exists
46 try {
47 git.removeWorktree(project.path, id);
48 } catch {
49 // Worktree might not exist, that's ok
50 }
51 // Clean up session artifacts 31 // Clean up session artifacts
52 claude.clearSessionArtifacts(project.path, id); 32 claude.clearSessionArtifacts(project.path, id);
53 } 33 }
@@ -162,23 +142,6 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void {
162 } 142 }
163 ); 143 );
164 144
165 // Git
166 ipcMain.handle("git:isRepo", (_, projectPath: string) => {
167 return git.isGitRepo(projectPath);
168 });
169
170 ipcMain.handle("git:worktreeInfo", (_, projectPath: string, sessionId: string) => {
171 return git.getWorktreeInfo(projectPath, sessionId);
172 });
173
174 ipcMain.handle("git:commit", (_, worktreePath: string, message: string, files?: string[]) => {
175 git.commitChanges(worktreePath, message, files);
176 });
177
178 ipcMain.handle("git:hasChanges", (_, worktreePath: string) => {
179 return git.hasUncommittedChanges(worktreePath);
180 });
181
182 // Dialogs 145 // Dialogs
183 ipcMain.handle("dialog:selectDirectory", async () => { 146 ipcMain.handle("dialog:selectDirectory", async () => {
184 const result = await dialog.showOpenDialog(mainWindow, { 147 const result = await dialog.showOpenDialog(mainWindow, {