Skip to content

fix(react-core): scope streamdown markdown styles - #5099

Merged
tylerslaton merged 2 commits into
CopilotKit:mainfrom
Tushar-Khandelwal-2004:fix/5072
Jun 12, 2026
Merged

tylerslaton merged 2 commits into
CopilotKit:mainfrom
Tushar-Khandelwal-2004:fix/5072

Conversation

@Tushar-Khandelwal-2004

Copy link
Copy Markdown
Contributor

Summary

Fixes #5072

Fix unstyled Streamdown markdown in non-Tailwind apps that import @copilotkit/react-core/v2/styles.css.

Streamdown renders plain utility class names, but CopilotKit’s CSS bundle is generated with the cpk: Tailwind prefix. That left default markdown elements like headings, lists, strong text, tables, blockquotes, inline code, and code blocks without matching styles unless the host app also shipped unprefixed Tailwind utilities.

Changes

-> Add scoped fallback styles for Streamdown’s stable data-streamdown elements under [data-copilotkit].
-> Use CopilotKit theme variables and prefixed Tailwind utilities so styles stay inside the CopilotKit surface.
-> Remove the ineffective Streamdown @source scan, since it only generated prefixed utilities that Streamdown does not emit.
-> Add a regression test to ensure the scoped Streamdown selectors remain present.

Testing

-> node node_modules\nx\bin\nx.js run @copilotkit/react-core:build:css --excludeTaskDependencies
-> node node_modules\nx\bin\nx.js run @copilotkit/react-core:test --excludeTaskDependencies --skip-nx-cache -- src/v2/styles/__tests__/streamdown-styles.test.ts

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Jun 12, 2026 4:55pm
docs Ready Ready Preview, Comment Jun 12, 2026 4:55pm
form-filling Ready Ready Preview, Comment Jun 12, 2026 4:55pm
research-canvas Ready Ready Preview, Comment Jun 12, 2026 4:55pm
travel Ready Ready Preview, Comment Jun 12, 2026 4:55pm

Request Review

@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

@Tushar-Khandelwal-2004 is attempting to deploy a commit to the CopilotKit Team on Vercel.

A member of the Team first needs to authorize it.

@onsclom onsclom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the great solution and tests in this PR! Was able to repro the problem locally and see this fixes most cases.

I pushed up three more selectors that 1.6.11 also emits: mermaid-block, subscript, superscript, plus the matching test assertions.

Heads up that some Streamdown chrome (loading spinner, code block language dropdown, mermaid fullscreen modal, error states) uses unprefixed Tailwind classes without data-streamdown attributes, so attribute selectors can't reach those. We'll do a follow-up with a build-scan approach: a second Tailwind pass over Streamdown's chunk files that scopes the output under [data-copilotkit]. Shouldn't block this PR.

Thanks again!

@pkg-pr-new

pkg-pr-new Bot commented May 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@5099

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@5099

@copilotkitnext/angular

pnpm add https://pkg.pr.new/@copilotkitnext/angular@5099

@copilotkit/bot

pnpm add https://pkg.pr.new/@copilotkit/bot@5099

@copilotkit/bot-slack

pnpm add https://pkg.pr.new/@copilotkit/bot-slack@5099

@copilotkit/bot-ui

pnpm add https://pkg.pr.new/@copilotkit/bot-ui@5099

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@5099

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@5099

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@5099

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@5099

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@5099

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@5099

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@5099

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@5099

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@5099

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@5099

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@5099

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@5099

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@5099

commit: 9275ec2

@Tushar-Khandelwal-2004

Copy link
Copy Markdown
Contributor Author

Thanks a lot for reviewing and for adding the missing selectors/tests. Glad the repro confirmed the fix for the main cases.

onsclom added a commit that referenced this pull request Jun 2, 2026
## Problem

The `format` job sets `ref: github.head_ref` but leaves `repository:`
unset, so it checks the head branch out of the **base** repo. For fork
PRs the head branch only exists on the fork, so checkout fails before
formatting even runs.

Seen on #5099 (fork PR, branch `fix/5072`):

```
##[error]A branch or tag with the name 'fix/5072' could not be found
```

## Fix

Resolve `repository` to the head repo on PRs, matching `ref`:

```yaml
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
```

Same-repo PRs are unchanged (head repo == base repo), so the auto-format
push-back still works.
pull Bot pushed a commit to TheTechOddBug/CopilotKit that referenced this pull request Jun 2, 2026
The format job checked out github.head_ref without setting repository,
so it defaulted to the base repo. For fork PRs the head branch only
exists on the fork, making checkout fail with 'a branch or tag with the
name <branch> could not be found' (e.g. PR CopilotKit#5099). Resolve repository to
the head repo on pull_request events; same-repo PRs are unchanged, so
the same-repo-guarded auto-format push-back still works.
@tylerslaton
tylerslaton merged commit d33c40c into CopilotKit:main Jun 12, 2026
39 checks passed
BenTaylorDev added a commit that referenced this pull request Jul 13, 2026
…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 added a commit that referenced this pull request Jul 13, 2026
…SS (#5775) (#5944)

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.css` but 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 stable `data-streamdown`
attribute**, 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 no `data-streamdown` hook):

- controls row → `> div:first-child:not(:last-child)` (flex,
right-aligned, gap)
- per-button wrapper → `… > div` (relative, positions the popover)
- trigger buttons → `… > div > button` (matches the code-block
copy/download button styling)
- dropdown popover → `… > div > div`
- popover menu items → `… > div > div > button`

The 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

- **Compiles.** Built `globals.css` through the Tailwind v4 CLI — every
`@apply` resolves (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.
- **Selectors match the real DOM.** A new DOM test
(`streamdown-table-controls.test.tsx`) renders a real `<Streamdown>`
table and asserts the controls row is `table-wrapper`'s first-non-only
child, carries no `data-streamdown` attribute, and contains the trigger
buttons under `> div > button` — i.e. the scoped selectors target real
elements. This also guards against streamdown markup drift.
- **Selector presence** guarded by `streamdown-styles.test.ts`
(whitespace-robust).
- Full `styles/__tests__` suite green; `oxlint`/`oxfmt` clean.

## Note (out of scope, discovered while fixing)

At runtime in streamdown `1.6.11` the `<table>` element is stamped
`data-streamdown="table-wrapper"` (not `"table"`): `MarkdownTable`
passes `data-streamdown="table-wrapper"` as a prop that leaks through
`...rest` onto the `<table>`, overriding the intended `"table"`. So
#5099's `[data-streamdown="table"]` selector currently matches nothing,
and the table also matches the `table-wrapper` rules. The controls fix
here is unaffected (its child-combinator selectors don't match the
table's `thead`/`tbody` children), but the `[data-streamdown="table"]`
selector is worth a separate follow-up / upstream report.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

This branch was successfully deployed

5 active and 1 inactive deployments
Preview – travel — 9275ec2c Deployed Jun 12, 2026 by vercel[bot]
Preview – research-canvas — 9275ec2c Deployed Jun 12, 2026 by vercel[bot]
Preview – form-filling — 9275ec2c Deployed Jun 12, 2026 by vercel[bot]
Preview – chat-with-your-data — 9275ec2c Deployed Jun 12, 2026 by vercel[bot]
Preview – docs — 9275ec2c Deployed Jun 12, 2026 by vercel[bot]
npm — 9275ec2c Deployed Jun 12, 2026 by onsclom via build #6536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Default Streamdown markdown classes are unstyled in non-Tailwind consumers due to cpk: prefix

3 participants