Skip to content

Commit fcd62c2

Browse files
built-by-asclaude
andcommitted
Add custom branch name feature
Users can now specify a custom branch name when creating a session. If provided, the custom name is used as both the git branch name and the session display name. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9405824 commit fcd62c2

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ <h2 class="modal-title">New Session Configuration</h2>
7171
</select>
7272
</div>
7373

74+
<div class="form-group">
75+
<label class="form-label">Branch Name (optional)</label>
76+
<input type="text" id="branch-name" class="form-input" placeholder="e.g., feature/add-login" />
77+
<span class="text-xs text-gray-400 mt-1 block">Custom branch name (will also be used as session name)</span>
78+
</div>
79+
7480
<div class="form-group">
7581
<label class="form-label">Coding Agent</label>
7682
<select id="coding-agent" class="form-select">

main.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const execAsync = promisify(exec);
1414
interface 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);

renderer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FitAddon } from "xterm-addon-fit";
55
interface SessionConfig {
66
projectDir: string;
77
parentBranch: string;
8+
branchName?: string;
89
codingAgent: string;
910
skipPermissions: boolean;
1011
setupCommands?: string[];
@@ -761,6 +762,7 @@ ipcRenderer.on("session-created", (_event, sessionId: string, persistedSession:
761762
const modal = document.getElementById("config-modal");
762763
const projectDirInput = document.getElementById("project-dir") as HTMLInputElement;
763764
const parentBranchSelect = document.getElementById("parent-branch") as HTMLSelectElement;
765+
const branchNameInput = document.getElementById("branch-name") as HTMLInputElement;
764766
const setupCommandsTextarea = document.getElementById("setup-commands") as HTMLTextAreaElement;
765767

766768
if (createBtn) {
@@ -775,6 +777,9 @@ ipcRenderer.on("session-created", (_event, sessionId: string, persistedSession:
775777
projectDirInput.value = "";
776778
selectedDirectory = "";
777779
parentBranchSelect.innerHTML = '<option value="">Loading branches...</option>';
780+
if (branchNameInput) {
781+
branchNameInput.value = "";
782+
}
778783
if (setupCommandsTextarea) {
779784
setupCommandsTextarea.value = "";
780785
}
@@ -934,9 +939,13 @@ createBtn?.addEventListener("click", () => {
934939
? setupCommandsText.split("\n").filter(cmd => cmd.trim())
935940
: undefined;
936941

942+
const branchNameInput = document.getElementById("branch-name") as HTMLInputElement;
943+
const branchName = branchNameInput?.value.trim() || undefined;
944+
937945
const config: SessionConfig = {
938946
projectDir: selectedDirectory,
939947
parentBranch: parentBranchSelect.value,
948+
branchName,
940949
codingAgent: codingAgentSelect.value,
941950
skipPermissions: codingAgentSelect.value === "claude" ? skipPermissionsCheckbox.checked : false,
942951
setupCommands,

0 commit comments

Comments
 (0)