Skip to content

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

Open
warp-agent-staging[bot] wants to merge 5 commits into
mainfrom
factory/quality-1631-mermaid-diagram-support
Open

Add Mermaid diagram support to docs.warp.dev with custom Warp branding#515
warp-agent-staging[bot] wants to merge 5 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 — see code comment for why a literal hex is used instead of a var(--sl-color-*) reference).
  • 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) on Node 22 (matching CI's node-version: '22').
  • npm ci — installs cleanly on Node 22, matching the CI environment exactly.
  • npm run lint (trunk check) — the trunk CLI is not available in this sandbox, so this documented check could not be run here; it is left to the PR's CI as an available lint gate.
  • No regression test added: this is a config/integration + content change with no new production logic (config-only / pure data-copy-adjacent), 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, via DevTools computed styles, that the toolbar's background/border/icon colors are theme-correct (not plain white in dark mode) and clearly differ between themes; that buttons are flat/borderless by default with a themed hover highlight; and that zoom-in/zoom-out/pan/reset/fullscreen all function correctly and smoothly (no jank observed), including immediately after a theme switch (which fully replaces the diagram's DOM). No browser console errors.

Rework changes (cycle 3 — requester follow-up, PR already review-done)

  • Toolbar didn't match the site's design system: 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. Restyled it as a single pill matching .copy-dropdown-panel, with borderless/transparent buttons matching .copy-dropdown-item, using Warp's existing color tokens (!important is used because the library's own CSS shares the same selector specificity and can load after this stylesheet in the Vite bundle). Verified via DevTools computed styles that colors now genuinely differ between dark and light theme.
  • Interaction smoothness: checked zoom-in/zoom-out/pan/reset for jank. The library already disables its CSS transition during active drag (applying transforms directly) and only animates discrete actions like reset, so no smoothness issue was found or needed fixing; confirmed this holds after the restyle with a recorded zoom/pan/reset pass.

Rework changes (cycle 2 — requester follow-up, PR already review-done)

  • Spacing bug: the diagram's self-loop edge ("Cloud to cloud") made Mermaid reserve extra vertical space in the SVG that its visible content never filled, leaving a large blank band inside the bordered container. Redesigned the flow as two sequential "Cloud agent run" nodes instead of a self-loop — same three handoff directions, no layout artifact. Confirmed via DevTools that the container height now exactly matches its content plus normal padding/border.
  • Diagram controls: added zoom/pan/reset/fullscreen controls (see Summary), matching the general control set observed on the referenced docs.auto.sh page (zoom in/out, reset, fullscreen, in a hover toolbar), implemented with the small zero-dependency svg-toolbelt library rather than hand-rolling touch/keyboard/accessibility handling.

Rework changes (cycle 1 — blocked)

  • CRITICAL (CI): package-lock.json was generated with an unsupported Node version and was missing a lockfile entry for @emnapi/runtime@1.11.1, making npm ci fail. Regenerated the lockfile on Node 22 (matching CI), adding only the two new packages on top of the original lockfile so there are no unrelated dependency bumps. Verified npm ci now succeeds.
  • SUGGESTION: Set enableLog: false on the astro-mermaid integration to avoid production console noise (this was already applied via a bot-suggested commit before this rework pass).
  • Requester feedback — page choice: Moved the example diagram off the software-factory page (an internal/process page) to the handoff overview page, where it visualizes a real product flow (the three handoff directions).
  • Requester feedback — legibility: The original diagram was a wide 7-node left-right flowchart that had to scale down significantly to fit the content column, shrinking all text. Replaced it with a compact top-down flowchart that renders at normal, readable text size.
  • Requester feedback — comments: Trimmed the astro-mermaid integration comments in astro.config.mjs to the essential rationale only.

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

Computer-use screenshots (2)

Dark theme: Mermaid flowchart diagram with hover toolbar visible in top-right corner, showing fullscreen/zoom-in/zoom-out/reset icons on a dark pill-shaped background, with the fullscreen button in a hovered/highlighted state.
Dark theme: the restyled toolbar as a single dark pill with flat icon buttons, matching the site's existing copy-button chrome.

Light theme: Same Mermaid flowchart diagram with hover toolbar visible in top-right corner, now showing a white pill-shaped background with dark icons, and a subtle gray hover highlight on the zoom-in button.
Light theme: the same toolbar re-themed to a white pill with dark icons after switching themes.

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 13, 2026 8:05pm

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>
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