From 7fa76cae99f84a63dea34014f015a3ea41ead469 Mon Sep 17 00:00:00 2001 From: Sergio Esteban Date: Sat, 21 Mar 2026 00:57:27 +0100 Subject: [PATCH] fix: pass worktree branch name from New Task dialog to launch command The branch name entered in the "Branch name" field was collected and shown in the command preview but never threaded through to the actual launch function, causing all worktrees to get random names instead. --- Sources/KanbanCode/ContentView.swift | 8 ++++---- Sources/KanbanCode/NewTaskDialog.swift | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/KanbanCode/ContentView.swift b/Sources/KanbanCode/ContentView.swift index 47ee8741..5ede910f 100644 --- a/Sources/KanbanCode/ContentView.swift +++ b/Sources/KanbanCode/ContentView.swift @@ -669,8 +669,8 @@ struct ContentView: View { onCreate: { prompt, projectPath, title, startImmediately, images in createManualTask(prompt: prompt, projectPath: projectPath, title: title, startImmediately: startImmediately, images: images) }, - onCreateAndLaunch: { prompt, projectPath, title, createWorktree, runRemotely, skipPermissions, commandOverride, images, assistant in - createManualTaskAndLaunch(prompt: prompt, projectPath: projectPath, title: title, createWorktree: createWorktree, runRemotely: runRemotely, skipPermissions: skipPermissions, commandOverride: commandOverride, images: images, assistant: assistant) + onCreateAndLaunch: { prompt, projectPath, title, createWorktree, worktreeBranch, runRemotely, skipPermissions, commandOverride, images, assistant in + createManualTaskAndLaunch(prompt: prompt, projectPath: projectPath, title: title, createWorktree: createWorktree, worktreeBranch: worktreeBranch, runRemotely: runRemotely, skipPermissions: skipPermissions, commandOverride: commandOverride, images: images, assistant: assistant) } ) } @@ -2259,7 +2259,7 @@ struct ContentView: View { } } - private func createManualTaskAndLaunch(prompt: String, projectPath: String?, title: String? = nil, createWorktree: Bool, runRemotely: Bool, skipPermissions: Bool = true, commandOverride: String? = nil, images: [ImageAttachment] = [], assistant: CodingAssistant = .claude) { + private func createManualTaskAndLaunch(prompt: String, projectPath: String?, title: String? = nil, createWorktree: Bool, worktreeBranch: String? = nil, runRemotely: Bool, skipPermissions: Bool = true, commandOverride: String? = nil, images: [ImageAttachment] = [], assistant: CodingAssistant = .claude) { let trimmed = prompt.trimmingCharacters(in: .whitespacesAndNewlines) let name: String if let title, !title.isEmpty { @@ -2291,7 +2291,7 @@ struct ContentView: View { let project = settings?.projects.first(where: { $0.path == effectivePath }) let builtPrompt = PromptBuilder.buildPrompt(card: link, project: project, settings: settings) - let wtName: String? = (createWorktree && assistant.supportsWorktree) ? "" : nil + let wtName: String? = (createWorktree && assistant.supportsWorktree) ? (worktreeBranch ?? "") : nil executeLaunch(cardId: link.id, prompt: builtPrompt, projectPath: effectivePath, worktreeName: wtName, runRemotely: runRemotely, skipPermissions: skipPermissions, commandOverride: commandOverride, images: images, assistant: assistant) } } diff --git a/Sources/KanbanCode/NewTaskDialog.swift b/Sources/KanbanCode/NewTaskDialog.swift index 9ecc725e..bfca3cbb 100644 --- a/Sources/KanbanCode/NewTaskDialog.swift +++ b/Sources/KanbanCode/NewTaskDialog.swift @@ -9,8 +9,8 @@ struct NewTaskDialog: View { var enabledAssistants: [CodingAssistant] = CodingAssistant.allCases /// (prompt, projectPath, title, startImmediately, images) — creates task without an assistant set var onCreate: (String, String?, String?, Bool, [ImageAttachment]) -> Void = { _, _, _, _, _ in } - /// (prompt, projectPath, title, createWorktree, runRemotely, skipPermissions, commandOverride, images, assistant) — creates and launches directly (skips LaunchConfirmation) - var onCreateAndLaunch: (String, String?, String?, Bool, Bool, Bool, String?, [ImageAttachment], CodingAssistant) -> Void = { _, _, _, _, _, _, _, _, _ in } + /// (prompt, projectPath, title, createWorktree, worktreeBranch, runRemotely, skipPermissions, commandOverride, images, assistant) — creates and launches directly (skips LaunchConfirmation) + var onCreateAndLaunch: (String, String?, String?, Bool, String?, Bool, Bool, String?, [ImageAttachment], CodingAssistant) -> Void = { _, _, _, _, _, _, _, _, _, _ in } @AppStorage("selectedAssistant") private var selectedAssistantRaw: String = CodingAssistant.claude.rawValue private var selectedAssistant: CodingAssistant { @@ -234,11 +234,13 @@ struct NewTaskDialog: View { let titleOrNil = title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? nil : title.trimmingCharacters(in: .whitespacesAndNewlines) if let proj { lastSelectedProjectPath = proj } if startImmediately { + let branch = worktreeBranch.trimmingCharacters(in: .whitespacesAndNewlines) onCreateAndLaunch( prompt, proj, titleOrNil, createWorktree && isGitRepo && selectedAssistant.supportsWorktree, + branch.isEmpty ? nil : branch, runRemotely && hasRemoteConfig, dangerouslySkipPermissions, commandEdited ? command : nil,