From b15718acfc5e79dff8cc8999eada7c80df9c85cb Mon Sep 17 00:00:00 2001 From: felixxia-oai Date: Thu, 24 Sep 2026 12:16:56 +0000 Subject: [PATCH] Wait for login completion in recommended plugin tests (#47828) ## Why Login clears the recommendation cache after its RPC response, allowing thread startup to race with cache invalidation in the external login tests. ## What changed Wait for `account/login/completed` and assert a successful notification before starting the thread. This keeps thread startup and the background refresh on the same cache generation in both variants of the recommended plugin test, with `tool_suggest` enabled and disabled. GitOrigin-RevId: 7be46dacd947b30a28c83176dc2e3b5f730005f1 --- .../tests/suite/v2/recommended_plugins.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/codex-rs/app-server/tests/suite/v2/recommended_plugins.rs b/codex-rs/app-server/tests/suite/v2/recommended_plugins.rs index eab39bba8f..0d8ddf5ac7 100644 --- a/codex-rs/app-server/tests/suite/v2/recommended_plugins.rs +++ b/codex-rs/app-server/tests/suite/v2/recommended_plugins.rs @@ -1,12 +1,15 @@ use anyhow::Result; +use anyhow::bail; use app_test_support::ChatGptIdTokenClaims; use app_test_support::TestAppServer; use app_test_support::encode_id_token; use app_test_support::to_response; use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url; +use codex_app_server_protocol::AccountLoginCompletedNotification; use codex_app_server_protocol::JSONRPCResponse; use codex_app_server_protocol::LoginAccountResponse; use codex_app_server_protocol::RequestId; +use codex_app_server_protocol::ServerNotification; use codex_app_server_protocol::ThreadStartParams; use codex_app_server_protocol::ThreadStartResponse; use codex_app_server_protocol::TurnStartParams; @@ -127,6 +130,26 @@ async fn recommended_plugins_after_external_login( LoginAccountResponse::ChatgptAuthTokens {} ); + // Login clears the recommendation cache after its RPC response. Wait for completion so + // thread startup and the background refresh share the same cache generation. + let notification = timeout( + DEFAULT_READ_TIMEOUT, + app_server.read_stream_until_notification_message("account/login/completed"), + ) + .await??; + let ServerNotification::AccountLoginCompleted(payload) = notification.try_into()? else { + bail!("unexpected notification") + }; + assert_eq!( + payload, + AccountLoginCompletedNotification { + login_id: None, + success: true, + error: None, + onboarding_entrypoint: None, + } + ); + let thread_id = app_server .send_thread_start_request_with_auto_env(ThreadStartParams { model: Some("mock-model".to_string()),