diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index a43921e144..3ac1aa2c34 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -304,6 +304,53 @@ describe('Server Config (config.ts)', () => { }); }); + describe('setShellExecutionConfig', () => { + it('should preserve existing shell execution fields that are not being updated', () => { + const config = new Config({ + ...baseParams, + sandbox: { + enabled: true, + command: 'windows-native', + networkAccess: false, + }, + shellBackgroundCompletionBehavior: 'notify', + }); + + expect(config.getShellExecutionConfig()).toEqual( + expect.objectContaining({ + sandboxConfig: expect.objectContaining({ + enabled: true, + command: 'windows-native', + networkAccess: false, + }), + backgroundCompletionBehavior: 'notify', + }), + ); + + config.setShellExecutionConfig({ + terminalWidth: 123, + terminalHeight: 45, + showColor: true, + pager: 'cat', + sanitizationConfig: config.sanitizationConfig, + sandboxManager: config.sandboxManager, + }); + + expect(config.getShellExecutionConfig()).toEqual( + expect.objectContaining({ + terminalWidth: 123, + terminalHeight: 45, + sandboxConfig: expect.objectContaining({ + enabled: true, + command: 'windows-native', + networkAccess: false, + }), + backgroundCompletionBehavior: 'notify', + }), + ); + }); + }); + beforeEach(() => { // Reset mocks if necessary vi.clearAllMocks(); diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 2ef6fc26a8..5e8507eba4 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -3334,6 +3334,7 @@ export class Config implements McpContext, AgentLoopContext { setShellExecutionConfig(config: ShellExecutionConfig): void { this.shellExecutionConfig = { + ...this.shellExecutionConfig, terminalWidth: config.terminalWidth ?? this.shellExecutionConfig.terminalWidth, terminalHeight: