diff options
Diffstat (limited to 'src/main/ipc/handlers.ts')
| -rw-r--r-- | src/main/ipc/handlers.ts | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts index 145c6e2..f0a5b82 100644 --- a/src/main/ipc/handlers.ts +++ b/src/main/ipc/handlers.ts | |||
| @@ -2,6 +2,7 @@ import { ipcMain, dialog, type BrowserWindow } from "electron"; | |||
| 2 | import * as projects from "../db/projects"; | 2 | import * as projects from "../db/projects"; |
| 3 | import * as sessions from "../db/sessions"; | 3 | import * as sessions from "../db/sessions"; |
| 4 | import * as claude from "../claude"; | 4 | import * as claude from "../claude"; |
| 5 | import { createSessionBranch } from "../git"; | ||
| 5 | import type { UserPermissionMode } from "../claude/phases"; | 6 | import type { UserPermissionMode } from "../claude/phases"; |
| 6 | 7 | ||
| 7 | export function registerIpcHandlers(mainWindow: BrowserWindow): void { | 8 | export function registerIpcHandlers(mainWindow: BrowserWindow): void { |
| @@ -19,9 +20,19 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void { | |||
| 19 | sessions.listSessions(projectId) | 20 | sessions.listSessions(projectId) |
| 20 | ); | 21 | ); |
| 21 | 22 | ||
| 22 | ipcMain.handle("sessions:create", (_, projectId: string, name: string) => | 23 | ipcMain.handle("sessions:create", (_, projectId: string, name: string) => { |
| 23 | sessions.createSession(projectId, name) | 24 | const project = projects.getProject(projectId); |
| 24 | ); | 25 | if (!project) throw new Error("Project not found"); |
| 26 | |||
| 27 | const session = sessions.createSession(projectId, name); | ||
| 28 | |||
| 29 | const branchName = createSessionBranch(project.path, session.name, session.id); | ||
| 30 | if (branchName) { | ||
| 31 | sessions.updateSession(session.id, { git_branch: branchName }); | ||
| 32 | } | ||
| 33 | |||
| 34 | return { ...session, git_branch: branchName ?? null }; | ||
| 35 | }); | ||
| 25 | 36 | ||
| 26 | ipcMain.handle("sessions:delete", (_, id: string) => { | 37 | ipcMain.handle("sessions:delete", (_, id: string) => { |
| 27 | const session = sessions.getSession(id); | 38 | const session = sessions.getSession(id); |
