From 216e7a0a567ce128688310a3b12eb40f4dc8f21e Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 20 Apr 2026 16:43:21 -0700 Subject: [PATCH] Warn when trusting Git subdirectories (#18602) Addresses #18505 ## Summary When Codex is launched from a subdirectory of a Git repository, the onboarding trust prompt says it is trusting the current directory even though the persisted trust target is the repository root. That can make the scope of the trust decision unclear. This updates the TUI trust prompt to show a yellow note only when the current directory differs from the resolved trust target, explaining that trust applies to the repository root and displaying that root. It also removes the stale onboarding TODO now that the warning is implemented. --- .../tui/src/onboarding/onboarding_screen.rs | 1 - codex-rs/tui/src/onboarding/trust_directory.rs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/codex-rs/tui/src/onboarding/onboarding_screen.rs b/codex-rs/tui/src/onboarding/onboarding_screen.rs index c30ee500a..0c7ebda08 100644 --- a/codex-rs/tui/src/onboarding/onboarding_screen.rs +++ b/codex-rs/tui/src/onboarding/onboarding_screen.rs @@ -139,7 +139,6 @@ impl OnboardingScreen { error: None, })) } - // TODO: add git warning. Self { request_frame: tui.frame_requester(), steps, diff --git a/codex-rs/tui/src/onboarding/trust_directory.rs b/codex-rs/tui/src/onboarding/trust_directory.rs index f04e9f9af..5a1626fda 100644 --- a/codex-rs/tui/src/onboarding/trust_directory.rs +++ b/codex-rs/tui/src/onboarding/trust_directory.rs @@ -51,6 +51,23 @@ impl WidgetRef for &TrustDirectoryWidget { ])); column.push(""); + if self.cwd != self.trust_target { + #[allow(clippy::disallowed_methods)] + let git_root_warning = Paragraph::new(format!( + "Note: You’re in a subdirectory of a Git project. Trusting will apply to the repository root: {}", + self.trust_target.display() + )) + .yellow(); + column.push( + git_root_warning + .wrap(Wrap { trim: true }) + .inset(Insets::tlbr( + /*top*/ 0, /*left*/ 2, /*bottom*/ 0, /*right*/ 0, + )), + ); + column.push(""); + } + column.push( Paragraph::new( "Do you trust the contents of this directory? Working with untrusted \