MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/commands/sandbox-toggle/sandbox-toggle.tsx:10–82  ·  view source on GitHub ↗
(onDone: (result?: string) => void, _context: unknown, args?: string)

Source from the content-addressed store, hash-verified

8import { getSettings_DEPRECATED, getSettingsFilePathForSource } from '../../utils/settings/settings.js';
9import type { ThemeName } from '../../utils/theme.js';
10export async function call(onDone: (result?: string) => void, _context: unknown, args?: string): Promise<React.ReactNode | null> {
11 const settings = getSettings_DEPRECATED();
12 const themeName: ThemeName = settings.theme as ThemeName || 'light';
13 const platform = getPlatform();
14 if (!SandboxManager.isSupportedPlatform()) {
15 // WSL1 users will see this since isSupportedPlatform returns false for WSL1
16 const errorMessage = platform === 'wsl' ? 'Error: Sandboxing requires WSL2. WSL1 is not supported.' : 'Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.';
17 const message = color('error', themeName)(errorMessage);
18 onDone(message);
19 return null;
20 }
21
22 // Check dependencies - get structured result with errors/warnings
23 const depCheck = SandboxManager.checkDependencies();
24
25 // Check if platform is in enabledPlatforms list (undocumented enterprise setting)
26 if (!SandboxManager.isPlatformInEnabledList()) {
27 const message = color('error', themeName)(`Error: Sandboxing is disabled for this platform (${platform}) via the enabledPlatforms setting.`);
28 onDone(message);
29 return null;
30 }
31
32 // Check if sandbox settings are locked by higher-priority settings
33 if (SandboxManager.areSandboxSettingsLockedByPolicy()) {
34 const message = color('error', themeName)('Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.');
35 onDone(message);
36 return null;
37 }
38
39 // Parse the arguments
40 const trimmedArgs = args?.trim() || '';
41
42 // If no args, show the interactive menu
43 if (!trimmedArgs) {
44 return <SandboxSettings onComplete={onDone} depCheck={depCheck} />;
45 }
46
47 // Handle subcommands
48 if (trimmedArgs) {
49 const parts = trimmedArgs.split(' ');
50 const subcommand = parts[0];
51 if (subcommand === 'exclude') {
52 // Handle exclude subcommand
53 const commandPattern = trimmedArgs.slice('exclude '.length).trim();
54 if (!commandPattern) {
55 const message = color('error', themeName)('Error: Please provide a command pattern to exclude (e.g., /sandbox exclude "npm run test:*")');
56 onDone(message);
57 return null;
58 }
59
60 // Remove quotes if present
61 const cleanPattern = commandPattern.replace(/^["']|["']$/g, '');
62
63 // Add to excludedCommands
64 addToExcludedCommands(cleanPattern);
65
66 // Get the local settings path and make it relative to cwd
67 const localSettingsPath = getSettingsFilePathForSource('localSettings');

Callers

nothing calls this directly

Calls 10

getPlatformFunction · 0.85
colorFunction · 0.85
addToExcludedCommandsFunction · 0.85
getCwdStateFunction · 0.85
isSupportedPlatformMethod · 0.80
checkDependenciesMethod · 0.80
onDoneFunction · 0.50

Tested by

no test coverage detected