Show the selected ChatGPT workspace in /status (#57366)

## What changed

- Return the selected workspace's display name as `workspaceName` in ChatGPT account responses, caching it alongside workspace routing and updating generated schemas and bindings.
- Display a `ChatGPT workspace` row with the name and account ID, falling back to the ID when the name is unavailable or invalid. Refresh workspace details with account identity updates and hide the row for providers that do not use ChatGPT authentication.

## Testing

Update account-response tests to cover workspace names and null values, add workspace details to the status snapshot, and verify that switching to a custom API-key provider hides the workspace row.

GitOrigin-RevId: 4b30ab8a39e1fa7ad1ba7367c5295544be8f6001
This commit is contained in:
Eric Traut
2026-10-27 05:22:23 +00:00
committed by copyberry
parent 6c0db39b94
commit 155dde7ff6
26 changed files with 216 additions and 38 deletions
@@ -37,17 +37,20 @@ pub(super) type WorkspaceRoutingFetches = HashMap<WorkspaceRoutingKey, Weak<Work
pub(super) struct WorkspaceRoutingFetch {
discovery: Semaphore,
routing: Mutex<Option<WorkspaceRouting>>,
routing: Mutex<Option<CachedWorkspaceRouting>>,
}
#[derive(Clone)]
pub(super) struct CachedWorkspaceRouting {
key: WorkspaceRoutingKey,
routing: WorkspaceRouting,
name: Option<String>,
}
pub(super) struct AccountRead {
account_state: ProviderAccountState,
pub(super) workspace_routing: Option<WorkspaceRouting>,
workspace_name: Option<String>,
}
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
@@ -264,9 +267,13 @@ impl AccountRequestProcessor {
AccountReadError::InvalidAccount(error) => invalid_request(error.to_string()),
AccountReadError::Routing(error) => internal_error(error.to_string()),
})?;
let mut account = read.account_state.account.map(Account::from);
if let Some(Account::Chatgpt { workspace_name, .. }) = &mut account {
*workspace_name = read.workspace_name;
}
Ok(Some(
GetAccountResponse {
account: read.account_state.account.map(Account::from),
account,
requires_openai_auth: read.account_state.requires_openai_auth,
workspace_routing: read.workspace_routing.map(|routing| {
codex_app_server_protocol::WorkspaceRouting {
@@ -387,7 +394,7 @@ impl AccountRequestProcessor {
.await
.as_ref()
.filter(|cached| cached.key == key)
.map(|cached| cached.routing.clone()),
.cloned(),
};
let routing = if let Some(cached) = cached {
cached
@@ -450,7 +457,7 @@ impl AccountRequestProcessor {
.accounts
.into_iter()
.filter(|account| account.id == account_id);
let entry = accounts
let mut entry = accounts
.next()
.ok_or(WorkspaceRoutingError::MissingWorkspace)?;
if accounts.next().is_some() {
@@ -471,6 +478,7 @@ impl AccountRequestProcessor {
{
return Err(WorkspaceRoutingError::ConfigurationChanged.into());
}
let name = entry.name.take();
let routing = resolve_routing(
entry,
required_chatgpt_base_url.as_deref(),
@@ -481,15 +489,17 @@ impl AccountRequestProcessor {
{
return Err(WorkspaceRoutingError::AccountChanged.into());
}
let routing = CachedWorkspaceRouting {
key: WorkspaceRoutingKey {
auth_generation: discovery_generation,
..key
},
routing,
name,
};
// Same-owner refresh can complete a newer discovery first.
if current_auth_changes.borrow().generation == discovery_generation {
*cached = Some(CachedWorkspaceRouting {
key: WorkspaceRoutingKey {
auth_generation: discovery_generation,
..key
},
routing: routing.clone(),
});
*cached = Some(routing.clone());
}
routing
};
@@ -509,9 +519,9 @@ impl AccountRequestProcessor {
let session_bootstrap_origin = Url::parse(&request.chatgpt_base_url)
.map_err(|_| WorkspaceRoutingError::InvalidSessionBootstrapUrl)?
.origin();
let selected_backend = workspace_routing
.as_ref()
.is_some_and(|routing| routing.backend_origin == origin.ascii_serialization());
let selected_backend = workspace_routing.as_ref().is_some_and(|routing| {
routing.routing.backend_origin == origin.ascii_serialization()
});
let workspace_bound = request.previously_routed
|| request.provider_base_url == codex_model_provider::CHATGPT_CODEX_BASE_URL
|| origin == session_bootstrap_origin
@@ -522,9 +532,13 @@ impl AccountRequestProcessor {
return Err(WorkspaceRoutingError::SessionBackendChanged.into());
}
}
let (workspace_routing, workspace_name) = workspace_routing
.map(|workspace| (Some(workspace.routing), workspace.name))
.unwrap_or_default();
Ok(AccountRead {
account_state,
workspace_routing,
workspace_name,
})
});
let result = tokio::select! {