diff options
Diffstat (limited to 'src/main/ipc')
| -rw-r--r-- | src/main/ipc/handlers.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts index bc7d78d..e0863f3 100644 --- a/src/main/ipc/handlers.ts +++ b/src/main/ipc/handlers.ts | |||
| @@ -3,7 +3,7 @@ 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 * as settingsDb from "../db/settings"; | 5 | import * as settingsDb from "../db/settings"; |
| 6 | import { createSessionBranch, ensureGitIgnore } from "../git"; | 6 | import { createSessionBranch, ensureGitIgnore, ensureGitRepo, getCurrentBranch } from "../git"; |
| 7 | import type { UserPermissionMode } from "../claude/phases"; | 7 | import type { UserPermissionMode } from "../claude/phases"; |
| 8 | import { getDefaultSystemPromptTemplate } from "../claude/phases"; | 8 | import { getDefaultSystemPromptTemplate } from "../claude/phases"; |
| 9 | 9 | ||
| @@ -113,10 +113,27 @@ export function registerIpcHandlers(mainWindow: BrowserWindow): void { | |||
| 113 | if (nextPhase === "implement") { | 113 | if (nextPhase === "implement") { |
| 114 | const project = projects.getProject(session.project_id); | 114 | const project = projects.getProject(session.project_id); |
| 115 | if (project) { | 115 | if (project) { |
| 116 | const branchName = createSessionBranch(project.path, session.name, session.id); | 116 | const branchingSetting = settingsDb.getSetting("git.branchingEnabled"); |
| 117 | if (branchName) { | 117 | const branchingEnabled = branchingSetting === "true"; // opt-in; default = off |
| 118 | sessions.updateSession(sessionId, { git_branch: branchName }); | 118 | |
| 119 | git_branch = branchName; | 119 | // Always ensure repo + gitignore so commits work regardless of mode |
| 120 | try { ensureGitIgnore(project.path); } catch { /* non-fatal */ } | ||
| 121 | try { ensureGitRepo(project.path); } catch { /* non-fatal */ } | ||
| 122 | |||
| 123 | if (branchingEnabled) { | ||
| 124 | // createSessionBranch internally calls ensureGitIgnore/ensureGitRepo again | ||
| 125 | // (belt-and-suspenders), then checks out a new claude-flow/<slug>-<id> branch | ||
| 126 | const branchName = createSessionBranch(project.path, session.name, session.id); | ||
| 127 | if (branchName) { | ||
| 128 | sessions.updateSession(sessionId, { git_branch: branchName }); | ||
| 129 | git_branch = branchName; | ||
| 130 | } | ||
| 131 | } else { | ||
| 132 | // No new branch — commit to whatever branch is currently checked out. | ||
| 133 | // Store the branch name so autoCommitTurn's boolean guard passes. | ||
| 134 | const currentBranch = getCurrentBranch(project.path) ?? "main"; | ||
| 135 | sessions.updateSession(sessionId, { git_branch: currentBranch }); | ||
| 136 | git_branch = currentBranch; | ||
| 120 | } | 137 | } |
| 121 | } | 138 | } |
| 122 | } | 139 | } |
