Skip to content

fix(site/src/pages/AgentsPage/components/ChatElements): align code block rendering#24966

Merged
DanielleMaywood merged 5 commits into
mainfrom
fix/agents-markdown-code-blocks
May 5, 2026
Merged

fix(site/src/pages/AgentsPage/components/ChatElements): align code block rendering#24966
DanielleMaywood merged 5 commits into
mainfrom
fix/agents-markdown-code-blocks

Conversation

@DanielleMaywood
Copy link
Copy Markdown
Contributor

@DanielleMaywood DanielleMaywood commented May 5, 2026

Note

🤖 This PR was written by Coder Agent on behalf of Danielle Maywood

Agent markdown fenced code blocks keep using @pierre/diffs FileViewer so the original Shiki syntax highlighting quality is preserved. The markdown renderer now applies host CSS variables and Shadow DOM unsafeCSS overrides so fenced blocks match the Agent terminal block feel: Geist Mono at 12px, 20px line height, symmetric 8px vertical padding, 12px line padding, collapsed disabled line-number gutter, and no phantom scrollbar padding.

Also applies the shared DIFFS_FONT_STYLE to a generic tool FileViewer path that was missing it.

Research

Agent assistant responses render through site/src/pages/AgentsPage/components/ChatElements/Response.tsx, not the shared Markdown component.

Markdown fenced code blocks are rendered by the Streamdown pre override. The right component to keep is FileViewer from @pierre/diffs/react, which renders a <diffs-container> web component with open Shadow DOM and Shiki-highlighted token spans.

The visual mismatch came from the @pierre/diffs default Shadow DOM layout, especially [data-code] asymmetric padding for scrollbar space, the disabled line-number gutter still reserving width, and default font sizing. These can be corrected without replacing the component by combining options.unsafeCSS for Shadow DOM selectors with style CSS variables on the diffs-container host.

Storybook interaction tests can inspect host.shadowRoot directly, so the assertions now verify the actual FileViewer DOM, padding, font sizing, collapsed gutter, absence of raw fences, and presence of inline-colored highlighted spans.

Validation
cd site
pnpm exec biome check --error-on-warnings src/pages/AgentsPage/components/ChatElements/Response.tsx src/pages/AgentsPage/components/ChatElements/Response.stories.tsx src/pages/AgentsPage/components/ChatElements/tools/utils.ts src/pages/AgentsPage/components/ChatElements/tools/Tool.tsx
pnpm run lint:types
pnpm exec vitest run --project=unit src/pages/AgentsPage/components/ChatElements/tools/utils.test.ts
pnpm exec vitest run --project=storybook src/pages/AgentsPage/components/ChatElements/Response.stories.tsx
cd ..
git diff --check
make lint/emdash
make lint

The pre-commit hook passed for the code-change commits.

@DanielleMaywood DanielleMaywood marked this pull request as ready for review May 5, 2026 13:27
@DanielleMaywood DanielleMaywood merged commit 5322755 into main May 5, 2026
32 checks passed
@DanielleMaywood DanielleMaywood deleted the fix/agents-markdown-code-blocks branch May 5, 2026 13:28
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants