Preserve app-server thread working directories across platforms (#62375)

## Why

A remote app server can report a working directory in a different path
convention from the client. Decoding a Windows drive path as a client-native
absolute path can make a Unix client reject the thread response.

## What changed

Keep thread `cwd` values as server-native strings in summaries, settings,
and start, resume, and fork responses. Preserve the JSON and generated SDK
types. In the TUI, store the session directory as a `PathUri` using the
server's path convention when available. Use that directory to match diff
and skill results and to display the project name in the terminal title.

## Testing

Add regression coverage for foreign-path response round trips, diff results
matched against a remote session directory, and terminal titles derived
from a Windows path. Verify that the server rejects a working directory
that cannot be encoded as UTF-8.

GitOrigin-RevId: 600f0b531939db4cd4ec884de166224082995e00
This commit is contained in:
Eric Traut
2026-11-18 22:13:26 +00:00
committed by copyberry
parent fecf5cc672
commit b82943092c
111 changed files with 720 additions and 479 deletions
+3 -2
View File
@@ -122,6 +122,7 @@ use codex_utils_absolute_path::canonicalize_existing_preserving_symlinks;
use codex_utils_cli::SharedCliOptions;
use codex_utils_oss::ensure_oss_provider_ready;
use codex_utils_oss::get_default_model_for_oss_provider;
use codex_utils_path_uri::LegacyAppPathString;
use codex_worktree::CreateWorktree;
use codex_worktree::WorktreeManager;
use codex_worktree::WorktreeSettings;
@@ -1852,7 +1853,7 @@ fn session_configured_from_thread_response(
approvals_reviewer: codex_protocol::config_types::ApprovalsReviewer,
permission_profile: PermissionProfile,
active_permission_profile: Option<codex_protocol::models::ActivePermissionProfile>,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
reasoning_effort: Option<codex_protocol::openai_models::ReasoningEffort>,
) -> Result<SessionConfiguredEvent, String> {
let session_id = SessionId::from_string(session_id)
@@ -1882,7 +1883,7 @@ fn session_configured_from_thread_response(
approvals_reviewer,
permission_profile,
active_permission_profile,
cwd,
cwd: AbsolutePathBuf::try_from(cwd).map_err(|err| err.to_string())?,
reasoning_effort,
network_proxy: None,
rollout_path,
+3 -3
View File
@@ -375,7 +375,7 @@ fn turn_items_for_thread_returns_matching_turn_items() {
recency_at: Some(0),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: None,
cwd: test_path_buf("/tmp/project").abs(),
cwd: test_path_buf("/tmp/project").abs().into(),
cli_version: "0.0.0-test".to_string(),
originator: None,
source: codex_app_server_protocol::SessionSource::Exec,
@@ -896,7 +896,7 @@ fn sample_thread_start_response() -> ThreadStartResponse {
recency_at: Some(0),
status: codex_app_server_protocol::ThreadStatus::Idle,
path: Some(PathBuf::from("/tmp/rollout.jsonl")),
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
cli_version: "0.0.0".to_string(),
source: codex_app_server_protocol::SessionSource::Cli,
can_accept_direct_input: None,
@@ -910,7 +910,7 @@ fn sample_thread_start_response() -> ThreadStartResponse {
model: "gpt-5.4".to_string(),
model_provider: "openai".to_string(),
service_tier: None,
cwd: test_path_buf("/tmp").abs(),
cwd: test_path_buf("/tmp").abs().into(),
runtime_workspace_roots: Vec::new(),
instruction_sources: Vec::new(),
approval_policy: codex_app_server_protocol::AskForApproval::OnRequest,