mirror of
https://github.com/openai/codex.git
synced 2026-12-03 00:41:03 +00:00
Preserve wrapped help links in Windows sandbox prompts (#51459)
## What changed Render help text in Windows sandbox setup and fallback prompts with `HyperlinkText` so each wrapped URL fragment links to the complete destination. Strip OSC 8 sequences when rendering popup snapshots to keep assertions focused on visible text. ## Testing Add a regression test covering both prompts at 40 columns, asserting that every linked cell retains the complete destination and the visible link text remains intact. Include a snapshot of the wrapped setup prompt. GitOrigin-RevId: 98bd60f04ab3ec8d6552a0b74b9637cce26169d5
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
+28
@@ -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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user