Report selected environment connection transitions (#33251)

## What changed

- Track connected and disconnected states across initial remote exec-server connections and reconnection attempts.
- Emit experimental `thread/environment/connected` and `thread/environment/disconnected` app-server notifications for each thread selecting the environment. Each payload identifies the thread and environment; current state is not replayed when a thread starts.
- Stop forwarding connection events when an environment selection is removed or replaced.

## Testing

- Cover connection, disconnection, reconnection, shared-environment notifications, and replacement of a selected environment.

GitOrigin-RevId: 5dd767372363c4a2a8319fc16164be117d5bd20c
This commit is contained in:
sayan-oai
2026-07-15 05:21:13 +00:00
committed by copyberry
parent 8aae858958
commit 3afbd8dd45
28 changed files with 672 additions and 32 deletions
@@ -22,6 +22,7 @@ use codex_app_server_protocol::CommandExecutionSource;
use codex_app_server_protocol::CommandExecutionStatus;
use codex_app_server_protocol::DeprecationNoticeNotification;
use codex_app_server_protocol::DynamicToolCallParams;
use codex_app_server_protocol::EnvironmentConnectionNotification;
use codex_app_server_protocol::ErrorNotification;
use codex_app_server_protocol::ExecPolicyAmendment as V2ExecPolicyAmendment;
use codex_app_server_protocol::FileChangeApprovalDecision;
@@ -225,6 +226,26 @@ pub(crate) async fn apply_bespoke_event_handling(
.send_server_notification(ServerNotification::McpServerStatusUpdated(notification))
.await;
}
EventMsg::EnvironmentConnected(event) => {
outgoing
.send_server_notification(ServerNotification::EnvironmentConnected(
EnvironmentConnectionNotification {
thread_id: conversation_id.to_string(),
environment_id: event.environment_id,
},
))
.await;
}
EventMsg::EnvironmentDisconnected(event) => {
outgoing
.send_server_notification(ServerNotification::EnvironmentDisconnected(
EnvironmentConnectionNotification {
thread_id: conversation_id.to_string(),
environment_id: event.environment_id,
},
))
.await;
}
EventMsg::Warning(warning_event) => {
let notification = WarningNotification {
thread_id: Some(conversation_id.to_string()),