Repository navigation
Conversation
ymichael
force-pushed
the
bb/swing-7c-one-stored-workspace-descriptor-thr_aix5mkmch4
branch
2 times, most recently
from
October 23, 2026 23:12
f9c0ea3 to
e9189bf
Compare
bb-environment-provider-host imported @bb/domain, which the plugin host build rejects, so the git-worktree, project-checkout and GitHub PR status hosts failed to build. Its types are local again, and a test now builds those three hosts. describeHostWorkspace is the only place that assembles a workspace's path, repository root, branch and default branch; environment.attach, the workspace watcher and host.describe_workspace all use it. The root lookup runs alongside repository inspection and branch reads skip a repeated repository check (median 60 -> 41 ms on the bb repo, identical output). selectWorktreeBaseBranch is shared by the worktree plugin and the server instead of two copies. Also drops cross-package re-exports, the unread HostWorkspace.descriptor, leftover test fixture junk, and stale --base-branch help. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Workspace status now carries the repository root and the environment folder's prefix within it. The thread view uses that to open a changed file immediately: files inside the environment folder open in the normal workspace preview tab, files elsewhere in the repository open as host files. Open in editor uses the same mapping and falls back to the environment folder until status arrives. The thread view no longer fetches the workspace description. detectGitRepoKind is back to a single rev-parse that returns "none" on failure; the full inspection runs only when attaching a folder and for linked-worktree detection. The revision-file route test now answers host.describe_workspace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
git rev-parse --show-toplevel prints forward slashes on Windows, so the root no longer matched the environment path's form. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The diff panel and Info changes list pass repository-relative paths, but the preview opened them relative to the environment folder and Copy path joined them to it, so a subfolder project showed File not found and copied a doubled path. Files inside the environment folder now open in the workspace preview, files elsewhere in the repository open as host files, and diff cards copy paths from the repository root. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…covery Workspace discovery moved onto the shared provider-host Git runner, which lacked host-workspace's retry for silent STATUS_DLL_INIT_FAILED startup crashes, so a transient crash could classify a repository as non-Git. The runner now retries those crashes the same bounded way. readWorkTreeLocation split combined --show-toplevel/--show-prefix output at its last newline, which misparsed subfolder names containing newlines. It now reads the two values with separate commands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/swing-7c-one-stored-workspace-descriptor-thr_aix5mkmch4
branch
from
October 26, 2026 19:11
5f168ef to
500550d
Compare
Collaborator
Author
|
Superseded. #6165 rebuilt git reads and the shared git runner on main, which replaced this PR's git-helper consolidation, Windows retry and priority handling, and moved the code the subfolder fix touched into the Git plugin. The base-branch rule (#1917) and non-git parent environment reuse moved to #6336. The subfolder diff fix (#3905) will be redone inside the Git plugin after #6157 lands.
|
ymichael
added a commit
that referenced
this pull request
Oct 26, 2026
…folders (#6336) ## Human comments ## What was wrong `bb thread spawn --base-branch main` passed `main` to `git worktree add` unchanged. When the local `main` was behind `origin/main`, the new worktree started from the stale local commit. Only names that already began with `origin/` were fetched first. The default base (no `--base-branch`) already compared local with origin; named branches skipped that comparison. Separately, a child of a live thread in a project whose folder is not a Git repository always asked the git-worktree provider for a fresh worktree on the parent's machine. That fails, because there is no repository to make a worktree of. This is the part of #6193 that still applies after #6165. #6165 rebuilt git reads and the shared git runner on main, which replaced the rest of #6193. ## What changed - **Named bases use the default-branch rule** (`plugins/environment-git-worktree/host/base-branch.ts`): - a bare branch name uses `origin/<name>` when local is equal or behind; - it keeps local when local is ahead, diverged or unknown; - it uses the remote when only the remote branch exists. Explicit remote names such as `origin/main` and `refs/...` paths are used exactly. The selected remote base is fetched before creation, as before. - **The default base is always returned and stored.** Before, the resolver returned `null` when the result equaled the local default, and `createWorktree` re-read the repository default. `defaultBaseBranch` and `create` now share one resolver. - `readBranchRelation` (previously the private `readDefaultBranchRelation` in `bb-environment-provider-host/workspace-git`) is exported, so the plugin can compare any local/remote branch pair. - **Non-git parent reuse** (`apps/server/src/services/threads/thread-default-policy.ts`): a child of a live thread in the same project reuses its parent's environment instead of requesting a worktree. This applies only when: - the child asked for the project default, or the implicit host default on the parent's machine; - the parent's environment is ready; - the environment is not a Git repository and its path is not owned by a provider. - **Docs:** the `--base-branch` help in `bb thread spawn` and `bb thread fork`, the threads guide and the worktree plugin README describe both rules. No wire changes and no SDK changes. ## How you verified - `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`: 123/123 pass. - `pnpm exec turbo run test` for the git-worktree, project-checkout and Git plugins, `bb-environment-provider-host`, `@bb/cli` and `@bb/templates`: all pass. The server's `thread-default-policy` and `worktree-base-branch` tests pass. - Tests added. Against main's code, the stale-base and reuse tests fail and the rest pass: - `host.test.ts`: a stale local `main` or `release` now starts from the remote commit. `origin/main` is used as the remote. `refs/heads/main` keeps the local commit. These fail on main for `main` and `release`. - `host.test.ts`: local commits are kept when local is ahead or diverged, for `main`, `release`, `refs/heads/main` and the default base. These guard against the new rule dropping local work. - `thread-default-policy.test.ts`: implicit project-default and host children of a non-git parent reuse its environment. Both fail on main. Fixes #1917 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: review <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
About a dozen places each worked out a workspace's repository root, branch and base branch separately, and they disagreed. Git commands ran in the environment folder, while diff and status paths are relative to the repository root. So a project in a subfolder of a repository got an empty or wrong diff, and its changed files would not open. Base-branch selection was copied between the worktree plugin and the server. A bare
--base-branch mainused the localmaineven when it was behindorigin/main.What changed
describeHostWorkspaceinpackages/host-workspaceis now the only code that builds a workspace's path, repository root, branch and default branch.environment.attach, the workspace watcher and the newhost.describe_workspacecommand all use it. Repository root and folder prefix come fromgit rev-parse --show-topleveland--show-prefix, read separately so a folder name containing a newline can't be misparsed. Workspace git operations run at the repository root. Discovery now runs on the sharedbb-environment-provider-hostgit runner, which gains host-workspace's bounded retry for silent WindowsSTATUS_DLL_INIT_FAILEDstartup crashes; without it, a transient crash could report a repository as non-Git.WorkspaceStatusgains a requiredrepository: { root, workspacePrefix }. In the thread view, a changed file inside the environment folder opens in the normal preview tab. A file elsewhere in the repository opens as a host file. "Open in editor" uses the same mapping.selectWorktreeBaseBranch(bb-environment-provider-host/base-branch):origin/<name>when local is equal to it or behind;--base-branchhelp inbb thread spawnandbb thread forkdescribes this rule.PluginBbSdk.environments.experimental_describeWorkspaceandbb environment workspace <id>, with entries indocs/api_to_audit.md, the Plugin Guide and the CLI command index.bb-environment-provider-hostno longer imports@bb/domain. The plugin host build rejects that import, so the git-worktree, project-checkout and GitHub PR status hosts would not have built. A new plugin-build test builds those three hosts.host-workspace, and the unread descriptor fields in daemon test fakes.Wire changes:
HOST_DAEMON_PROTOCOL_VERSIONgoes from 252 to 253, for the newhost.describe_workspacecommand and the requiredrepositoryfield on theworkspace.statusresult.@get-bb/plugin-sdk0.6.83: main has bumped to that version and it is not published yet.How you verified
pnpm exec turbo run typecheck lint --filter='...[origin/main]': 146/146 pass.oxfmt --checkpasses on changed files.pnpm install --frozen-lockfilepasses.pnpm exec turbo run test --filter='...[origin/main]'. Under full parallel load, Pi provider timeouts and two server plugin-loading tests failed; all of them pass when re-run alone.@bb/desktop's Electron preload smoke test times out the same way on a cleanorigin/maincheckout.packages/app/prefix in status;locateRepositoryFilecases, including thepackages/application/near-miss;selectWorktreeBaseBranchcases;The retry and newline tests fail on the code before the fix.
pnpm start:worktreeinstance. The project was thepackages/appsubfolder of a temporary repository.{"root":"…/qa-repo","workspacePrefix":"packages/app/"}.packages/app/inside.txtopened the workspace preview with the right content.OUTSIDE.mdopened a host-file tab at the repository-root path with the right content.Fixes #3905
Fixes #1917
Related: #3955
🤖 Generated with Claude Code