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
@@ -14,7 +14,7 @@ use codex_protocol::protocol::SessionSource as CoreSessionSource;
use codex_protocol::protocol::SubAgentSource as CoreSubAgentSource;
use codex_protocol::protocol::ThreadHistoryMode as CoreThreadHistoryMode;
use codex_protocol::protocol::ThreadSource as CoreThreadSource;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
#[cfg(test)]
use schemars::r#gen::SchemaGenerator;
#[cfg(test)]
@@ -265,7 +265,10 @@ pub struct Thread {
/// [UNSTABLE] Path to the thread on disk.
pub path: Option<PathBuf>,
/// Working directory captured for the thread.
pub cwd: AbsolutePathBuf,
// Preserve the published SDK type for this server-native absolute path.
#[schemars(with = "codex_utils_absolute_path::AbsolutePathBuf")]
#[ts(as = "codex_utils_absolute_path::AbsolutePathBuf")]
pub cwd: LegacyAppPathString,
/// Version of the CLI that created the thread.
pub cli_version: String,
/// Originator recorded when the thread was created, independent of its current client or executor.
@@ -328,7 +331,7 @@ struct ThreadCompatibility {
recency_at: Option<i64>,
status: ThreadStatus,
path: Option<PathBuf>,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
cli_version: String,
originator: Option<String>,
source: SessionSource,