diff options
Diffstat (limited to 'src/main/ipc')
| -rw-r--r-- | src/main/ipc/handlers.ts | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts index f0a5b82..774eb63 100644 --- a/src/main/ipc/handlers.ts +++ b/src/main/ipc/handlers.ts | |||
| @@ -2,7 +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 { createSessionBranch, ensureGitIgnore } from "../git"; |
| 6 | import type { UserPermissionMode } from "../claude/phases"; | 6 | import type { UserPermissionMode } from "../claude/phases"; |
| 7 | 7 | ||
| 8 | export function registerIpcHandlers(mainWindow: BrowserWindow): void { | 8 | export function registerIpcHandlers(mainWindow: BrowserWindow): void { |
| @@ -26,12 +26,11 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void { | |||
| 26 | 26 | ||
| 27 | const session = sessions.createSession(projectId, name); | 27 | const session = sessions.createSession(projectId, name); |
| 28 | 28 | ||
| 29 | const branchName = createSessionBranch(project.path, session.name, session.id); | 29 | // Ensure .claude-flow/ is gitignored from day one. |
| 30 | if (branchName) { | 30 | // Branch creation is deferred until the session advances to implement. |
| 31 | sessions.updateSession(session.id, { git_branch: branchName }); | 31 | try { ensureGitIgnore(project.path); } catch { /* non-fatal */ } |
| 32 | } | ||
| 33 | 32 | ||
| 34 | return { ...session, git_branch: branchName ?? null }; | 33 | return session; |
| 35 | }); | 34 | }); |
| 36 | 35 | ||
| 37 | ipcMain.handle("sessions:delete", (_, id: string) => { | 36 | ipcMain.handle("sessions:delete", (_, id: string) => { |
| @@ -103,7 +102,24 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void { | |||
| 103 | ipcMain.handle("workflow:advance", (_, sessionId: string) => { | 102 | ipcMain.handle("workflow:advance", (_, sessionId: string) => { |
| 104 | const session = sessions.getSession(sessionId); | 103 | const session = sessions.getSession(sessionId); |
| 105 | if (!session) throw new Error("Session not found"); | 104 | if (!session) throw new Error("Session not found"); |
| 106 | return claude.advancePhase(session); | 105 | |
| 106 | const nextPhase = claude.advancePhase(session); | ||
| 107 | if (!nextPhase) return null; | ||
| 108 | |||
| 109 | let git_branch = session.git_branch; | ||
| 110 | |||
| 111 | if (nextPhase === "implement") { | ||
| 112 | const project = projects.getProject(session.project_id); | ||
| 113 | if (project) { | ||
| 114 | const branchName = createSessionBranch(project.path, session.name, session.id); | ||
| 115 | if (branchName) { | ||
| 116 | sessions.updateSession(sessionId, { git_branch: branchName }); | ||
| 117 | git_branch = branchName; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | return { phase: nextPhase, git_branch }; | ||
| 107 | }); | 123 | }); |
| 108 | 124 | ||
| 109 | ipcMain.handle( | 125 | ipcMain.handle( |
