Route cyber Trusted Access links by plan type (#40504)

## What changed

- Send `Free`, `Go`, `Plus`, `Pro`, and `ProLite` ChatGPT users to the individual Trusted Access page when a cybersecurity policy error ends a turn.
- Keep the enterprise Trusted Access application for other plans and sessions without a ChatGPT account or known plan.

## Testing

- Cover individual and enterprise link selection in chat widget tests and history-cell snapshots.

GitOrigin-RevId: a563560d15c401b47f1865a6f58ea4692d31d457
This commit is contained in:
Eric Traut
2026-08-25 00:29:54 +00:00
committed by copyberry
parent ebe18fc982
commit 80e871309a
5 changed files with 53 additions and 5 deletions

View File

@@ -104,9 +104,27 @@ async fn app_server_cyber_policy_error_renders_dedicated_notice() {
let rendered = lines_to_single_string(&cells[0]);
assert!(rendered.contains("This content can't be shown"));
assert!(rendered.contains("extra caution with cybersecurity requests"));
assert!(rendered.contains("openai.com/form/enterprise-trusted-access-for-cyber"));
assert!(!rendered.contains("server fallback message"));
}
#[tokio::test]
async fn app_server_cyber_policy_error_uses_individual_link_for_personal_plan() {
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
chat.plan_type = Some(PlanType::Free);
chat.has_chatgpt_account = true;
handle_error(
&mut chat,
"server fallback message",
Some(CodexErrorInfo::CyberPolicy),
);
let cells = drain_insert_history(&mut rx);
assert_eq!(cells.len(), 1);
assert!(lines_to_single_string(&cells[0]).contains("https://chatgpt.com/cyber/"));
}
#[tokio::test]
async fn app_server_model_verification_renders_warning() {
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;

View File

@@ -385,7 +385,12 @@ impl ChatWidget {
pub(super) fn on_cyber_policy_error(&mut self) {
self.input_queue.submit_pending_steers_after_interrupt = false;
self.finalize_turn();
self.add_to_history(history_cell::new_cyber_policy_error_event());
let plan_type = if self.has_chatgpt_account {
self.plan_type
} else {
None
};
self.add_to_history(history_cell::new_cyber_policy_error_event(plan_type));
self.request_redraw();
// After an error ends the turn, try sending the next queued input.

View File

@@ -93,6 +93,9 @@ pub(crate) struct SafetyAccessBlockCell {
const SAFETY_ACCESS_BLOCK_TITLE: &str = "This content can't be shown";
const SAFETY_ACCESS_BLOCK_LEARN_MORE_URL: &str = "https://help.openai.com/en/articles/20001326";
const CYBER_INDIVIDUAL_TRUSTED_ACCESS_URL: &str = "https://chatgpt.com/cyber/";
const CYBER_ENTERPRISE_TRUSTED_ACCESS_URL: &str =
"https://openai.com/form/enterprise-trusted-access-for-cyber/";
pub(crate) fn new_safety_access_block_event() -> SafetyAccessBlockCell {
SafetyAccessBlockCell {
@@ -101,10 +104,16 @@ pub(crate) fn new_safety_access_block_event() -> SafetyAccessBlockCell {
}
}
pub(crate) fn new_cyber_policy_error_event() -> SafetyAccessBlockCell {
pub(crate) fn new_cyber_policy_error_event(plan_type: Option<PlanType>) -> SafetyAccessBlockCell {
let trusted_access_url = match plan_type {
Some(
PlanType::Free | PlanType::Go | PlanType::Plus | PlanType::Pro | PlanType::ProLite,
) => CYBER_INDIVIDUAL_TRUSTED_ACCESS_URL,
_ => CYBER_ENTERPRISE_TRUSTED_ACCESS_URL,
};
SafetyAccessBlockCell {
body: "We take extra caution with cybersecurity requests. If youre a security professional, you may be able to apply for Trusted Access.",
trusted_access_url: "https://openai.com/form/enterprise-trusted-access-for-cyber/",
trusted_access_url,
}
}

View File

@@ -0,0 +1,9 @@
---
source: tui/src/history_cell/tests.rs
expression: rendered
---
ⓘ This content can't be shown
We take extra caution with cybersecurity requests. If youre a security
professional, you may be able to apply for Trusted Access.
Trusted Access: https://chatgpt.com/cyber/
Learn more: https://help.openai.com/en/articles/20001326

View File

@@ -752,7 +752,14 @@ fn ps_output_multiline_snapshot() {
#[test]
fn cyber_policy_error_event_snapshot() {
let cell = new_cyber_policy_error_event();
let cell = new_cyber_policy_error_event(/*plan_type*/ None);
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
insta::assert_snapshot!(rendered);
}
#[test]
fn cyber_policy_error_event_individual_snapshot() {
let cell = new_cyber_policy_error_event(Some(PlanType::Pro));
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
insta::assert_snapshot!(rendered);
}
@@ -766,7 +773,7 @@ fn safety_access_block_event_snapshot() {
#[test]
fn cyber_policy_error_event_narrow_snapshot() {
let cell = new_cyber_policy_error_event();
let cell = new_cyber_policy_error_event(/*plan_type*/ None);
let rendered = render_lines(&cell.display_lines(/*width*/ 36)).join("\n");
insta::assert_snapshot!(rendered);
}