Skip to content

fix: twoslash popup rendering and styling#2274

Draft
benjamincanac wants to merge 3 commits into
mainfrom
fix/twoslash-popups
Draft

fix: twoslash popup rendering and styling#2274
benjamincanac wants to merge 3 commits into
mainfrom
fix/twoslash-popups

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

Twoslash popups are rendered through MDC, so the code/pre nodes they embed get mapped to Nuxt UI's Prose components (ProseCodeInline / ProsePre). That wrapped popups in bordered, padded code blocks with a copy button instead of plain highlighted code.

  • Reset the inherited Prose styles within .twoslash-popup-container (margins, borders, padding, bg-muted, copy button) so popups show plain highlighted code, for both the inline and multi-line (pre) type cases as well as inline code in the docs section
  • Add a patch for nuxt-content-twoslash so config-level globals like defineNuxtConfig resolve in untagged config snippets (Nuxt's type-context split means nuxt.d.ts no longer references the nuxt package types)

Test plan

  • Hover a type in a twoslash code block, confirm the popup shows plain highlighted code with no border, copy button, or extra padding
  • Check both a single-line type popup and a multi-line type popup
  • Check inline code inside a popup's docs section renders without the Nuxt UI inline-code chip styling

Twoslash popups render through MDC, so the embedded code/pre nodes were
mapped to Nuxt UI Prose components (bordered code blocks with a copy
button). Reset those styles so popups show plain highlighted code, drop
the prose classMarkdown, patch nuxt-content-twoslash to resolve config
globals like defineNuxtConfig, and enable twoslash in dev.
@benjamincanac benjamincanac requested a review from atinux as a code owner June 11, 2026 09:23
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
nuxt Ready Ready Preview, Comment Jun 11, 2026 9:53am

@benjamincanac benjamincanac requested a review from danielroe June 11, 2026 09:25
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adjusts Twoslash code popup rendering and type resolution. It adds a TypeScript reference directive patch to the Twoslash transformer to resolve Nuxt types correctly, registers the patch in workspace dependencies, updates the base code font size from 1em to 0.875rem, adds CSS overrides to Twoslash popup containers to neutralize Prose/MDC styling, normalizes typography in documentation blocks, and removes an unused floatingVueOptions configuration from the Twoslash module settings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: twoslash popup rendering and styling' accurately summarizes the primary change: resetting Prose styles and patching twoslash popups to render correctly.
Description check ✅ Passed The PR description is directly related to the changeset, explaining the Prose style wrapping issue, the CSS fixes, the nuxt-content-twoslash patch, and providing clear test steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/twoslash-popups

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
app/assets/css/twoslash.css (1)

56-59: 💤 Low value

Consider adding a comment to explain the line-height calculation.

The calc(1.25 / 0.875) expression (≈1.4286) works correctly, but a brief comment explaining why this specific calculation is needed would improve maintainability.

For example:

/* Maintain consistent line-height ratio adjusted for the reduced font size */
line-height: calc(1.25 / 0.875);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/assets/css/twoslash.css` around lines 56 - 59, Add a brief explanatory
comment above the .twoslash-popup-docs p rule explaining why line-height uses
calc(1.25 / 0.875) (e.g., that it maintains a consistent line-height ratio when
font-size is reduced to 0.875) so future maintainers understand the rationale;
update the comment near the .twoslash-popup-docs p selector and keep it concise
and specific to the adjustment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/assets/css/twoslash.css`:
- Around line 56-59: Add a brief explanatory comment above the
.twoslash-popup-docs p rule explaining why line-height uses calc(1.25 / 0.875)
(e.g., that it maintains a consistent line-height ratio when font-size is
reduced to 0.875) so future maintainers understand the rationale; update the
comment near the .twoslash-popup-docs p selector and keep it concise and
specific to the adjustment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8e8f133-b1fb-4aee-8a18-e2777ead39b2

📥 Commits

Reviewing files that changed from the base of the PR and between 4b35385 and 5a2ee1e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • app/assets/css/twoslash.css
  • nuxt.config.ts
  • patches/nuxt-content-twoslash@0.4.0.patch
  • pnpm-workspace.yaml
💤 Files with no reviewable changes (1)
  • nuxt.config.ts

) {
const prepend = [
+ // `nuxt.d.ts` (app context) no longer references the `nuxt` package types since
+ // Nuxt's type-context split, so config-level globals like `defineNuxtConfig` are

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this shouldn't be needed. instead we should set the nuxt.config.ts file name for any code examples that use defineNuxtConfig, so the node types are pulled in

which ones were causing an issue?

@benjamincanac benjamincanac Jun 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well all code-blocks, on nuxt.com twoslash is not working at all at the moment and has doubled the build time. So we either need to fix it or disable it.

I don't think this patch should be merged, this PR is an experiment to fix twoslash upstream. I should have marked it as draft.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you for diving into this ❤️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What should we do then? Should I apply this patch on nuxt-content-twoslash or you don't think it's correct?

@benjamincanac benjamincanac marked this pull request as draft June 11, 2026 13:32
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.

2 participants