[codex] Run user shell commands in explicit remote environments#28364
[codex] Run user shell commands in explicit remote environments#28364rasmusrygaard wants to merge 3 commits into
Conversation
67fe692 to
ecf2567
Compare
ecf2567 to
fda28a2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0968f33680
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Ok(crate::shell::get_shell_by_model_provided_path( | ||
| &info.shell.path.into(), | ||
| )) |
There was a problem hiding this comment.
Use remote shell info without local path probing
For remotes on another OS or with a shell path absent locally, this host-side detection can fall back to /bin/sh and send that argv remotely, so explicit remote ! commands fail despite valid remote shell info. Use ShellInfo/turn_environment.shell directly. guidance
Useful? React with 👍 / 👎.
| stdout: StreamOutput::new(String::from_utf8_lossy(&stdout).into_owned()), | ||
| stderr: StreamOutput::new(String::from_utf8_lossy(&stderr).into_owned()), | ||
| aggregated_output: StreamOutput::new( | ||
| String::from_utf8_lossy(&aggregated_output).into_owned(), |
There was a problem hiding this comment.
Decode remote output with the normal exec decoder
For remote Windows shells or commands emitting non-UTF-8, these lossy conversions bypass normal exec's smart decoder, so final stdout/stderr/history show replacement characters for supported code pages. Convert through StreamOutput<Vec<u8>>::from_utf8_lossy(). guidance
Useful? React with 👍 / 👎.
| return RemoteUserShellResult::Error(format!("execution error: {err}")); | ||
| } | ||
| }; | ||
| after_seq = Some(read.next_seq); |
There was a problem hiding this comment.
Advance remote reads to the last consumed sequence
When remote output spans multiple reads, setting after_seq to read.next_seq skips the next chunk: the exec-server read API returns chunks with seq > after_seq, so a later chunk whose sequence equals the previous next_seq is filtered out. This drops stdout/stderr and streamed deltas for longer-running or chatty remote ! commands; store the last consumed chunk seq instead (or next_seq - 1).
Useful? React with 👍 / 👎.
Why
A turn can select a remote environment, but user shell commands could only run on the local host. Callers that know which selected environment the user intends to target need a way to execute the command there without silently falling back to local execution.
What changed
environment_idtoRunUserShellCommand; omitting it preserves the existing local app-server and TUI behavior.Environment selection policy remains with the caller: core honors an explicit ID but does not infer a default when multiple environments are selected.
Test coverage
environment_id: None.