fix(core): preserve shell execution config fields on update (#25113)

This commit is contained in:
Jason Matthew Suhari
2026-04-11 01:55:40 +08:00
committed by GitHub
parent 31069329bb
commit 86f5a198bd
2 changed files with 48 additions and 0 deletions
+47
View File
@@ -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();
+1
View File
@@ -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: