Prompt before trusting local project directories (#36960)

## Why

Trusting a directory enables project-local config, hooks, and exec policies, which can increase exposure to prompt injection. Require an explicit decision instead of automatically trusting projects whose trust level is unset.

## What changed

- Add a directory-trust step to TUI onboarding, with options to trust and continue or quit.
- Apply trust to the Git repository root when starting from a subdirectory, persist the decision, and reload config before continuing.
- Keep the prompt active and show the config error when trust cannot be persisted. Skip the prompt for remote workspaces and projects with an explicit trust level.

## Testing

- Cover trust-screen rendering, keyboard selection, persistence failures, and prompt visibility for explicit trust and Windows sandbox states.

GitOrigin-RevId: 850e6f54aec84d584cd161348ecdb1da89aaabd4
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-04 19:48:21 +00:00
1 parent 92689b6b7b
commit 17801b4206
12 files changed
+690 -388

No files matched your search

-3
View File
@@ -293,7 +293,6 @@ pub async fn load_config_layers_state(
}
let mut startup_warnings = None;
let mut project_root = None;
if let Some(cwd) = cwd {
let mut merged_so_far = TomlValue::Table(toml::map::Map::new());
for layer in &layers {
@@ -351,7 +350,6 @@ pub async fn load_config_layers_state(
strict_config,
)
.await?;
project_root = Some(project_trust_context.project_root.clone());
layers.extend(project_layers.layers);
startup_warnings = Some(project_layers.startup_warnings);
}
@@ -434,7 +432,6 @@ pub async fn load_config_layers_state(
config_requirements_toml.clone().try_into()?,
config_requirements_toml.into_toml(),
)?
.with_project_root(project_root)
.with_user_and_project_exec_policy_rules_ignored(ignore_user_and_project_exec_policy_rules);
Ok(match startup_warnings {
Some(startup_warnings) => config_layer_stack.with_startup_warnings(startup_warnings),