Repository navigation
Description
Summary
Codex writes file citations in the Codex-app directive format (:codex-file-citation{path=… purpose=… sheet=… range=…}). bb renders that directive as raw literal text in the middle of the assistant's prose, so every citation shows up as a wall of markup. bb already parses the directive correctly — remark-directive is in the pipeline and yields a clean textDirective node with all attributes — but remarkMessageDirectives mounts leaf directives (::name{}) only and unconditionally splices every text directive (:name{}) back as its verbatim source. The parsed attributes are discarded. I expected bb to either render the citation as a file reference or drop it, not to print the markup.
Versions and environment
- bb 0.41.0 (desktop app), macOS 26.4 (build 25E246), Apple silicon
- Provider: codex,
codex-cli 0.152.1 - Source read at
main@6185c34984e3fea55b4a7ebbf047c23b8b657974 - Occurs in both worktree and project-checkout environments; bb Connect paired (not required to reproduce)
Steps to reproduce
A. Renderer path — deterministic, no model involved.
Any assistant message whose text contains a :codex-file-citation{…} text directive renders it literally. Minimal body:
Revenue for July includes an adjustment. :codex-file-citation{path="/tmp/book.xlsx" purpose="source" artifact_kind="workbook" sheet="Sheet1" range="A1:G5"}
The same holds for any :name{…} text directive, registered or not — codex-file-citation is just the one that shows up in practice.
B. Field path — how it actually arises.
- Start a bb thread on the
codexprovider. - Attach a spreadsheet or PDF with the composer's attachment button. bb stores it under
~/.bb/thread-storage/<thread-id>/Attachments/<name>. - Ask a question that forces Codex to read the attachment and say where each figure came from, e.g. "Summarize the monthly revenue totals and cite the rows each number comes from."
- Codex answers and appends its citation in the Codex-app directive form.
Step 4 is model-dependent — not every turn emits a citation — but when it does, step A's rendering bug always follows. Codex also emits purpose="output" citations for files it wrote into the workspace, so thread attachments are not the only trigger.
Did not reproduce with: the claude-code provider, which does not emit this citation format.
Expected vs actual
Actual — verbatim from the timeline, paths redacted:
July B2C revenue includes a $264,013,444 adjustment, including $42,153,407 of VAT,
explicitly described as having no supporting boletas. :codex-file-citation{path="/Us
ers/<user>/.bb/thread-storage/<thread-id>/Attachments/<workbook>.xlsx" purpose="sourc
e" artifact_kind="workbook" sheet="Libro Diario 2025" range="A151522:G151526"}
Expected: the sentence, followed by a citation affordance — or, at minimum, nothing at all. The directive carries real provenance (sheet, range pin the exact rows behind the figure). Today that provenance is parsed, then thrown away, and the user is shown the serialization instead.
Two knock-on effects:
- The raw directive text is indexed into
thread_search_segments, so it pollutes thread search. - A reader skimming the answer sees what looks like a malfunction, which undercuts trust in a number that is in fact better sourced than an uncited one.
Evidence
The directive parses cleanly. Standalone check with the same remark-parse + remark-directive combination bb uses:
node.type : textDirective
node.name : codex-file-citation
attributes : {"path":"…/<workbook>.xlsx","purpose":"source","artifact_kind":"workbook","sheet":"Libro Diario 2025","range":"A151522:G151526"}
source slice: :codex-file-citation{path="…
Every attribute is available. Nothing is malformed.
Where it is dropped. remarkMessageDirectives returns the literal source for any node that is not a leafDirective, before name lookup or registry lookup happens:
bb/apps/app/src/components/ui/markdown-message-directives.tsx
Lines 243 to 245 in 6185c34
| if (directive.type !== "leafDirective") { | |
| return spliceLiteralDirective(parent, index, directive.type, source); | |
| } |
spliceLiteralDirective then restores the exact source slice into the text run:
bb/apps/app/src/components/ui/markdown-message-directives.tsx
Lines 166 to 192 in 6185c34
| }, | |
| }; | |
| } | |
| function spliceLiteralDirective( | |
| parent: Parent, | |
| index: number, | |
| type: DirectiveNodeType, | |
| source: string, | |
| ): number { | |
| if (type !== "textDirective") { | |
| parent.children.splice(index, 1, { | |
| type: "paragraph", | |
| children: [{ type: "text", value: source }], | |
| }); | |
| return index; | |
| } | |
| const previous = parent.children[index - 1]; | |
| const next = parent.children[index + 1]; | |
| if (previous?.type === "text") { | |
| previous.value += source; | |
| previous.position = undefined; | |
| if (next?.type === "text") { | |
| previous.value += next.value; | |
| parent.children.splice(index, 2); | |
| } else { |
remark-directive is registered in the preview pipeline here, which is why the node exists to be discarded in the first place:
bb/apps/app/src/components/ui/markdown-preview.tsx
Lines 1672 to 1681 in 6185c34
| if (messageDirectiveMounts !== null) { | |
| plugins.push(remarkDirective); | |
| plugins.push([ | |
| remarkMessageDirectives, | |
| { | |
| mounts: messageDirectiveMounts.mounts, | |
| registry: messageDirectiveMounts.registry, | |
| }, | |
| ]); | |
| } |
Frequency. In one bb installation: 29 occurrences across 8 threads (thr_fghc6jzzua, thr_gtp3379ggr, thr_j7ys8ph3ex, thr_na2qwx5b5h, thr_nf3bgm6naq, thr_sgddkbwnch, thr_smxthjni5h, thr_zxba8c72br), counted with:
select thread_id, count(*) from thread_search_segments
where text like '%codex-file-citation%' group by thread_id;Observed attribute shapes across those 29: path always; purpose ∈ {source, output}; artifact_kind ∈ {workbook, spreadsheet} when present; sheet and range present for workbooks.
What you ruled out
- Not a duplicate: searched open and closed issues for
codex-file-citation,artifact_kind, "file citation", "citation directive" — no match. perf(app): replace react-markdown with Streamdown (PoC) #1317 (Streamdown PoC) and [issue sweep] Load the diff renderer and KaTeX on demand #1527 (lazy diff/KaTeX) touch the renderer but not directives. - Not a Codex malfunction: the directive is the Codex app's documented citation form and parses cleanly. bb is the side that does not handle it.
- Not provider-specific to my setup: reproduces on the renderer path (A) with no provider involved at all.
- Not a
remark-directivebug: the parse output above is correct and complete. - Not caused by a plugin registering a colliding directive id: the leaf-only guard returns before any registry lookup.
Suggested priority and effort
Medium — hits every Codex user who attaches a file or has the agent write one; no workaround beyond ignoring the noise; no data lost, but provenance that bb already holds in parsed form is discarded. Effort likely Low-to-Medium depending on which direction is chosen:
- Strip the directive in
provider-codex— smallest diff, discardssheet/range. - Render it as a file chip in
apps/app, reusing the existingmarkdown-local-file-linkrouting so a click opens the path;sheet/rangebecome label and tooltip. Keeps the provenance. - Generalize: let
remarkMessageDirectivesmount text directives too and haveprovider-codexregister acodex-file-citationmessage-directive slot. Most consistent with the existing plugin extension point, but changes core renderer behavior for every plugin, so it is a design call rather than a bug fix.
Happy to open a PR for whichever direction you prefer — per CONTRIBUTING.md I am filing the issue first, since the two renderer options are UI changes.
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 2, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui,provider-codex,confirmed-reproconfirmed-repro