@@ -38,7 +38,7 @@ import {
3838 useSessionK8sResources ,
3939 useContinueSession ,
4040} from "@/services/queries" ;
41- import { useWorkspaceList , useGitMergeStatus , useGitPull , useGitPush , useGitCreateBranch , useGitListBranches } from "@/services/queries/use-workspace" ;
41+ import { useWorkspaceList , useGitMergeStatus , useGitPull , useGitPush , useGitListBranches } from "@/services/queries/use-workspace" ;
4242import { successToast , errorToast } from "@/hooks/use-toast" ;
4343import { useOOTBWorkflows , useWorkflowMetadata } from "@/services/queries/use-workflows" ;
4444import { useMutation } from "@tanstack/react-query" ;
@@ -90,7 +90,6 @@ export default function ProjectSessionDetailPage({
9090 const [ synchronizing , setSynchronizing ] = useState ( false ) ;
9191 const [ newBranchName , setNewBranchName ] = useState ( "" ) ;
9292 const [ showCreateBranch , setShowCreateBranch ] = useState ( false ) ;
93- const [ branchModalOpen , setBranchModalOpen ] = useState ( false ) ;
9493 const [ fileViewerOpen , setFileViewerOpen ] = useState ( false ) ;
9594 const [ viewingFile , setViewingFile ] = useState < { path : string ; content : string } | null > ( null ) ;
9695 const [ loadingFileContent , setLoadingFileContent ] = useState ( false ) ;
@@ -250,7 +249,6 @@ export default function ProjectSessionDetailPage({
250249 ) ;
251250 const gitPullMutation = useGitPull ( ) ;
252251 const gitPushMutation = useGitPush ( ) ;
253- const gitCreateBranchMutation = useGitCreateBranch ( ) ;
254252
255253 // Fetch directory file listing
256254 const { data : directoryFiles = [ ] , refetch : refetchDirectoryFiles } = useWorkspaceList (
@@ -627,39 +625,6 @@ export default function ProjectSessionDetailPage({
627625 }
628626 } ;
629627
630- // Handler to create new branch
631- const handleCreateBranch = ( ) => {
632- if ( ! newBranchName . trim ( ) ) {
633- errorToast ( "Branch name is required" ) ;
634- return ;
635- }
636-
637- const branchName = newBranchName . trim ( ) ;
638-
639- gitCreateBranchMutation . mutate (
640- {
641- projectName,
642- sessionName,
643- branchName,
644- path : selectedDirectory . path ,
645- } ,
646- {
647- onSuccess : ( ) => {
648- successToast ( `Branch ${ branchName } created and switched` ) ;
649- const newRemotes = { ...directoryRemotes } ;
650- newRemotes [ selectedDirectory . path ] = {
651- url : currentRemote ?. url || '' ,
652- branch : branchName ,
653- } ;
654- setDirectoryRemotes ( newRemotes ) ;
655- setNewBranchName ( "" ) ;
656- setShowCreateBranch ( false ) ;
657- refetchMergeStatus ( ) ;
658- } ,
659- onError : ( err ) => errorToast ( err instanceof Error ? err . message : "Failed to create branch" ) ,
660- }
661- ) ;
662- } ;
663628
664629 // Helper to derive repo folder from URL
665630 const deriveRepoFolderFromUrl = useCallback ( ( url : string ) : string => {
@@ -1437,7 +1402,7 @@ export default function ProjectSessionDetailPage({
14371402 < span > Directory Browser</ span >
14381403 { gitStatus ?. hasChanges && (
14391404 < Badge variant = "outline" className = "bg-yellow-50 text-yellow-700 border-yellow-200 ml-auto mr-2" >
1440- { gitStatus . uncommittedFiles } changes
1405+ + { gitStatus . totalAdded } - { gitStatus . totalRemoved }
14411406 </ Badge >
14421407 ) }
14431408 </ div >
@@ -1586,25 +1551,16 @@ export default function ProjectSessionDetailPage({
15861551 </ Button >
15871552 </ DropdownMenuTrigger >
15881553 < DropdownMenuContent align = "end" >
1589- < DropdownMenuItem
1590- onClick = { ( ) => {
1591- setNewBranchName ( `session-${ sessionName . substring ( 0 , 20 ) } ` ) ;
1592- setShowCreateBranch ( true ) ;
1593- setBranchModalOpen ( true ) ;
1594- } }
1595- >
1596- < GitBranch className = "mr-2 h-3 w-3" />
1597- Switch Branch
1598- </ DropdownMenuItem >
15991554 < DropdownMenuItem
16001555 onClick = { ( ) => {
16011556 setRemoteUrl ( currentRemote ?. url || '' ) ;
16021557 setRemoteBranch ( currentRemote ?. branch || 'main' ) ;
1558+ setShowCreateBranch ( false ) ;
16031559 setRemoteDialogOpen ( true ) ;
16041560 } }
16051561 >
16061562 < Edit className = "mr-2 h-3 w-3" />
1607- Edit Remote
1563+ Manage Remote
16081564 </ DropdownMenuItem >
16091565 < DropdownMenuSeparator />
16101566 < DropdownMenuItem
@@ -1941,13 +1897,13 @@ export default function ProjectSessionDetailPage({
19411897 </ DialogContent >
19421898 </ Dialog >
19431899
1944- { /* Configure Directory Remote Dialog */ }
1900+ { /* Manage Remote Dialog - Combined URL and Branch Management */ }
19451901 < Dialog open = { remoteDialogOpen } onOpenChange = { setRemoteDialogOpen } >
1946- < DialogContent >
1902+ < DialogContent className = "max-w-md" >
19471903 < DialogHeader >
1948- < DialogTitle > Configure Git Remote for { selectedDirectory . name } </ DialogTitle >
1904+ < DialogTitle > Manage Remote for { selectedDirectory . name } </ DialogTitle >
19491905 < DialogDescription >
1950- Set up a Git repository to save and synchronize changes for this directory.
1906+ Configure repository URL and select branch for git operations
19511907 </ DialogDescription >
19521908 </ DialogHeader >
19531909
@@ -1960,144 +1916,110 @@ export default function ProjectSessionDetailPage({
19601916 value = { remoteUrl }
19611917 onChange = { ( e ) => setRemoteUrl ( e . target . value ) }
19621918 />
1963- < p className = "text-xs text-muted-foreground" >
1964- The repository where changes will be pushed. Git will be initialized if not already done.
1965- </ p >
19661919 </ div >
19671920
1968- < div className = "space-y-2" >
1969- < Label htmlFor = "remote-branch" > Branch</ Label >
1970- < Input
1971- id = "remote-branch"
1972- placeholder = "main"
1973- value = { remoteBranch }
1974- onChange = { ( e ) => setRemoteBranch ( e . target . value ) }
1975- />
1976- < p className = "text-xs text-muted-foreground" >
1977- Branch to push to (will be created if it doesn't exist)
1978- </ p >
1979- </ div >
1980- </ div >
1981-
1982- < DialogFooter >
1983- < Button
1984- variant = "outline"
1985- onClick = { ( ) => setRemoteDialogOpen ( false ) }
1986- >
1987- Cancel
1988- </ Button >
1989- < Button
1990- onClick = { handleConfigureRemote }
1991- disabled = { ! remoteUrl . trim ( ) }
1992- >
1993- Configure Remote
1994- </ Button >
1995- </ DialogFooter >
1996- </ DialogContent >
1997- </ Dialog >
1998-
1999- { /* Branch Management Dialog */ }
2000- < Dialog open = { branchModalOpen } onOpenChange = { setBranchModalOpen } >
2001- < DialogContent >
2002- < DialogHeader >
2003- < DialogTitle > Manage Branch for { selectedDirectory . name } </ DialogTitle >
2004- < DialogDescription >
2005- Switch branches or create a new one for git operations
2006- </ DialogDescription >
2007- </ DialogHeader >
2008-
2009- < div className = "space-y-4" >
20101921 { ! showCreateBranch ? (
2011- < >
2012- < div className = "space-y-2" >
2013- < Label > Switch to Existing Branch </ Label >
1922+ < div className = "space-y-2" >
1923+ < Label htmlFor = "remote-branch" > Branch </ Label >
1924+ < div className = "flex gap-2" >
20141925 < Select
2015- value = { currentRemote ?. branch || 'main' }
2016- onValueChange = { ( branch ) => {
2017- const newRemotes = { ...directoryRemotes } ;
2018- newRemotes [ selectedDirectory . path ] = {
2019- url : currentRemote ?. url || '' ,
2020- branch
2021- } ;
2022- setDirectoryRemotes ( newRemotes ) ;
2023- refetchMergeStatus ( ) ;
2024- setBranchModalOpen ( false ) ;
2025- } }
1926+ value = { remoteBranch }
1927+ onValueChange = { ( branch ) => setRemoteBranch ( branch ) }
20261928 >
2027- < SelectTrigger >
1929+ < SelectTrigger className = "flex-1" >
20281930 < SelectValue />
20291931 </ SelectTrigger >
20301932 < SelectContent >
1933+ { ! remoteBranches . includes ( remoteBranch ) && remoteBranch && (
1934+ < SelectItem value = { remoteBranch } > { remoteBranch } (current)</ SelectItem >
1935+ ) }
20311936 { remoteBranches . map ( b => (
20321937 < SelectItem key = { b } value = { b } > { b } </ SelectItem >
20331938 ) ) }
20341939 </ SelectContent >
20351940 </ Select >
1941+ < Button
1942+ size = "sm"
1943+ variant = "outline"
1944+ onClick = { ( ) => {
1945+ setShowCreateBranch ( true ) ;
1946+ setNewBranchName ( `session-${ sessionName . substring ( 0 , 20 ) } ` ) ;
1947+ } }
1948+ >
1949+ New
1950+ </ Button >
20361951 </ div >
2037- < Button
2038- variant = "outline"
2039- className = "w-full"
2040- onClick = { ( ) => setShowCreateBranch ( true ) }
2041- >
2042- Create New Branch
2043- </ Button >
2044- </ >
1952+ </ div >
20451953 ) : (
20461954 < div className = "space-y-2" >
2047- < Label > New Branch Name </ Label >
1955+ < Label > Create New Branch</ Label >
20481956 < Input
20491957 placeholder = "branch-name"
20501958 value = { newBranchName }
20511959 onChange = { e => setNewBranchName ( e . target . value ) }
20521960 onKeyDown = { ( e ) => {
20531961 if ( e . key === 'Enter' && newBranchName . trim ( ) ) {
2054- handleCreateBranch ( ) ;
2055- setBranchModalOpen ( false ) ;
1962+ setRemoteBranch ( newBranchName . trim ( ) ) ;
1963+ setShowCreateBranch ( false ) ;
20561964 }
20571965 } }
20581966 autoFocus
20591967 />
20601968 < div className = "flex gap-2" >
20611969 < Button
1970+ size = "sm"
20621971 className = "flex-1"
20631972 onClick = { ( ) => {
2064- handleCreateBranch ( ) ;
2065- setBranchModalOpen ( false ) ;
1973+ setRemoteBranch ( newBranchName . trim ( ) ) ;
1974+ setShowCreateBranch ( false ) ;
20661975 } }
2067- disabled = { ! newBranchName . trim ( ) || gitCreateBranchMutation . isPending }
1976+ disabled = { ! newBranchName . trim ( ) }
20681977 >
2069- { gitCreateBranchMutation . isPending ? < Loader2 className = "h-3 w-3 animate-spin" /> : "Create" }
1978+ Set Branch
20701979 </ Button >
20711980 < Button
1981+ size = "sm"
20721982 variant = "outline"
20731983 onClick = { ( ) => {
20741984 setShowCreateBranch ( false ) ;
20751985 setNewBranchName ( "" ) ;
20761986 } }
20771987 >
2078- Back
1988+ Cancel
20791989 </ Button >
20801990 </ div >
20811991 </ div >
20821992 ) }
20831993
2084- { mergeStatus && (
2085- < div className = "text-sm border-t pt-3 " >
1994+ { mergeStatus && ! showCreateBranch && (
1995+ < div className = "text-xs text-muted-foreground border-t pt-2 " >
20861996 { mergeStatus . canMergeClean ? (
2087- < div className = "text-green-600" > ✓ Can merge cleanly</ div >
1997+ < span className = "text-green-600" > ✓ Can merge cleanly</ span >
20881998 ) : (
2089- < div className = "text-amber-600" > ⚠️ { mergeStatus . conflictingFiles . length } conflicts detected </ div >
1999+ < span className = "text-amber-600" > ⚠️ { mergeStatus . conflictingFiles . length } conflicts</ span >
20902000 ) }
20912001 </ div >
20922002 ) }
20932003 </ div >
20942004
20952005 < DialogFooter >
2096- < Button variant = "outline" onClick = { ( ) => {
2097- setBranchModalOpen ( false ) ;
2098- setShowCreateBranch ( false ) ;
2099- } } >
2100- Close
2006+ < Button
2007+ variant = "outline"
2008+ onClick = { ( ) => {
2009+ setRemoteDialogOpen ( false ) ;
2010+ setShowCreateBranch ( false ) ;
2011+ } }
2012+ >
2013+ Cancel
2014+ </ Button >
2015+ < Button
2016+ onClick = { ( ) => {
2017+ handleConfigureRemote ( ) ;
2018+ setShowCreateBranch ( false ) ;
2019+ } }
2020+ disabled = { ! remoteUrl . trim ( ) }
2021+ >
2022+ Save Remote
21012023 </ Button >
21022024 </ DialogFooter >
21032025 </ DialogContent >
0 commit comments