Skip to content

Add Mermaid diagram support to docs.warp.dev with custom Warp branding - #515

Merged
hongyi-chen merged 12 commits into
mainfrom
factory/quality-1631-mermaid-diagram-support
Aug 14, 2026
Merged

Add Mermaid diagram support to docs.warp.dev with custom Warp branding#515
hongyi-chen merged 12 commits into
mainfrom
factory/quality-1631-mermaid-diagram-support

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Mermaid diagram support to docs.warp.dev with custom Warp branding, a real example diagram on an existing feature page, and Warp-styled zoom/pan/fullscreen controls for viewing diagrams.

  • Registers the astro-mermaid + mermaid integration (client-side rendering, no Playwright/Chromium build dependency) before starlight() in astro.config.mjs, per the integration's required ordering.
  • autoTheme: true keeps each diagram's Mermaid base theme (default/dark) in sync with the site's data-theme attribute, so diagrams automatically get a correctly light/dark background and text color.
  • Brands the diagram accent (node border + connector line color) and font with Warp's Inter font stack and accent blue (--sl-color-accent, inlined as #51a6ec since Mermaid computes shades from this value at init time and can't consume a CSS custom property).
  • Adds .mermaid container CSS polish in src/styles/custom.css (border/radius aligned with the existing code-block tokens, responsive SVG sizing).
  • Adds a real flowchart to the handoff overview page's "Directions of handoff" section, visualizing the three handoff directions (local to cloud, cloud to cloud, cloud to local) between a local Warp session and a cloud agent run.
  • Adds MermaidControls.astro (included once via the site-wide footer), which layers zoom/pan/reset/fullscreen controls onto rendered diagrams using svg-toolbelt (zero runtime dependencies, ~5KB) — astro-mermaid/mermaid don't expose zoom/pan hooks themselves. Restyled to match the site's existing .copy-dropdown-panel/.copy-dropdown-item chrome (a single pill with flat, borderless buttons) in both themes.

Verification

  • npm run typecheck (astro check) — 0 errors, 0 warnings (pre-existing hints only).
  • npm run build (astro build) — succeeds end to end (364 pages built).
  • npm ci — installs cleanly on Node 22, matching the CI environment.
  • No regression test added: this is a config/integration + content change with no new production logic, so a unit test would only assert that a fenced code block renders — the real verification is the build succeeding and the rendered output, confirmed with computer-use visual proof below.
  • Visual proof: verified with computer use, in both dark and light theme, that the diagram renders as real SVG (legible, correctly branded, re-themes on switch) and the toolbar's zoom/pan/reset/fullscreen controls all work correctly with no browser console errors.

Full rework history for this PR (four review/requester cycles) is tracked as a comment on the linked Linear ticket, QUALITY-1631.

Originating thread: https://warpdev.slack.com/archives/C09BVK0PL3Y/p1786636610730459

Computer-use screenshots (3)

Light theme: Mermaid flowchart diagram with all 4 nodes (Local Warp session, Cloud agent run, Cloud agent run follow-up, New local Warp session) fully visible, with the hover toolbar (fullscreen, zoom-in, zoom-out, reset icons) visible in the top-right corner of the diagram.
Light theme: the diagram with the corrected toolbar.

Dark theme: Mermaid flowchart diagram with all 4 nodes fully visible on dark background, with the hover toolbar (fullscreen, zoom-in, zoom-out, reset icons) clearly visible in the top-right corner of the diagram.
Dark theme: the same diagram and toolbar, correctly re-themed.

Close-up of the Mermaid diagram's toolbar in dark theme, showing all 4 icons: fullscreen (corner brackets), zoom-in (+), zoom-out (-), and reset (house-shaped icon).
Close-up confirming all 4 toolbar icons render correctly.

Add astro-mermaid + mermaid so fenced ```mermaid blocks render as
client-side SVG diagrams instead of plain code blocks. The integration
is registered before starlight() per its required ordering, and
autoTheme keeps each diagram's base theme in sync with the site's
data-theme attribute. Brand the diagram accent (border/line color) and
font with Warp's Inter stack and accent blue as literal values, since
Mermaid resolves theme colors through its own color-math library at
init time and can't parse a CSS var() reference.

Add a real example diagram to the software-factory page's "How it
works" section, showing the inner-loop handoff between agents and the
human review gate.

Co-Authored-By: Warp Agent <agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Aug 13, 2026
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 14, 2026 6:20pm

Request Review

@warp-agent-staging warp-agent-staging Bot added the warpy-factory Opened by the Warp factory agents label Aug 13, 2026
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review August 13, 2026 16:49
@oz-for-oss

oz-for-oss Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@warp-agent-staging[bot]

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

View run View conversation

@oz-for-oss oz-for-oss 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.

Overview

This PR adds client-side Mermaid rendering to the Astro/Starlight docs site, configures Warp-branded theme variables, adds container styling, and includes a software-factory flowchart example. The implementation follows the required integration order, the content change fits the existing conceptual page, and I did not find security or spec-alignment blockers.

Concerns

  • The only concern is non-blocking production console noise from astro-mermaid's default client logging; set enableLog: false in the integration config.

Verdict

Found: 0 critical, 0 important, 1 suggestions

Approve with nits

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread astro.config.mjs
Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>

@warp-agent-staging warp-agent-staging Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Overview

This PR adds client-side Mermaid rendering with branded theming and a software-factory flowchart. It cannot be accepted while the committed lockfile prevents required CI from installing dependencies.

Concerns

Required CI fails at npm ci because package-lock.json is missing @emnapi/runtime@1.11.1; the Vercel deployment fails downstream. Regenerate the lockfile with a supported Node/npm version and re-run the checks.

Verdict

Checks: CI ❌ (npm ci lockfile mismatch) · typecheck ✅ · build ✅ (with the documented Node stack workaround; the default-stack failure reproduces on main) · visual proof ✅
Found: 1 critical, 0 important, 1 suggestions

Request changes

Review run

https://oz.staging.warp.dev/runs/019ffc0a-b5ff-72e7-9ea1-81da6514bb26

Comment thread astro.config.mjs
- Regenerate package-lock.json with a Node version in the repo's
  supported engines range (Node 22, matching CI). The previous lockfile
  was generated with an unsupported Node version and was missing a
  package-lock entry for @emnapi/runtime@1.11.1, which made `npm ci`
  fail in CI. Restored the original lockfile as a base and added only
  the two new packages, instead of a full re-resolution, to keep the
  diff minimal (no unrelated dependency bumps).
- Move the example diagram off the software-factory page (an internal
  process page) to the handoff overview page, where it visualizes the
  three real handoff directions between a local session and a cloud
  run.
- Redesign the diagram as a compact top-down flowchart (3 nodes) instead
  of a wide left-right one (7 nodes), fixing legibility: the previous
  diagram's SVG had to scale down significantly to fit the content
  column width, shrinking all diagram text well below normal body size.
- Trim the astro-mermaid integration comments to the essential
  rationale (required integration order, and why colors are literal
  hex instead of CSS variables).

Co-Authored-By: Warp Agent <agent@warp.dev>
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

Addressed: regenerated package-lock.json with a Node version in this repo's supported engines range (^20.19.0 || ^22.12.0 || ^24), matching CI's node-version: '22'. The previous lockfile was generated with an unsupported Node version, which left it missing a package-lock entry for @emnapi/runtime@1.11.1, causing npm ci to fail with "Missing: @emnapi/runtime@1.11.1 from lock file". Verified locally with npm ci on Node v22.23.2 — installs cleanly now. Restored the original lockfile as a base and added only the two new packages (rather than a full re-resolution) so the diff stays minimal with no unrelated dependency bumps (e.g. astro itself stays pinned at 7.1.3).

Fixed in commit 368165b.

@warp-agent-staging warp-agent-staging Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Overview

This PR adds client-side Mermaid rendering with branded theming and a compact Handoff flowchart. The rework resolves the lockfile and logging findings, and the final implementation meets the ticket’s acceptance criteria.

Verdict

Checks: CI ✅ · clean install ✅ · typecheck ✅ · style/link checks ✅ · visual proof ✅
Found: 0 critical, 0 important, 0 suggestions

Approve

Review run

https://oz.staging.warp.dev/runs/019ffc0a-b5ff-72e7-9ea1-81da6514bb26

- The handoff diagram's self-loop edge ("Cloud to cloud") made Mermaid
  reserve extra vertical space in the SVG's viewBox that the visible
  content never filled, showing as a large blank gap below the diagram.
  Redesign the flow as two sequential "Cloud agent run" nodes instead of
  a self-loop, which represents the same three handoff directions
  without the layout artifact.
- Add MermaidControls.astro, a small component (included once via the
  site-wide footer) that layers zoom/pan/reset/fullscreen controls onto
  rendered diagrams using svg-toolbelt (zero runtime dependencies,
  ~5KB). astro-mermaid/mermaid expose no such hooks themselves. Re-runs
  after every astro-mermaid re-render, since a theme switch replaces a
  diagram's entire DOM subtree and would otherwise drop the controls.
- Brand the controls' background, border, and hover colors to match the
  site's existing code-block/copy-button chrome in both themes.

Co-Authored-By: Warp Agent <agent@warp.dev>

@warp-agent-staging warp-agent-staging Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Accepted

No blocking findings in the follow-up controls and spacing update.

Validated:

  • Current CI, clean npm ci, typecheck, docs style/link checks, and full production build.
  • svg-toolbelt 0.7.0 is MIT-licensed and adds no runtime dependencies.
  • The Handoff diagram has no stray bottom whitespace in light or dark themes.
  • Zoom in/out, reset, fullscreen, and fullscreen exit work; one toolbar remains functional after a theme switch with no Mermaid/control console errors.
  • The PR body includes refreshed video proof for this interactive follow-up.

Review run: https://oz.staging.warp.dev/runs/019ffc0a-b5ff-72e7-9ea1-81da6514bb26

svg-toolbelt's own stylesheet hardcoded a light-only look (white
background, gray border, a column of individually-bordered squares)
that didn't re-theme with the site and read as a foreign floating
widget. Restyle it as a single pill matching .copy-dropdown-panel, with
borderless, transparent buttons matching .copy-dropdown-item, using
Warp's existing color tokens so it re-themes correctly. `!important` is
used because the library's own CSS uses the same selector specificity
and can load after this stylesheet in the bundle.

Verified with computer use: the toolbar's computed background/border/
icon colors now differ correctly between dark and light theme, buttons
are flat/borderless by default with a themed hover highlight, and
zoom/pan/reset interactions are smooth with no jank (the library
already disables its CSS transition during active drag and only
applies it to discrete actions like reset).

Co-Authored-By: Warp Agent <agent@warp.dev>
- The fullscreen toolbar button used svg-toolbelt's default '⛶' glyph,
  which rendered as a missing-glyph box on systems without a symbol-font
  fallback for that character. Replaced it with an inline stroke SVG icon
  matching the site's existing icon convention (see CopyPageButton.astro).
- The idempotency guard and the fullscreen background CSS rule both
  targeted '.svg-toolbelt-wrapper', a class the library only applies via
  its separate initializeSvgToolbelt() helper. MermaidControls.astro
  instead instantiates SvgToolbelt directly on pre.mermaid, which carries
  '.svg-toolbelt-container' instead — so the guard never actually
  prevented re-processing on every poll tick, and the themed fullscreen
  background rule never applied. Fixed both to target the class that is
  actually present.

Co-Authored-By: Warp <agent@warp.dev>
warp-agent-staging Bot and others added 2 commits August 14, 2026 18:06
Per explicit requester feedback (Slack), removed the integration-order/
hex-value comment above the mermaid() call in astro.config.mjs and the
svg-toolbelt-wrapper/container comment in custom.css, since the requester
considers this class of 'why we did it this way' comment unnecessary here.

Did a follow-up pass over the rest of the diff's comments with the same
stricter bar (only keep a comment if it guards against a specific
regression, not just background context) and also removed:
- the accent-blue label comment in astro.config.mjs,
- the top-of-file rationale banner in MermaidControls.astro,
- the descriptive prose in custom.css's Mermaid section banner (kept
  just the section title).

Comments that document the exact bugs fixed in the previous rework pass
(the fullscreen-icon glyph fix, the .svg-toolbelt-controls idempotency-
guard fix, the MutationObserver/polling/DOMContentLoaded rationale) were
kept, since removing them risks a future edit silently reintroducing
those regressions.

Co-Authored-By: Warp <agent@warp.dev>
warp-agent-staging Bot and others added 2 commits August 14, 2026 18:15
Per explicit requester feedback (Slack: 'honestly i think you should
probably just remove like basically all of the comments'), removed
essentially every comment this PR added in MermaidControls.astro and
custom.css, keeping only a single one-line note guarding the exact
selector-mismatch bug already fixed once (.svg-toolbelt-container vs
.svg-toolbelt-wrapper).

Co-Authored-By: Warp <agent@warp.dev>
@hongyi-chen
hongyi-chen merged commit c35aab4 into main Aug 14, 2026
8 checks passed
@hongyi-chen
hongyi-chen deleted the factory/quality-1631-mermaid-diagram-support branch August 14, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed warpy-factory Opened by the Warp factory agents

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants