fix(sandbox): guard enable path and harden UI rendering performance (#341)

* fix(sandbox): guard enable path and harden UI rendering performance

* chore(deps): allow esbuild postinstall in pnpm onlyBuiltDependencies

* fix(sandbox): align availability reporting and address PR review feedback

* fix(sandbox): block planning without process attestation
This commit is contained in:
Chris Scott authored and GitHub committed 2026-08-27 08:58:23 -04:00
1 parent ba8e8f4b29
commit d63198ec8a
19 files changed
+501 -82

No files matched your search

@@ -5,6 +5,7 @@ import { SandboxSettings } from './SandboxSettings'
import { useSettings } from '@/hooks/useSettings'
import { useServerHealth } from '@/hooks/useServerHealth'
import { showToast } from '@/lib/toast'
import { FetchError } from '@/api/fetchWrapper'
vi.mock('@/hooks/useSettings')
vi.mock('@/hooks/useServerHealth')
@@ -132,6 +133,24 @@ describe('SandboxSettings', () => {
expect(vi.mocked(showToast.error)).toHaveBeenCalledWith('Failed to update sandbox preference')
})
it('shows the backend error when enabling sandboxing is rejected', async () => {
const user = userEvent.setup()
mockUseSettings({
updateSettingsAsync: vi.fn().mockRejectedValue(
new FetchError('Cannot enable sandboxing: process identity attestation is unavailable', 400),
),
})
mockHealth({ available: true, enforced: false })
render(<SandboxSettings />)
await user.click(screen.getByRole('switch', { name: 'Toggle sandbox' }))
expect(vi.mocked(showToast.error)).toHaveBeenCalledWith(
'Cannot enable sandboxing: process identity attestation is unavailable',
)
})
it('preserves the git credential preference when the sandbox toggle changes', async () => {
const user = userEvent.setup()
const { updateSettingsAsync } = mockUseSettings({
@@ -5,6 +5,7 @@ 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'
export function SandboxSettings() {
const { preferences, updateSettingsAsync, isUpdating } = useSettings()
@@ -19,8 +20,8 @@ export function SandboxSettings() {
try {
await updateSettingsAsync({ sandbox: next })
showToast.success(message)
} catch {
showToast.error('Failed to update sandbox preference')
} catch (error) {
showToast.error(error instanceof FetchError ? error.message : 'Failed to update sandbox preference')
}
}