All reports

#7984 · Continuation placement and sidebar sections

Bug Priority: Medium Effort: Low threads ui

2026-11-21 · GitHub issue · trusted origin/main 35a03bbbb3f4d8dc814c1a152db5a463102b4250

PARTIALLY REPRODUCED · Root-cause confidence: medium for the original report; high for the custom-section variant.

1. TL;DR

The continuation/handoff request keeps the existing environment ID, so sharing a worktree alone did not reproduce the reported escape from its branch group. A concrete nearby defect does reproduce: a source inside a custom sidebar section produces a continuation with no section. The real section-aware sidebar model then places the continuation outside the source section and its worktree bucket. The failing case and passing unsectioned control repeat in a second clean checkout at the same trusted commit. The report does not establish whether the reporter's group was a custom section, a worktree group, or a nested parent hierarchy.

This is not a full browser reproduction. The isolated app started, but the local Browser Automation backend could not open Chrome/Chromium. No screenshot is supplied, and no issue attachment was fetched. No provider turn was executed. These limits are why the verdict is partial and no automatic fix PR is opened.

2. Claims vs findings

Claim or tested hypothesisFindingEvidence
A continuation loses its source's existing environment.Not observed in the handoff pathThe real create route returns the same environment ID in both test cases.
Continuing a root thread in a shared worktree necessarily loses branch grouping.Not reproduced by the controlWith no custom section, the actual sidebar grouping function returns one environment group containing all three threads.
A continuation can appear outside the source's sidebar grouping.Verified for custom sectionsThe source's non-null section ID becomes null on the continuation. Section-aware grouping returns a section plus a loose thread.
The original screenshot's exact layout, action and group type.UnverifiedThe text does not disambiguate them; external attachment fetching is prohibited by this automation.
Provider-specific behavior or a regression limited to release 0.50.1.UnverifiedThe test runs current trusted main and schedules dispatch in the future; it does not launch Claude Code or Codex.

3. Environment

4. Minimal reproduction

  1. Check out the trusted base in a disposable clone and install the repository's frozen dependencies:
git clone https://github.com/get-bb/bb.git bb-7984
cd bb-7984
git checkout --detach 35a03bbbb3f4d8dc814c1a152db5a463102b4250
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build

The first whole-repository build initially failed because plugin SDK runtime dist files were missing; explicitly building the SDK and repeating the build succeeded (74 tasks). This setup failure is unrelated to the defect.

  1. Save the reproduction test as apps/server/test/public/issue-7984-repro.test.ts.
  2. Run the real handoff request builder, real public create route and real section-aware sidebar model:
pnpm exec turbo run test --filter=@bb/server -- test/public/issue-7984-repro.test.ts --silent=false

Expected: both cases retain the source environment and section. Without a section, all three siblings remain in one worktree group. With a section, the continuation should remain inside that section.

Actual: one control passes; one section-inheritance assertion fails. Random IDs vary, but null versus a non-null source section is invariant. The exact captured records are below.

{"withSection":false,"environmentRetained":true,"sourceSection":null,"continuationSection":null,"sidebarSummary":[{"kind":"environment","threads":3}]}
{"withSection":true,"environmentRetained":true,"sourceSection":"sec_ejcecwq44c","continuationSection":null,"sidebarSummary":[{"kind":"section"},{"kind":"thread"}]}
AssertionError: expected null to be 'sec_ejcecwq44c' // Object.is equality
      Tests  1 failed | 1 passed (2)
Complete executable reproduction test
import { buildThreadHandoffCreateRequest } from "@bb/client-core";
import { createThread, createThreadSection } from "@bb/db";
import { threadResponseSchema } from "@bb/server-contract";
import { describe, expect, it } from "vitest";
import { readJson } from "../helpers/json.js";
import {
  seedEnvironment,
  seedHostSession,
  seedProjectWithSource,
} from "../helpers/seed.js";
import { withTestHarness } from "../helpers/test-app.js";
import { buildSectionThreadList } from "../../../../plugins/thread-list/app/model/project-thread-groups.js";
import {
  makeSidebarEnvironment,
  makeSidebarThread,
} from "../../../../plugins/thread-list/app/model/fixtures.js";

describe("issue 7984 continuation placement", () => {
  it.each([false, true])(
    "retains the source environment and section (section: %s)",
    async (withSection) => {
      await withTestHarness(async (harness) => {
        const { host } = seedHostSession(harness.deps);
        const { project } = seedProjectWithSource(harness.deps, {
          hostId: host.id,
        });
        const environment = seedEnvironment(harness.deps, {
          hostId: host.id,
          projectId: project.id,
          branchName: "bb/test",
        });
        const sectionId = withSection
          ? createThreadSection(harness.db, harness.deps.hub, {
              name: "Reproduction section",
            }).section.id
          : null;
        const source = createThread(harness.db, harness.deps.hub, {
          projectId: project.id,
          providerId: "codex",
          environmentId: environment.id,
          sectionId,
        });
        const seed = {
          environmentId: source.environmentId,
          projectId: source.projectId,
          sourceThreadId: source.id,
          sourceThreadTitle: "Source thread",
          sectionId: source.sectionId,
        };
        const request = buildThreadHandoffCreateRequest({
          draft: { text: "Keep going", mentions: [], attachments: [] },
          execution: {
            providerId: "codex",
            model: "gpt-5",
            reasoningLevel: "high",
            serviceTier: undefined,
            supportsServiceTier: false,
            permissionMode: "full",
          },
          seed,
          sendAt: Date.now() + 3_600_000,
        });
        const response = await harness.app.request("/api/v1/threads", {
          method: "POST",
          headers: { "content-type": "application/json" },
          body: JSON.stringify({ ...request, origin: "app" }),
        });
        expect(response.status).toBe(201);
        const continuation = threadResponseSchema.parse(
          await readJson(response),
        );
        const sidebarEnvironment = makeSidebarEnvironment({
          id: environment.id,
          branchName: environment.branchName,
          isWorktree: true,
        });
        const sidebarItems = buildSectionThreadList(
          [
            makeSidebarThread({
              id: source.id,
              sectionId: source.sectionId,
              environment: sidebarEnvironment,
            }),
            makeSidebarThread({
              id: "thr_peer",
              sectionId: source.sectionId,
              environment: sidebarEnvironment,
            }),
            makeSidebarThread({
              id: continuation.id,
              sectionId: continuation.sectionId,
              environment: sidebarEnvironment,
            }),
          ],
          undefined,
          sectionId === null
            ? []
            : [{ id: sectionId, name: "Reproduction section" }],
          true,
        );
        const sidebarSummary = sidebarItems.map((item) =>
          item.kind === "environment"
            ? { kind: item.kind, threads: item.group.nodes.length }
            : { kind: item.kind },
        );
        console.log(
          JSON.stringify({
            withSection,
            environmentRetained:
              continuation.environmentId === source.environmentId,
            sourceSection: source.sectionId,
            continuationSection: continuation.sectionId,
            sidebarSummary,
          }),
        );
        expect(continuation.environmentId).toBe(source.environmentId);
        expect(continuation.sectionId).toBe(source.sectionId);
        expect(sidebarSummary).toEqual(
          withSection
            ? [{ kind: "section" }]
            : [{ kind: "environment", threads: 3 }],
        );
      });
    },
  );
});

5. Root cause

The handoff seed carries environment/project/source identity, but no sidebar section. The UI builds that same incomplete seed. The handoff request explicitly reuses the environment but sends no section or hierarchy placement. At the server's create boundary, an absent section becomes null. Section-aware sidebar grouping buckets by section before grouping shared worktrees, so the continuation cannot join the source's section-local environment bucket.

Relevant history: 1983b0dfb5 added the slash-command handoff entry. This is context, not proof that the original issue was introduced there. The test distinguishes the source of persisted placement data from the renderer; changing the renderer to ignore sections would hide the defect and violate existing organization.

6. Proposed fix and simple-fix decision

For the verified custom-section variant, propagate the source section through the existing handoff seed and request, using the already-supported create-request section field. A regression should assert actual persisted section membership and verify grouped and ungrouped sources. Before applying that to this issue, establish the original group's type and the exact continuation entry point; separately test nested hierarchy placement if applicable.

No automatic fix branch or PR was created. The plain shared-worktree control passes, and no live browser reproduction establishes that the original scenario uses the section-aware path. Choosing section inheritance or a hierarchy repair as the issue's fix would therefore exceed the evidence. No linked open PR was present in the issue timeline or the open-PR search at investigation time.

7. Verification

The same agent repeated the final test in a second clean, detached checkout at the exact recorded commit, with its own frozen dependency installation and new migrated database harnesses. This is a repeat, not an independent review. No development server, ports or production runtime data were reused for this second route/model reproduction.

cd /tmp/slopcop-7984-verify
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run test --filter=@bb/server -- test/public/issue-7984-repro.test.ts --silent=false

{"withSection":false,"environmentRetained":true,"sourceSection":null,"continuationSection":null,"sidebarSummary":[{"kind":"environment","threads":3}]}
{"withSection":true,"environmentRetained":true,"sourceSection":"sec_vbnx87v3rh","continuationSection":null,"sidebarSummary":[{"kind":"section"},{"kind":"thread"}]}
AssertionError: expected null to be 'sec_vbnx87v3rh' // Object.is equality
      Tests  1 failed | 1 passed (2)

Correction during investigation: a first model probe used the project-only grouping entry point, which intentionally does not partition sections. The final artifact uses the actual section-aware entry point and its output supports only the narrower custom-section finding. Both final runs use byte-identical test files. No claim of a complete UI or provider reproduction is made.

8. Related issues

#7380 concerns global versus project-owned sidebar sections. It is adjacent organization work, not established as a duplicate or explanation of #7984.

9. Appendix and artifacts

Reproduction label: partial-repro. Report by SlopCop. Agent generated.