import { useSettings } from '@/hooks/useSettings' import { useServerHealth } from '@/hooks/useServerHealth' import { Switch } from '@/components/ui/switch' import { Alert, AlertDescription } from '@/components/ui/alert' import { Badge } from '@/components/ui/badge' import { Box, RotateCcw } from 'lucide-react' import { showToast } from '@/lib/toast' import { FetchError } from '@/api/fetchWrapper' import { SettingsDisclosure } from './SettingsDisclosure' export function SandboxSettings() { const { preferences, updateSettingsAsync, isUpdating } = useSettings() const { data: health } = useServerHealth() const sandbox = health?.sandbox const isAvailable = sandbox?.available === true const enabled = preferences?.sandbox?.enabled ?? false const gitCredentials = preferences?.sandbox?.gitCredentials ?? false const saveSandbox = async (next: { enabled: boolean; gitCredentials: boolean }, message: string) => { try { await updateSettingsAsync({ sandbox: next }) showToast.success(message) } catch (error) { showToast.error(error instanceof FetchError ? error.message : 'Failed to update sandbox preference') } } const handleToggle = (next: boolean) => saveSandbox({ enabled: next, gitCredentials }, next ? 'Sandboxing enabled' : 'Sandboxing disabled') const handleGitCredentialsToggle = (next: boolean) => saveSandbox( { enabled, gitCredentials: next }, next ? 'Git credentials will be forwarded into the sandbox' : 'Git credential forwarding disabled', ) return ( } meta={ sandbox?.msbVersion ? ( msb {sandbox.msbVersion} ) : undefined } contentClassName="space-y-3" >

Run OpenCode agent commands inside microVMs for isolation.

{sandbox === undefined ? (

Checking sandbox availability...

) : !isAvailable && (

{sandbox.reason ?? 'Sandboxing is unavailable on this host.'}

)}

Git credentials in sandbox

Forward git credentials into the microVM so sandboxed git and gh commands can authenticate. A prompt-injected agent can exfiltrate any credential you forward.

{health?.opencodeRestartPending && ( Restart the OpenCode server to apply sandbox changes. )}
) }