mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-05 09:33:07 +00:00
Merge pull request #545 from stefandevo/fix/sandbox-warning-persistence
fix: sandbox warning persistence and add env var option
This commit is contained in:
@@ -388,6 +388,7 @@ npm run lint
|
|||||||
|
|
||||||
- `VITE_SKIP_ELECTRON` - Skip Electron in dev mode
|
- `VITE_SKIP_ELECTRON` - Skip Electron in dev mode
|
||||||
- `OPEN_DEVTOOLS` - Auto-open DevTools in Electron
|
- `OPEN_DEVTOOLS` - Auto-open DevTools in Electron
|
||||||
|
- `AUTOMAKER_SKIP_SANDBOX_WARNING` - Skip sandbox warning dialog (useful for dev/CI)
|
||||||
|
|
||||||
### Authentication Setup
|
### Authentication Setup
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,14 @@ TERMINAL_PASSWORD=
|
|||||||
|
|
||||||
ENABLE_REQUEST_LOGGING=false
|
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
|
# OPTIONAL - Debugging
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ import type { Request, Response } from 'express';
|
|||||||
|
|
||||||
export interface EnvironmentResponse {
|
export interface EnvironmentResponse {
|
||||||
isContainerized: boolean;
|
isContainerized: boolean;
|
||||||
|
skipSandboxWarning?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createEnvironmentHandler() {
|
export function createEnvironmentHandler() {
|
||||||
return (_req: Request, res: Response): void => {
|
return (_req: Request, res: Response): void => {
|
||||||
res.json({
|
res.json({
|
||||||
isContainerized: process.env.IS_CONTAINERIZED === 'true',
|
isContainerized: process.env.IS_CONTAINERIZED === 'true',
|
||||||
|
skipSandboxWarning: process.env.AUTOMAKER_SKIP_SANDBOX_WARNING === 'true',
|
||||||
} satisfies EnvironmentResponse);
|
} satisfies EnvironmentResponse);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,6 +483,7 @@ export const verifySession = async (): Promise<boolean> => {
|
|||||||
*/
|
*/
|
||||||
export const checkSandboxEnvironment = async (): Promise<{
|
export const checkSandboxEnvironment = async (): Promise<{
|
||||||
isContainerized: boolean;
|
isContainerized: boolean;
|
||||||
|
skipSandboxWarning?: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
}> => {
|
}> => {
|
||||||
try {
|
try {
|
||||||
@@ -498,7 +499,10 @@ export const checkSandboxEnvironment = async (): Promise<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return { isContainerized: data.isContainerized ?? false };
|
return {
|
||||||
|
isContainerized: data.isContainerized ?? false,
|
||||||
|
skipSandboxWarning: data.skipSandboxWarning ?? false,
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Sandbox environment check failed:', error);
|
logger.error('Sandbox environment check failed:', error);
|
||||||
return { isContainerized: false, error: 'Network error' };
|
return { isContainerized: false, error: 'Network error' };
|
||||||
|
|||||||
@@ -269,15 +269,16 @@ function RootLayoutContent() {
|
|||||||
setIsMounted(true);
|
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(() => {
|
useEffect(() => {
|
||||||
// Skip if already decided
|
// Skip if already decided
|
||||||
if (sandboxStatus !== 'pending') {
|
if (sandboxStatus !== 'pending') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't check sandbox until user is authenticated and has completed setup
|
// Don't check sandbox until user is authenticated, has completed setup, and settings are loaded
|
||||||
if (!authChecked || !isAuthenticated || !setupComplete) {
|
// CRITICAL: settingsLoaded must be true to ensure skipSandboxWarning has been hydrated from server
|
||||||
|
if (!authChecked || !isAuthenticated || !setupComplete || !settingsLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +289,8 @@ function RootLayoutContent() {
|
|||||||
if (result.isContainerized) {
|
if (result.isContainerized) {
|
||||||
// Running in a container, no warning needed
|
// Running in a container, no warning needed
|
||||||
setSandboxStatus('containerized');
|
setSandboxStatus('containerized');
|
||||||
} else if (skipSandboxWarning) {
|
} else if (result.skipSandboxWarning || skipSandboxWarning) {
|
||||||
// User opted to skip the warning, auto-confirm
|
// Skip if env var is set OR if user preference is set
|
||||||
setSandboxStatus('confirmed');
|
setSandboxStatus('confirmed');
|
||||||
} else {
|
} else {
|
||||||
// Not containerized, show warning dialog
|
// Not containerized, show warning dialog
|
||||||
@@ -307,7 +308,14 @@ function RootLayoutContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
checkSandbox();
|
checkSandbox();
|
||||||
}, [sandboxStatus, skipSandboxWarning, authChecked, isAuthenticated, setupComplete]);
|
}, [
|
||||||
|
sandboxStatus,
|
||||||
|
skipSandboxWarning,
|
||||||
|
authChecked,
|
||||||
|
isAuthenticated,
|
||||||
|
setupComplete,
|
||||||
|
settingsLoaded,
|
||||||
|
]);
|
||||||
|
|
||||||
// Handle sandbox risk confirmation
|
// Handle sandbox risk confirmation
|
||||||
const handleSandboxConfirm = useCallback(
|
const handleSandboxConfirm = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user