11'use client'
22
33import Sandbox from 'e2b'
4- import { useRouter } from 'next/navigation'
54import type { ReactNode } from 'react'
65import {
76 createContext ,
@@ -11,9 +10,7 @@ import {
1110 useMemo ,
1211 useRef ,
1312} from 'react'
14- import { SUPABASE_AUTH_HEADERS } from '@/configs/api'
15- import { AUTH_URLS } from '@/configs/urls'
16- import { supabase } from '@/core/shared/clients/supabase/client'
13+ import type { SandboxManagementAuth } from '@/core/shared/sandbox-management-auth'
1714import { useSandboxInspectAnalytics } from '@/lib/hooks/use-analytics'
1815import { getParentPath , normalizePath } from '@/lib/utils/filesystem'
1916import { useDashboard } from '../../context'
@@ -34,11 +31,13 @@ const SandboxInspectContext = createContext<SandboxInspectContextValue | null>(
3431interface SandboxInspectProviderProps {
3532 children : ReactNode
3633 rootPath : string
34+ sandboxManagementAuth : SandboxManagementAuth
3735}
3836
3937export default function SandboxInspectProvider ( {
4038 children,
4139 rootPath,
40+ sandboxManagementAuth,
4241} : SandboxInspectProviderProps ) {
4342 const { team } = useDashboard ( )
4443 const teamId = team . id
@@ -47,7 +46,6 @@ export default function SandboxInspectProvider({
4746 const storeRef = useRef < FilesystemStore | null > ( null )
4847 const sandboxManagerRef = useRef < SandboxManager | null > ( null )
4948
50- const router = useRouter ( )
5149 const { trackInteraction } = useSandboxInspectAnalytics ( )
5250
5351 // ---------- synchronous store initialisation ----------
@@ -181,19 +179,12 @@ export default function SandboxInspectProvider({
181179 sandboxManagerRef . current . stopWatching ( )
182180 }
183181
184- const { data } = await supabase . auth . getSession ( )
185-
186- if ( ! data || ! data . session ) {
187- router . replace ( AUTH_URLS . SIGN_IN )
188- return
189- }
190-
191182 const sandbox = await Sandbox . connect ( sandboxInfo . sandboxID , {
192183 domain : process . env . NEXT_PUBLIC_E2B_DOMAIN ,
193184 // Keep inspect connections from extending sandbox TTL via SDK default connect timeout.
194185 timeoutMs : 1_000 ,
195186 headers : {
196- ...SUPABASE_AUTH_HEADERS ( data . session . access_token , teamId ) ,
187+ ...sandboxManagementAuth . headers ,
197188 } ,
198189 } )
199190
@@ -209,7 +200,7 @@ export default function SandboxInspectProvider({
209200 team_id : teamId ,
210201 root_path : rootPath ,
211202 } )
212- } , [ sandboxInfo , teamId , rootPath , trackInteraction , router ] )
203+ } , [ sandboxInfo , teamId , rootPath , trackInteraction , sandboxManagementAuth ] )
213204
214205 // handle sandbox connection / disconnection
215206 useEffect ( ( ) => {
0 commit comments