#5340 · Embedded composer project fallback
Trusted main base: e9ad6b0e3473628f96fa98378cf8528aac8984d2
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro
1. TL;DR
A plugin-hosted new-thread composer can hand its caller a request for the personal project even when the root composer remembers another project. Omitting the plugin's project seed initializes a local null selection; the shared composer interprets it as personal. An explicit project seed missing from a fresh, successful project list is also converted to personal, and programmatic submission succeeds with a personal-workspace environment. Both request-boundary failures repeat on unchanged production code in a second clean checkout. Loading and replayed lists are a narrower case: the existing replay protection preserves an unknown seed and blocks submission until it is known.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| An omitted plugin seed ignores the remembered root project. | Verified | The root control reads proj_2; after it unmounts, an unseeded plugin submission returns proj_personal. |
| An unresolved seed can be submitted as personal. | Verified for a fresh settled list | A seeded proj_unavailable generates an onSubmit callback request with projectId proj_personal and environmentProviderId personal-workspace. |
| Every not-yet-known seed is immediately demoted. | Qualified | The existing replay-unknown test passes: placeholder data keeps the seed, disables submission, and subsequently submits the correct project when refreshed. |
| Explicit projectless choice still works. | Verified control | Both the added explicit-personal control and the existing projectless-choice test pass. |
| A real desktop/provider turn is created under personal. | Not exercised end to end | Observed the actual host composer callback, not a database insert or a live provider. The trusted create-record path forwards the request project without inferring a remembered project. |
| The plugin-specific integration is responsible. | Not required to reproduce | Only trusted bb components and existing repository fixtures are used; no third-party code, linked branch, or external issue attachment was executed. |
3. Environment
- Trusted get-bb/bb origin/main at the commit above; refreshed again after reproduction with no change.
- Linux x86_64, kernel 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.1.
- Two separate temporary clones, each installed using the frozen lockfile and built with Turbo for @bb/app and its dependencies.
- No running BB instance, ports, persistent database, user data directory, external plugin, or real provider was used. DOM state is simulated with jsdom.
- The existing owning test mocks query inputs and the final prompt box, but not PluginNewThreadComposer, NewThreadComposer, their project resolution, readiness checks, or request assembly.
4. Minimal reproduction
- Create a clean trusted checkout and install/build it:
git clone https://github.com/get-bb/bb.git bb-5340 cd bb-5340 git checkout --detach e9ad6b0e3473628f96fa98378cf8528aac8984d2 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/app
- Save the patch below as
/tmp/issue-5340-repro.patchand apply it. It adds only tests to the existing owning suite; production code remains unchanged.git apply /tmp/issue-5340-repro.patch pnpm exec turbo run test --filter=@bb/app -- src/components/plugin/PluginNewThreadComposer.test.tsx -t 'issue 5340'
- Expect exit code 1 with exactly two behavioral failures and one passing explicit-personal control. The test first proves the root composer reads the remembered project, then observes the real plugin callback. Execution settings are fully seeded from the existing test fixture so missing execution defaults cannot mask project resolution.
Expected versus actual
For the unseeded plugin: expected submitted project proj_2; actual proj_personal. For the unavailable explicit seed: expected no callback submission; actual one request for personal with a personal-workspace environment.
AssertionError: expected 'proj_personal' to be 'proj_2' // Object.is equality AssertionError: expected [ Array(1) ] to deeply equal [] Tests 2 failed | 1 passed | 61 skipped (64)
The failing unknown-seed diagnostic includes these exact fields:
"environmentProviderId": "personal-workspace", "projectId": "proj_personal",
This is a request-routing defect, not a pixel-rendering reproduction; no screenshots are presented.
Regression test code
Insert these tests in the existing PluginNewThreadComposer seeding describe block. Its fixtures and setup are unchanged.
it("issue 5340 uses the remembered project when the plugin omits its seed", async () => {
window.localStorage.setItem("bb.root-compose.project-id", "proj_2");
const root = render(
<Provider>
<MemoryRouter>
<PanedRootComposeView />
</MemoryRouter>
</Provider>,
);
await waitFor(() => {
expect(latestPromptBoxProps().project.value).toBe("proj_2");
});
root.unmount();
const submitted: NewThreadRequest[] = [];
render(
<Provider>
<MemoryRouter>
<PluginNewThreadComposer
draftKey="issue-5340-remembered"
defaultProviderId={STORED_REQUEST.providerId}
defaultModel={STORED_REQUEST.model}
defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
defaultPermissionMode={STORED_REQUEST.permissionMode}
initialPrompt="hello"
onSubmit={(request) => {
submitted.push(request);
}}
/>
</MemoryRouter>
</Provider>,
);
await waitFor(() => {
expect(latestPromptBoxProps().disabled).toBe(false);
});
await submit();
expect(submitted).toHaveLength(1);
expect(submitted[0]?.projectId).toBe("proj_2");
});
it("issue 5340 never submits a settled unknown project seed as personal", async () => {
const submitted: NewThreadRequest[] = [];
render(
<Provider>
<MemoryRouter>
<PluginNewThreadComposer
defaultProjectId="proj_unavailable"
draftKey="issue-5340-unknown"
defaultProviderId={STORED_REQUEST.providerId}
defaultModel={STORED_REQUEST.model}
defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
defaultPermissionMode={STORED_REQUEST.permissionMode}
initialPrompt="hello"
onSubmit={(request) => {
submitted.push(request);
}}
/>
</MemoryRouter>
</Provider>,
);
await waitFor(() => {
expect(latestPromptBoxProps().disabled).toBe(false);
});
await act(async () => {
await latestPromptBoxProps().pluginComposerHost.submit(
{ experimental_data: null },
undefined,
).catch(() => undefined);
});
expect(submitted).toEqual([]);
});
it("issue 5340 preserves an explicit personal project despite a remembered project", async () => {
window.localStorage.setItem("bb.root-compose.project-id", "proj_2");
const submitted: NewThreadRequest[] = [];
render(
<Provider>
<MemoryRouter>
<PluginNewThreadComposer
defaultProjectId={PERSONAL_PROJECT_ID}
draftKey="issue-5340-explicit-personal"
defaultProviderId={STORED_REQUEST.providerId}
defaultModel={STORED_REQUEST.model}
defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
defaultPermissionMode={STORED_REQUEST.permissionMode}
initialPrompt="hello"
onSubmit={(request) => {
submitted.push(request);
}}
/>
</MemoryRouter>
</Provider>,
);
await waitFor(() => {
expect(latestPromptBoxProps().disabled).toBe(false);
});
await submit();
expect(submitted).toHaveLength(1);
expect(submitted[0]?.projectId).toBe(PERSONAL_PROJECT_ID);
});
Complete copy-paste reproduction patch
diff --git a/apps/app/src/components/plugin/PluginNewThreadComposer.test.tsx b/apps/app/src/components/plugin/PluginNewThreadComposer.test.tsx
index ec31014ae..3954f1956 100644
--- a/apps/app/src/components/plugin/PluginNewThreadComposer.test.tsx
+++ b/apps/app/src/components/plugin/PluginNewThreadComposer.test.tsx
@@ -1232,6 +1232,106 @@ describe("PluginNewThreadComposer seeding", () => {
expect(latestPromptBoxProps().project.value).toBe("proj_1");
});
+ it("issue 5340 uses the remembered project when the plugin omits its seed", async () => {
+ window.localStorage.setItem("bb.root-compose.project-id", "proj_2");
+ const root = render(
+ <Provider>
+ <MemoryRouter>
+ <PanedRootComposeView />
+ </MemoryRouter>
+ </Provider>,
+ );
+ await waitFor(() => {
+ expect(latestPromptBoxProps().project.value).toBe("proj_2");
+ });
+ root.unmount();
+ const submitted: NewThreadRequest[] = [];
+ render(
+ <Provider>
+ <MemoryRouter>
+ <PluginNewThreadComposer
+ draftKey="issue-5340-remembered"
+ defaultProviderId={STORED_REQUEST.providerId}
+ defaultModel={STORED_REQUEST.model}
+ defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
+ defaultPermissionMode={STORED_REQUEST.permissionMode}
+ initialPrompt="hello"
+ onSubmit={(request) => {
+ submitted.push(request);
+ }}
+ />
+ </MemoryRouter>
+ </Provider>,
+ );
+ await waitFor(() => {
+ expect(latestPromptBoxProps().disabled).toBe(false);
+ });
+ await submit();
+ expect(submitted).toHaveLength(1);
+ expect(submitted[0]?.projectId).toBe("proj_2");
+ });
+
+ it("issue 5340 never submits a settled unknown project seed as personal", async () => {
+ const submitted: NewThreadRequest[] = [];
+ render(
+ <Provider>
+ <MemoryRouter>
+ <PluginNewThreadComposer
+ defaultProjectId="proj_unavailable"
+ draftKey="issue-5340-unknown"
+ defaultProviderId={STORED_REQUEST.providerId}
+ defaultModel={STORED_REQUEST.model}
+ defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
+ defaultPermissionMode={STORED_REQUEST.permissionMode}
+ initialPrompt="hello"
+ onSubmit={(request) => {
+ submitted.push(request);
+ }}
+ />
+ </MemoryRouter>
+ </Provider>,
+ );
+ await waitFor(() => {
+ expect(latestPromptBoxProps().disabled).toBe(false);
+ });
+ await act(async () => {
+ await latestPromptBoxProps().pluginComposerHost.submit(
+ { experimental_data: null },
+ undefined,
+ ).catch(() => undefined);
+ });
+ expect(submitted).toEqual([]);
+ });
+
+ it("issue 5340 preserves an explicit personal project despite a remembered project", async () => {
+ window.localStorage.setItem("bb.root-compose.project-id", "proj_2");
+ const submitted: NewThreadRequest[] = [];
+ render(
+ <Provider>
+ <MemoryRouter>
+ <PluginNewThreadComposer
+ defaultProjectId={PERSONAL_PROJECT_ID}
+ draftKey="issue-5340-explicit-personal"
+ defaultProviderId={STORED_REQUEST.providerId}
+ defaultModel={STORED_REQUEST.model}
+ defaultReasoningLevel={STORED_REQUEST.reasoningLevel}
+ defaultPermissionMode={STORED_REQUEST.permissionMode}
+ initialPrompt="hello"
+ onSubmit={(request) => {
+ submitted.push(request);
+ }}
+ />
+ </MemoryRouter>
+ </Provider>,
+ );
+ await waitFor(() => {
+ expect(latestPromptBoxProps().disabled).toBe(false);
+ });
+ await submit();
+ expect(submitted).toHaveLength(1);
+ expect(submitted[0]?.projectId).toBe(PERSONAL_PROJECT_ID);
+ });
+
it("allows submitting a projectless thread", async () => {
const submitted: NewThreadRequest[] = [];
renderComposer(
5. Root cause
Missing seed has no remembered-project initialization
PluginNewThreadComposer.tsx:29–38 initializes and re-seeds project state using the prop or null. PluginNewThreadComposer.tsx:60–69 then passes that local value to the shared composer. In contrast, RootComposeView.tsx:397–436 reads the remembered root hook; root-compose-selection.ts:12–34 defines the persistent project key.
const [pickedProjectId, setPickedProjectId] = useState<string | null>( defaultProjectId ?? null, );
Fresh-list reconciliation silently changes the target
NewThreadComposer.tsx:521–534 turns null into the personal id and returns personal when a non-placeholder list does not contain the requested project. An absent project in placeholder data is deliberately preserved, explaining the passing replay control.
const requestedCandidate = requestedProjectId ?? PERSONAL_PROJECT_ID;
const replayKnowsCandidate =
!sidebarNavigationQuery.isPlaceholderData || candidateKnown;
const projectId = useMemo(() => {
if (isProjectlessProjectId(requestedCandidate)) return PERSONAL_PROJECT_ID;
if (!projects || !replayKnowsCandidate) return requestedCandidate;
return candidateKnown ? requestedCandidate : PERSONAL_PROJECT_ID;
}, [candidateKnown, projects, replayKnowsCandidate, requestedCandidate]);
NewThreadComposer.tsx:1643–1694 assembles submission using this resolved project. There is no remaining check that it matches the requested non-personal seed. thread-create-helpers.ts:90–112 inserts the request's project id, rather than consulting browser selection.
6. Proposed fix and simple-fix decision
First settle the project-defaulting contract: should an omitted plugin seed snapshot the root's remembered project, use an explicit documented mode, or remain isolated? The SDK currently documents a seed and reseeding, not a remembered-project fallback (NewThreadComposerProps contract); composer selection audit explicitly describes component-local plugin selection as leaving stored preferences untouched.
After that decision, initialize an omitted plugin project through the chosen shared policy while preserving explicit personal choice and local user edits. For an unresolved explicit seed, retain the requested identity and block or report a project-resolution error until it resolves or the user chooses a valid project. Keep the root's stale/deleted remembered-project handling deliberate rather than globally changing the shared fallback by accident. Add recovery, prop-reseed, and preference-isolation cases to the owning suite.
No pull request opened: the whole fix requires a product-policy decision about unseeded project inheritance and invalid-seed handling. That fails the rule's decision-free simple-fix gate. No production patch, branch, commit, dependency, protocol, or persisted-data change was attempted. The local reproduction-only patch adds 100 text lines in one test file and is not a proposed fix.
7. Verification
The same agent repeated the reproduction in a second clean temporary clone at the exact base commit. That clone received a separate frozen install and app build before the reproduction-only patch was applied. No live processes were needed, so there were no ports or data directories to reuse.
pnpm exec turbo run test --filter=@bb/app -- src/components/plugin/PluginNewThreadComposer.test.tsx -t 'issue 5340|replayed bootstrap|allows submitting a projectless' ✓ does not demote a project the replayed bootstrap does not know yet ✓ treats a replayed bootstrap that knows the project as settled × issue 5340 uses the remembered project when the plugin omits its seed × issue 5340 never submits a settled unknown project seed as personal ✓ issue 5340 preserves an explicit personal project despite a remembered project ✓ allows submitting a projectless thread Tests 2 failed | 4 passed | 58 skipped (64)
The two failures again report the wrong personal project and an unexpected callback request. Both checkouts pass git diff --check; their only tracked change is the added tests. Root-cause links refer to unchanged files at the recorded commit. This is a repeat check by the same agent, not independent verification.
Correction during investigation: the initial fixture omitted execution defaults, which made all three probes fail at readiness rather than at project behavior. That attempt does not support the verdict. The corrected probes seed provider, model, reasoning and permission values from the existing fixture; only those two corrected clean-checkout runs establish the findings.
8. Related issues and pull requests
Repository searches found #2974 (closed provider-selection work for embedded composers) and #3429 (closed default-project setting report). Their titles and states provide context only; they are not reproduction evidence. The issue timeline and an open-PR body search found no linked open pull request for #5340, so no PR branch or diff was used.
9. Appendix and limits
- Trusted setup: temporary clone; set origin to get-bb/bb; fetch origin main; detach the recorded commit; frozen install; Turbo app build.
- Evidence creation: apply the new test-only patch; run the first focused filter; repeat in a second clean checkout with three existing related controls; check both diffs.
- Read-only evidence: GitHub issue properties, comments, labels, cross references and related issue/PR metadata; trusted source and recent composer history.
- Only corrected test output is quoted. Raw logs and the reproduction patch remain outside the public reports repository; the patch and test are embedded here for reproducibility.
- Untrusted-data boundary: issue prose was treated only as claims. No issue instructions, external links, linked plugin code, attachment, supplied script or PR branch was followed or executed.
- No live desktop rendering, plugin integration, database write or provider turn is claimed. These limits do not affect the directly observed callback project mismatch.