#6996 · Multiword mention sessions outlive empty results
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro
1. TL;DR
The composer treats ordinary spaces as valid characters inside mention names. That is intentional: real mentions can have multiple words. However, a completed search with no suggestions does not end a multiword mention session, so ordinary prose continues to own an empty suggestion menu. A focused test of the real composer reproduces this in two separate clean checkouts of the same trusted main commit. A separate direct parser probe confirms that the eventual cutoff comes from the bounded scan rather than a semantic end to the query.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Spaces do not terminate a mention query. | Verified | The trusted parser returns a mention for a synthetic multiword query, including a 254-character query. |
| The empty menu survives a settled multiword search. | Verified | The real ComposerBox DOM contains “No matching mentions”; the search remains active instead of returning to a null query. |
| The late cutoff is a 256-character scan-window effect. | Verified | For a space-delimited trigger at offset 6, query length 254 is active and query length 255 is not. The boundary character preceding the trigger has left the window. |
| Every keystroke causes a network request. | Not established | The editor updates the search input when the trigger query changes. Actual source requests are debounced and cached; this investigation does not equate input updates with network calls. |
| The same visible behavior occurs on the reported macOS build. | Unverified platform | Repeated on Linux using the actual composer DOM in jsdom. No macOS or real-browser screenshot verification was available. |
3. Environment
- Public repository
get-bb/bb; trustedorigin/maincommit64c2f7099e1a678070dd24d730aa1120b2fb18e1. - Linux x86_64; Node
v22.19.0; pnpm9.15.0; Vitest4.1.1. - Two distinct clean temporary Git worktrees at that exact commit; only the investigator-authored regression test was added to each for the baseline runs.
- No provider session, database fixture, account, or external mention provider is needed. Existing composer fixtures supply a completed empty search while the real editor, SDK composer host, menu, and dismissal lifecycle execute.
- An isolated dev instance was briefly launched on app/server/daemon ports
14667/22667/30667, using its fresh checkout-specific store. Server health passed. Browser Automation could not open a session because Chrome/Chromium was absent; it produced no screenshots. The dev processes were stopped.
4. Minimal reproduction
A. Repeatable real-composer regression
- Create a fresh checkout at the trusted base. Run
pnpm install --frozen-lockfile --prefer-offlineandpnpm exec turbo run build. - Add this case inside the existing
ComposerBox mention triggersdescribe block inapps/app/src/components/promptbox/PromptBoxInternal.test.tsx. It uses the file's existing real-composer harness:
it("ends an unmatched multiword mention occurrence without changing prose", async () => {
const text = "Notes @unlisted topic";
const { changes, onMentionQueryChange, promptBoxRef } = renderPromptBox(text);
await focusPromptEnd(promptBoxRef);
await waitFor(() =>
expect(onMentionQueryChange).toHaveBeenLastCalledWith(null, null),
);
expect(screen.queryByText("No matching mentions")).toBeNull();
expect(screen.queryByRole("button", { name: "Close suggestions" })).toBeNull();
expect(getPromptEditorElement().textContent).toBe(text);
onMentionQueryChange.mockClear();
await act(async () =>
promptBoxRef.current?.voice?.deliverTranscript("continues", "insert"),
);
await waitFor(() =>
expect(latestValue(changes)).toBe(`${text} continues`),
);
expect(onMentionQueryChange.mock.calls.every(([query]) => query === null)).toBe(true);
expect(screen.queryByRole("button", { name: "Close suggestions" })).toBeNull();
expect(latestChange(changes)?.mentions).toEqual([]);
});
Run from the repository root:
pnpm exec turbo run test --filter=@bb/app -- \ src/components/promptbox/PromptBoxInternal.test.tsx \ -t 'ends an unmatched multiword mention occurrence' \ --reporter=json --outputFile=/tmp/6996-results.json
Expected: the completed empty multiword search becomes inactive, its menu closes, subsequent prose does not restart that occurrence, and no text or mention data changes. Actual on trusted main, in both clean worktrees:
numPassedTests: 0 numFailedTests: 1 AssertionError: expected last "vi.fn()" call to have been called with [ null, null ]
The failure's captured real composer DOM includes this text under data-promptbox-typeahead-menu:
No matching mentions
B. Direct scan-window probe
Save the following as scan-window-repro.mjs and run node --import tsx ./scan-window-repro.mjs "$PWD" from the trusted repository root. This probe characterizes existing parsing; it is not a substitute for the failing composer regression.
import assert from "node:assert/strict";
import { resolve } from "node:path";
import { pathToFileURL } from "node:url";
const repositoryRoot = process.argv[2];
const { findActiveTrigger } = await import(pathToFileURL(resolve(repositoryRoot, "plugins/composer/src/mentions/find-active-trigger.ts")));
const text = `Notes @${"unlisted topic ".repeat(24)}`;
const triggerOffset = text.indexOf("@");
const triggers = [{ char: "@", kind: "mention" }];
for (const queryLength of [0, 14, 100, 254, 255]) {
const caret = triggerOffset + 1 + queryLength;
const editor = {
state: {
selection: { empty: true, from: caret },
doc: { textBetween: (from, to) => text.slice(from, to) },
},
};
const active = findActiveTrigger(editor, triggers);
assert.equal(active?.query.length ?? null, queryLength < 255 ? queryLength : null);
console.log(JSON.stringify({ caret, queryLength, active: active?.kind ?? null, actualQueryLength: active?.query.length ?? null }));
}
Verbatim output from both worktrees:
{"caret":7,"queryLength":0,"active":"mention","actualQueryLength":0}
{"caret":21,"queryLength":14,"active":"mention","actualQueryLength":14}
{"caret":107,"queryLength":100,"active":"mention","actualQueryLength":100}
{"caret":261,"queryLength":254,"active":"mention","actualQueryLength":254}
{"caret":262,"queryLength":255,"active":null,"actualQueryLength":null}
5. Root cause
The mention regex, lines 47–58, intentionally admits ordinary spaces. The following trusted excerpt shows why a paragraph of prose can remain a single query:
const queryPattern =
trigger.kind === "mention" ? `(?:[^\\s${escapedChar}]| )*` : "\\S*";
const boundary = options.windowed ? "([\\s([{])" : "(^|[\\s([{])";
const TRIGGER_SCAN_WINDOW = 256;
The windowed scan, lines 60–81, excludes a start-of-input boundary once the window begins inside a document. After 254 query characters the leading space, trigger, and query still fit; the next character discards the leading space, so the regex stops matching.
The menu policy, lines 2318–2331, hides unmatched commands but has no analogous settled-empty multiword mention condition:
const showTypeaheadMenu = !showVoiceActionGroup && activeTrigger !== null && !isCommandTriggerLiteral && !isBareNonDefaultMentionTrigger;
The underlying omission is lifecycle feedback, not an incorrect choice of regex window size. The search has finished and found nothing, but the composer never retires that occurrence. Merely hiding its menu would still leave repeated query updates active.
6. Proposed fix
Keep multiword parsing intact. Once a trimmed mention query contains an internal space, the mention search is ready and not refreshing, and the combined local-attachment and remote suggestion set is empty, retire the occurrence using the existing dismissComposerMenu path. That path records a dismissed range and sends null to the search API, so extending the same prose does not reactivate it. Preserve bare triggers, single-token empty searches, matching multiword mentions, local attachment matches, pending searches, and errors.
A local implementation adds 12 production lines and 99 test lines in two existing composer-subsystem files: 111 additions plus deletions in total. The added regression fails before the repair and passes afterward. The expanded composer suite passes all 184 cases; the composer plugin suite passes 96 cases with three existing performance cases skipped. Both affected scopes pass lint and typecheck; the app lint reports 219 existing warnings and zero errors. No dependency, wire contract, schema, persistence, packaging, or release behavior changes.
7. Verification
The same investigator repeated the reproduction in a second, separately installed temporary worktree at the exact recorded base commit. This is a clean repeat, not independent verification. The second worktree contained no production edits and only the same investigator-authored regression case. It used no server, ports, database, or provider session.
| Check | First worktree | Second clean worktree |
|---|---|---|
| Focused real-composer regression on unmodified production | 1 expected assertion failure | 1 identical expected assertion failure |
| Scan-window probe | Active at query length 254; inactive at 255 | Identical JSON output |
| Focused regression after local repair | 1 passed | Not applied: retained as the trusted baseline |
No correction to the root-cause finding was required by the second run. The report narrows the network-request and macOS claims rather than presenting them as verified. Browser Automation was attempted but could not locate Chrome/Chromium; no image is presented as if a real browser screenshot had been captured.
8. Related issues and pull requests
No open pull request linked to this issue was found through its cross-reference timeline or the repository's open pull request search before the repair. Nearby issue #4413 concerns search/typeahead latency; #5475 is another separately tracked mention-search defect. This report establishes a session-termination failure, not a latency measurement or a duplicate verdict.
9. Appendix
Relevant checks, from the first worktree after the local repair:
pnpm exec turbo run test --filter=@bb/app -- src/components/promptbox/PromptBoxInternal.test.tsx 184 passed, 0 failed pnpm exec turbo run test lint typecheck --filter=bb-plugin-bb--composer 96 passed, 3 skipped; 9 Turbo tasks successful pnpm exec turbo run lint typecheck --filter=@bb/app 6 Turbo tasks successful; lint: 219 warnings, 0 errors git diff --check no output; exit 0 git diff --numstat origin/main 99 0 apps/app/src/components/promptbox/PromptBoxInternal.test.tsx 12 0 plugins/composer/src/PromptBoxInternal.tsx
The initial full trusted-base build completed 73 tasks successfully. The repository's broad verification inventory reports pre-existing documentation drift for the diagnostics CLI family; that is unrelated to this composer fix and was not changed. Raw logs, complete JSON test output, and the regression patch remain in private thread storage rather than being committed to this public reports repository. Reproduction source and exact significant output are embedded here so the report is self-contained.
Trust boundary: Issue content and any suggestions it contained were treated solely as untrusted claims. No issue-supplied test, script, branch, patch, or external link was executed or fetched. The tests above were designed from trusted repository code.
AGENT GENERATED