Skip to content

Conversation

@a7medev
Copy link

@a7medev a7medev commented Jan 13, 2026

What does this PR do?

Fixes #8192.

Fixes false permission requests when chained cd commands navigate within the project directory. Previously, commands like cd subdir && do something && cd .. would incorrectly trigger an external_directory permission request because all paths were resolved relative to the initial working directory rather than tracking the effective directory after each cd.

image

The fix tracks an effectiveCwd variable that updates after each cd command, so subsequent path resolutions use the correct context.

How did you verify your code works?

Added three tests in test/tool/bash.test.ts:

  • cd subdir && ls && cd .. does not request external_directory permission
  • cd a && cd b && cd c && cd .. && cd .. && cd .. (nested navigation) does not request permission
  • cd subdir && cd ../.. (actually escapes project) still correctly requests permission

Verified tests fail before the fix and pass after.


WIP: Not all combinations of commands are &&s, so cd shouldn't always change the effective working directory of the next command. We should instead use the AST provided by the tree-sitter and track the working directory along its paths.

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found one potentially related PR:

Related PR:

This PR appears related because it also addresses external_directory permission handling. You may want to review it to ensure there's no overlap with your fix or to understand the broader context of external_directory permission logic.

The other PR (#6123) about allow_tmpdir is less relevant to your CD navigation fix.

@a7medev a7medev marked this pull request as draft January 13, 2026 11:31
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.

OpenCode asks for permission for chained cd's that stay within the project

1 participant