Repository navigation
Accept Windows drive-letter paths for projects and workspaces - #4659
Conversation
Project and workspace paths had to start with `/`, so a native Windows host could not add `C:\src\repo`, and paths were compared as raw strings. - Add `@bb/domain` host-path helpers that infer POSIX or Windows from the path's shape and normalize, join, compare, and contain paths for either. - Store a Windows path in one spelling and compare Windows paths without regard to case in the database; POSIX paths keep exact comparison. - Join host paths on the server with the host's separator instead of the server's own `node:path`. - Build managed worktree and personal workspace paths with native separators. - Refuse a Windows path for a machine that reported macOS, Linux, or WSL, and refuse UNC paths. Co-Authored-By: Claude Code <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd5661dec0
ℹ️ 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".
|
|
||
| export function hostPathEquals(column: SQLiteColumn, path: string): SQL { | ||
| return isWindowsHostPath(path) | ||
| ? sql`${column} = ${path} COLLATE NOCASE` |
There was a problem hiding this comment.
Compare non-ASCII Windows paths case-insensitively
SQLite's built-in NOCASE collation only folds ASCII characters, so paths such as C:\src\Équipe and C:\src\équipe still compare as different even though they normally identify the same directory on Windows. This affects project deduplication and environment path claims, potentially allowing two environments to operate concurrently on the same checkout; use a normalized comparison key whose segments are case-folded before storage or lookup rather than relying on NOCASE.
Useful? React with 👍 / 👎.
|
|
||
| export function hostPathContains(column: SQLiteColumn, path: string): SQL { | ||
| const descendant = isWindowsHostPath(path) | ||
| ? sql`${path} LIKE ${column} || '\\%'` |
There was a problem hiding this comment.
Escape LIKE metacharacters in Windows containment checks
When a managed Windows path contains the legal filename characters _ or %, concatenating the stored column directly into a LIKE pattern treats those characters as wildcards. For example, an owned root C:\repos\foo_bar incorrectly contains C:\repos\fooXbar\child, which can cause unrelated workspaces to be rejected as provider-owned; escape metacharacters and add an explicit ESCAPE clause before performing this prefix match.
Useful? React with 👍 / 👎.
SQLite's NOCASE collation folds only ASCII letters, and the containment check built a LIKE pattern from the stored path, so '_' and '%' in a directory name matched any character. Path equality and containment now run through connection-registered SQL functions backed by the shared host path helpers. Co-Authored-By: Claude Code <[email protected]>
## Human comments ## What was wrong File links that an agent prints with a Windows path did not work in rendered Markdown: - `[readme](C:\src\repo\README.md)` and `[readme](C:/src/repo/README.md:12)` rendered as plain text. The link parser tested the href against a URI-scheme pattern first, so `C:` was read as a scheme, the href was not recognised as a local file, and the default URL transform dropped it. - Markdown treats a backslash before punctuation as an escape, so a destination such as `C:\src\repo\.config\app.json` lost its `\.` before the parser saw it. - `file:///C:/src/repo/README.md` parsed to the POSIX-looking path `/C:/src/repo/README.md` and rendered as an external link. Part of #1206. Stacked on #4659, which adds the Windows-aware path helpers this uses for containment. ## What changed - `apps/app/src/components/ui/markdown-local-file-link.ts`: a drive-letter path (`C:\…` or `C:/…`) is a local file path, not a URL. `file:` and editor URLs whose pathname is `/C:/…` yield `C:/…`. Validation rejects drive roots and directory paths the same way it rejects `/` and trailing-slash POSIX paths. `buildLocalFileAnchorHref` renders a Windows link as `file:///C:/…` with each segment percent-encoded. - `markdown-local-file-link-normalize.ts`: before Markdown parsing, an inline link destination that is a Windows drive path is rewritten to forward slashes inside angle brackets, so no backslash is consumed as an escape and spaces survive. While finding where such a destination ends, a backslash is read as a path separator, not an escape, so `[draft](C:\docs\(draft).md)` keeps its parentheses and becomes `<C:/docs/(draft).md>`. POSIX link handling is unchanged; the existing tests pass unmodified. ## How you verified - Windows 11 Enterprise VM (build 26300), installed desktop build containing this change and the other open Windows changes, driven through its web UI: a message containing `[readme](C:\src\testrepo\README.md)`, `[fwd](C:/src/testrepo/README.md:1)`, and `[uri](file:///C:/src/testrepo/README.md)` rendered three anchors with hrefs `file:///C:/src/testrepo/README.md`, `…README.md#L1`, and `…README.md`. Clicking `fwd` opened the file preview panel titled `C:\src\testrepo\README.md` showing the file's contents. Before the change the first two were plain text and the third was an external link. - Linux: `turbo run lint typecheck test --filter=@bb/app` passes (6 of 6 tasks). New tests cover drive paths with line suffixes, `file:///C:/…` URLs, rejected roots and directories, case-insensitive containment in a Windows workspace root, the rendered anchor href, relative links under a Windows root, and the normalization of backslash and space-containing destinations and of a file name in parentheses after a separator. The two link test files also pass on the VM (41 of 41). Not verified: bare Windows paths that are not Markdown links are still plain text (the same is true of bare POSIX paths); editor-scheme URLs (`vscode://file/C:/…`) are covered only by the shared parsing path, not by a click on Windows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Code <[email protected]>
## Human comments ## What was wrong After #4659 added the shared host-path parser (`packages/domain/src/host-path.ts`), the server files route, the skills listing and the daemon skill-tree check kept their own path code. The copies disagreed. Skill dirname/basename/join used a drive-letter regex, so UNC paths were treated as POSIX and resolved to the wrong folder. File preview `rootPath` accepted a rootless `\foo`. Relative paths starting with a drive letter (`C:/x`) passed the files route, thread open and skill reads, but the daemon rejected them. Skill reads returned 404 for malformed paths that every other route rejects with 400. ## What changed - `@bb/domain`: new `getRelativeHostPathSegments` next to the absolute-path parser. - `apps/server/src/routes/files.ts`: uses the shared normalize/join and the shared relative check. Windows separators in URL paths are still turned into `/` before the check. - `routes/relative-route-path.ts` deleted; thread open calls the shared check. - Skills listing and shared skills use the shared dirname/basename/join (wrapped in `services/lib/host-path.ts`) and the shared relative check. Hidden files still return 404; malformed paths now return 400. - `apps/host-daemon/src/injected-skills.ts`: `isSafeTreePath` uses the shared check plus its depth limit. No wire change. Net: 119 added, 137 removed. ## How you verified - One test table in `packages/domain/test/host-path.test.ts` runs every removed check's cases (and the newly rejected ones) against `getRelativeHostPathSegments`; added UNC dirname/basename cases. - Updated `public-project-skills.test.ts`: `references/../../secrets.md` now expects 400. - `pnpm exec turbo run test lint --filter=@bb/server --filter=@bb/host-daemon --filter=@bb/domain` and `turbo run typecheck` for server and daemon pass. > AGENT GENERATED Co-authored-by: Claude Opus 5.5 <[email protected]>
## Human comments ## What was wrong The Automations CLI copies core's thread-spawn helpers, and the copies drifted. Its path check missed Windows paths (#4659), so `--environment C:\repo` was saved as an environment id. `--new-environment` and workspace paths picked the first host matching a `connected` field that doesn't exist, then any connected host, then `hosts[0]` even when offline. Core uses the CLI's own machine. `--at 2026-12-01` was read as UTC midnight, but core rejects a date with no time as ambiguous. ## What changed `plugins/automations/src/cli.ts` only: - The path check uses core's rules: a backslash or a leading drive letter makes the value a path. - New environments and workspace paths run on the calling thread's machine, falling back to `primaryHostId`. This reuses the thread-host lookup that `--script-file` already had. The old host-list scan is deleted. - A date-only `--at` is rejected. Other `--at` values parse as before. - The `--environment` help text now says where a path runs. No plugin SDK, host-daemon protocol, or RPC contract changes. Open #6056 makes the same default-machine change as part of a larger feature; whichever lands second will need a small conflict fix in `cli.ts`. ## How you verified New tests in `server-harness.test.ts` failed before the fix and pass after: - `--environment C:\repo` and `--new-environment worktree` from a thread land on that thread's machine. Before, the path was saved as `reuse` and the worktree went to the first connected host. - A date-only `--at` is rejected. Before, it was accepted. Three existing expectations moved from the first connected host to the primary host, so they now cover the no-thread fallback. `pnpm exec turbo run test typecheck lint --filter=bb-plugin-automations` passes: 166 tests; lint has 0 errors and 4 warnings, all pre-existing in other files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Opus 5.5 <[email protected]>
Human comments
What was wrong
bb's path model was POSIX-only, so a native Windows host could not add a project or run a thread.
packages/domain/src/project-path.tsrejected every drive-letter path ("Native Windows paths are not supported"), several server checks requiredstartsWith("/"), and the worktree and personal-workspace plugins built managed paths withpath.posix.join, which on Windows produced mixed separators (C:\…\host-data/worktrees/…). Paths were also compared as raw strings, soC:\repo,c:/repo/, andC:\REPOwould have become separate projects, environments, and path claims. The server joined host paths with its ownnode:path, which is wrong whenever the server and the host run different operating systems. Part of #1206.What changed
packages/domain/src/host-path.ts: pure string helpers that infer POSIX or Windows from the path's shape and normalize, join, take the directory or base name, compare, and test containment for either.project-path.tsnow accepts drive-letter paths and stores them in one spelling (upper-case drive letter, backslashes, no trailing separator). UNC paths are refused with a message that says to map a drive. POSIX normalization is unchanged.update_environment_directory, the environment providerexistingPathandclaimPathresults, and path admission accept any absolute host path and canonicalize it. Thread storage, the thread-storage orphan sweep, the host'sthreadStorageRootPath, the diff-file route, workspace skills, and workspaceAGENTS.mdare joined with the host path's own separator throughservices/lib/host-path.ts.isBbManagedWorkspacePathuses the same helpers. Project create, source create, and source update refuse a Windows path for a machine that reporteddarwin,linux, orwsl, so that input still fails clearly on existing hosts.packages/db/src/data/host-path-sql.tsregisters two SQL functions on every connection, backed by the domain helpers:bb_host_path_key(the case-folded comparison key) andbb_host_path_contains. A Windows-shaped path is compared by key, so letters outside ASCII fold too (C:\src\ÉquipeequalsC:\src\équipe; SQLite'sNOCASEfolds only ASCII). Containment no longer builds aLIKEpattern from the stored path, so_and%in a directory name are literal, for POSIX paths as well. POSIX equality is still an exact, case-sensitive=. Used for project sources, environments, and path claims. No schema change or migration.environment-git-worktreeandenvironment-personal-workspacebuild managed paths with the host's nativepath.join, and comparegit worktree listoutput (which uses/on Windows) throughpath.relative.apps/app/src/lib/absolute-file-path.tsandthread-local-file-links.tsuse the domain helpers, so a file link under a Windows workspace root resolves to its workspace-relative path.bb thread spawn --environmentrecognizesC:\…andc:/…as a path, not an ID.docs/platform-support.mddocuments the drive-letter rules.No wire change: the daemon protocol and
HostPlatformare untouched, so a Windows daemon still reportsunknown. Not included: Windows paths in Markdown file links that agents print, drive switching in the remote path browser, and the dialog placeholder text.How you verified
turbo run lint typecheck testfor@bb/domain,@bb/db,@bb/server-contract,@bb/server,@bb/cli,@bb/app, and the two environment plugins. 25 of 26 tasks passed in the combined run; the server task had 4 failures of 3,226 tests (machine-environment.test.tstimeout and threeplugin-native-server-loading.test.tscases) while two other Turbo runs shared the machine. Both files pass when rerun alone on this branch (5 of 5), and the second file is untouched by this change.node:path:host-path.test.ts(flavor, normalization, comparison, containment, join), updatedproject-path.test.tsand contract test, case-insensitive Windows lookups (including a non-ASCII folder name), literal_and%in owned paths, and case-sensitive POSIX lookups inenvironments.test.ts, managed-root detection for a Windows data directory, two route tests (three spellings of one Windows folder yield one project; a Windows folder is refused for a POSIX machine), app path helper and file-link tests, and the CLI path detection test.bb project create --rootwithC:\src\testrepo,c:/src/TestRepo/, andC:\SRC\testrepo\.returned the same project with source pathC:\src\testrepo; a UNC root returned HTTP 400 with the network-path message; a worktree thread got the environment pathC:\bb-data\plugins\environment-git-worktree\host-data\worktrees\thr_…-1\PlainRepo(all backslashes); two checkout threads started with--environment C:\src\plainrepoand--environment c:/SRC/plainrepo/shared oneproject-checkoutenvironment; all three threads completed a turn.environments.test.tsalso passes on the VM (16 of 16).🤖 Generated with Claude Code