Repository navigation
fix(react-core): scope streamdown table action controls in packaged CSS (#5775) - #5944
Merged
Merged
Conversation
BenTaylorDev
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
July 13, 2026 21:32
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
Contributor
|
Size Change: 0 B Total Size: 1.18 MB ℹ️ View Unchanged
|
…SS (#5775) After #5099 the table wrapper/cells are styled via [data-streamdown] selectors, but the copy/download controls row, button wrappers, trigger buttons, dropdown popovers and menu items render with raw Tailwind utilities and no stable data-streamdown attribute — so hosts that import @copilotkit/react-core/v2 styles without shipping streamdown's own utilities saw them unstyled (icons stacked vertically instead of a right-aligned row). Add scoped fallback selectors under [data-copilotkit] [data-streamdown= "table-wrapper"], targeting the controls chrome structurally. The controls row is the first child ONLY when controls are enabled, so :not(:last-child) leaves a control-less table (single child = the scroll container) untouched. Verified against streamdown 1.6.11's actual rendered DOM (a new DOM test guards that the structure the selectors assume still holds) and by compiling the CSS. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
BenTaylorDev
force-pushed
the
fix/5775-streamdown-table-controls
branch
from
July 13, 2026 21:58
537165d to
b693416
Compare
Contributor
Author
tylerslaton
approved these changes
Jul 13, 2026
tylerslaton
left a comment
Contributor
There was a problem hiding this comment.
Verified the structural selectors against [email protected]’s actual table/control markup, including the lazily rendered popovers. The packaged CSS build emits the scoped rules as intended, and pnpm nx run @copilotkit/react-core:test --skip-nx-cache passed (116 files / 1,429 tests). No blocking issues found.
3 tasks done
BenTaylorDev
added a commit
that referenced
this pull request
Sep 4, 2026
… (#6902) ## What does this PR do? Fixes #3330 — fenced markdown code blocks render as one collapsed line in the packaged v2 React UI. ### Root cause streamdown renders one `<span>` per source line inside `pre[data-streamdown="code-block-body"] > code`, and leaves **no newline characters** in the text. The line break comes entirely from the raw Tailwind utility `block` on that span: ```js // streamdown 1.6.11, dist/code-block-*.js var v = cn("block", "before:content-[counter(line)]", ...); ``` CopilotKit builds Tailwind with `@import "tailwindcss" prefix(cpk)`, so `.block` is never emitted into `dist/v2/index.css` — only `.cpk\:block` is. Every line therefore renders inline and the block collapses onto one row. The line spans carry no `data-streamdown` attribute, so the rule has to be scoped structurally, the same way the table action controls were in #5944: ```css [data-copilotkit] [data-streamdown="code-block-body"] > code > span { @apply cpk:block; } ``` ### Why the earlier attempts did not work Three previous PRs (#3441, #3615, #5387) added `whitespace-pre` to the `<pre>`. That is a no-op: the UA stylesheet already applies `white-space: pre` to `<pre>`, nothing in the packaged CSS overrides it, and there are no newlines in the text for it to preserve. ### Knowingly not fixed here - **Line-number gutter.** streamdown's `before:content-[counter(line)] before:w-4 before:mr-4 …` utilities are unprefixed too, so the gutter never renders. That is cosmetic, and the repo's existing scoped rules do not port it either. - **The pre-highlight loading skeleton** (`space-y-4`, `divide-y`, `animate-spin`) is unprefixed as well — a brief flash of unstyled skeleton before shiki resolves. - **The broader class of bug.** Every unprefixed streamdown utility has to be hand-ported like this. streamdown 2.x adds a `prefix` prop that would fix the whole surface at once, and #5147 proposes removing the bundled renderer entirely. Both are larger calls than this bug fix. ## Testing **1. Live browser verification.** Built `dist/v2/index.css` from `origin/main` and from this branch, rendered streamdown 1.6.11's actual code-block DOM against each, and measured layout in Chromium: | | `white-space` on `<pre>` | line-span `display` | distinct rendered rows | `<pre>` height | |---|---|---|---|---| | main | `pre` | `inline` | **1** | 52px | | this PR | `pre` | `block` | **5** | 112px | Indentation is preserved after the fix (`spans[1].textContent` starts with two spaces). **2. Compiled CSS.** `tailwindcss -i src/v2/styles/globals.css -o … -m` emits exactly: ```css [data-copilotkit] [data-streamdown=code-block-body]>code>span{display:block} ``` **3. Tests** — `pnpm -C packages/react-core exec vitest run src/v2/styles` ``` ✓ src/v2/styles/__tests__/streamdown-styles.test.ts (3 tests) 2ms ✓ src/v2/styles/__tests__/streamdown-table-controls.test.tsx (1 test) 37ms ✓ src/v2/styles/__tests__/streamdown-code-block-lines.test.tsx (1 test) 430ms Test Files 3 passed (3) Tests 5 passed (5) ``` Two tests, following the split established by #5944 — a source-string test that the selector exists, and a DOM test that streamdown still renders the structure that selector assumes (so a streamdown markup change fails loudly instead of silently un-fixing this). **4. Mutation-checked both tests.** Removing the CSS rule fails the string test: ``` × Streamdown styles > ships a scoped display rule for code block lines (#3330) 3ms Tests 1 failed | 2 passed (3) ``` Pointing the DOM test at a selector streamdown does not render fails it: ``` × Streamdown code block lines DOM (#3330) > renders one line span per source line 428ms Tests 1 failed (1) ``` **5. Formatting** — `oxfmt --check` clean on all three files; `git diff --check` clean. `tsc --noEmit` in this worktree reports 58 pre-existing errors, all from a stale cross-package `@copilotkit/core` dist; none are in the changed files (which are CSS plus tests). ## Related PRs and Issues Fixes #3330 Supersedes #3441, #3615, #5387, #5996 (all added a no-op `whitespace-pre`) ## Checklist - [x] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [x] If the PR changes or adds functionality, I have updated the relevant documentation (not applicable: scoped visual bug fix) - [x] "Allow edits by maintainers" is checked <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Fixed fenced code blocks collapsing into a single line in the packaged UI. - Code lines now render vertically as separate rows with the correct layout styling. - **Tests** - Added regression coverage to verify code-line rendering and scoped styles for code blocks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #5775.
Problem
After #5099 scoped the streamdown markdown/table styles under
[data-copilotkit] [data-streamdown="…"], the table action controls (copy / download) are still unstyled for hosts that import@copilotkit/react-core/v2/styles.cssbut don't also ship streamdown's raw Tailwind utilities. streamdown renders the controls row, per-button wrappers, trigger buttons, dropdown popovers and menu items with unprefixed utilities (flex,items-center,justify-end,gap-1,cursor-pointer,p-1, …) and no stabledata-streamdownattribute, so CopilotKit's packaged CSS didn't cover them — the controls rendered as vertically stacked plain icons instead of a right-aligned row.Fix
Add scoped fallback selectors under
[data-copilotkit] [data-streamdown="table-wrapper"], targeting the controls chrome structurally (since it has nodata-streamdownhook):> div:first-child:not(:last-child)(flex, right-aligned, gap)… > div(relative, positions the popover)… > div > button(matches the code-block copy/download button styling)… > div > div… > div > div > buttonThe controls row is
table-wrapper's first child only when controls are enabled;:not(:last-child)leaves a control-less table (whose single child is the scroll container, already styled by #5099) untouched.Verification
globals.cssthrough the Tailwind v4 CLI — every@applyresolves (e.g.bg-background→var(--background),shadow-lg→ the shadow vars,min-w-[120px]→min-width:120px) and all five rules emit with correct values.streamdown-table-controls.test.tsx) renders a real<Streamdown>table and asserts the controls row istable-wrapper's first-non-only child, carries nodata-streamdownattribute, and contains the trigger buttons under> div > button— i.e. the scoped selectors target real elements. This also guards against streamdown markup drift.streamdown-styles.test.ts(whitespace-robust).styles/__tests__suite green;oxlint/oxfmtclean.Note (out of scope, discovered while fixing)
At runtime in streamdown
1.6.11the<table>element is stampeddata-streamdown="table-wrapper"(not"table"):MarkdownTablepassesdata-streamdown="table-wrapper"as a prop that leaks through...restonto the<table>, overriding the intended"table". So #5099's[data-streamdown="table"]selector currently matches nothing, and the table also matches thetable-wrapperrules. The controls fix here is unaffected (its child-combinator selectors don't match the table'sthead/tbodychildren), but the[data-streamdown="table"]selector is worth a separate follow-up / upstream report.🤖 Generated with Claude Code