Repository navigation
fix(react-core): scope streamdown markdown styles - #5099
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@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. |
d15d350 to
8c6bd1d
Compare
onsclom
left a comment
There was a problem hiding this comment.
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!
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkitnext/angular
@copilotkit/bot
@copilotkit/bot-slack
@copilotkit/bot-ui
@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-inspector
commit: |
|
Thanks a lot for reviewing and for adding the missing selectors/tests. Glad the repro confirmed the fix for the main cases. |
## 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.
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.
…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]>
…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)
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-streamdownelements under[data-copilotkit].-> Use CopilotKit theme variables and prefixed Tailwind utilities so styles stay inside the CopilotKit surface.
-> Remove the ineffective Streamdown
@sourcescan, 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