Repository navigation
fix(plugins): allow relative paths inside a drive-root workspace - #1739
Conversation
Windows drive and UNC roots, and the POSIX root, already end with a separator. Containment that always appended another separator rejected every child as an escape, so plugin file APIs, project-instruction reads, and local-file preview failed for a workspace opened at C:\ or E:\. fixes vastsa#1715
|
Follow-up on my scope note: checked the third surface I flagged — |
|
Status ping: this is now #1715 is the only open report for the drive-root containment bug, so merging this closes it. Flagging in case it fell off the queue during the beta.4 release. |
|
Merge-readiness check, done locally so it does not need another CI cycle:
So this is safe to merge as-is; the merge is a no-op conflict-wise. It is the only fix for #1715 (plugin relative paths rejected when the workspace is a drive root), and the failure it addresses is a hard blocker for any Windows user whose project sits at If it is easier for you, I can push the merge commit to my fork and open it as a refreshed head — say the word and I will; otherwise a plain merge button works. |
|
I confirmed #1715's root cause: appending a separator to a filesystem root that already ends with one creates a boundary prefix that rejects every child. The proposed normalization fixes the drive/UNC/POSIX root cases while preserving sibling and The passing checks are for head |
Summary
Fixes #1715
When a workspace is opened at a drive root (
C:\,E:\), every plugin relative path such as.workflow/knowhow/x.mdwas rejected as escaping the workspace.Root cause: the containment checks build the boundary as
root + sep. A Windows drive root (C:\), a UNC share root, and the POSIX root (/) already end with a separator, so the boundary becameC:\\and no child path could ever match it. The fix only appends the separator when the root does not already end with one.Changed call sites (same one-line rule in each):
packages/host-runtime/src/workspace-files.ts—resolveWithinRoot(plugin file APIs / workspace files)packages/agent-runtime/src/project-instructions.ts—isWithinRoot(project instruction reads)apps/desktop/electron/main/browser-view.ts—isWithinRoot(local-file preview)resolveWithinRootandisWithinRoottake an optionalpathimplementation (defaulting tonode:path) so the Windows behavior can be tested withpath.win32on Linux CI. Theagent-runtimeindex now re-exports the existing public names explicitly so the newly exportedisWithinRoothelper does not become part of the package API. Runtime behavior for non-root workspaces is unchanged.Specs / ADRs / E2E
path.win32instead.Tests
New
apps/desktop/test/drive-root-path-containment.test.mjs(6 tests, all pass):C:/,C:\,E:/,E:\contain relative plugin paths../code-evil/x,E:\code-evil\x,C:/Windows/xfromC:/Users/su, sibling-prefix../project-evil/x, empty root)..at a drive root stays on the drive/contains a relative path; sibling-prefix escape under/srv/appis rejectedC:\Users\su-evilLocal run of the PR workflows (
ci.ymljobsjs,rust,trusted-extensions-e2e, andpr-base.yml) on headccded1b18, Node 24.21.0, rustc 1.99.1:pnpm check:pr-base/check-pr-base-main.mjs+ its unit testpnpm install --frozen-lockfile,pnpm build:jspnpm lint, architecture check,pi-patch-hashtestcargo fmt --all -- --check,cargo clippy --workspace --all-targets --all-featuresSUMMARY 57/57 passedpnpm -r --if-present testcargo test -p host-core --lockedPre-existing local failures (same on merge-base)
Both failing steps were re-run on the merge-base
e219a3e4c(currentupstream/main) and fail identically there, so they are environment/baseline failures and not caused by this diff:pnpm -r --if-present test— 12apps/desktop*-user-path/plugin-view-bounds-synctests fail withElectron binary missingfromscripts/e2e/boot.mjs, becausepnpm install --frozen-lockfiledoes not download the Electron binary (CI installs it later, in thetrusted-extensions-e2ejob). Same 12 tests, same error on both commits. Totals: head 4089 tests / 4070 pass / 12 fail; base 4083 / 4064 / 12. The +6 on head are the new tests above, all passing.cargo test -p host-core --locked—tools::tests::bash_inherits_user_login_pathpanics withevery injected login-PATH entry is presenton both commits (960 passed, 1 failed, 1 ignored on each). The local host's login shell rewrites aPATHentry. This PR changes no Rust sources.NOT RUN
ci.yml/rust-windows(windows-latest) — no Windows host available locally. The diff touches no Rust code. The Windows path behavior is covered by thepath.win32unit tests above; the remaining risk is that a real Windows run differs frompath.win32, which is low.Compatibility / security
The containment checks are a security boundary. The change only accepts children of a root that already ends with a separator; sibling-prefix escapes (
C:\codevsC:\code-evil) and..escapes are still rejected, and the tests assert that. No migration.AI disclosure
This change was prepared with AI assistance (code, tests, and this description). The diff was reviewed and every check listed above was actually run locally; nothing is reported as passing that was not executed.
Baseline comparison (refresh onto main 589e580)
Local CI mirror at
585c641(merge of current main589e580): all steps pass exceptjs-unit-tests(Electron binary unavailable in the local sandbox) andrust-test(bash_inherits_user_login_path). Both fail identically on unmodified589e580, so they are environment/baseline failures unrelated to this diff.