@@ -46,6 +46,24 @@ const Projects: FC = () => {
4646 const api = useApi ( )
4747 const apps = useApps ( )
4848
49+ const isLoggedIn = ! ! account . user
50+
51+ // Single helper to check login and show dialog if needed
52+ const requireLogin = React . useCallback ( ( ) : boolean => {
53+ if ( ! account . user ) {
54+ account . setShowLoginWindow ( true )
55+ return false
56+ }
57+ return true
58+ } , [ account ] )
59+
60+ // Show login dialog on mount if not logged in (only after account is initialized)
61+ React . useEffect ( ( ) => {
62+ if ( account . initialized && ! isLoggedIn ) {
63+ account . setShowLoginWindow ( true )
64+ }
65+ } , [ account . initialized , isLoggedIn ] )
66+
4967 // Load apps on mount to get app names for project lozenges
5068 React . useEffect ( ( ) => {
5169 if ( account . user ?. id ) {
@@ -69,8 +87,8 @@ const Projects: FC = () => {
6987 // Check if org slug is set in the URL
7088 // const orgSlug = router.params.org_id || ''
7189
72- const { data : projects = [ ] , isLoading, error } = useListProjects ( account . organizationTools . organization ?. id || '' )
73- const { data : sampleProjects = [ ] } = useListSampleProjects ( )
90+ const { data : projects = [ ] , isLoading, error } = useListProjects ( account . organizationTools . organization ?. id || '' , { enabled : isLoggedIn } )
91+ const { data : sampleProjects = [ ] } = useListSampleProjects ( { enabled : isLoggedIn } )
7492 const instantiateSampleMutation = useInstantiateSampleProject ( )
7593
7694 // Get tab from URL query parameter
@@ -87,8 +105,8 @@ const Projects: FC = () => {
87105 // List repos by organization_id when in org context, or by owner_id for personal workspace
88106 const { data : repositories = [ ] , isLoading : reposLoading } = useGitRepositories (
89107 currentOrg ?. id
90- ? { organizationId : currentOrg . id }
91- : { ownerId : account . user ?. id }
108+ ? { organizationId : currentOrg . id , enabled : isLoggedIn }
109+ : { ownerId : account . user ?. id , enabled : isLoggedIn }
92110 )
93111
94112 // Repository dialog states
@@ -224,22 +242,14 @@ const Projects: FC = () => {
224242 handleMenuClose ( )
225243 }
226244
227- const checkLoginStatus = ( ) : boolean => {
228- if ( ! account . user ) {
229- account . setShowLoginWindow ( true )
230- return false
231- }
232- return true
233- }
234-
235245 const handleNewProject = ( ) => {
236- if ( ! checkLoginStatus ( ) ) return
246+ if ( ! requireLogin ( ) ) return
237247 setCreateDialogOpen ( true )
238248 }
239249
240250 // Step 1: User clicks on sample project - show agent selection modal
241251 const handleInstantiateSample = async ( sampleId : string , sampleName : string ) => {
242- if ( ! checkLoginStatus ( ) ) return
252+ if ( ! requireLogin ( ) ) return
243253
244254 // Store the pending fork request and show agent selection modal
245255 setPendingSampleFork ( { sampleId, sampleName } )
@@ -549,7 +559,10 @@ const Projects: FC = () => {
549559 color = "secondary"
550560 size = "small"
551561 startIcon = { < FolderSearch size = { 16 } /> }
552- onClick = { ( ) => setBrowseProvidersOpen ( true ) }
562+ onClick = { ( ) => {
563+ if ( ! requireLogin ( ) ) return
564+ setBrowseProvidersOpen ( true )
565+ } }
553566 sx = { { mr : 1 } }
554567 >
555568 Connect & Browse
@@ -558,7 +571,10 @@ const Projects: FC = () => {
558571 variant = "outlined"
559572 size = "small"
560573 startIcon = { < Link size = { 16 } /> }
561- onClick = { ( ) => setLinkRepoDialogOpen ( true ) }
574+ onClick = { ( ) => {
575+ if ( ! requireLogin ( ) ) return
576+ setLinkRepoDialogOpen ( true )
577+ } }
562578 sx = { { textTransform : 'none' , mr : 1 } }
563579 >
564580 Link Manually
@@ -567,7 +583,10 @@ const Projects: FC = () => {
567583 variant = "outlined"
568584 size = "small"
569585 startIcon = { < Plus size = { 16 } /> }
570- onClick = { ( ) => setCreateRepoDialogOpen ( true ) }
586+ onClick = { ( ) => {
587+ if ( ! requireLogin ( ) ) return
588+ setCreateRepoDialogOpen ( true )
589+ } }
571590 sx = { { textTransform : 'none' } }
572591 >
573592 New Empty
@@ -580,7 +599,7 @@ const Projects: FC = () => {
580599 { currentView === 'projects' && (
581600 < ProjectsListView
582601 projects = { projects }
583- error = { error }
602+ error = { isLoggedIn ? error : null }
584603 searchQuery = { projectsSearchQuery }
585604 onSearchChange = { setProjectsSearchQuery }
586605 page = { projectsPage }
@@ -612,8 +631,14 @@ const Projects: FC = () => {
612631 paginatedRepositories = { paginatedRepositories }
613632 totalPages = { reposTotalPages }
614633 onViewRepository = { handleViewRepository }
615- onCreateRepo = { ( ) => setCreateRepoDialogOpen ( true ) }
616- onLinkExternalRepo = { ( ) => setLinkRepoDialogOpen ( true ) }
634+ onCreateRepo = { ( ) => {
635+ if ( ! requireLogin ( ) ) return
636+ setCreateRepoDialogOpen ( true )
637+ } }
638+ onLinkExternalRepo = { ( ) => {
639+ if ( ! requireLogin ( ) ) return
640+ setLinkRepoDialogOpen ( true )
641+ } }
617642 />
618643 ) }
619644
0 commit comments