@@ -43,6 +43,7 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
4343 const [ directMode , setDirectMode ] = createSignal ( false ) ;
4444 const [ skipPermissions , setSkipPermissions ] = createSignal ( false ) ;
4545 const [ branchPrefix , setBranchPrefix ] = createSignal ( '' ) ;
46+ const [ baseBranch , setBaseBranch ] = createSignal ( '' ) ;
4647 let promptRef ! : HTMLTextAreaElement ;
4748 let formRef ! : HTMLFormElement ;
4849
@@ -105,6 +106,7 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
105106 setLoading ( false ) ;
106107 setDirectMode ( false ) ;
107108 setSkipPermissions ( false ) ;
109+ setBaseBranch ( '' ) ;
108110
109111 void ( async ( ) => {
110112 if ( store . availableAgents . length === 0 ) {
@@ -194,6 +196,32 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
194196 setBranchPrefix ( pid ? getProjectBranchPrefix ( pid ) : 'task' ) ;
195197 } ) ;
196198
199+ // Auto-detect base branch when project changes
200+ createEffect ( ( ) => {
201+ const pid = selectedProjectId ( ) ;
202+ const path = pid ? getProjectPath ( pid ) : undefined ;
203+ let cancelled = false ;
204+
205+ if ( ! path ) {
206+ setBaseBranch ( '' ) ;
207+ return ;
208+ }
209+
210+ void ( async ( ) => {
211+ try {
212+ const detected = await invoke < string > ( IPC . GetMainBranch , { projectRoot : path } ) ;
213+ if ( cancelled ) return ;
214+ setBaseBranch ( ( prev ) => ( prev === '' ? detected : prev ) ) ;
215+ } catch {
216+ /* ignore */
217+ }
218+ } ) ( ) ;
219+
220+ onCleanup ( ( ) => {
221+ cancelled = true ;
222+ } ) ;
223+ } ) ;
224+
197225 // Pre-check direct mode based on project setting
198226 createEffect ( ( ) => {
199227 const pid = selectedProjectId ( ) ;
@@ -298,6 +326,7 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
298326 skipPermissions : agentSupportsSkipPermissions ( ) && skipPermissions ( ) ,
299327 } ) ;
300328 } else {
329+ const bb = baseBranch ( ) . trim ( ) || undefined ;
301330 taskId = await createTask ( {
302331 name : n ,
303332 agentDef : agent ,
@@ -307,6 +336,7 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
307336 branchPrefixOverride : prefix ,
308337 githubUrl : ghUrl ,
309338 skipPermissions : agentSupportsSkipPermissions ( ) && skipPermissions ( ) ,
339+ baseBranch : bb ,
310340 } ) ;
311341 }
312342 // Drop flow: prefill prompt without auto-sending
@@ -495,6 +525,45 @@ export function NewTaskDialog(props: NewTaskDialogProps) {
495525 />
496526 </ Show >
497527
528+ < Show when = { ! directMode ( ) } >
529+ < div
530+ data-nav-field = "base-branch"
531+ style = { { display : 'flex' , 'flex-direction' : 'column' , gap : '8px' } }
532+ >
533+ < label
534+ style = { {
535+ 'font-size' : '11px' ,
536+ color : theme . fgMuted ,
537+ 'text-transform' : 'uppercase' ,
538+ 'letter-spacing' : '0.05em' ,
539+ } }
540+ >
541+ Base branch{ ' ' }
542+ < span style = { { opacity : '0.5' , 'text-transform' : 'none' } } > (merge target)</ span >
543+ </ label >
544+ < input
545+ class = "input-field"
546+ type = "text"
547+ value = { baseBranch ( ) }
548+ onInput = { ( e ) => setBaseBranch ( e . currentTarget . value ) }
549+ placeholder = "main"
550+ style = { {
551+ background : theme . bgInput ,
552+ border : `1px solid ${ theme . border } ` ,
553+ 'border-radius' : '8px' ,
554+ padding : '10px 14px' ,
555+ color : theme . fg ,
556+ 'font-size' : '13px' ,
557+ 'font-family' : "'JetBrains Mono', monospace" ,
558+ outline : 'none' ,
559+ } }
560+ />
561+ < span style = { { 'font-size' : '11px' , color : theme . fgSubtle , padding : '0 2px' } } >
562+ Worktree branches from and merges back into this branch.
563+ </ span >
564+ </ div >
565+ </ Show >
566+
498567 < AgentSelector
499568 agents = { store . availableAgents }
500569 selectedAgent = { selectedAgent ( ) }
0 commit comments