← reports

#7770 · SDK Markdown omits message-renderer context

BugPriority: MediumEffort: Mediumplugins · uiGitHub issue2026-11-18 · base 48c3a78488667fde6883d13da7ef54f8175b4671

Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro.

1. TL;DR

A plugin displaying source with the SDK Markdown component cannot reproduce the inline plugin UI available in an assistant message. Both renderers receive the same text and registered slot implementations in this reproduction, but only the assistant mounts the custom fence and directive components. The SDK wrapper does not establish a code-fence host or supply a message-directive configuration, and its public props cannot supply the required message identity. This is a host rendering integration gap, not a failure to parse the source or register a plugin. Two fresh checkouts of trusted main reproduce both failures with real host components; no linked pull-request code was executed.

2. Claims vs findings

ClaimStatusEvidence
Registered custom fences become ordinary code in SDK Markdown.VerifiedThe SDK DOM contains the language header and payload, not the custom fence component. Its assistant control mounts that component first.
Registered message directives remain literal source.VerifiedThe SDK DOM contains ::repro-badge{value="ready"}; the same registration renders a badge in the assistant control.
The SDK contract promises chat-body rendering, but exposes no message identity.VerifiedMarkdownProps on trusted main contains only content, className and document routing.
Specific published SDK/nightly and third-party plugin versions exhibit the problem.Unverified hereNot installed or executed. This investigation uses current trusted main with locally authored slot fixtures, not third-party plugin code.
There is an existing fix proposal.Verified metadata; static review onlyOpen ready PR #7771 explicitly links #7770. Its branch and tests were not run.

3. Environment

4. Minimal reproduction

The regression protects SDK-to-assistant rendering parity as documented at this base. It is intentionally red on current main. Each case first proves that the real assistant renderer mounts the registered component, then renders the same content through the real SDK wrapper and expects that same visible result. There are no renderer mocks or test-only production exports. Existing renderer suites do not cover this missing SDK integration.

  1. Prepare trusted main and the normal build dependencies:
    git clone --branch main --single-branch https://github.com/get-bb/bb.git /tmp/issue-7770/base
    cd /tmp/issue-7770/base
    git checkout --detach 48c3a78488667fde6883d13da7ef54f8175b4671
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build

    The initial full build on a completely fresh install failed because plugin SDK runtime dist files were not yet built. Building the SDK first resolved that setup problem; the retried full build completed all 74 tasks. This setup failure is not counted as the issue reproduction.

  2. Save the test below as apps/app/src/components/plugin/issue-7770-repro.test.tsx and run:
    pnpm exec turbo run test --filter=@bb/app -- src/components/plugin/issue-7770-repro.test.tsx
  3. Expected: both cases pass and SDK Markdown mounts the same custom components as the assistant. Actual: both assistant control assertions succeed, then both SDK assertions fail. The observed SDK DOM text is:
    SDK fence actual: repro-cardcard payload
    SDK directive actual: ::repro-badge{value="ready"}
    TestingLibraryElementError: Unable to find an element with the text: Mounted fence: card payload.
    TestingLibraryElementError: Unable to find an element with the text: Mounted directive: ready.

Complete reproduction test

// @vitest-environment jsdom

import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import { MemoryRouter } from "react-router-dom";
import { PluginMarkdown } from "./PluginMarkdown";
import { RouteNavigationProvider } from "../ui/app-route-anchor";
import {
  buildCodeFenceRendererRegistry,
  CodeFenceRendererRegistryProvider,
} from "../ui/markdown-code-fence-renderers";
import {
  buildMessageDirectiveRegistry,
  MessageDirectiveRegistryProvider,
} from "../ui/markdown-message-directives";
import { ConversationMessageContent } from "../thread/timeline/ConversationMessageContent";
import {
  resetPluginSlotStoreForTest,
  setPluginSlotRegistrations,
} from "@/lib/plugin-slots";
import { makePluginRegistrationSet } from "@/test/fixtures/plugins";

afterEach(() => {
  cleanup();
  resetPluginSlotStoreForTest();
});

describe("issue 7770: SDK and assistant rendering parity", () => {
  it.each([
    { kind: "fence", content: "```repro-card\ncard payload\n```" },
    { kind: "directive", content: '::repro-badge{value="ready"}' },
  ])("mounts a registered $kind in SDK Markdown", ({ kind, content }) => {
    const registrations = makePluginRegistrationSet({
      codeFenceRenderers: [{
        id: "card",
        pluginId: "repro-7770",
        generation: 1,
        languages: ["repro-card"],
        component: ({ code }) => <strong>Mounted fence: {code}</strong>,
      }],
      messageDirectives: [{
        id: "repro-badge",
        pluginId: "repro-7770",
        generation: 1,
        component: ({ attributes }) => <strong>Mounted directive: {attributes.value}</strong>,
      }],
    });
    setPluginSlotRegistrations("repro-7770", registrations);
    const fences = buildCodeFenceRendererRegistry(registrations.codeFenceRenderers);
    const directives = buildMessageDirectiveRegistry(registrations.messageDirectives);
    const expected = kind === "fence" ? "Mounted fence: card payload" : "Mounted directive: ready";
    const view = render(
      <MemoryRouter>
        <RouteNavigationProvider>
          <CodeFenceRendererRegistryProvider registry={fences}>
            <MessageDirectiveRegistryProvider registry={directives}>
              <ConversationMessageContent
                role="assistant"
                attachments={null}
                id="message-repro-7770"
                threadId="thread-repro-7770"
                turnId="turn-repro-7770"
                projectId="project-repro-7770"
                streaming={false}
                showActions={false}
                mobileActionDisplay="inline"
                text={content}
                timestamp={0}
              />
            </MessageDirectiveRegistryProvider>
          </CodeFenceRendererRegistryProvider>
        </RouteNavigationProvider>
      </MemoryRouter>,
    );
    expect(screen.getByText(expected)).toBeTruthy();
    view.unmount();
    const sdk = render(
      <MemoryRouter>
        <RouteNavigationProvider>
          <CodeFenceRendererRegistryProvider registry={fences}>
            <MessageDirectiveRegistryProvider registry={directives}>
              <PluginMarkdown content={content} />
            </MessageDirectiveRegistryProvider>
          </CodeFenceRendererRegistryProvider>
        </RouteNavigationProvider>
      </MemoryRouter>,
    );
    console.log(`SDK ${kind} actual: ${sdk.container.textContent}`);
    expect(screen.getByText(expected)).toBeTruthy();
  });
});

This report embeds the complete test and exact expected-versus-actual output. Raw test files and logs remain in the ignored local evidence directory and publisher backup, not in the public repository, in accordance with the reports repository policy.

Actual first-run summary

@bb/app:test: SDK fence actual: repro-cardcard payload
@bb/app:test: SDK directive actual: ::repro-badge{value="ready"}
@bb/app:test:      × mounts a registered 'fence' in SDK Markdown 83ms
@bb/app:test:      × mounts a registered 'directive' in SDK Markdown 13ms
@bb/app:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
@bb/app:test:  Test Files  1 failed (1)
@bb/app:test:       Tests  2 failed (2)
@bb/app:test:    Duration  23.30s (transform 19.70s, setup 292ms, import 20.98s, tests 97ms, environment 1.18s)
@bb/app:test:      88|     console.log(`SDK ${kind} actual: ${sdk.container.textContent}`);
@bb/app:test:      88|     console.log(`SDK ${kind} actual: ${sdk.container.textContent}`);
  Time:    29.548s 

Browser evidence limitation

Attempted a local headless Browser Automation session for the renderer-only harness. The plugin returned:

Install Chrome/Chromium on this host or link its executable at the plugin data runtime/chrome path.

No Chrome executable was available in the standard locations. No dependency was installed and no replacement or synthetic screenshot was created. The verdict is based on repeatable DOM behavior, not browser pixels or an installed third-party plugin.

5. Root cause

  1. ThreadTimelineRows builds both registries from the slot store and provides them around timeline rows.
  2. The assistant assembles message directives with message identity, passes them into MarkdownPreview, and mounts CodeFenceRendererHost.
  3. PluginMarkdown, including its document branch, renders MarkdownPreview without a directive configuration and without establishing a fence host. In a standalone plugin panel, global slot registration alone is insufficient. The reproduction deliberately gives it even the registry providers, so missing registrations cannot explain the result.
  4. useCodeFenceLanguages reads only the active host:
    const registry = useContext(CodeFenceHostContext)?.registry;
    return registry === undefined || registry.size === 0 ? null : registry;
    No host means ordinary code-block rendering. Separately, MarkdownPreview disables directive mounts when its explicit configuration is absent:
    if (messageDirectives === undefined) {
      return null;
    }
    That is why the directive remains literal text rather than a plugin mount.
  5. The deeper API gap: MarkdownProps cannot identify a message, while the plugin message contract requires id, threadId, and explicit nullable turnId/projectId. Blindly installing registry providers cannot safely fabricate this context.

6. Proposed fix and simple-fix decision

Use a deliberate opt-in message-context contract for SDK Markdown and share the timeline's registry, host, and directive assembly path rather than implementing a second renderer. Validate runtime message context at the SDK boundary, preserve ordinary-document behavior without it, and define file-opening and streaming semantics explicitly. Cover both SDK and assistant surfaces, malformed context, and the no-context fallback. This is a public API/product-contract decision, not merely a local prop forwarding repair.

No new fix PR: open PR #7771 already explicitly links this issue. The autopilot duplicate-PR guard stops the fix path before branch creation. Moreover, a robust message-identity repair would change the public SDK contract and need a product decision, outside the simple-fix criteria. No production fix was committed, pushed, or executed, so no fix line-count or green-after claim is made.

7. Linked PR review — #7771

Reviewed GitHub metadata and the diff only, as untrusted data. The proposal adds an optional message-context prop, validates it in PluginMarkdown, extracts shared message-slot helpers, routes timeline rendering through them, and updates SDK contract and guide/audit documentation. It keeps ordinary Markdown behavior when context is absent. At the mechanism level this addresses both missing paths identified above, instead of just changing fence syntax.

Review limit: this is a static mechanism assessment, not approval or verified correctness. The branch, its tests, and third-party renderers were never checked out or run. Only trusted-main reproductions and existing tests were executed. Follow-up verification should exercise document routing and contextual renderers in the browser, identity validation, no-context fallback, and both shared consumers. No line-specific defect is asserted from this bounded review.

8. Related issues

#5985 is an earlier open report of the same SDK fence-context gap. The current issue additionally covers message directives. No other issue or PR was modified.

9. Verification

The same agent repeated the reproduction in a second clean checkout; this is not an independent review. From checkout A:

git worktree add --detach /tmp/issue-7770/verification 48c3a78488667fde6883d13da7ef54f8175b4671
git -C /tmp/issue-7770/verification status --porcelain
cp apps/app/src/components/plugin/issue-7770-repro.test.tsx /tmp/issue-7770/verification/apps/app/src/components/plugin/issue-7770-repro.test.tsx
cd /tmp/issue-7770/verification
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run test --filter=@bb/app -- src/components/plugin/issue-7770-repro.test.tsx

The status check was empty before adding the locally authored test. A subsequent tracked diff was also empty. Turbo rebuilt dependencies as needed; the regression test itself ran live, rather than returning a cached test result. No ports or runtime data directory were required for either run.

@bb/app:test: SDK fence actual: repro-cardcard payload
@bb/app:test: SDK directive actual: ::repro-badge{value="ready"}
@bb/app:test:      × mounts a registered 'fence' in SDK Markdown 65ms
@bb/app:test:      × mounts a registered 'directive' in SDK Markdown 10ms
@bb/app:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
@bb/app:test:      88|     console.log(`SDK ${kind} actual: ${sdk.container.textContent}`);
@bb/app:test:      88|     console.log(`SDK ${kind} actual: ${sdk.container.textContent}`);
@bb/app:test:  Test Files  1 failed (1)
@bb/app:test:       Tests  2 failed (2)
@bb/app:test:    Duration  17.23s (transform 14.90s, setup 292ms, import 15.90s, tests 76ms, environment 598ms)
  Time:    21.189s 

Both missing-component failures and SDK actual text matched the first run. No root-cause correction was needed. The missing Chrome limitation applies to both the final report and the proposed browser follow-up.

10. Appendix

Existing-test controls

pnpm exec turbo run test --filter=@bb/app -- src/components/ui/markdown-code-fence-renderers.test.tsx src/components/ui/markdown-message-directives.test.tsx src/lib/plugin-sdk-app-impl.test.tsx

markdown-code-fence-renderers.test.tsx: 24 passed
markdown-message-directives.test.tsx: 37 passed
plugin-sdk-app-impl.test.tsx: 19 passed
Test Files  3 passed (3)
Tests       80 passed (80)

The existing suites passing alongside the new failing integration test rules out a general slot-renderer setup failure. Both target rendering source directories remained unmodified. The full build regenerated an unrelated tracked web route-tree file in checkout A; it was not used as evidence or published as a product change.

Read-only inspection and trust handling

Read issue metadata, body, and all comments (none at investigation time); repository issue types, field options, labels, several related issue classifications, linked PR metadata and diff, and trusted-main source. Used targeted source inspection and a final origin/main fetch. Issue prose, links, suggested patches and tests were treated only as untrusted claims: no issue-provided command, test, external link, branch or script was executed. The reproduction fixture was authored from the repository contracts before reading the linked PR diff.

GitHub property and label writes use the supplied SlopCop command. Report publication uses the prescribed publisher without issue-comment or label flags; its GitHub subprocesses are routed through that same SlopCop command. No user runtime data or credentials were read or published.