@@ -14,6 +14,7 @@ const execAsync = promisify(exec);
1414interface SessionConfig {
1515 projectDir : string ;
1616 parentBranch : string ;
17+ branchName ?: string ;
1718 codingAgent : string ;
1819 skipPermissions : boolean ;
1920 setupCommands ?: string [ ] ;
@@ -343,14 +344,21 @@ async function ensureFleetcodeExcluded(projectDir: string) {
343344 }
344345}
345346
346- async function createWorktree ( projectDir : string , parentBranch : string , sessionNumber : number , sessionUuid : string ) : Promise < string > {
347+ async function createWorktree ( projectDir : string , parentBranch : string , sessionNumber : number , sessionUuid : string , customBranchName ?: string ) : Promise < string > {
347348 const git = simpleGit ( projectDir ) ;
348349 const fleetcodeDir = path . join ( projectDir , ".fleetcode" ) ;
349350 const worktreeName = `session${ sessionNumber } ` ;
350351 const worktreePath = path . join ( fleetcodeDir , worktreeName ) ;
351- // Include short UUID to ensure branch uniqueness across deletes/recreates
352- const shortUuid = sessionUuid . split ( '-' ) [ 0 ] ;
353- const branchName = `fleetcode/session${ sessionNumber } -${ shortUuid } ` ;
352+
353+ // Use custom branch name if provided, otherwise generate default
354+ let branchName : string ;
355+ if ( customBranchName ) {
356+ branchName = customBranchName ;
357+ } else {
358+ // Include short UUID to ensure branch uniqueness across deletes/recreates
359+ const shortUuid = sessionUuid . split ( '-' ) [ 0 ] ;
360+ branchName = `fleetcode/session${ sessionNumber } -${ shortUuid } ` ;
361+ }
354362
355363 // Create .fleetcode directory if it doesn't exist
356364 if ( ! fs . existsSync ( fleetcodeDir ) ) {
@@ -434,16 +442,18 @@ ipcMain.on("create-session", async (event, config: SessionConfig) => {
434442 try {
435443 const sessionNumber = getNextSessionNumber ( ) ;
436444 const sessionId = `session-${ Date . now ( ) } ` ;
437- const sessionName = `Session ${ sessionNumber } ` ;
445+
446+ // Use custom branch name as session name if provided, otherwise default
447+ const sessionName = config . branchName || `Session ${ sessionNumber } ` ;
438448
439449 // Generate UUID for this session (before creating worktree)
440450 const sessionUuid = uuidv4 ( ) ;
441451
442452 // Ensure .fleetcode is excluded (async, don't wait)
443453 ensureFleetcodeExcluded ( config . projectDir ) ;
444454
445- // Create git worktree with unique branch name
446- const worktreePath = await createWorktree ( config . projectDir , config . parentBranch , sessionNumber , sessionUuid ) ;
455+ // Create git worktree with custom or default branch name
456+ const worktreePath = await createWorktree ( config . projectDir , config . parentBranch , sessionNumber , sessionUuid , config . branchName ) ;
447457
448458 // Extract and write MCP config
449459 const mcpServers = extractProjectMcpConfig ( config . projectDir ) ;
0 commit comments