Uh oh!
There was an error while loading. Please reload this page.
fix(seatbelt): Apply the cwd to the spawn_open (in-terminal) launch path. - #1079
fix(seatbelt): Apply the cwd to the spawn_open (in-terminal) launch path.#1079Elliot (theelliotm) wants to merge 5 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Fixes Seatbelt’s Terminal-based launch path to honor the requested working directory.
Changes:
- Resolves, validates, and applies
cwdin open mode. - Extracts shell escaping/helper generation and adds unit tests.
- Documents Seatbelt working-directory access requirements.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/backends/seatbelt/common/src/seatbelt_runner.rs | Applies cwd in the generated helper and adds tests. |
docs/seatbelt/seatbelt-backend.md | Documents profile access requirements for cwd. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
process.cwd may be relative; the exec path resolves it against the MXC process's directory via chdir. The helper script runs from Terminal's directory, so a relative value could enter a different same-named directory while open -W still reported success. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
src/backends/seatbelt/common/src/seatbelt_runner.rs:348
is_dir()verifies only the file type, not whether this user can enter the directory. For example, metadata can identify a directory whose execute/search permission is denied; this check then passes, the helper'scdfails, andopen -Wstill reports a clean run without executing the workload. Use a preflight child withCommand::current_dir(&cwd)(or propagate the helper's status back) so an unusable cwd is reported like the exec path.
if !Path::new(&cwd).is_dir() {
Uh oh!
There was an error while loading. Please reload this page.
chdir accepts an absolute path even when the launching process own directory has been removed, so an eager current_dir() call rejected a request the exec path launches without complaint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The preflight accepts directories lacking the search permission required by cd, allowing hidden launch failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
Uh oh!
There was an error while loading. Please reload this page.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
📖 Description
spawn_opennever appliedprocess.cwd.openhands the launch to Terminal,which starts the helper in its own directory (normally
$HOME), so theresolved working directory was silently discarded — only
spawn_execset it.The generated helper script now does what
spawn_execdoes before the sandboxis applied:
cdintoresolve_working_directory(request)and exportPWDtoit. The
cdis guarded (|| exit 1) — a bare one would leave the workloadrunning in Terminal's directory. A directory that doesn't exist is rejected
before Terminal launches, matching the exec path's spawn failure, since
open -Wreports its own status and not the helper's.🔗 References
None.
🔍 Validation
5 new unit tests in
seatbelt_runner:cd+PWDemitted, abort guardordering,
PWDassigned after caller env, single-quote escaping, and paritywith the exec path's resolution.
cargo test -p seatbelt_common— 106 passed.cargo fmt --all -- --check,cargo clippy -p seatbelt_common -p mxc_darwin --all-targets -- -D warnings— clean.Manual, macOS 26.6.2, against the real generated profile with
cwdgranted inreadwritePaths:pwd/Users/agos/tmp/mxc611_workcat f.txt(relative)No such file or directoryhello✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see docs/pull-requests.md)📋 Issue Type
Microsoft Reviewers: Open in CodeFlow