Merge pull request #545 from stefandevo/fix/sandbox-warning-persistence

fix: sandbox warning persistence and add env var option
This commit is contained in:
Shirone
2026-01-17 18:57:19 +00:00
committed by GitHub
5 changed files with 30 additions and 7 deletions

View File

@@ -68,6 +68,14 @@ TERMINAL_PASSWORD=
ENABLE_REQUEST_LOGGING=false
# ============================================
# OPTIONAL - UI Behavior
# ============================================
# Skip the sandbox warning dialog on startup (default: false)
# Set to "true" to disable the warning entirely (useful for dev/CI environments)
AUTOMAKER_SKIP_SANDBOX_WARNING=false
# ============================================
# OPTIONAL - Debugging
# ============================================

View File

@@ -9,12 +9,14 @@ import type { Request, Response } from 'express';
export interface EnvironmentResponse {
isContainerized: boolean;
skipSandboxWarning?: boolean;
}
export function createEnvironmentHandler() {
return (_req: Request, res: Response): void => {
res.json({
isContainerized: process.env.IS_CONTAINERIZED === 'true',
skipSandboxWarning: process.env.AUTOMAKER_SKIP_SANDBOX_WARNING === 'true',
} satisfies EnvironmentResponse);
};
}

View File

@@ -483,6 +483,7 @@ export const verifySession = async (): Promise<boolean> => {
*/
export const checkSandboxEnvironment = async (): Promise<{
isContainerized: boolean;
skipSandboxWarning?: boolean;
error?: string;
}> => {
try {
@@ -498,7 +499,10 @@ export const checkSandboxEnvironment = async (): Promise<{
}
const data = await response.json();
return { isContainerized: data.isContainerized ?? false };
return {
isContainerized: data.isContainerized ?? false,
skipSandboxWarning: data.skipSandboxWarning ?? false,
};
} catch (error) {
logger.error('Sandbox environment check failed:', error);
return { isContainerized: false, error: 'Network error' };

View File

@@ -269,15 +269,16 @@ function RootLayoutContent() {
setIsMounted(true);
}, []);
// Check sandbox environment only after user is authenticated and setup is complete
// Check sandbox environment only after user is authenticated, setup is complete, and settings are loaded
useEffect(() => {
// Skip if already decided
if (sandboxStatus !== 'pending') {
return;
}
// Don't check sandbox until user is authenticated and has completed setup
if (!authChecked || !isAuthenticated || !setupComplete) {
// Don't check sandbox until user is authenticated, has completed setup, and settings are loaded
// CRITICAL: settingsLoaded must be true to ensure skipSandboxWarning has been hydrated from server
if (!authChecked || !isAuthenticated || !setupComplete || !settingsLoaded) {
return;
}
@@ -288,8 +289,8 @@ function RootLayoutContent() {
if (result.isContainerized) {
// Running in a container, no warning needed
setSandboxStatus('containerized');
} else if (skipSandboxWarning) {
// User opted to skip the warning, auto-confirm
} else if (result.skipSandboxWarning || skipSandboxWarning) {
// Skip if env var is set OR if user preference is set
setSandboxStatus('confirmed');
} else {
// Not containerized, show warning dialog
@@ -307,7 +308,14 @@ function RootLayoutContent() {
};
checkSandbox();
}, [sandboxStatus, skipSandboxWarning, authChecked, isAuthenticated, setupComplete]);
}, [
sandboxStatus,
skipSandboxWarning,
authChecked,
isAuthenticated,
setupComplete,
settingsLoaded,
]);
// Handle sandbox risk confirmation
const handleSandboxConfirm = useCallback(