[codex-cli][app-server] Update self-serve business usage limit copy in error returned (#15478)

## Summary
- update the self-serve business usage-based limit message to direct
users to their admin for additional credits
- add a focused unit test for the self_serve_business_usage_based plan
branch

Added also: 

If you are at a rate limit but you still have credits, codex cli would
tell you to switch the model. We shouldnt do this if you have credits so
fixed this.

## Test
- launched the source-built CLI and verified the updated message is
shown for the self-serve business usage-based plan

![Test
screenshot](https://raw.githubusercontent.com/openai/codex/5cc3c013ef17ac5c66dfd9395c0d3c4837602231/docs/images/self-serve-business-usage-limit.png)
This commit is contained in:
dhruvgupta-oai
2026-03-24 00:41:38 -04:00
committed by GitHub
parent 431af0807c
commit c2410060ea
12 changed files with 129 additions and 179 deletions

View File

@@ -139,23 +139,27 @@ trust_level = "trusted"
let mut exit_rx = exit_rx;
let writer_tx = session.writer_sender();
let interrupt_writer = writer_tx.clone();
let interrupt_task = tokio::spawn(async move {
sleep(Duration::from_secs(2)).await;
for _ in 0..4 {
let _ = interrupt_writer.send(vec![3]).await;
sleep(Duration::from_millis(500)).await;
}
});
let mut startup_ready = false;
let mut answered_cursor_query = false;
let exit_code_result = timeout(Duration::from_secs(15), async {
loop {
select! {
result = output_rx.recv() => match result {
Ok(chunk) => {
if chunk.windows(4).any(|window| window == b"\x1b[6n") {
let has_cursor_query = chunk.windows(4).any(|window| window == b"\x1b[6n");
if has_cursor_query {
let _ = writer_tx.send(b"\x1b[1;1R".to_vec()).await;
answered_cursor_query = true;
}
output.extend_from_slice(&chunk);
if !startup_ready && answered_cursor_query && !has_cursor_query {
startup_ready = true;
for _ in 0..4 {
let _ = interrupt_writer.send(vec![3]).await;
sleep(Duration::from_millis(500)).await;
}
}
}
Err(tokio::sync::broadcast::error::RecvError::Closed) => break exit_rx.await,
Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => {}
@@ -166,8 +170,6 @@ trust_level = "trusted"
})
.await;
interrupt_task.abort();
let exit_code = match exit_code_result {
Ok(Ok(code)) => code,
Ok(Err(err)) => return Err(err.into()),