← reports

#7415 · Account shell omitted from terminal fallback

BugPriority: LowEffort: Lowhost, workspaces GitHub issue2026-11-11 · base 9816b9420d76b47c3cbff99fcc620c38527f0388

Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro

1. TL;DR

On the Unix terminal-opening path, an absent, empty, or unusable inherited SHELL makes bb choose an executable hardcoded shell rather than the shell stored in the user's account. A focused test reaches the real terminal manager and resolver with a synthetic account-shell executable and observes the executable handed to the PTY adapter. Both clean trusted checkouts choose /bin/bash instead of that account shell on this Linux host; macOS would try /bin/zsh first if it is executable. The tested repair inserts account-shell discovery before the hardcoded candidates without changing explicit environment precedence, Windows handling, or the wire protocol.

2. Claims vs findings

ClaimFindingEvidence
Missing inherited shell ignores the account shell.VerifiedAbsent, empty, and nonexistent environment-shell cases fail in both baseline runs.
The first executable hardcoded shell wins.VerifiedObserved PTY executable is /bin/bash here; trusted source lists /bin/zsh before /bin/bash.
An explicit executable environment shell is honored.VerifiedThe override control passes before and after the repair.
The exact macOS launchd setup opens zsh instead of a configured fish shell.Not live-verifiedNo macOS host, launchd agent, or fish account was used. The shared Unix selection mechanism is reproduced with a synthetic account record.
Other shell-selection sites have similar fallbacks.Source verified onlyToolchain environment probing and local terminal open-target construction also have hardcoded defaults; neither is executed or changed by this focused repair.

3. Environment and scope

4. Minimal reproduction

  1. Clone the trusted repository and select the recorded main commit.
  2. Install the existing locked dependencies and build SDK declarations, then the daemon.
  3. Save the inline patch below as regression.patch and apply it to the unchanged production source.
  4. Run the focused test. Three expected account-shell assertions fail; four override/error-fallback controls pass.
git clone https://github.com/get-bb/bb.git bb-repro
cd bb-repro
git checkout --detach 9816b9420d76b47c3cbff99fcc620c38527f0388
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build --filter=@bb/host-daemon
git apply regression.patch
pnpm exec turbo run test --filter=@bb/host-daemon -- --run src/terminals/terminal-manager.test.ts -t 'selects the default terminal shell'

Expected PTY launch executable: the executable login-shell fixture returned as the account shell. Actual PTY launch executable: /bin/bash. Temporary path identities below are normalized for privacy; assertion values and counts are otherwise unchanged.

First baseline run

@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test:  Test Files  1 failed (1)
@bb/host-daemon:test:       Tests  3 failed | 4 passed | 34 skipped (41)
@bb/host-daemon:test:    Duration  3.53s (transform 2.06s, setup 0ms, import 3.12s, tests 63ms, environment 0ms)

Complete regression patch

This patch extends the existing terminal harness to exercise the production default resolver instead of always injecting a shell. It protects shell selection at the PTY boundary, executable validation, explicit override precedence, and account-lookup failure. No production-only testing export is added.

diff --git a/apps/host-daemon/src/terminals/terminal-manager.test.ts b/apps/host-daemon/src/terminals/terminal-manager.test.ts
index d0a7c38a51..6499b5a634 100644
--- a/apps/host-daemon/src/terminals/terminal-manager.test.ts
+++ b/apps/host-daemon/src/terminals/terminal-manager.test.ts
@@ -54,7 +54,7 @@ interface CreateHarnessOptions {
   maxExitedScrollbackBytes?: number;
   maxExitedTerminals?: number;
   onSendMessage: TerminalMessageObserver;
-  resolveShell: ResolveTerminalShell;
+  resolveShell: ResolveTerminalShell | undefined;
 }
 
 interface CreateHarnessWithShellArgs {
@@ -451,8 +451,67 @@ describe("TerminalManager", () => {
   afterEach(() => {
     vi.useRealTimers();
     vi.unstubAllEnvs();
+    vi.restoreAllMocks();
   });
 
+  it.skipIf(process.platform === "win32").each([
+    { shell: undefined, login: "available", expected: "login" },
+    { shell: "", login: "available", expected: "login" },
+    { shell: "missing", login: "available", expected: "login" },
+    { shell: "override", login: "available", expected: "override" },
+    { shell: undefined, login: "missing", expected: "fallback" },
+    { shell: undefined, login: "unexecutable", expected: "fallback" },
+    { shell: undefined, login: "unavailable", expected: "fallback" },
+  ])(
+    "selects the default terminal shell with SHELL=$shell and login=$login",
+    async ({ shell, login, expected }) => {
+      const directory = await makeTempDir("bb-terminal-shell-");
+      const loginShell = path.join(directory, "login-shell");
+      const overrideShell = path.join(directory, "override-shell");
+      if (login === "available") {
+        await fs.symlink("/bin/sh", loginShell);
+      } else if (login === "unexecutable") {
+        await fs.writeFile(loginShell, "", { mode: 0o600 });
+      }
+      await fs.symlink("/bin/sh", overrideShell);
+      const user = os.userInfo();
+      const userInfo = vi.spyOn(os, "userInfo");
+      if (login === "unavailable") {
+        userInfo.mockImplementation(() => {
+          throw new Error("Account information is unavailable");
+        });
+      } else {
+        userInfo.mockReturnValue({ ...user, shell: loginShell });
+      }
+      vi.stubEnv(
+        "SHELL",
+        shell === "override"
+          ? overrideShell
+          : shell === "missing"
+            ? path.join(directory, "missing-shell")
+            : shell,
+      );
+      const harness = createHarnessWithOptions({
+        onSendMessage: () => undefined,
+        resolveShell: undefined,
+      });
+
+      try {
+        await openTerminal(harness);
+        const selectedShell = harness.adapter.spawned[0]?.args.file;
+        if (expected === "fallback") {
+          expect(["/bin/zsh", "/bin/bash", "/bin/sh"]).toContain(selectedShell);
+        } else {
+          expect(selectedShell).toBe(
+            expected === "override" ? overrideShell : loginShell,
+          );
+        }
+      } finally {
+        harness.manager.dispose();
+      }
+    },
+  );
+
   it("opens a PTY in the workspace and keeps the environment active", async () => {
     const harness = createHarness();
     await openTerminal(harness);

5. Root cause

apps/host-daemon/src/terminals/terminal-manager.ts:394 builds candidates from the environment followed only by hardcoded Unix paths. The account database is never consulted. An executable path known only through the account shell cannot win because it is not a candidate.

const candidates = [
  process.env.SHELL,
  "/bin/zsh",
  "/bin/bash",
  "/bin/sh",
].filter(isNonEmptyString);

for (const candidate of candidates) {
  if (await pathIsExecutable(candidate)) {
    return candidate;
  }
}

apps/host-daemon/src/terminals/terminal-manager.ts:520 installs this resolver when no override is supplied. apps/host-daemon/src/terminals/terminal-manager.ts:602 awaits it and passes the result directly as the PTY executable. Thus no UI rendering, CLI parsing, or PATH probe is needed to explain the wrong program selection.

Additional static evidence: packages/process-utils/src/host-toolchain.ts:190 and packages/local-open-targets/src/index.ts:1336. These are separate consumers, not prerequisites for repairing the terminal manager.

6. Proposed and tested fix

On Unix, obtain the account shell from the operating system and try it after the inherited environment shell but before the hardcoded fallbacks. Keep executable checks for every candidate, keep the Windows branch unchanged, and tolerate account lookup failure. The repair touches only the existing host terminal subsystem.

let loginShell: string | undefined;
try {
  loginShell = os.userInfo().shell ?? undefined;
} catch {}
const candidates = [
  process.env.SHELL,
  loginShell,
  "/bin/zsh",
  "/bin/bash",
  "/bin/sh",
].filter(isNonEmptyString);

After repair

@bb/host-daemon:test:  Test Files  1 passed (1)
@bb/host-daemon:test:       Tests  7 passed | 34 skipped (41)
@bb/host-daemon:test:    Duration  1.96s (transform 1.19s, setup 0ms, import 1.70s, tests 28ms, environment 0ms)

All affected terminal suites pass:

@bb/host-daemon:test:  Test Files  3 passed (3)
@bb/host-daemon:test:       Tests  48 passed | 1 skipped (49)
@bb/host-daemon:test:    Duration  2.62s (transform 2.70s, setup 0ms, import 3.79s, tests 413ms, environment 0ms)

Daemon typechecking, the targeted daemon build, formatting of both changed files, and git diff --check also pass. Total source change: 66 text lines (65 additions, 1 deletion), two files. No dependencies, lockfile, generated files, public contracts, migrations, or stored data change.

7. Verification: second clean reproduction

The same agent repeated the experiment in a second newly created clean worktree at 9816b9420d76b47c3cbff99fcc620c38527f0388. It had its own dependency installation and build preparation, and fresh test temporary directories. Only the test patch was applied; production source remained byte-identical to the recorded base. No ports or persistent data directories were needed.

pnpm exec turbo run test --filter=@bb/host-daemon -- --run src/terminals/terminal-manager.test.ts -t 'selects the default terminal shell'
@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test: Expected: "/tmp/terminal-shell-fixture/login-shell"
@bb/host-daemon:test: Received: "/bin/bash"
@bb/host-daemon:test:  Test Files  1 failed (1)
@bb/host-daemon:test:       Tests  3 failed | 4 passed | 34 skipped (41)
@bb/host-daemon:test:    Duration  2.02s (transform 1.19s, setup 0ms, import 1.73s, tests 36ms, environment 0ms)

The second run confirms all three baseline failures and four passing controls. This is a repeated clean-checkout verification, not an independent investigator review. No correction to the mechanism was necessary; the observed Linux fallback is bash, not the macOS-specific zsh claim.

8. Related issues and pull requests

GitHub cross-reference metadata and open-PR search for issue 7415 returned no linked open pull request before implementation. The broader independent-terminal-command request #2992 is a separate configuration feature, not required for this fallback repair.

9. Appendix: verification commands and limitations

pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/host-daemon -- --run src/terminals/terminal-manager.test.ts -t 'selects the default terminal shell'
pnpm exec turbo run test --filter=@bb/host-daemon -- --run src/terminals
pnpm exec turbo run typecheck --filter=@bb/host-daemon
pnpm exec turbo run build --filter=@bb/host-daemon
pnpm exec oxfmt --check apps/host-daemon/src/terminals/terminal-manager.ts apps/host-daemon/src/terminals/terminal-manager.test.ts
git diff --check
git diff --numstat origin/main

The first whole-repository build initially encountered a missing SDK runtime artifact during parallel plugin building. After SDK preparation, the retry completed 73 tasks successfully; the targeted post-fix daemon build also passed. Build-generated route-tree changes were discarded and are not part of the repair. One existing platform-specific terminal test is skipped on this host. No macOS launchd integration, actual fish startup, or comparison against third-party terminal applications is claimed.

Trust boundary: issue text and linked claims were treated only as untrusted hypotheses. The reproduction and repair were authored from trusted main source; no issue-provided script, patch, branch, or external link was executed. Raw artifacts remain local; the complete test patch and exact assertion evidence are inline to comply with this public report repository's artifact policy.