@@ -7,17 +7,7 @@ import {
77 FolderIcon ,
88 ScaleIcon ,
99} from "lucide-react" ;
10- import {
11- type Ref ,
12- memo ,
13- useImperativeHandle ,
14- useCallback ,
15- useEffect ,
16- useLayoutEffect ,
17- useMemo ,
18- useRef ,
19- useState ,
20- } from "react" ;
10+ import { memo , useCallback , useEffect , useLayoutEffect , useMemo , useRef , useState } from "react" ;
2111
2212import { useComposerDraftStore , type DraftId } from "../composerDraftStore" ;
2313import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon" ;
@@ -34,10 +24,7 @@ import {
3424 resolvePreviousWorktreeSeed ,
3525 shouldShowEnvironmentIndicator ,
3626} from "./BranchToolbar.logic" ;
37- import {
38- BranchToolbarBranchSelector ,
39- type BranchToolbarBranchSelectorHandle ,
40- } from "./BranchToolbarBranchSelector" ;
27+ import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector" ;
4128import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector" ;
4229import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector" ;
4330import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent" ;
@@ -61,14 +48,9 @@ import { measureRestingComposerControls } from "./chat/restingComposerControlsMe
6148import { resolveRestingComposerControlsNaturalWidth } from "./composerFooterLayout" ;
6249import { cn } from "~/lib/utils" ;
6350
64- export interface BranchToolbarHandle {
65- openBranchPicker : ( ) => void ;
66- usePreviousWorktree : ( ) => void ;
67- }
68-
6951interface BranchToolbarProps {
70- forceNewWorktree ?: boolean ;
71- ref ?: Ref < BranchToolbarHandle > ;
52+ layout ?: "composer" | "panel" ;
53+ panelSection ?: "all" | "workspace" | "branch" ;
7254 environmentId : EnvironmentId ;
7355 threadId : ThreadId ;
7456 showGitControls : boolean ;
@@ -211,10 +193,6 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
211193 render = { < ComposerControl size = "xs" /> }
212194 className = "min-w-0 max-w-[48%] flex-initial justify-start"
213195 data-composer-context-control
214- data-composer-shortcut = { [
215- showEnvironmentPicker && ! envLocked ? "composer.host" : "" ,
216- ! envModeLocked ? "composer.workspace" : "" ,
217- ] . join ( " " ) }
218196 >
219197 { triggerContent }
220198 < ChevronDownIcon className = "size-3 shrink-0 opacity-50" />
@@ -504,8 +482,8 @@ function useLabelsOverflow(element: HTMLDivElement | null): boolean {
504482}
505483
506484export const BranchToolbar = memo ( function BranchToolbar ( {
507- forceNewWorktree = false ,
508- ref ,
485+ layout = "composer" ,
486+ panelSection = "all" ,
509487 environmentId,
510488 threadId,
511489 showGitControls,
@@ -526,7 +504,6 @@ export const BranchToolbar = memo(function BranchToolbar({
526504 composerControlsHostRef,
527505 contextStripVisible = true ,
528506} : BranchToolbarProps ) {
529- const branchSelectorRef = useRef < BranchToolbarBranchSelectorHandle > ( null ) ;
530507 const threadRef = useMemo (
531508 ( ) => scopeThreadRef ( environmentId , threadId ) ,
532509 [ environmentId , threadId ] ,
@@ -590,25 +567,6 @@ export const BranchToolbar = memo(function BranchToolbar({
590567 } ) ;
591568 } , [ activeProjectRef , draftId , previousWorktreeSeed , setDraftThreadContext , threadRef ] ) ;
592569
593- useImperativeHandle (
594- ref ,
595- ( ) => ( {
596- openBranchPicker : ( ) => branchSelectorRef . current ?. open ( ) ,
597- usePreviousWorktree : ( ) => {
598- if ( ! showGitControls || ! canUsePreviousWorktree || ! previousWorktreeSeed ) return ;
599- onUsePreviousWorktree ( ) ;
600- onComposerFocusRequest ?.( ) ;
601- } ,
602- } ) ,
603- [
604- canUsePreviousWorktree ,
605- onComposerFocusRequest ,
606- onUsePreviousWorktree ,
607- previousWorktreeSeed ,
608- showGitControls ,
609- ] ,
610- ) ;
611-
612570 const showEnvironmentPicker = Boolean (
613571 availableEnvironments && availableEnvironments . length > 1 && onEnvironmentChange ,
614572 ) ;
@@ -623,6 +581,40 @@ export const BranchToolbar = memo(function BranchToolbar({
623581
624582 if ( ! hasActiveThread || ! activeProject ) return null ;
625583
584+ if ( layout === "panel" ) {
585+ return (
586+ < div className = "flex w-full flex-col" data-thread-panel-run-context >
587+ { panelSection !== "branch" ? (
588+ < BranchToolbarEnvModeSelector
589+ displayMode = "panel"
590+ envLocked = { envModeLocked }
591+ effectiveEnvMode = { effectiveEnvMode }
592+ activeWorktreePath = { activeWorktreePath }
593+ workspaceRoot = { activeProject . workspaceRoot }
594+ onEnvModeChange = { onEnvModeChange }
595+ />
596+ ) : null }
597+ { panelSection !== "workspace" ? (
598+ < BranchToolbarBranchSelector
599+ displayMode = "panel"
600+ className = "w-full"
601+ environmentId = { environmentId }
602+ threadId = { threadId }
603+ { ...( draftId ? { draftId } : { } ) }
604+ envLocked = { envLocked }
605+ { ...( effectiveEnvModeOverride ? { effectiveEnvModeOverride } : { } ) }
606+ { ...( activeThreadBranchOverride !== undefined ? { activeThreadBranchOverride } : { } ) }
607+ { ...( onActiveThreadBranchOverrideChange ? { onActiveThreadBranchOverrideChange } : { } ) }
608+ startFromOrigin = { startFromOrigin }
609+ onStartFromOriginChange = { onStartFromOriginChange }
610+ { ...( onCheckoutPullRequestRequest ? { onCheckoutPullRequestRequest } : { } ) }
611+ { ...( onComposerFocusRequest ? { onComposerFocusRequest } : { } ) }
612+ />
613+ ) : null }
614+ </ div >
615+ ) ;
616+ }
617+
626618 return (
627619 < ComposerSurface . ContextStrip
628620 ref = { setStripElement }
@@ -713,8 +705,6 @@ export const BranchToolbar = memo(function BranchToolbar({
713705
714706 { showGitControls ? (
715707 < BranchToolbarBranchSelector
716- forceNewWorktree = { forceNewWorktree }
717- ref = { branchSelectorRef }
718708 className = "min-w-0 flex-initial justify-end @3xl/composer-surface:ml-auto"
719709 environmentId = { environmentId }
720710 threadId = { threadId }
0 commit comments