mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
Revert "Option to Notify Workspace Owner When Usage Limit is Reached" (#17391)
Reverts openai/codex#16969 #sev3-2026-04-10-accountscheckversion-500s-for-openai-workspace-7300
This commit is contained in:
1 parent
a3be74143a
commit
930e5adb7e
82 files changed
+60
-3233
No files matched your search
@@ -130,8 +130,6 @@ async fn helpers_are_available_and_do_not_panic() {
|
||||
feedback: codex_feedback::CodexFeedback::new(),
|
||||
is_first_run: true,
|
||||
status_account_display: None,
|
||||
initial_workspace_role: None,
|
||||
initial_is_workspace_owner: None,
|
||||
initial_plan_type: None,
|
||||
model: Some(resolved_model),
|
||||
startup_tooltip_override: None,
|
||||
@@ -236,7 +234,6 @@ async fn rate_limit_snapshot_keeps_prior_credits_when_missing_from_headers() {
|
||||
unlimited: false,
|
||||
balance: Some("17.5".to_string()),
|
||||
}),
|
||||
spend_control: None,
|
||||
plan_type: None,
|
||||
}));
|
||||
let initial_balance = chat
|
||||
@@ -256,7 +253,6 @@ async fn rate_limit_snapshot_keeps_prior_credits_when_missing_from_headers() {
|
||||
}),
|
||||
secondary: None,
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: None,
|
||||
}));
|
||||
|
||||
@@ -295,7 +291,6 @@ async fn rate_limit_snapshot_updates_and_retains_plan_type() {
|
||||
resets_at: None,
|
||||
}),
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: Some(PlanType::Plus),
|
||||
}));
|
||||
assert_eq!(chat.plan_type, Some(PlanType::Plus));
|
||||
@@ -314,7 +309,6 @@ async fn rate_limit_snapshot_updates_and_retains_plan_type() {
|
||||
resets_at: Some(234),
|
||||
}),
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: Some(PlanType::Pro),
|
||||
}));
|
||||
assert_eq!(chat.plan_type, Some(PlanType::Pro));
|
||||
@@ -333,7 +327,6 @@ async fn rate_limit_snapshot_updates_and_retains_plan_type() {
|
||||
resets_at: Some(567),
|
||||
}),
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: None,
|
||||
}));
|
||||
assert_eq!(chat.plan_type, Some(PlanType::Pro));
|
||||
@@ -357,7 +350,6 @@ async fn rate_limit_snapshots_keep_separate_entries_per_limit_id() {
|
||||
unlimited: false,
|
||||
balance: Some("5.00".to_string()),
|
||||
}),
|
||||
spend_control: None,
|
||||
plan_type: Some(PlanType::Pro),
|
||||
}));
|
||||
|
||||
@@ -371,7 +363,6 @@ async fn rate_limit_snapshots_keep_separate_entries_per_limit_id() {
|
||||
}),
|
||||
secondary: None,
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: Some(PlanType::Pro),
|
||||
}));
|
||||
|
||||
@@ -396,101 +387,6 @@ async fn rate_limit_snapshots_keep_separate_entries_per_limit_id() {
|
||||
assert!(other.credits.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn core_usage_limit_error_shows_notify_owner_hint() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.update_account_state(
|
||||
/*status_account_display*/ None,
|
||||
/*workspace_role*/ None,
|
||||
Some(false),
|
||||
Some(PlanType::SelfServeBusinessUsageBased),
|
||||
/*has_chatgpt_account*/ true,
|
||||
);
|
||||
chat.on_rate_limit_snapshot(Some(RateLimitSnapshot {
|
||||
limit_id: Some("codex".to_string()),
|
||||
limit_name: Some("codex".to_string()),
|
||||
primary: None,
|
||||
secondary: None,
|
||||
credits: Some(CreditsSnapshot {
|
||||
has_credits: false,
|
||||
unlimited: false,
|
||||
balance: None,
|
||||
}),
|
||||
spend_control: None,
|
||||
plan_type: Some(PlanType::SelfServeBusinessUsageBased),
|
||||
}));
|
||||
|
||||
chat.handle_codex_event(Event {
|
||||
id: "usage-limit".to_string(),
|
||||
msg: EventMsg::Error(ErrorEvent {
|
||||
message: "The usage limit has been reached".to_string(),
|
||||
codex_error_info: Some(CodexErrorInfo::UsageLimitExceeded),
|
||||
}),
|
||||
});
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
assert_eq!(cells.len(), 1);
|
||||
let rendered = lines_to_single_string(&cells[0]);
|
||||
assert!(
|
||||
rendered.contains("Your workspace is out of credits."),
|
||||
"expected usage-limit error, got {rendered:?}"
|
||||
);
|
||||
assert!(
|
||||
rendered.contains("Request more from your workspace owner? [y/N]"),
|
||||
"expected workspace-owner prompt, got {rendered:?}"
|
||||
);
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 80);
|
||||
assert!(
|
||||
popup.contains("Request more credits from your workspace owner?"),
|
||||
"expected workspace-owner confirmation popup, got {popup:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn core_usage_limit_error_shows_spend_cap_hint_when_reached() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.update_account_state(
|
||||
/*status_account_display*/ None,
|
||||
/*workspace_role*/ None,
|
||||
Some(false),
|
||||
Some(PlanType::SelfServeBusinessUsageBased),
|
||||
/*has_chatgpt_account*/ true,
|
||||
);
|
||||
chat.on_rate_limit_snapshot(Some(RateLimitSnapshot {
|
||||
limit_id: Some("codex".to_string()),
|
||||
limit_name: Some("codex".to_string()),
|
||||
primary: None,
|
||||
secondary: None,
|
||||
credits: Some(CreditsSnapshot {
|
||||
has_credits: true,
|
||||
unlimited: false,
|
||||
balance: None,
|
||||
}),
|
||||
spend_control: Some(codex_protocol::protocol::SpendControlSnapshot { reached: true }),
|
||||
plan_type: Some(PlanType::SelfServeBusinessUsageBased),
|
||||
}));
|
||||
|
||||
chat.handle_codex_event(Event {
|
||||
id: "usage-limit".to_string(),
|
||||
msg: EventMsg::Error(ErrorEvent {
|
||||
message: "The usage limit has been reached".to_string(),
|
||||
codex_error_info: Some(CodexErrorInfo::UsageLimitExceeded),
|
||||
}),
|
||||
});
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
assert_eq!(cells.len(), 1);
|
||||
let rendered = lines_to_single_string(&cells[0]);
|
||||
assert!(
|
||||
rendered.contains("Your workspace has reached its spend cap."),
|
||||
"expected spend-cap hint, got {rendered:?}"
|
||||
);
|
||||
assert!(
|
||||
!rendered.contains("Request more from your workspace owner? [y/N]"),
|
||||
"expected spend-cap hint instead of workspace-owner prompt, got {rendered:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rate_limit_switch_prompt_skips_when_on_lower_cost_model() {
|
||||
let (mut chat, _, _) = make_chatwidget_manual(Some(NUDGE_MODEL_SLUG)).await;
|
||||
@@ -519,7 +415,6 @@ async fn rate_limit_switch_prompt_skips_non_codex_limit() {
|
||||
}),
|
||||
secondary: None,
|
||||
credits: None,
|
||||
spend_control: None,
|
||||
plan_type: None,
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user