Skip to content

grok-mermaid: render wide diagrams with horizontal scroll on narrow screens#294

Merged
simonw merged 1 commit into
mainfrom
claude/grok-mermaid-mobile-safari-9vcy9u
Jul 16, 2026
Merged

grok-mermaid: render wide diagrams with horizontal scroll on narrow screens#294
simonw merged 1 commit into
mainfrom
claude/grok-mermaid-mobile-safari-9vcy9u

Conversation

@simonw

@simonw simonw commented Jul 16, 2026

Copy link
Copy Markdown
Owner

https://tools.simonwillison.net/grok-mermaid does not seem to work in mobile Safari - investigate

On phone-width viewports the default 'Fit output panel' mode computed
~43 columns, which no example diagram fits in, so the renderer silently
fell back to a framed echo of the raw source — making the page look
completely broken on mobile (reproduced in both WebKit and Chromium at
390px; it was viewport-driven, not a Safari engine bug).

Since max_width never reshapes a diagram (it only swaps in the fallback
when the art is too wide), fit mode now re-renders uncapped when the cap
changes the output, shows the real diagram in the already-scrollable
output panel, and notes 'scroll the output sideways' in the status line.

Also for mobile Safari: 16px textarea font below 600px so iOS stops
zooming the page on focus, and autocapitalize/autocorrect off so it
stops mangling Mermaid source.

While investigating, wasm-tools validate showed grok-mermaid.wasm
required reference-types support: wasm-ld encodes the call_indirect
table-index immediate as an overlong LEB, which engines without that
feature (e.g. Safari < 15) reject with 'zero byte expected' — the
wasm-opt step in build_wasm.sh that would have fixed the encoding was
optional and had not run. Re-encoded the module with binaryen -Oz
(190 KB -> 163 KB, output byte-identical across all example diagrams
and widths), and made build_wasm.sh pass the right --enable flags and
warn loudly when wasm-opt is missing.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01DYG8viWcVWafLHxXRA3RXE

…creens

On phone-width viewports the default 'Fit output panel' mode computed
~43 columns, which no example diagram fits in, so the renderer silently
fell back to a framed echo of the raw source — making the page look
completely broken on mobile (reproduced in both WebKit and Chromium at
390px; it was viewport-driven, not a Safari engine bug).

Since max_width never reshapes a diagram (it only swaps in the fallback
when the art is too wide), fit mode now re-renders uncapped when the cap
changes the output, shows the real diagram in the already-scrollable
output panel, and notes 'scroll the output sideways' in the status line.

Also for mobile Safari: 16px textarea font below 600px so iOS stops
zooming the page on focus, and autocapitalize/autocorrect off so it
stops mangling Mermaid source.

While investigating, wasm-tools validate showed grok-mermaid.wasm
required reference-types support: wasm-ld encodes the call_indirect
table-index immediate as an overlong LEB, which engines without that
feature (e.g. Safari < 15) reject with 'zero byte expected' — the
wasm-opt step in build_wasm.sh that would have fixed the encoding was
optional and had not run. Re-encoded the module with binaryen -Oz
(190 KB -> 163 KB, output byte-identical across all example diagrams
and widths), and made build_wasm.sh pass the right --enable flags and
warn loudly when wasm-opt is missing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DYG8viWcVWafLHxXRA3RXE
@simonw simonw merged commit a66e080 into main Jul 16, 2026
0 of 4 checks passed
@claude

claude Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

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