Skip to content

Commit f985fca

Browse files
fix(Mountain): Inject security.workspace.trust.enabled=false by default
Atom I7: Add logic to AppLifecycle to ensure the VS Code workspace trust system is disabled in User/settings.json. Without this, opening the Land repo as a workspace triggers VS Code's trust gate which marks built-in extensions as `DisabledByTrustRequirement` because they ship under `Element/Sky/Target/Static/Application/extensions/` — inside the repo. This writes `"security.workspace.trust.enabled": false` only if the key isn't already present. Users can opt back in by editing their User/settings.json. This ensures built-in extensions load reliably regardless of which folder the user picks as their workspace.
1 parent b5b669a commit f985fca

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Source/Binary/Main/AppLifecycle.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,44 @@ pub fn AppLifecycleSetup(
264264
}
265265
}
266266

267+
// Atom I7: ensure `security.workspace.trust.enabled: false` lives
268+
// in User/settings.json. Without it, opening the Land repo as a
269+
// workspace triggers VS Code's workspace-trust gate: built-in
270+
// extensions whose `location` is inside the picked folder are
271+
// marked `DisabledByTrustRequirement` (see
272+
// `extensionEnablementService.ts:549`). Since our built-ins ship
273+
// under `Element/Sky/Target/Static/Application/extensions/` —
274+
// which IS inside the repo — any user picking the repo as a
275+
// workspace hits this filter for every extension. Disabling the
276+
// trust system wholesale is the correct Land-level policy; we're
277+
// a personal editor, not a multi-user sandbox. Users can opt
278+
// back in by flipping this key in their User/settings.json.
279+
{
280+
let SettingsPath = AppDataDir.join("User/settings.json");
281+
let Current = std::fs::read_to_string(&SettingsPath).unwrap_or_else(|_| "{}".to_string());
282+
if !Current.contains("\"security.workspace.trust.enabled\"") {
283+
if let Ok(mut Parsed) = serde_json::from_str::<serde_json::Value>(&Current) {
284+
if !Parsed.is_object() {
285+
Parsed = serde_json::json!({});
286+
}
287+
if let Some(Obj) = Parsed.as_object_mut() {
288+
Obj.insert(
289+
"security.workspace.trust.enabled".to_string(),
290+
serde_json::Value::Bool(false),
291+
);
292+
}
293+
if let Ok(Serialized) = serde_json::to_string_pretty(&Parsed) {
294+
let _ = std::fs::write(&SettingsPath, Serialized);
295+
dev_log!(
296+
"lifecycle",
297+
"[Lifecycle] [Dirs] Injected default 'security.workspace.trust.enabled=false' into {}",
298+
SettingsPath.display()
299+
);
300+
}
301+
}
302+
}
303+
}
304+
267305
// Set GlobalMementoPath now that we know the real Tauri app data dir
268306
if let Ok(mut Path) = app_state.GlobalMementoPath.lock() {
269307
*Path = AppDataDir.join("User/globalStorage/global.json");

0 commit comments

Comments
 (0)