Skip to content

fix(shell): default no-cwd shell commands to context.workspace#4673

Merged
Hmbown merged 2 commits into
Hmbown:mainfrom
fleitz:main
Jul 21, 2026
Merged

fix(shell): default no-cwd shell commands to context.workspace#4673
Hmbown merged 2 commits into
Hmbown:mainfrom
fleitz:main

Conversation

@fleitz

@fleitz fleitz commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

When the BashTool receives no explicit cwd, the working directory now defaults to context.workspace (the sub-agent's worktree when worktree: true was used) instead of None, which fell through to the shared ShellManager's parent-workspace default.

This ensures sub-agents in isolated worktrees run shell commands in their worktree directory rather than the parent checkout.

The fix threads the resolved working_dir through execute_foreground_via_background (which previously always passed None) and adds a test that verifies the context.workspace priority over the ShellManager's default_workspace.

Closes #4674

When the BashTool receives no explicit `cwd`, the working directory now
defaults to `context.workspace` (the sub-agent's worktree when
`worktree: true` was used) instead of `None`, which fell through to the
shared ShellManager's parent-workspace default.

This ensures sub-agents in isolated worktrees run shell commands in their
worktree directory rather than the parent checkout.

Previously, the foreground execution path (`execute_foreground_via_background`)
always passed `None` as the working directory, so it always used the
ShellManager's `default_workspace` regardless of the input `cwd`. Now the
resolved `working_dir` from the BashTool's cwd handling is threaded through
to the execution path.

Co-authored-by: fleitz <fleitzo@gmail.com>
@fleitz
fleitz requested a review from Hmbown as a code owner July 21, 2026 20:18
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @fleitz for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

Detect the selected workspace through marker files instead of comparing path spellings. This keeps Fred Leitz’s regression meaningful on PowerShell, where canonical and printed Windows paths can differ.

Signed-off-by: Hunter B <hmbown@gmail.com>
@Hmbown

Hmbown commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Maintainer follow-up added without rewriting Fred’s commit: 6d0ebc881a8bd2469c45b25f2a606fa63681e112 remains the exact parent of 64ddbdf22d580269e4b0889064f46130bfbb5b84.

The newly authorized Windows matrix run confirmed the implementation itself and 7,694 other TUI tests, but its new regression compared PowerShell pwd output to a canonical Windows path spelling. The follow-up keeps the same behavioral assertion and selects the active directory through distinct marker files instead. Local exact test, cargo fmt --all -- --check, and git diff --check pass. CI is now rerunning against main with the additive Fred identity mapping from #4678.

@Hmbown Hmbown left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the exact contributor commit and the additive portability follow-up. The original Fred Leitz commit 6d0ebc8 remains unchanged; 64ddbdf makes only the regression test path-independent. Focused local shell tests passed, and hosted lint, DCO, macOS, Windows, web, and offline eval checks are green.

@Hmbown
Hmbown merged commit a7c00a1 into Hmbown:main Jul 21, 2026
16 checks passed
pull Bot pushed a commit to Stars1233/DeepSeek-TUI that referenced this pull request Jul 21, 2026
Map Fred Leitz to his canonical GitHub noreply identity and allow only PR Hmbown#4673 exact commit trailer to resolve through it, preserving the reviewed contributor commit without weakening the gate for altered identities.

Co-authored-by: Fred Leitz <345780+fleitz@users.noreply.github.com>
Signed-off-by: Hunter B <hmbown@gmail.com>
Hmbown added a commit that referenced this pull request Jul 22, 2026
Label v0.9.1 as an unpublished source candidate while keeping v0.9.0 as the verified latest release. Correct channel and Android/Termux preview guidance, narrow model claims, synchronize localized README controls, and credit @fleitz for PR #4673/#4674 without rewriting contributor history.

Signed-off-by: Hunter B <hmbown@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BashTool ignores context.workspace for default cwd — sub-agent worktrees run commands in parent checkout

2 participants