mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Tailor TUI cyber refusal notices to Daybreak eligibility (#42667)
## What changed - Prefetch ChatGPT account eligibility in the background and cache it across TUI widget replacements. - Show an application link when Daybreak is available but not enabled, an Astra-specific explanation for unsupported models, and neutral copy when access is already present or eligibility cannot be determined. - Refresh eligibility after account changes and reconnects without changing the selected model or delaying refusal handling. ## Testing - Cover eligibility responses, account changes, model-specific notices, fallback behavior, and rendered notice snapshots. GitOrigin-RevId: 7ae8613a946cb46b8f0b46bf47e5e15ae258ed86
This commit is contained in:
1 parent
a7ab2d66d7
commit
ff2f01b0c2
21 files changed
+469
-80
No files matched your search
@@ -90,33 +90,55 @@ pub(crate) fn new_warning_event(message: String) -> PrefixedWrappedHistoryCell {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct SafetyAccessBlockCell {
|
||||
title: &'static str,
|
||||
body: &'static str,
|
||||
trusted_access_url: &'static str,
|
||||
actions: &'static [(&'static str, &'static str)],
|
||||
}
|
||||
|
||||
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 {
|
||||
title: "This content can't be shown",
|
||||
body: "We take extra caution with requests involving biological research and applications that could pose safety risks. Eligible researchers can apply for Trusted Access.",
|
||||
trusted_access_url: "https://chatgpt.com/r/b749fb02595e04c3007a54375f3f4374",
|
||||
actions: &[
|
||||
(
|
||||
"Trusted Access",
|
||||
"https://chatgpt.com/r/b749fb02595e04c3007a54375f3f4374",
|
||||
),
|
||||
("Learn more", SAFETY_ACCESS_BLOCK_LEARN_MORE_URL),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
pub(crate) fn new_cyber_policy_error_event(
|
||||
notice: crate::daybreak::Notice,
|
||||
) -> SafetyAccessBlockCell {
|
||||
use crate::daybreak::Notice;
|
||||
let (body, actions): (_, &'static [(&str, &str)]) = match notice {
|
||||
Notice::Apply => (
|
||||
"We take extra care with some cybersecurity requests. If you’re doing authorized security work, apply for Daybreak to get broader access.",
|
||||
&[
|
||||
("Learn more", SAFETY_ACCESS_BLOCK_LEARN_MORE_URL),
|
||||
(
|
||||
"Apply for Daybreak",
|
||||
"https://openai.com/form/enterprise-trusted-access-for-cyber/",
|
||||
),
|
||||
],
|
||||
),
|
||||
Notice::Astra => (
|
||||
"Daybreak isn’t available for Astra. Some cybersecurity requests may still be limited.",
|
||||
&[("Learn more", SAFETY_ACCESS_BLOCK_LEARN_MORE_URL)],
|
||||
),
|
||||
Notice::Limited => (
|
||||
"We take extra care with some cybersecurity requests.",
|
||||
&[("Learn more", SAFETY_ACCESS_BLOCK_LEARN_MORE_URL)],
|
||||
),
|
||||
};
|
||||
SafetyAccessBlockCell {
|
||||
body: "We take extra caution with cybersecurity requests. If you’re a security professional, you may be able to apply for Trusted Access.",
|
||||
trusted_access_url,
|
||||
title: "This content can’t be shown",
|
||||
body,
|
||||
actions,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +149,7 @@ impl HistoryCell for SafetyAccessBlockCell {
|
||||
|
||||
fn display_hyperlink_lines(&self, width: u16) -> Vec<HyperlinkLine> {
|
||||
let mut lines = vec![HyperlinkLine::new(
|
||||
vec!["ⓘ ".cyan(), SAFETY_ACCESS_BLOCK_TITLE.bold()].into(),
|
||||
vec!["ⓘ ".cyan(), self.title.bold()].into(),
|
||||
)];
|
||||
let body = Line::from(vec![" ".into(), self.body.dim()]);
|
||||
let wrap_width = width.saturating_sub(2).max(1) as usize;
|
||||
@@ -139,10 +161,7 @@ impl HistoryCell for SafetyAccessBlockCell {
|
||||
push_owned_lines(&wrapped, &mut wrapped_body);
|
||||
lines.extend(plain_hyperlink_lines(wrapped_body));
|
||||
|
||||
for (label, url) in [
|
||||
("Trusted Access", self.trusted_access_url),
|
||||
("Learn more", SAFETY_ACCESS_BLOCK_LEARN_MORE_URL),
|
||||
] {
|
||||
for &(label, url) in self.actions {
|
||||
let source = crate::terminal_hyperlinks::annotate_web_urls_in_line(
|
||||
vec![format!(" {label}: ").dim(), url.cyan().underlined()].into(),
|
||||
);
|
||||
@@ -161,13 +180,13 @@ impl HistoryCell for SafetyAccessBlockCell {
|
||||
}
|
||||
|
||||
fn raw_lines(&self) -> Vec<Line<'static>> {
|
||||
let trusted_access_url = self.trusted_access_url;
|
||||
vec![
|
||||
Line::from(SAFETY_ACCESS_BLOCK_TITLE),
|
||||
Line::from(self.body),
|
||||
Line::from(format!("Trusted Access: {trusted_access_url}")),
|
||||
Line::from(format!("Learn more: {SAFETY_ACCESS_BLOCK_LEARN_MORE_URL}")),
|
||||
]
|
||||
let mut lines = vec![Line::from(self.title), Line::from(self.body)];
|
||||
lines.extend(
|
||||
self.actions
|
||||
.iter()
|
||||
.map(|(label, target)| Line::from(format!("{label}: {target}"))),
|
||||
);
|
||||
lines
|
||||
}
|
||||
|
||||
fn transcript_hyperlink_lines(&self, width: u16) -> Vec<HyperlinkLine> {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
source: tui/src/history_cell/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
ⓘ This content can’t be shown
|
||||
Daybreak isn’t available for Astra. Some cybersecurity requests may still be
|
||||
limited.
|
||||
Learn more: https://help.openai.com/en/articles/20001326
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
---
|
||||
source: tui/src/history_cell/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
ⓘ This content can't be shown
|
||||
We take extra caution with cybersecurity requests. If you’re 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
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tui/src/history_cell/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
ⓘ This content can’t be shown
|
||||
We take extra care with some cybersecurity requests.
|
||||
Learn more: https://help.openai.com/en/articles/20001326
|
||||
+9
-8
@@ -1,16 +1,17 @@
|
||||
---
|
||||
source: tui/src/history_cell/tests.rs
|
||||
assertion_line: 821
|
||||
expression: rendered
|
||||
---
|
||||
ⓘ This content can't be shown
|
||||
We take extra caution with
|
||||
ⓘ This content can’t be shown
|
||||
We take extra care with some
|
||||
cybersecurity requests. If
|
||||
you’re a security professional,
|
||||
you may be able to apply for
|
||||
Trusted Access.
|
||||
Trusted Access: https://
|
||||
openai.com/form/enterprise-
|
||||
trusted-access-for-cyber/
|
||||
you’re doing authorized security
|
||||
work, apply for Daybreak to get
|
||||
broader access.
|
||||
Learn more: https://
|
||||
help.openai.com/en/
|
||||
articles/20001326
|
||||
Apply for Daybreak: https://
|
||||
openai.com/form/enterprise-
|
||||
trusted-access-for-cyber/
|
||||
+7
-6
@@ -1,10 +1,11 @@
|
||||
---
|
||||
source: tui/src/history_cell.rs
|
||||
assertion_line: 3305
|
||||
source: tui/src/history_cell/tests.rs
|
||||
assertion_line: 774
|
||||
expression: rendered
|
||||
---
|
||||
ⓘ This content can't be shown
|
||||
We take extra caution with cybersecurity requests. If you’re a security
|
||||
professional, you may be able to apply for Trusted Access.
|
||||
Trusted Access: https://openai.com/form/enterprise-trusted-access-for-cyber/
|
||||
ⓘ This content can’t be shown
|
||||
We take extra care with some cybersecurity requests. If you’re doing
|
||||
authorized security work, apply for Daybreak to get broader access.
|
||||
Learn more: https://help.openai.com/en/articles/20001326
|
||||
Apply for Daybreak: https://openai.com/form/enterprise-trusted-access-for-
|
||||
cyber/
|
||||
@@ -769,14 +769,21 @@ fn ps_output_multiline_snapshot() {
|
||||
|
||||
#[test]
|
||||
fn cyber_policy_error_event_snapshot() {
|
||||
let cell = new_cyber_policy_error_event(/*plan_type*/ None);
|
||||
let cell = new_cyber_policy_error_event(crate::daybreak::Notice::Apply);
|
||||
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));
|
||||
fn cyber_policy_error_event_astra_snapshot() {
|
||||
let cell = new_cyber_policy_error_event(crate::daybreak::Notice::Astra);
|
||||
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
|
||||
insta::assert_snapshot!(rendered);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cyber_policy_error_event_limited_snapshot() {
|
||||
let cell = new_cyber_policy_error_event(crate::daybreak::Notice::Limited);
|
||||
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
|
||||
insta::assert_snapshot!(rendered);
|
||||
}
|
||||
@@ -790,7 +797,7 @@ fn safety_access_block_event_snapshot() {
|
||||
|
||||
#[test]
|
||||
fn cyber_policy_error_event_narrow_snapshot() {
|
||||
let cell = new_cyber_policy_error_event(/*plan_type*/ None);
|
||||
let cell = new_cyber_policy_error_event(crate::daybreak::Notice::Apply);
|
||||
let rendered = render_lines(&cell.display_lines(/*width*/ 36)).join("\n");
|
||||
insta::assert_snapshot!(rendered);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user