mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
codex: normalize legacy URI cwd on rollout replay (#29472)
This commit is contained in:
@@ -94,7 +94,7 @@ pub fn build_command_execution_begin_item(payload: &ExecCommandBeginEvent) -> Th
|
||||
ThreadItem::CommandExecution {
|
||||
id: payload.call_id.clone(),
|
||||
command: shlex_join(&payload.command),
|
||||
cwd: payload.cwd.clone(),
|
||||
cwd: normalized_app_server_cwd(&payload.cwd),
|
||||
process_id: payload.process_id.clone(),
|
||||
source: payload.source.into(),
|
||||
status: CommandExecutionStatus::InProgress,
|
||||
@@ -117,7 +117,7 @@ pub fn build_command_execution_end_item(payload: &ExecCommandEndEvent) -> Thread
|
||||
ThreadItem::CommandExecution {
|
||||
id: payload.call_id.clone(),
|
||||
command: shlex_join(&payload.command),
|
||||
cwd: payload.cwd.clone(),
|
||||
cwd: normalized_app_server_cwd(&payload.cwd),
|
||||
process_id: payload.process_id.clone(),
|
||||
source: payload.source.into(),
|
||||
status: (&payload.status).into(),
|
||||
@@ -128,6 +128,12 @@ pub fn build_command_execution_end_item(payload: &ExecCommandEndEvent) -> Thread
|
||||
}
|
||||
}
|
||||
|
||||
fn normalized_app_server_cwd(cwd: &LegacyAppPathString) -> LegacyAppPathString {
|
||||
cwd.to_inferred_path_uri()
|
||||
.map(LegacyAppPathString::from)
|
||||
.unwrap_or_else(|| cwd.clone())
|
||||
}
|
||||
|
||||
fn command_actions_for_legacy_cwd(
|
||||
parsed_cmd: &[ParsedCommand],
|
||||
cwd: &LegacyAppPathString,
|
||||
|
||||
@@ -47,8 +47,8 @@ fn raw_file_uri_cwd_is_converted_for_command_actions() {
|
||||
let raw_uri = "file:///C:/src";
|
||||
#[cfg(not(windows))]
|
||||
let raw_uri = "file:///usr/local/src";
|
||||
let expected_path = PathUri::parse(raw_uri)
|
||||
.expect("raw file URI should parse")
|
||||
let cwd_uri = PathUri::parse(raw_uri).expect("raw file URI should parse");
|
||||
let expected_path = cwd_uri
|
||||
.to_abs_path()
|
||||
.expect("raw file URI should be native")
|
||||
.join("file.txt");
|
||||
@@ -60,6 +60,10 @@ fn raw_file_uri_cwd_is_converted_for_command_actions() {
|
||||
path: PathBuf::from("file.txt"),
|
||||
}];
|
||||
|
||||
assert_eq!(
|
||||
normalized_app_server_cwd(&cwd),
|
||||
LegacyAppPathString::from(cwd_uri),
|
||||
);
|
||||
assert_eq!(
|
||||
command_actions_for_legacy_cwd(&parsed_cmd, &cwd),
|
||||
vec![CommandAction::Read {
|
||||
|
||||
Reference in New Issue
Block a user