diff options
| author | bndw <ben@bdw.to> | 2026-02-28 20:07:05 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-28 20:07:05 -0800 |
| commit | 9d192d16b7a4026b35ad2bcaff9edb9f2670de2b (patch) | |
| tree | 2603dd04c3567074e84be271c448ede02ee7097d /src/main/ipc/handlers.ts | |
| parent | 283013c09d4855529e846951a1e090f0f16030a8 (diff) | |
feat: git branches
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); |
