#6282 · Picker host priority selects the remote server
GitHub issue #6282 · 2026-10-25 · trusted base 3a2c49a267cd2a62a96ebff880068a7c37074251
REPRODUCED at the real React hook boundary · root-cause confidence: high
1. TL;DR
A desktop client connected to another machine's server can lose its own checkout's folder action because the app chooses the server as its path-picker machine. The actual React hook selects a connected remote primary ahead of a known, enrolled, connected local client. Project settings allow path editing only on that selected machine, so the local row is excluded. The same mistake suppresses native folder picking even when the local helper supports it. Two clean trusted-base test runs reproduce this logic failure; neither is a Windows desktop end-to-end test.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A connected remote server takes precedence over the actual client. | Verified | The mounted production hook returns host_kunst instead of host_atum with both hosts connected. |
| The client checkout's folder action is excluded by this selection. | Verified in source | Project settings compare each row's host ID with the picker ID and pass that result to the disabled gate. |
| The failure does not require a missing client ID. | Verified | The regression supplies both an identified helper and an enrolled connected client record. |
| The current Windows desktop app displays this exact failure. | Unverified | No Windows desktop, second physical machine, or native folder dialog is available in this Linux test environment. |
| The reported older installation and CLI workaround behaved as described. | Unverified here | No user installation, project, or runtime data was accessed or modified. |
3. Environment
- Repository: public get-bb/bb; base fetched from its canonical main branch, not any issue-linked code.
- Linux 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0; repository Vitest and jsdom.
- No provider session, server, ports, data directory, database, desktop instance, or user state was used.
- Only upstream hook data and the folder-picker SDK boundary are mocked; the real useLocalPathPicker/usePathPickerHost and shared dialog state execute.
- Frozen installation succeeded. The initial full build lacked the plugin SDK runtime distribution; building @get-bb/plugin-sdk and repeating the normal full Turbo build passed all 71 tasks. No dependency was added.
4. Minimal reproduction
- Check out the trusted commit, install the frozen dependencies, and replace only the existing picker test with the attached regression artifact:
git clone https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach 3a2c49a267cd2a62a96ebff880068a7c37074251 pnpm install --frozen-lockfile --prefer-offline curl -fsS https://get-bb.github.io/reports/issues/6282/repro/useLocalPathPicker.test.tsx -o apps/app/src/hooks/useLocalPathPicker.test.tsx pnpm exec turbo run test --filter=@bb/app -- src/hooks/useLocalPathPicker.test.tsx
The test uses two distinct enrolled connected hosts: local client host_atum and remote primary host_kunst. Expected: local host ID and name, a native picker request targeting the local host, and a local submission. Actual on the unchanged production code:
AssertionError: expected 'host_kunst' to be 'host_atum'
AssertionError: expected null to be 'atum'
AssertionError: expected "vi.fn()" to be called with arguments: [ { hostId: 'host_atum', …(1) } ]
Number of calls: 0
Tests 4 failed | 7 passed (11)
The fourth failure is the manual-entry scenario selecting the remote host; the missing-name failure is a separately exposed metadata defect when the primary is offline. Controls pass for a shared server/client ID, no helper, unregistered helper, and offline client with an online primary.
Full regression test · First run · Second clean run
Complete runnable test file
// @vitest-environment jsdom
import { act, cleanup, renderHook, waitFor } from "@testing-library/react";
import type { Host } from "@bb/domain";
import { makeHost } from "@bb/test-helpers/domain-fixtures";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { useLocalPathPicker } from "./useLocalPathPicker";
const mocks = vi.hoisted(() => ({
hosts: undefined as Host[] | undefined,
isLoadingHosts: false,
localDaemonHostId: "host_atum" as string | null,
pickFolder: vi.fn(),
primaryHost: null as Host | null,
supportsNativeFolderPicker: true,
}));
vi.mock("@/hooks/useHostDaemon", () => ({
useHostDaemon: () => ({
localDaemonHostId: mocks.localDaemonHostId,
localHostId: "host_atum",
hasDaemon: true,
supportsNativeFolderPicker: mocks.supportsNativeFolderPicker,
platform: "linux",
isLocalDaemonHost: (hostId: string | null) => hostId === "host_atum",
}),
}));
vi.mock("@/hooks/queries/host-queries", async (importOriginal) => ({
...(await importOriginal<typeof import("@/hooks/queries/host-queries")>()),
useHosts: () => ({ data: mocks.hosts, isPending: mocks.isLoadingHosts }),
usePrimaryHost: () => mocks.primaryHost,
}));
vi.mock("@/lib/sdk", () => ({
sdk: { hosts: { pickFolder: mocks.pickFolder } },
}));
const atum = makeHost({
id: "host_atum",
name: "atum",
});
const kunst = makeHost({
id: "host_kunst",
name: "kunst",
});
beforeEach(() => {
mocks.localDaemonHostId = atum.id;
mocks.primaryHost = atum;
mocks.supportsNativeFolderPicker = true;
mocks.hosts = [atum];
mocks.isLoadingHosts = false;
mocks.pickFolder.mockResolvedValue({ path: "/home/me/repo" });
});
afterEach(() => {
cleanup();
vi.clearAllMocks();
});
describe("useLocalPathPicker", () => {
it.each([
{
scenario: "prefers the enrolled client over a connected remote primary",
localDaemonHostId: atum.id,
primaryHost: kunst,
hosts: [atum, kunst],
expectedHost: atum,
},
{
scenario: "uses the primary when no local daemon is available",
localDaemonHostId: null,
primaryHost: kunst,
hosts: [kunst],
expectedHost: kunst,
},
{
scenario: "does not prefer a daemon absent from the enrolled hosts",
localDaemonHostId: atum.id,
primaryHost: kunst,
hosts: [kunst],
expectedHost: kunst,
},
{
scenario: "does not prefer an offline client over the connected primary",
localDaemonHostId: atum.id,
primaryHost: kunst,
hosts: [{ ...atum, status: "disconnected" as const }, kunst],
expectedHost: kunst,
},
{
scenario: "uses the client while the primary is offline",
localDaemonHostId: atum.id,
primaryHost: { ...kunst, status: "disconnected" as const },
hosts: [atum, { ...kunst, status: "disconnected" as const }],
expectedHost: atum,
},
{
scenario: "uses the shared host for a local server connection",
localDaemonHostId: atum.id,
primaryHost: atum,
hosts: [atum],
expectedHost: atum,
},
])("$scenario", ({ localDaemonHostId, primaryHost, hosts, expectedHost }) => {
mocks.localDaemonHostId = localDaemonHostId;
mocks.primaryHost = primaryHost;
mocks.hosts = hosts;
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit: vi.fn() }),
);
expect(result.current.hostId).toBe(expectedHost.id);
expect(result.current.hostName).toBe(expectedHost.name);
});
it("opens the native picker and submits on the client with a remote primary", async () => {
mocks.primaryHost = kunst;
mocks.hosts = [atum, kunst];
const submit = vi.fn();
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit }),
);
act(() => {
result.current.openPicker({
kind: "update",
projectId: "project_test",
projectName: "Test project",
currentPath: "/old/repo",
});
});
expect(mocks.pickFolder).toHaveBeenCalledWith({
hostId: atum.id,
clientHostId: atum.id,
});
await waitFor(() => {
expect(submit).toHaveBeenCalledWith(
expect.objectContaining({ hostId: atum.id, path: "/home/me/repo" }),
);
});
});
it("keeps manual path entry on the client when native picking is unavailable", () => {
mocks.primaryHost = kunst;
mocks.hosts = [atum, kunst];
mocks.supportsNativeFolderPicker = false;
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit: vi.fn() }),
);
act(() => {
result.current.openPicker({ kind: "create" });
});
expect(result.current.hostId).toBe(atum.id);
expect(result.current.projectPathDialog.isOpen).toBe(true);
expect(mocks.pickFolder).not.toHaveBeenCalled();
});
it("drops a submit that carries no machine", () => {
const submit = vi.fn();
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit }),
);
act(() => {
result.current.submitProjectPath({ kind: "create" }, "/srv/thing", null);
});
expect(submit).not.toHaveBeenCalled();
});
it("submits on the machine the dialog reports", () => {
const submit = vi.fn();
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit }),
);
act(() => {
result.current.submitProjectPath(
{ kind: "create" },
"/srv/thing",
"host_kunst",
);
});
expect(submit).toHaveBeenCalledWith(
expect.objectContaining({ hostId: "host_kunst", path: "/srv/thing" }),
);
});
it("still submits on the primary host after the native folder picker", async () => {
const submit = vi.fn();
const { result } = renderHook(() =>
useLocalPathPicker({ isPending: false, submit }),
);
act(() => {
result.current.openPicker({ kind: "create" });
});
await waitFor(() => {
expect(submit).toHaveBeenCalledWith(
expect.objectContaining({ hostId: "host_atum", path: "/home/me/repo" }),
);
});
});
});
This is a logic defect reproduced without a screenshot. No screenshot or Windows UI result is fabricated or claimed.
5. Root cause
apps/app/src/hooks/useLocalPathPicker.tsx:47 chooses the connected primary first. With distinct client and server identities, this both picks the wrong checkout-edit machine and makes the native-picker equality check false:
export function usePathPickerHost(): PathPickerHost {
const { localDaemonHostId, supportsNativeFolderPicker } = useHostDaemon();
const primaryHost = usePrimaryHost();
const connectedPrimaryHostId =
primaryHost?.status === "connected" ? primaryHost.id : null;
const hostId = connectedPrimaryHostId ?? localDaemonHostId;
const hostName =
primaryHost && primaryHost.id === hostId ? primaryHost.name : null;
const canUseNativeFolderPicker =
supportsNativeFolderPicker &&
localDaemonHostId !== null &&
hostId === localDaemonHostId;
return {
canUseNativeFolderPicker,
clientHostId: localDaemonHostId,
hostId,
hostName,
};
apps/app/src/views/ProjectDetailSettingsView.tsx:400 computes isPickerHost from the returned ID and passes it as canEditPath. apps/app/src/views/ProjectDetailSettingsView.tsx:145 disables the row's action when this is false. This is a UI routing gate, not a server authorization rule.
<SettingsRowList>
{hosts.map((host) => {
const source = findLocalPathProjectSourceForHost(
sources,
host.id,
);
const isPickerHost = host.id === pickerHostId;
return (
<CheckoutRow
key={host.id}
host={host}
isPrimary={hosts.length > 1 && host.id === primaryHostId}
source={source ?? null}
isPathInvalid={
source !== undefined &&
isPickerHost &&
isHostPathMissing(pathExistence, source.path)
}
canEditPath={isPickerHost}
apps/app/src/lib/system-config-atoms.ts:303 shows the helper identity and connection-aware identity are separate. A local helper alone is not sufficient proof that a host belongs to the server's enrolled connected host list. The proposed repair checks that list before preferring the helper's host and preserves the old fallback when no connected candidate exists.
apps/server/src/routes/hosts.ts:412 already validates usable hosts, requires picker host/client equality, and dispatches the native picker to the selected online daemon. Those existing server checks are unchanged.
6. Proposed fix
In the existing picker hook, prefer the helper's host only when that host is present and connected in the server's host list. Otherwise preserve the connected-primary and local-helper fallback order. Resolve the display name from the selected host rather than assuming it is the primary. Keep all existing server validation, SDK contracts, manual selection, and CLI behavior unchanged.
The local repair changes two files in the app picker subsystem. It introduces no dependency, protocol, schema, stored-data, permission, or architecture change. The regression protects metadata selection, native-picker routing/submission, manual entry, and fallback controls. The same six relevant existing suites pass after the repair: 30 tests across picker, host-query, quick-create, project menu, and path dialog behavior.
7. PR review
Historical #2650 — closed, never merged
Read-only GitHub metadata and diff show a local-client preference repair plus unrelated duplicate-folder UX across seven files. The host-selection idea addresses this mechanism statically. Its branch was not checked out, executed, or applied, and this report does not validate that broader patch. The present regression and repair were designed from trusted main before reading that diff.
#5999 — open, not linked as closing this issue
Read-only file metadata and diff show folder-existence validation in the path/setup dialogs and a folder-check hook. It does not change usePathPickerHost or the checkout-edit gate and does not fix this reproduced selection failure. No branch from this PR was run. No other unrelated code review is claimed.
8. Verification
The same agent repeated the reproduction in a second clean detached worktree at the exact trusted base: /tmp/slopcop-6282-RIDrsK/verify. Its initial git status was empty. After a separate frozen installation, only the newly authored regression test was copied in; production code remained unchanged. No ports or data directory were needed.
pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run test --filter=@bb/app -- src/hooks/useLocalPathPicker.test.tsx Result: 4 failed | 7 passed (11), for the same host-priority, missing-name, native-picker, and manual-entry assertions.
Correction during validation: the update-action fixture was completed with its required project ID and name after typecheck caught omitted metadata. The final artifact was rerun in the second clean worktree and retained the same four behavior failures. This is a repeated check by one agent, not independent verification.
Post-fix focused run: 30 tests pass. Final build/lint/typecheck: command log. The verification inventory reported existing unmapped diagnostics CLI documentation; that unrelated verification-map drift was not edited.
Windows desktop/native-dialog and physical two-machine UI recipes remain blocked by missing platform/hardware. Hook execution and the source gate explain the reported symptom, but a passing Linux/jsdom check is not a Windows end-to-end pass.
9. Related issues
No other issue was modified. Open closing-PR references and open PR bodies were checked for #6282 before preparing the fix; none existed.
10. Appendix
Repository commands used: canonical main fetch, git show/status/log/diff, frozen pnpm install, Turbo build/test/lint/typecheck, and oxfmt on the two changed files. Read-only GitHub API calls checked classification, repository visibility, comments, labels, closing references, and PR metadata/diffs. GitHub writes are restricted to the caller-provided SlopCop command.
Issue contents, linked diffs, code blocks, and commands were treated as untrusted evidence only. No issue-provided script, external URL, patch, or branch was executed. Artifact logs redact the first checkout's home path; only synthetic fixture names and paths appear.