Surface model provider authentication recovery progress (#41239)

## What changed

- Emit turn-scoped authentication recovery started and completed events when a model provider refreshes expired credentials.
- Add stable `modelProvider/authRecoveryStarted` and `modelProvider/authRecoveryCompleted` app-server notifications with the thread, turn, provider, and user-facing message.
- Show recovery progress in the TUI and `codex exec`, including Amazon Bedrock session reauthentication.

## Testing

- Cover provider recovery success and failure events, app-server routing, client rendering, and Amazon Bedrock credential refresh.

GitOrigin-RevId: 3010c38d0676f18bced27761cf86dd38344d09f9
This commit is contained in:
alexsong-oai authored and copyberry committed 2026-08-28 01:14:02 +00:00
1 parent f1bb4c168d
commit 41d3dc56a0
33 files changed
+611 -11

No files matched your search

@@ -13,6 +13,7 @@ use crate::thread_status::ThreadWatchActiveGuard;
use crate::thread_status::ThreadWatchManager;
use codex_app_server_protocol::AccountRateLimitsUpdatedNotification;
use codex_app_server_protocol::AdditionalPermissionProfile as V2AdditionalPermissionProfile;
use codex_app_server_protocol::AuthRecoveryNotification;
use codex_app_server_protocol::CodexErrorInfo as V2CodexErrorInfo;
use codex_app_server_protocol::CommandAction as V2ParsedCommand;
use codex_app_server_protocol::CommandExecutionApprovalDecision;
@@ -252,6 +253,30 @@ pub(crate) async fn apply_bespoke_event_handling(
))
.await;
}
EventMsg::AuthRecoveryStarted(event) => {
outgoing
.send_server_notification(ServerNotification::AuthRecoveryStarted(
AuthRecoveryNotification {
thread_id: conversation_id.to_string(),
turn_id: event_turn_id,
provider: event.provider,
message: event.message,
},
))
.await;
}
EventMsg::AuthRecoveryCompleted(event) => {
outgoing
.send_server_notification(ServerNotification::AuthRecoveryCompleted(
AuthRecoveryNotification {
thread_id: conversation_id.to_string(),
turn_id: event_turn_id,
provider: event.provider,
message: event.message,
},
))
.await;
}
EventMsg::Warning(warning_event) => {
let notification = WarningNotification {
thread_id: Some(conversation_id.to_string()),
@@ -2180,6 +2205,7 @@ mod tests {
use codex_protocol::plan_tool::StepStatus;
use codex_protocol::protocol::AgentMessageEvent;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::AuthRecoveryEvent;
use codex_protocol::protocol::CreditsSnapshot;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::GuardianAssessmentEvent;
@@ -3418,11 +3444,11 @@ mod tests {
}),
},
conversation_id,
conversation,
thread_manager,
outgoing,
thread_state,
thread_watch_manager,
Arc::clone(&conversation),
Arc::clone(&thread_manager),
outgoing.clone(),
Arc::clone(&thread_state),
thread_watch_manager.clone(),
Arc::new(tokio::sync::Semaphore::new(/*permits*/ 1)),
"test-provider".to_string(),
)
@@ -3437,6 +3463,52 @@ mod tests {
}
other => bail!("unexpected message: {other:?}"),
}
for (phase, method, event) in [
(
"started",
"modelProvider/authRecoveryStarted",
EventMsg::AuthRecoveryStarted as fn(AuthRecoveryEvent) -> EventMsg,
),
(
"completed",
"modelProvider/authRecoveryCompleted",
EventMsg::AuthRecoveryCompleted,
),
] {
let message = format!("Authentication recovery {phase}.");
apply_bespoke_event_handling(
Event {
id: "turn-1".to_string(),
msg: event(AuthRecoveryEvent {
provider: "test-provider".to_string(),
message: message.clone(),
}),
},
conversation_id,
Arc::clone(&conversation),
Arc::clone(&thread_manager),
outgoing.clone(),
Arc::clone(&thread_state),
thread_watch_manager.clone(),
Arc::new(tokio::sync::Semaphore::new(/*permits*/ 1)),
"test-provider".to_string(),
)
.await;
assert_eq!(
serde_json::to_value(recv_broadcast_notification(&mut rx).await?)?,
json!({
"method": method,
"params": {
"threadId": conversation_id.to_string(),
"turnId": "turn-1",
"provider": "test-provider",
"message": message,
}
})
);
}
Ok(())
}