Use lightweight settings for app-server thread metadata (#63990)

## Why

Enriching loaded thread results builds a full configuration snapshot,
including an execution permission profile, just to read display settings.

## What changed

Read the configured model, reasoning effort, environment selections, and
session source directly from the loaded thread when enriching results.
The environment data still includes the working directory and runtime
workspace roots.

## Testing

Extend the core test to verify that reading display settings matches the
configured snapshot's display fields without triggering a model lookup.
Extend the app-server test to verify that thread reads and lists return
explicit runtime workspace roots.

GitOrigin-RevId: f7053554fdb0f02bebb51b4cafda2ef39e6e81a5
This commit is contained in:
Charlie Marsh
2026-11-25 22:40:22 +00:00
committed by copyberry
parent ceed625df9
commit a089ec6a93
7 changed files with 113 additions and 13 deletions
+20 -5
View File
@@ -209,6 +209,7 @@ use codex_app_server_protocol::ThreadDecrementElicitationResponse;
use codex_app_server_protocol::ThreadDeleteParams;
use codex_app_server_protocol::ThreadDeleteResponse;
use codex_app_server_protocol::ThreadDeletedNotification;
use codex_app_server_protocol::ThreadEnvironment;
use codex_app_server_protocol::ThreadForkParams;
use codex_app_server_protocol::ThreadForkResponse;
use codex_app_server_protocol::ThreadGoal;
@@ -616,11 +617,11 @@ pub(crate) fn apply_live_thread_settings(
loaded_thread: &CodexThread,
config_snapshot: &ThreadConfigSnapshot,
) {
thread.daybreak_program_propagation_enrolled =
Some(loaded_thread.daybreak_program_propagation_enrolled());
thread.model = Some(config_snapshot.model.clone());
thread.reasoning_effort = config_snapshot.reasoning_effort.clone();
thread.environments = Some(
apply_thread_view_settings(
thread,
loaded_thread,
config_snapshot.model.clone(),
config_snapshot.reasoning_effort.clone(),
config_snapshot
.environment_selections()
.iter()
@@ -629,6 +630,20 @@ pub(crate) fn apply_live_thread_settings(
);
}
fn apply_thread_view_settings(
thread: &mut Thread,
loaded_thread: &CodexThread,
model: String,
reasoning_effort: Option<ReasoningEffort>,
environments: Vec<ThreadEnvironment>,
) {
thread.daybreak_program_propagation_enrolled =
Some(loaded_thread.daybreak_program_propagation_enrolled());
thread.model = Some(model);
thread.reasoning_effort = reasoning_effort;
thread.environments = Some(environments);
}
fn resolve_request_cwd(cwd: Option<PathBuf>) -> Result<Option<AbsolutePathBuf>, JSONRPCErrorError> {
cwd.map(|cwd| {
AbsolutePathBuf::relative_to_current_dir(path_utils::normalize_for_native_workdir(cwd))
@@ -1,9 +1,10 @@
use super::apply_live_thread_settings;
use super::apply_thread_view_settings;
use super::thread_input::can_accept_direct_input;
use crate::thread_status::ThreadWatchManager;
use crate::thread_status::resolve_thread_status;
use codex_app_server_protocol::SessionSource;
use codex_app_server_protocol::Thread;
use codex_app_server_protocol::ThreadEnvironment;
use codex_app_server_protocol::ThreadStatus;
use codex_core::ThreadManager;
use codex_protocol::ThreadId;
@@ -55,8 +56,22 @@ async fn enrich_loaded_thread(
let Ok(loaded_thread) = thread_manager.get_thread(thread_id).await else {
return;
};
let config_snapshot = loaded_thread.configured_snapshot().await;
apply_live_thread_settings(thread, &loaded_thread, &config_snapshot);
let settings = loaded_thread.thread_view_settings().await;
apply_thread_view_settings(
thread,
&loaded_thread,
settings.model,
settings.reasoning_effort,
settings
.environments
.into_iter()
.map(|env| ThreadEnvironment {
environment_id: env.environment_id,
cwd: env.cwd.into(),
runtime_workspace_roots: env.workspace_roots.into_iter().map(Into::into).collect(),
})
.collect(),
);
if !matches!(
&thread.source,
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { .. })
@@ -85,6 +100,6 @@ async fn enrich_loaded_thread(
}
thread.can_accept_direct_input = Some(can_accept_direct_input(
loaded_thread.multi_agent_version(),
&config_snapshot.session_source,
&settings.session_source,
));
}