Use the shared HTTP client for announcement tips (#35825)

## Why

Announcement prewarming disabled proxy discovery to avoid the macOS sandbox
panic fixed by https://github.com/openai/codex/pull/16670.

## What changed

- Fetch announcement tips asynchronously with `RouteAwareClientPool` instead
  of a blocking `reqwest` client.
- Pass the configured `HttpClientFactory` into prewarming so announcement
  requests honor the configured outbound proxy policy.

GitOrigin-RevId: 535158d95a99c6f515bd30ea6e3bcb2ac6bb6d7e
This commit is contained in:
Celia Chen
2026-07-28 20:12:13 +00:00
committed by copyberry
parent 8bbdf6c8f9
commit 155c3e299c
2 changed files with 16 additions and 18 deletions
+1 -1
View File
@@ -1341,7 +1341,7 @@ async fn run_ratatui_app(
let uses_remote_workspace = app_server_target.uses_remote_workspace();
color_eyre::install()?;
tooltips::announcement::prewarm();
tooltips::announcement::prewarm(initial_config.http_client_factory());
// Forward panic reports through tracing so they appear in the UI status
// line, but do not swallow the default/color-eyre panic handler.
+15 -17
View File
@@ -125,19 +125,27 @@ pub(crate) mod announcement {
use crate::version::CODEX_CLI_VERSION;
use chrono::NaiveDate;
use chrono::Utc;
use codex_http_client::ClientRouteClass;
use codex_http_client::HttpClientFactory;
use codex_http_client::RouteAwareClientPool;
use codex_protocol::account::PlanType;
use regex_lite::Regex;
use serde::Deserialize;
use std::sync::OnceLock;
use std::thread;
use std::time::Duration;
static ANNOUNCEMENT_TIP: OnceLock<Option<String>> = OnceLock::new();
const CURRENT_OS: TargetOs = TargetOs::current();
/// Prewarm the cache of the announcement tip.
pub(crate) fn prewarm() {
let _ = thread::spawn(|| ANNOUNCEMENT_TIP.get_or_init(init_announcement_tip_in_thread));
pub(crate) fn prewarm(http_client_factory: HttpClientFactory) {
if ANNOUNCEMENT_TIP.get().is_some() {
return;
}
tokio::spawn(async move {
let announcement_tip = fetch_announcement_tip_text(http_client_factory).await;
let _ = ANNOUNCEMENT_TIP.set(announcement_tip);
});
}
/// Fetch the announcement tip, return None if the prewarm is not done yet.
@@ -199,25 +207,15 @@ pub(crate) mod announcement {
}
}
fn init_announcement_tip_in_thread() -> Option<String> {
thread::spawn(blocking_init_announcement_tip)
.join()
.ok()
.flatten()
}
fn blocking_init_announcement_tip() -> Option<String> {
// Avoid system proxy detection to prevent macOS system-configuration panics (#8912).
let client = reqwest::blocking::Client::builder()
.no_proxy()
.build()
.ok()?;
async fn fetch_announcement_tip_text(http_client_factory: HttpClientFactory) -> Option<String> {
let client = RouteAwareClientPool::new(http_client_factory, ClientRouteClass::Other);
let response = client
.get(ANNOUNCEMENT_TIP_URL)
.timeout(Duration::from_millis(2000))
.send()
.await
.ok()?;
response.error_for_status().ok()?.text().ok()
response.error_for_status().ok()?.text().await.ok()
}
pub(crate) fn parse_announcement_tip_toml(