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
+5 -3
View File
@@ -173,7 +173,7 @@ impl ThreadState {
shutdown_drain: watch::Receiver<bool>,
conversation: &Arc<CodexThread>,
watch_registration: WatchRegistration,
thread_settings_baseline: ThreadSettings,
thread_settings_baseline: Option<ThreadSettings>,
history_mode: ThreadHistoryMode,
) -> (mpsc::UnboundedReceiver<ThreadListenerCommand>, u64) {
if let Some(previous) = self.cancel_tx.replace(cancel_tx) {
@@ -185,7 +185,7 @@ impl ThreadState {
self.shutdown_drain = Some(shutdown_drain);
self.listener_generation = self.listener_generation.wrapping_add(1);
self.listener_shutdown = false;
self.last_thread_settings = Some(thread_settings_baseline);
self.last_thread_settings = thread_settings_baseline;
self.history_mode = history_mode;
self.evict_superseded_agent_text =
history_mode == ThreadHistoryMode::Paginated && conversation.rollout_path().is_some();
@@ -393,7 +393,9 @@ mod tests {
ThreadSettings {
disabled_plugin_ids: Vec::new(),
environments: Some(Vec::new()),
cwd: AbsolutePathBuf::from_absolute_path("/tmp").expect("absolute path"),
cwd: AbsolutePathBuf::from_absolute_path("/tmp")
.expect("absolute path")
.into(),
approval_policy: AskForApproval::OnRequest,
approvals_reviewer: ApprovalsReviewer::User,
sandbox_policy: SandboxPolicy::ReadOnly {