Revert "Ignore workspace settings for untrusted folders" (#6672)

This commit is contained in:
Jacob Richman
2025-08-20 12:49:15 -07:00
committed by GitHub
parent fd64d89da0
commit 52e340a11b
16 changed files with 122 additions and 386 deletions

View File

@@ -16,7 +16,6 @@ import {
import stripJsonComments from 'strip-json-comments';
import { DefaultLight } from '../ui/themes/default-light.js';
import { DefaultDark } from '../ui/themes/default.js';
import { isWorkspaceTrusted } from './trustedFolders.js';
import { Settings, MemoryImportFormat } from './settingsSchema.js';
export type { Settings, MemoryImportFormat };
@@ -74,30 +73,7 @@ function mergeSettings(
system: Settings,
user: Settings,
workspace: Settings,
isTrusted?: boolean,
): Settings {
if (!isTrusted) {
return {
...user,
...system,
customThemes: {
...(user.customThemes || {}),
...(system.customThemes || {}),
},
mcpServers: {
...(user.mcpServers || {}),
...(system.mcpServers || {}),
},
includeDirectories: [
...(system.includeDirectories || []),
...(user.includeDirectories || []),
],
chatCompression: {
...(system.chatCompression || {}),
...(user.chatCompression || {}),
},
};
}
// folderTrust is not supported at workspace level.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { folderTrust, ...workspaceWithoutFolderTrust } = workspace;
@@ -135,13 +111,11 @@ export class LoadedSettings {
user: SettingsFile,
workspace: SettingsFile,
errors: SettingsError[],
isTrusted?: boolean,
) {
this.system = system;
this.user = user;
this.workspace = workspace;
this.errors = errors;
this.isTrusted = isTrusted;
this._merged = this.computeMergedSettings();
}
@@ -149,7 +123,6 @@ export class LoadedSettings {
readonly user: SettingsFile;
readonly workspace: SettingsFile;
readonly errors: SettingsError[];
private isTrusted: boolean | undefined;
private _merged: Settings;
@@ -157,17 +130,11 @@ export class LoadedSettings {
return this._merged;
}
recomputeMergedSettings(isTrusted?: boolean): void {
this.isTrusted = isTrusted;
this._merged = this.computeMergedSettings();
}
private computeMergedSettings(): Settings {
return mergeSettings(
this.system.settings,
this.user.settings,
this.workspace.settings,
this.isTrusted,
);
}
@@ -436,16 +403,11 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
}
}
// For the initial trust check, we can only use user and system settings.
const initialTrustCheckSettings = { ...systemSettings, ...userSettings };
const isTrusted = isWorkspaceTrusted(initialTrustCheckSettings);
// Create a temporary merged settings object to pass to loadEnvironment.
const tempMergedSettings = mergeSettings(
systemSettings,
userSettings,
workspaceSettings,
isTrusted,
);
// loadEnviroment depends on settings so we have to create a temp version of
@@ -472,7 +434,6 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
settings: workspaceSettings,
},
settingsErrors,
isTrusted,
);
// Validate chatCompression settings