Repository navigation
Description
Summary
When an assistant message has prose on the same line right after a plugin message directive, like ::browser-preview{session="…"}Next I'll load the page., the embed never mounts. The directive source shows up as literal text instead. I expected the embed to mount with the prose rendered after it. This affects every app.slots.messageDirective() embed (browser-preview, inline-vis, …), not one plugin.
Versions and environment
- bb 0.43.4 (desktop app), macOS 26.6
- claude-code, Claude Code 2.1.280
- Also reproduced from source on
mainat a19b3ed (renderer level, see steps)
Steps to reproduce
Renderer level, on main at a19b3ed4f:
- Render
MarkdownPreviewwith a registeredinline-vismessage directive and this content:::inline-vis{file="demo.html"}Next I will load the thread. - No directive mounts. The whole line renders as a literal paragraph.
- Put a newline after
}(::inline-vis{file="demo.html"}\nNext I will load the thread.). It mounts.
In the app: any assistant message where a registered ::name{...} is followed by prose on the same line. I saw this live with ::browser-preview (see Evidence).
Did not reproduce with the directive on its own line, or with a single \n right after }. A space after } still fails.
Expected vs actual
Input: ::inline-vis{file="demo.html"}Next I will load the thread.
Actual: literal paragraph "::inline-vis{file="demo.html"}Next I will load the thread.", 0 mounts
Expected: inline-vis embed (file=demo.html), then the paragraph "Next I will load the thread."
Before (main) |
Expected |
|---|---|
![]() |
![]() |
Look at the first line of each: on main it's raw ::inline-vis{…} text. The "Expected" shot comes from a patched build.
Evidence
Observed in thread thr_pdjcruqnvf (project proj_hmikzjrmwn, provider claude-code). bb browser-automation open returned a valid ready session every time. The agent then wrote the directive with prose glued on in 3 of 4 messages, and only the standalone one mounted:
seq 447 '::browser-preview{session="1cc01f18-…"}The browser is open (live view above). Next I'll check …' -> literal
seq 554 '::browser-preview{session="b901eef9-…"}' -> mounted
seq 639 '::browser-preview{session="79ad152b-…"}The aggregator has just started, so I'll switch back …' -> literal
seq 1660 '::browser-preview{session="94327984-…"}Next I'll load the `/moa` thread you pointed at, …' -> literal
For seq 1660, the directive and the prose arrived as separate deltas (1657, 1658) and were joined into one agentMessage with no separator. I haven't established whether the model emitted them back to back or the join dropped a newline. Either way the text reaches the renderer glued.
Root cause: [email protected] only emits a leafDirective when ::name{...} is the last thing on its line. Checked directly against the parser:
'::browser-preview{session="x"}Next' -> paragraph (text)
'::browser-preview{session="x"} Next' -> paragraph (text)
'::browser-preview{session="x"}\nNext' -> leafDirective + paragraph
'::browser-preview{session="x"}\n\nNext' -> leafDirective + paragraph
So remarkMessageDirectives() never sees a directive node for the glued form, and it renders as text:
bb/apps/app/src/components/ui/markdown-message-directives.tsx
Lines 218 to 266 in a19b3ed
| export function remarkMessageDirectives(args: { | |
| indexBase: number; | |
| limit: number; | |
| mounts: MountedMessageDirective[]; | |
| registry: MessageDirectiveRegistry; | |
| }) { | |
| const { indexBase, limit, mounts, registry } = args; | |
| return (tree: Nodes, file: RemarkMessageDirectiveFile): void => { | |
| const markdownSource = | |
| typeof file.value === "string" ? file.value : String(file.value ?? ""); | |
| mounts.length = 0; | |
| visit(tree, (node, index, parent: Parent | undefined) => { | |
| const directive = asDirectiveNode(node); | |
| if (directive === null || parent === undefined || index === undefined) { | |
| return; | |
| } | |
| const marker = DIRECTIVE_MARKERS[directive.type]; | |
| const name = typeof directive.name === "string" ? directive.name : ""; | |
| const attributes = normalizeDirectiveAttributes(directive.attributes); | |
| const source = directiveSourceFromNode( | |
| directive, | |
| markdownSource, | |
| name, | |
| attributes, | |
| marker, | |
| ); | |
| const entry = registry.get(name); | |
| if ( | |
| directive.type !== "leafDirective" || | |
| name.length === 0 || | |
| entry === undefined || | |
| entry.status === "collision" || | |
| mounts.length >= limit | |
| ) { | |
| return spliceLiteralDirective(parent, index, directive.type, source); | |
| } | |
| const mountIndex = indexBase + mounts.length; | |
| mounts.push({ | |
| attributes, | |
| index: mountIndex, | |
| slot: entry.slot, | |
| source, | |
| }); | |
| parent.children.splice(index, 1, messageDirectiveMountNode(mountIndex)); | |
| return index; | |
| }); | |
| }; |
The browser-automation skill already says to emit the directive "exactly once as a standalone line" (SKILL.md#L75), but agents still glue prose to it often. A prompt-only fix won't cover every plugin or provider.
What you ruled out
- Not the plugin or backend: the session was
ready/local, the id matchedSESSION_ID_PATTERN, and the standalone directive (seq 554) mounted fine. - Not an incomplete, still-streaming directive: seq 1660 is a completed
agentMessageitem. - Not Codex file-citation directives render as raw text: bb parses
:codex-file-citation{…}then discards the parsed attributes #2933: that one is:codex-file-citation{…}text directives whose attributes get discarded after parsing. Here no directive node is produced at all.
Suggested priority and effort
Medium. It hits every plugin message-directive embed whenever an agent continues on the same line, which happens often. The only workaround is agent formatting, and no data is lost. Effort is probably low: a tolerant fallback in remarkMessageDirectives().
Checks
- I reproduced this on
main(a19b3ed). - I searched open and closed issues for the same problem.


Activity
Mount message directive embeds glued to trailing prose (get-bb#4410)