mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
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:
@@ -687,7 +687,7 @@ fn sample_thread(thread_id: &str) -> Thread {
|
||||
recency_at: Some(2),
|
||||
status: AppServerThreadStatus::Idle,
|
||||
path: None,
|
||||
cwd: test_path_buf("/tmp").abs(),
|
||||
cwd: test_path_buf("/tmp").abs().into(),
|
||||
cli_version: "0.0.0".to_string(),
|
||||
source: AppServerSessionSource::Exec,
|
||||
can_accept_direct_input: None,
|
||||
@@ -707,7 +707,7 @@ fn sample_thread_start_response() -> ClientResponsePayload {
|
||||
model: "gpt-5".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: AppServerAskForApproval::OnRequest,
|
||||
@@ -726,7 +726,7 @@ fn sample_thread_resume_response() -> ClientResponsePayload {
|
||||
model: "gpt-5".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: AppServerAskForApproval::OnRequest,
|
||||
@@ -749,7 +749,7 @@ fn sample_thread_fork_response() -> ClientResponsePayload {
|
||||
model: "gpt-5".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: AppServerAskForApproval::OnRequest,
|
||||
@@ -935,10 +935,7 @@ fn track_response_ignores_unserializable_thread_responses() {
|
||||
let ClientResponsePayload::ThreadStart(thread_start) = &mut response else {
|
||||
panic!("expected thread/start response");
|
||||
};
|
||||
thread_start.cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(
|
||||
std::path::PathBuf::from(OsString::from_vec(vec![b'/', b'b', b'a', b'd', 0xff])),
|
||||
)
|
||||
.expect("non-UTF-8 Unix paths are valid absolute paths");
|
||||
thread_start.thread.path = Some(OsString::from_vec(b"/bad\xff".to_vec()).into());
|
||||
|
||||
client.track_response(/*connection_id*/ 7, RequestId::Integer(1), &response);
|
||||
|
||||
|
||||
@@ -2476,11 +2476,12 @@ impl AnalyticsReducer {
|
||||
out: &mut Vec<TrackEventRequest>,
|
||||
) {
|
||||
let session_source: SessionSource = thread.source.into();
|
||||
let is_worktree =
|
||||
codex_git_utils::repository_identity(thread.cwd.as_path()).and_then(|_| {
|
||||
codex_git_utils::get_git_repo_root(thread.cwd.canonicalize().ok()?.as_path())
|
||||
.map(|root| root.join(".git").is_file())
|
||||
});
|
||||
let is_worktree = thread.cwd.to_inferred_path_uri().and_then(|cwd| {
|
||||
let cwd = cwd.to_abs_path().ok()?;
|
||||
codex_git_utils::repository_identity(cwd.as_path())?;
|
||||
codex_git_utils::get_git_repo_root(cwd.canonicalize().ok()?.as_path())
|
||||
.map(|root| root.join(".git").is_file())
|
||||
});
|
||||
let session_id = thread.session_id;
|
||||
let thread_id = thread.id;
|
||||
let parent_thread_id = thread.parent_thread_id;
|
||||
|
||||
@@ -164,8 +164,7 @@ async fn thread_initialized_classifies_validated_linked_worktrees() {
|
||||
let ClientResponsePayload::ThreadStart(start) = &mut response else {
|
||||
panic!("expected thread/start response");
|
||||
};
|
||||
start.thread.cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(cwd)
|
||||
.expect("absolute checkout path");
|
||||
start.thread.cwd = codex_utils_path_uri::LegacyAppPathString::from_path(cwd);
|
||||
reducer
|
||||
.ingest(
|
||||
AnalyticsFact::ClientResponse {
|
||||
|
||||
@@ -129,7 +129,7 @@ pub(super) fn sample_thread_with_metadata(
|
||||
recency_at: Some(2),
|
||||
status: AppServerThreadStatus::Idle,
|
||||
path: None,
|
||||
cwd: test_path_buf("/tmp").abs(),
|
||||
cwd: test_path_buf("/tmp").abs().into(),
|
||||
cli_version: "0.0.0".to_string(),
|
||||
source,
|
||||
can_accept_direct_input: None,
|
||||
@@ -159,7 +159,7 @@ pub(super) fn sample_thread_start_response(
|
||||
model: model.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: AppServerAskForApproval::OnRequest,
|
||||
@@ -225,7 +225,7 @@ pub(super) fn sample_thread_resume_response_with_source(
|
||||
model: model.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: AppServerAskForApproval::OnRequest,
|
||||
|
||||
Reference in New Issue
Block a user