Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix GH flow [WIP]
Tomas Valenta7f5a6ad7f18c
diff --git a/components/Repos.tsx b/components/Repos.tsxindex deb5f5ba2..f3af12370 100644--- a/components/Repos.tsx+++ b/components/Repos.tsx@@ -7,6 +7,7 @@ import { useGitHub } from 'hooks/useGitHub'import useListenMessage from 'hooks/useListenMessage'import Button from 'components/Button'import Text from 'components/Text'+import { useLocalStorage } from 'hooks/useLocalStorage'import { useRepositories } from 'hooks/useRepositories'import { openPopupModal } from 'utils/popupModal'@@ -23,12 +24,14 @@ export interface PostProjectBody {id: string}+export interface Props {onRepoSelection: (repoSetup: Pick<PostProjectBody, 'accessToken' | 'installationID' | 'repositoryID'> & { fullName: string, defaultBranch: string, branches?: string[], url: string }) => voidaccessToken?: string}-function Repos({ onRepoSelection, accessToken }: Props) {+function Repos({ onRepoSelection }: Props) {+ const [accessToken, setAccessToken] = useLocalStorage<string | undefined>('gh_access_token', undefined)const gitHub = useGitHub(accessToken)const { repos, refetch } = useRepositories(gitHub)const [query, setQuery] = useState<string>()@@ -45,11 +48,11 @@ function Repos({ onRepoSelection, accessToken }: Props) {const handleEvent = useCallback((event: MessageEvent) => {if (event.data.accessToken) {- // setAccessToken(event.data.accessToken)+ setAccessToken(event.data.accessToken)} else if (event.data.installationID) {refetch()}- }, [refetch])+ }, [setAccessToken, refetch])useListenMessage(handleEvent)async function selectRepository(r: Pick<PostProjectBody, 'installationID' | 'repositoryID'> & { fullName: string, defaultBranch: string, url: string }) {@@ -74,6 +77,12 @@ function Repos({ onRepoSelection, accessToken }: Props) {})}+ async function signWithGitHubOAuth() {+ const url = new URL('/login/oauth/authorize', 'https://github.com')+ url.searchParams.set('client_id', process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID!)+ openPopupModal(url)+ }+function configureGitHubApp() {const url = new URL('https://github.com/apps/e2b-for-github/installations/new')openPopupModal(url)@@ -90,16 +99,16 @@ function Repos({ onRepoSelection, accessToken }: Props) {flex-1`,{ 'bg-white': accessToken },)}>- {/* {!accessToken &&+ {!accessToken &&<div className="flex flex-1 justify-center items-center"><Buttonvariant={Button.variant.Full}onClick={signWithGitHubOAuth}- text="Connect GitHub"+ text="Add GitHub Repository"icon={<GithubIcon />}/></div>- } */}+ }{accessToken &&<div className="flex overflow-hidden flex-col flex-1">@@ -176,10 +185,10 @@ function Repos({ onRepoSelection, accessToken }: Props) {</div>{accessToken &&<div className="flex justify-between">- {/* <TitleButton+ <TitleButtononClick={signWithGitHubOAuth}text="Reauthenticate GitHub Account"- /> */}+ /><TitleButtononClick={configureGitHubApp}text="Configure GitHub App"diff --git a/pages/agent/smol-developer/index.tsx b/pages/agent/smol-developer/index.tsxindex 52b1f00bc..001ea5ad2 100644--- a/pages/agent/smol-developer/index.tsx+++ b/pages/agent/smol-developer/index.tsx@@ -44,7 +44,6 @@ function SmolDeveloper() {provider: 'github',options: {redirectTo: window.location.href,- scopes: 'repo',}})console.log({ data, error })@@ -120,4 +119,4 @@ function SmolDeveloper() {)}-export default SmolDeveloper\ No newline at end of file+export default SmolDeveloperdiff --git a/pages/agent/smol-developer/repo.tsx b/pages/agent/smol-developer/repo.tsxindex 2e6e53d85..7a19276ab 100644--- a/pages/agent/smol-developer/repo.tsx+++ b/pages/agent/smol-developer/repo.tsx@@ -1,5 +1,5 @@import type { GetServerSideProps } from 'next'-import { useSupabaseClient } from '@supabase/auth-helpers-react'+import { useSessionContext, useSupabaseClient } from '@supabase/auth-helpers-react'import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'import {useUser,@@ -8,6 +8,7 @@ import {import { serverCreds } from 'db/credentials'import Repos from 'components/Repos'+import Button from 'components/Button'export const getServerSideProps: GetServerSideProps = async (ctx) => {@@ -31,6 +32,8 @@ function Repo() {const supabaseClient = useSupabaseClient()const user = useUser()const session = useSession()+ const sessionCtx = useSessionContext()+async function signOut() {await supabaseClient.auth.signOut()@@ -67,8 +70,14 @@ function Repo() {/>}</div>+ {!sessionCtx.isLoading && user && (+ <Button+ text="Sign out"+ onClick={signOut}+ />+ )}</div>)}-export default Repo\ No newline at end of file+export default Repo