mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
fix: clarify sandbox mode behavior in sdk-options
- Updated the checkSandboxCompatibility function to explicitly handle the case when enableSandboxMode is set to false, ensuring clearer logic for sandbox mode activation. - Adjusted unit tests to reflect the new behavior, confirming that sandbox mode defaults to enabled when not specified and correctly disables for cloud storage paths. - Enhanced test descriptions for better clarity on expected outcomes in various scenarios.
This commit is contained in:
@@ -147,15 +147,15 @@ export function checkSandboxCompatibility(
|
|||||||
cwd: string,
|
cwd: string,
|
||||||
enableSandboxMode?: boolean
|
enableSandboxMode?: boolean
|
||||||
): SandboxCheckResult {
|
): SandboxCheckResult {
|
||||||
// User has disabled sandbox mode
|
// User has explicitly disabled sandbox mode
|
||||||
if (!enableSandboxMode) {
|
if (enableSandboxMode === false) {
|
||||||
return {
|
return {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
disabledReason: 'user_setting',
|
disabledReason: 'user_setting',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for cloud storage incompatibility
|
// Check for cloud storage incompatibility (applies when enabled or undefined)
|
||||||
if (isCloudStoragePath(cwd)) {
|
if (isCloudStoragePath(cwd)) {
|
||||||
return {
|
return {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@@ -164,7 +164,7 @@ export function checkSandboxCompatibility(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sandbox is compatible and enabled
|
// Sandbox is compatible and enabled (true or undefined defaults to enabled)
|
||||||
return {
|
return {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,11 +140,21 @@ describe('sdk-options.ts', () => {
|
|||||||
expect(result.disabledReason).toBeUndefined();
|
expect(result.disabledReason).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return enabled=false when enableSandboxMode is undefined', async () => {
|
it('should return enabled=true when enableSandboxMode is undefined for local paths', async () => {
|
||||||
const { checkSandboxCompatibility } = await import('@/lib/sdk-options.js');
|
const { checkSandboxCompatibility } = await import('@/lib/sdk-options.js');
|
||||||
const result = checkSandboxCompatibility('/Users/test/project', undefined);
|
const result = checkSandboxCompatibility('/Users/test/project', undefined);
|
||||||
|
expect(result.enabled).toBe(true);
|
||||||
|
expect(result.disabledReason).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return enabled=false for cloud storage paths when enableSandboxMode is undefined', async () => {
|
||||||
|
const { checkSandboxCompatibility } = await import('@/lib/sdk-options.js');
|
||||||
|
const result = checkSandboxCompatibility(
|
||||||
|
'/Users/test/Library/CloudStorage/Dropbox-Personal/project',
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(result.enabled).toBe(false);
|
expect(result.enabled).toBe(false);
|
||||||
expect(result.disabledReason).toBe('user_setting');
|
expect(result.disabledReason).toBe('cloud_storage');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -360,14 +370,17 @@ describe('sdk-options.ts', () => {
|
|||||||
expect(options.sandbox).toBeUndefined();
|
expect(options.sandbox).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set sandbox when enableSandboxMode is not provided', async () => {
|
it('should enable sandbox by default when enableSandboxMode is not provided', async () => {
|
||||||
const { createChatOptions } = await import('@/lib/sdk-options.js');
|
const { createChatOptions } = await import('@/lib/sdk-options.js');
|
||||||
|
|
||||||
const options = createChatOptions({
|
const options = createChatOptions({
|
||||||
cwd: '/test/path',
|
cwd: '/test/path',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(options.sandbox).toBeUndefined();
|
expect(options.sandbox).toEqual({
|
||||||
|
enabled: true,
|
||||||
|
autoAllowBashIfSandboxed: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should auto-disable sandbox for cloud storage paths', async () => {
|
it('should auto-disable sandbox for cloud storage paths', async () => {
|
||||||
@@ -432,14 +445,17 @@ describe('sdk-options.ts', () => {
|
|||||||
expect(options.sandbox).toBeUndefined();
|
expect(options.sandbox).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set sandbox when enableSandboxMode is not provided', async () => {
|
it('should enable sandbox by default when enableSandboxMode is not provided', async () => {
|
||||||
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||||
|
|
||||||
const options = createAutoModeOptions({
|
const options = createAutoModeOptions({
|
||||||
cwd: '/test/path',
|
cwd: '/test/path',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(options.sandbox).toBeUndefined();
|
expect(options.sandbox).toEqual({
|
||||||
|
enabled: true,
|
||||||
|
autoAllowBashIfSandboxed: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should auto-disable sandbox for cloud storage paths', async () => {
|
it('should auto-disable sandbox for cloud storage paths', async () => {
|
||||||
@@ -453,6 +469,16 @@ describe('sdk-options.ts', () => {
|
|||||||
expect(options.sandbox).toBeUndefined();
|
expect(options.sandbox).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should auto-disable sandbox for cloud storage paths even when enableSandboxMode is not provided', async () => {
|
||||||
|
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||||
|
|
||||||
|
const options = createAutoModeOptions({
|
||||||
|
cwd: '/Users/test/Library/CloudStorage/Dropbox-Personal/project',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(options.sandbox).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should auto-disable sandbox for iCloud paths', async () => {
|
it('should auto-disable sandbox for iCloud paths', async () => {
|
||||||
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user