diff --git a/Sources/KanbanCode/ContentView.swift b/Sources/KanbanCode/ContentView.swift index 47ee874..5ede910 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 9ecc725..bfca3cb 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,