1- import  {  RocketLaunchIcon  }  from  "@heroicons/react/24/outline" ; 
2- import  {  useCallback ,  useState  }  from  "react" ; 
1+ import  { 
2+   ExclamationTriangleIcon , 
3+   RocketLaunchIcon , 
4+ }  from  "@heroicons/react/24/outline" ; 
5+ import  {  useCallback ,  useContext ,  useEffect ,  useState  }  from  "react" ; 
36import  {  useAuth  }  from  "../../context/Auth" ; 
7+ import  {  IdeMessengerContext  }  from  "../../context/IdeMessenger" ; 
48import  {  AgentsList  }  from  "./AgentsList" ; 
59
610interface  BackgroundModeViewProps  { 
@@ -9,7 +13,10 @@ interface BackgroundModeViewProps {
913
1014export  function  BackgroundModeView ( {  onCreateAgent } : BackgroundModeViewProps )  { 
1115  const  {  session,  login }  =  useAuth ( ) ; 
16+   const  ideMessenger  =  useContext ( IdeMessengerContext ) ; 
1217  const  [ isLoggingIn ,  setIsLoggingIn ]  =  useState ( false ) ; 
18+   const  [ showGitHubSetup ,  setShowGitHubSetup ]  =  useState ( false ) ; 
19+   const  [ checkingGitHub ,  setCheckingGitHub ]  =  useState ( true ) ; 
1320
1421  const  handleSignIn  =  useCallback ( async  ( )  =>  { 
1522    setIsLoggingIn ( true ) ; 
@@ -22,6 +29,48 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
2229    } 
2330  } ,  [ login ] ) ; 
2431
32+   const  handleOpenGitHubSettings  =  useCallback ( ( )  =>  { 
33+     // Open the hub settings page for GitHub integration 
34+     ideMessenger . post ( 
35+       "openUrl" , 
36+       "https://hub.continue.dev/settings/integrations/github" , 
37+     ) ; 
38+   } ,  [ ideMessenger ] ) ; 
39+ 
40+   // Check if user has GitHub installations when signed in 
41+   useEffect ( ( )  =>  { 
42+     async  function  checkGitHubAuth ( )  { 
43+       if  ( ! session )  { 
44+         setCheckingGitHub ( false ) ; 
45+         return ; 
46+       } 
47+ 
48+       try  { 
49+         setCheckingGitHub ( true ) ; 
50+         // Try to list agents - if this fails with GitHub token error, 
51+         // we know GitHub isn't connected 
52+         const  agents  =  await  ideMessenger . request ( "listBackgroundAgents" ,  { } ) ; 
53+ 
54+         // If we got here without error and have agents, GitHub is connected 
55+         // If we have no agents, we still don't know for sure, so we'll show 
56+         // the setup warning anyway (it will be dismissed after first agent creation) 
57+         setShowGitHubSetup ( false ) ; 
58+       }  catch  ( error : any )  { 
59+         // Check if error is related to GitHub token 
60+         if  ( 
61+           error ?. message ?. includes ( "GitHub token" )  || 
62+           error ?. message ?. includes ( "GitHub App" ) 
63+         )  { 
64+           setShowGitHubSetup ( true ) ; 
65+         } 
66+       }  finally  { 
67+         setCheckingGitHub ( false ) ; 
68+       } 
69+     } 
70+ 
71+     void  checkGitHubAuth ( ) ; 
72+   } ,  [ session ,  ideMessenger ] ) ; 
73+ 
2574  if  ( ! session )  { 
2675    return  ( 
2776      < div  className = "flex flex-col items-center justify-center gap-4 px-4 py-8" > 
@@ -46,6 +95,28 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
4695
4796  return  ( 
4897    < div  className = "flex flex-col gap-4 py-4" > 
98+       { ! checkingGitHub  &&  showGitHubSetup  &&  ( 
99+         < div  className = "mx-2 rounded-lg border border-yellow-200 bg-yellow-50 p-4" > 
100+           < div  className = "flex items-start gap-3" > 
101+             < ExclamationTriangleIcon  className = "h-5 w-5 flex-shrink-0 text-yellow-600"  /> 
102+             < div  className = "flex-1" > 
103+               < h4  className = "text-sm font-semibold text-yellow-900" > 
104+                 Connect GitHub
105+               </ h4 > 
106+               < p  className = "mt-1 text-sm text-yellow-800" > 
107+                 Background agents need access to your GitHub repositories.
108+                 Connect your GitHub account to get started.
109+               </ p > 
110+               < button 
111+                 onClick = { handleOpenGitHubSettings } 
112+                 className = "mt-3 rounded-md bg-yellow-600 px-4 py-2 text-sm font-medium text-white hover:bg-yellow-700" 
113+               > 
114+                 Connect GitHub Account
115+               </ button > 
116+             </ div > 
117+           </ div > 
118+         </ div > 
119+       ) } 
49120      < div  className = "px-2 text-sm text-gray-600" > 
50121        Agents you trigger will run in the background and appear below.
51122      </ div > 
0 commit comments