Expose loaded thread environments in app-server responses (#42386)

## What changed

- Add the experimental `Thread.environments` field with each selected environment's ID, working directory, and runtime workspace roots.
- Populate the field from live thread state in start, resume, read, list, and unarchive responses. Use `null` for unloaded threads and an empty list when a loaded thread has no environment selection.
- Document that the field reports selection rather than connection status and does not affect executor selection or resume behavior.

## Testing

- Cover selection updates, unloaded and resumed threads, loaded pathless unarchives, and clients that subscribe after environment connection notifications.

GitOrigin-RevId: a6daa06aff7089d7c5a1e4c7d03109b41f12fa3c
This commit is contained in:
Anton Panasenko
2026-09-02 23:41:14 +00:00
committed by copyberry
parent cff76fa96f
commit 2b554fd3f9
42 changed files with 681 additions and 11 deletions
@@ -39,6 +39,7 @@ fn overview_thread(
status: ThreadStatus,
) -> Thread {
Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
project_id: None,
+1
View File
@@ -135,6 +135,7 @@ mod tests {
fn test_thread(thread_id: ThreadId, source: SessionSource) -> Thread {
Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),
+3
View File
@@ -4039,6 +4039,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
agent_thread_id,
ServerNotification::ThreadStarted(ThreadStartedNotification {
thread: Thread {
environments: None,
id: agent_thread_id.to_string(),
extra: None,
session_id: agent_thread_id.to_string(),
@@ -4140,6 +4141,7 @@ async fn inactive_thread_started_notification_preserves_primary_model_when_path_
agent_thread_id,
ServerNotification::ThreadStarted(ThreadStartedNotification {
thread: Thread {
environments: None,
id: agent_thread_id.to_string(),
extra: None,
session_id: agent_thread_id.to_string(),
@@ -4208,6 +4210,7 @@ async fn thread_read_session_state_does_not_reuse_primary_permission_profile() {
app.primary_session_configured = Some(primary_session);
let thread = Thread {
environments: None,
id: read_thread_id.to_string(),
extra: None,
session_id: read_thread_id.to_string(),
+1
View File
@@ -933,6 +933,7 @@ async fn known_thread_started_preserves_session_without_reading_unmaterialized_r
);
let notification = ThreadStartedNotification {
thread: Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),
@@ -410,6 +410,7 @@ mod tests {
..test_thread_session(primary_thread_id, test_path_buf("/tmp/primary"))
};
let read_thread = Thread {
environments: None,
id: read_thread_id.to_string(),
extra: None,
session_id: read_thread_id.to_string(),
+1
View File
@@ -3686,6 +3686,7 @@ mod tests {
let read_only_profile = PermissionProfile::read_only();
let response = ThreadResumeResponse {
thread: codex_app_server_protocol::Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: ThreadId::new().to_string(),
+4
View File
@@ -6266,6 +6266,7 @@ session_picker_view = "dense"
fn app_server_row_keeps_pathless_threads() {
let thread_id = ThreadId::new();
let thread = Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),
@@ -6310,6 +6311,7 @@ session_picker_view = "dense"
let thread_id = ThreadId::new();
let thread = Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),
@@ -6394,6 +6396,7 @@ session_picker_view = "dense"
let thread_id = ThreadId::new();
let thread = Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),
@@ -6469,6 +6472,7 @@ session_picker_view = "dense"
let thread_id = ThreadId::new();
let thread = Thread {
environments: None,
id: thread_id.to_string(),
extra: None,
session_id: thread_id.to_string(),