Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Preserve wrapped help links in Windows sandbox prompts (#51459)

Charlie Marsh414d165b47a9
diff --git a/codex-rs/tui/src/chatwidget/tests/helpers.rs b/codex-rs/tui/src/chatwidget/tests/helpers.rs
index 2ccf46ce42..17dc47c3f6 100644
--- a/codex-rs/tui/src/chatwidget/tests/helpers.rs
+++ b/codex-rs/tui/src/chatwidget/tests/helpers.rs
@@ -1350,7 +1350,7 @@ pub(crate) fn render_bottom_popup(chat: &ChatWidget, width: u16) -> String {
if symbol.is_empty() {
line.push(' ');
} else {
- line.push_str(symbol);
+ line.push_str(&crate::terminal_hyperlinks::strip_osc8(symbol));
}
}
line.trim_end().to_string()
diff --git a/codex-rs/tui/src/chatwidget/tests/permissions.rs b/codex-rs/tui/src/chatwidget/tests/permissions.rs
index 4282cab86f..a08388f58d 100644
--- a/codex-rs/tui/src/chatwidget/tests/permissions.rs
+++ b/codex-rs/tui/src/chatwidget/tests/permissions.rs
@@ -659,6 +659,49 @@ async fn startup_windows_sandbox_prompt_blocks_disallowed_unelevated_fallback()
);
}
+#[tokio::test]
+async fn windows_sandbox_help_links_keep_complete_wrapped_destinations() {
+ let url = "https://developers.openai.com/codex/windows";
+ for fallback in [false, true] {
+ let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ let preset = builtin_approval_presets()
+ .into_iter()
+ .find(|preset| preset.id == "auto")
+ .unwrap();
+ if fallback {
+ chat.open_windows_sandbox_fallback_prompt(preset, /*profile_selection*/ None);
+ } else {
+ chat.open_windows_sandbox_enable_prompt(preset, /*profile_selection*/ None);
+ }
+ let area = Rect::new(0, 0, 40, 24);
+ let mut buf = Buffer::empty(area);
+ chat.bottom_pane.render(area, &mut buf);
+ let linked = buf
+ .content
+ .iter()
+ .filter(|cell| cell.symbol().contains("\x1b]8;;"))
+ .map(|cell| {
+ assert!(cell.symbol().starts_with(&format!("\x1b]8;;{url}\x07")));
+ crate::terminal_hyperlinks::strip_osc8(cell.symbol())
+ })
+ .collect::<String>();
+ assert_eq!(linked, url);
+ if !fallback {
+ let visible = buf
+ .content
+ .chunks(40)
+ .map(|row| {
+ row.iter()
+ .map(|cell| crate::terminal_hyperlinks::strip_osc8(cell.symbol()))
+ .collect::<String>()
+ })
+ .collect::<Vec<_>>()
+ .join("\n");
+ insta::assert_snapshot!("windows_sandbox_wrapped_help_url", visible);
+ }
+ }
+}
+
#[tokio::test]
async fn windows_sandbox_required_enable_prompt_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
diff --git a/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__permissions__windows_sandbox_wrapped_help_url.snap b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__permissions__windows_sandbox_wrapped_help_url.snap
new file mode 100644
index 0000000000..24f0a8e0bd
--- /dev/null
+++ b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__permissions__windows_sandbox_wrapped_help_url.snap
@@ -0,0 +1,28 @@
+---
+source: tui/src/chatwidget/tests/permissions.rs
+expression: visible
+---
+
+ Set up the Codex agent sandbox to
+ protect your files and control
+ network access. Learn more
+ <https://developers.openai.com/codex
+ /windows>
+
+
+› 1. Set up default sandbox (requires
+ Administrator permissions)
+ 2. Use non-admin sandbox (higher risk
+ if prompt injected)
+ 3. Quit
+
+
+
+
+
+
+
+
+
+
+ enter select · esc back
diff --git a/codex-rs/tui/src/chatwidget/windows_sandbox_prompts.rs b/codex-rs/tui/src/chatwidget/windows_sandbox_prompts.rs
index 0bcf5fbe1a..39bbb795f3 100644
--- a/codex-rs/tui/src/chatwidget/windows_sandbox_prompts.rs
+++ b/codex-rs/tui/src/chatwidget/windows_sandbox_prompts.rs
@@ -33,7 +33,7 @@ impl ChatWidget {
!allow_unelevated || self.elevated_windows_sandbox_setup_required();
let mut header = ColumnRenderable::new();
header.push(*Box::new(
- Paragraph::new(if allow_unelevated {
+ crate::terminal_hyperlinks::HyperlinkText::new(if allow_unelevated {
vec![
line!["Set up the Codex agent sandbox to protect your files and control network access. Learn more <https://developers.openai.com/codex/windows>"],
]
@@ -42,8 +42,7 @@ impl ChatWidget {
line!["Your organization requires the default Codex agent sandbox to continue. Set it up to protect your files and control network access."],
line!["Learn more <https://developers.openai.com/codex/windows>"],
]
- })
- .wrap(Wrap { trim: false }),
+ }),
));
let accept_otel = self.session_telemetry.clone();
@@ -170,7 +169,7 @@ impl ChatWidget {
]);
let mut header = ColumnRenderable::new();
- header.push(*Box::new(Paragraph::new(lines).wrap(Wrap { trim: false })));
+ header.push(crate::terminal_hyperlinks::HyperlinkText::new(lines));
let elevated_preset = preset.clone();
let legacy_preset = preset;