Skip to content

Update Pele to 1.13.0; Mermaid stays as the fallback - #4113

Merged
backnotprop merged 7 commits into
mainfrom
chore/pele-update
Nov 27, 2026
Merged

backnotprop merged 7 commits into
mainfrom
chore/pele-update

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Updates pele from 1.3.0 to 1.13.0 in packages/ui. Mermaid is unchanged and still draws any fence Pele cannot.

Why 1.13.0 and not an older version

Pele issue obsidianmd/pele#148 reports that 1.9.1 and later corrupt emoji in WebKit (Safari, WKWebView). The cause is a /u regex in Pele's SVG text escaping. The corruption depends on the WebKit version, not on the Pele version alone:

  • The issue's own repro is on Safari 17.6. It says WebKit fixed the underlying regex bug in 276031@main, with follow-ups through 287202@main.
  • The issue's regex returns the emoji intact in this Mac's system JavaScriptCore (macOS 26.3).
  • Through our own render path (renderDiagram → renderPele, with the app's theme tokens, sanitizer and label steps), Playwright WebKit 27.2 and Chromium 156 produce byte-identical label text on 1.3.0 and 1.13.0. The test labels hold a single emoji, a ZWJ family, flags, keycaps and emoji next to CJK. No lone surrogates appear in the SVG.
  • The iOS app's deployment target is iOS 26.0 (apps/mobile/ios/PlannotatorInbox.xcodeproj/project.pbxproj), which is newer than the fix.

Not checked: the Safari app itself and the iOS app on a device. Users on an older Safari (17.x, as in the issue) would see broken emoji in Pele diagrams after this update.

What changes in the drawings (16 diagrams, before and after, Chromium and WebKit)

Better:

  • Labels on custom fills (style/classDef) in a dark theme. On 1.3.0, light-filled nodes had near-invisible light text. They now get dark text (Pele 1.12).
  • List<T>, Map<K, V> and Option<String> in flowchart labels. 1.3.0 drew "List" and "Option" (Pele 1.9).
  • A long Chinese or Japanese label now wraps instead of stretching the diagram very wide (Pele 1.7).
  • A radar chart with keyword-prefixed names (titles, circles). On 1.3.0 both Pele and Mermaid gave a parse error. It now draws (Pele 1.10.1).

Worse: nothing left (diagram 13 was, and is fixed by the fourth commit, below).

Same: sequence with autonumber, class generics with ~T~, a pie with slices under 1%, state, gantt, ER, %% comments, requirement, flowchart with subgraphs. A mindmap is laid out differently (branches on other sides), but no better or worse.

Comment anchors on diagrams

With the app's own finder (PELE_COMPAT_FINDER), the harness lists every part a comment can attach to, on both versions. In all 16 diagrams the ids, kinds and ends are the same on 1.3.0 and 1.13.0, and every target round-trips. Stored anchors keep restoring. Two label differences came from the update:

  • CJK wrapping. Our wrapped-row spacing (peleRowSpaces.ts) and the anchor label reader (peleLabelText) put a space at every row break. That was right for word wrapping, but wrong for Chinese and Japanese, which Pele now breaks between characters. A row break inside CJK text now joins with no space, as Mermaid reads the label. New test in peleRowSpaces.test.ts; it fails without the fix.
  • Tag-like text in labels. class Odd["Odd & <x>"] is now drawn as written, where Mermaid drops <x>. A new comment there is labelled with the text the person sees. The class parity test in diagramAnchorPele.test.ts now lists the labels explicitly and checks that a comment made under Mermaid still restores on that class (nodes match by id first).

Other checks

  • API: we call only detectType, load and renderAsync from pele/lazy, never mount(), so the breaking mount() changes in 1.5 and 1.6 do not reach us. tsc for packages/ui and packages/ui/tsconfig.strict-consumer.json is clean.
  • Size: the plan review page (apps/hook Vite build, index.html) grows by 78 KB, from 25.17 MB to 25.25 MB (gzip 7.45 MB to 7.48 MB). This is recorded in PELE.md.
  • Licence: still MIT, with no runtime dependencies.
  • bun.lock was changed by bun install, not by hand. It also syncs ui's @plannotator/core entry to 0.25.34, which packages/ui/package.json already pins on main.
  • @plannotator/ui keeps its version: the next ui publish ships Pele 1.13.0.

Inline size of a Pele diagram (second commit)

Inline, a diagram used to be fitted to fill its box, scaling it up as far as 8× (useDiagramViewport.ts, Fit). Mermaid gets the same treatment, but Pele draws much tighter at the page's text size, so a small Pele diagram came out with text two to three times the body text. Through the real MermaidBlock → DiagramBlock path in a 760 px document column, identical on Pele 1.3.0 and 1.13.0 and in both Chromium and WebKit:

  • a 3-participant sequence was scaled 1.89× and now 0.99×;
  • a two-node flowchart was scaled 3.38× (text 61 px tall) and now 1×;
  • a short diagram's zoom controls covered its last row and now clear it;
  • the same page under Mermaid scales 1.09× and 1.97×, unchanged by this fix.

Fix: an inline Pele diagram is fitted at most at its own size (inlineFitMaxScale, fitAtMostNaturalSize), and the box height is computed at that scale. The popout, zooming and Mermaid's fit are unchanged. New test in DiagramBlock.engine.test.tsx: a narrow Pele diagram fits at scale 1 (3.40 without the fix), and a Mermaid diagram still fills its box at 2×.

Not changed here:

  • A node with a picture shape (id@{ img: "...", label: "..." }) is drawn by Pele as its caption with no box, because we render with images: false (utils/pele.ts:138). Our picture-only fallback to Mermaid (utils/pele-labels.ts:49) catches <img> tags in a label but not this shape. Same on 1.3.0.
  • (Was: a drawing could reach under the zoom controls. Fixed in the seventh commit, below.)

Engine test marker (third commit)

tests/entry-assets.test.ts checked that the diagram engine (diagram-engine/engine.js) carries no Mermaid by looking for the text flowchart-v2. Pele 1.13.0 names that diagram id in its own type-detect table (["flowchart","flowchart-v2",/^\s*(graph|flowchart)/], in pele/dist/esm/chunks/DKUZGKB3.js; Pele 1.3.0 has no such text), so the engine now has that text with no Mermaid in it. Mermaid is not bundled into the engine: on main, engine.js is 920.6 kB; on this branch it is 996.9 kB (+76 kB, which is the Pele growth). mermaid.js is 4813.9 kB on both.

The test now uses registerExternalDiagrams, a name on Mermaid's public API object, so minification keeps it. It is in mermaid.js, and it is not in engine.js, Pele 1.3.0 or 1.13.0, or any Plannotator source. The same test asserts the marker in mermaid.js (mermaidRuntime), so it still fails if Mermaid gets bundled into the engine. The same flaw was in the checks that Mermaid is packed into the plan page (apps/hook/dist/index.html), the Inbox window and the OpenCode page: all of these pack Pele 1.13, so flowchart-v2 was there even without Mermaid. They now use the same marker (fifth commit). In the built plan page it occurs 3 times, all in Mermaid code; engine.js, which holds Pele and no Mermaid, has flowchart-v2 once and the new marker 0 times, so a page without Mermaid fails the check. flowchart-v2 stays as an absent marker for the review page, which carries neither Pele nor Mermaid (0 hits): an absent check with a wider marker can only fail too often, never pass by mistake.

Sankey with a header row (fourth commit)

Pele 1.13.0 stops at Source,Target,Value with "Parse error on line 2 … Expecting a number". It is not supports() and not our gate: detectType says sankey and load succeeds. The parser needs parseFloat(value) to be finite. Pele 1.10.0 made this an error on purpose (release notes: "a value that doesn't start with a number, such as abc, is a syntax error instead of an empty flow", obsidianmd/pele#60). So every version from 1.10.0 on rejects the header row. 1.9.1 would accept it, but pinning it would lose the 1.10 to 1.13 fixes that this PR is for (1.12.0 dark-fill label contrast, diagram 11; 1.10.1 names that start with a keyword).

Fix: before Pele draws a sankey, its first row is read as a header when its value is not a number by Pele's own test (packages/ui/utils/peleSankeyHeader.ts, called in renderPele). The row's line stays, empty, so an error further down still names its own line. Every later row is left as written, so a bad value there is still an error. A first row with an empty value (A,B,) is not a header either: it stays Pele's error, as before. The Mermaid fallback and the source the person sees and copies are unchanged. On 1.3.0, and in Mermaid, the header was drawn as a stray "Source 0 → Target 0" flow across the top. It is now gone.

New test packages/ui/utils/peleSankeyHeader.test.ts (DOM): the header sankey draws in Pele with the four real nodes and four flows; a first row that is a flow stays a flow; a first row with an empty value is an error at line 2; a bad value on line 4 is still an error at line 4. Without the fix, 2 of 4 fail; without the empty-value rule, the empty-value case fails.

Pictures (before = main on 1.3.0, after = this branch), diagram 13 and contact sheets of all 16, Chromium 156 and WebKit 27.2, dark and light, are kept outside the repo. Only diagram 13 changed against the earlier 1.13.0 run.

Comment card at the bottom of a shorter box (sixth commit)

The phone e2e inbox-thread-diagram-comments.spec.ts:308 failed: the comment card on "Fix the build" ended 3.3 px below the diagram box. Cause, measured in a 390 px harness with that spec's diagram (Pele, drawn at 267 × 328): on main Fit scaled it 1.154× in a 546.6 px box, and the 108 px card sat 31.9 px clear of the bottom. With the fit cap it is drawn at 0.994× in a 374 px box, so the card is lifted to end exactly at the box's bottom. The card's entry animation (pn-cbox-in) rises from 4 px below, so its first frames run past that edge: 4.13 px at 48 ms and 3.25 px at 65 ms, settling at 0.13 px (the e2e read it mid-entry). No part of any diagram was outside its box in any case measured (tall, wide, small, phone and desktop).

Fix: a card lifted to fit the canvas comes in from above (data-above, the keyframes comment-card.css already has), DiagramComposer.tsx. The in-canvas card is at most the canvas less 16 px, so coming in from above stays inside. With it, the harness trace never passes the bottom (max +0.13 px). Tests: DiagramComposer.card.test.tsx, where a lifted card has data-above and one at its part does not (fails without the fix); DiagramBlock.engine.test.tsx, where a Pele diagram larger than its box in either direction is still scaled down to fit (a guard: Fit already did this).

Zoom controls clear of the drawing (seventh commit)

With the fit cap, the inline box is the drawing's height plus 48 px, and the zoom strip (− ⤢ +) is taller than Fit's 24 px margin. On a 390 px phone the strip covered "Deploy" in the 4-node top-down flowchart; on main the box was taller, so the drawing was clear of it.

Fix: when the fitted drawing would reach the strip, the inline box grows by the strip's measured band (its height plus its margin, read from its rect, not a constant), only as far as the drawing needs. The drawing keeps the scale Fit gives it and is centred in the area above the strip. A drawing already clear keeps its place and its box. The strip does not move. fitInHost in useDiagramViewport.ts decides; DiagramCanvas measures the strip; DiagramBlock adds the room to the box (controlsReserve, passed through DiagramViewer). Hosts that pass no reserve, such as the full-screen viewer, are unchanged.

Measured through the real MermaidBlock/GraphvizBlock path in a 760 px column, Chromium 156 and WebKit, 390 px and 1280 px wide:

  • 4-node flowchart on a phone: box 379 px before (strip over "Deploy"), 429 px now (strip 24 px under the drawing); main 548.6 px. At desktop width it was clear before, so it is unchanged (379 px; main 576 px).
  • Two-node, wide and tall flowcharts: clear before, so their boxes and places are unchanged (256, 256, 548.6/576 px).
  • The same page drawn by Mermaid, and two Graphviz diagrams: transform and box identical to main and to the previous head in all 8 engine/width/mode runs. None of them reached the strip.
  • The comment card on "Fix the build", phone: it now sits by its part, 26 px clear of the bottom of the 427 px canvas (before: lifted, flush with the bottom). Desktop: unchanged.

Tests: fitInHost.test.ts (plain): at rest, the strip's rect and the drawing's rect do not intersect for the 4-node, two-node, wide and tall flowcharts at 390 px and at desktop width; the scale is never below Fit's; the box grows by at most the band; a drawing already clear gets no room. 2 of 5 fail without the fix. DiagramCanvas.controlsReserve.test.tsx (DOM, browser layout stood in): the canvas asks once for the 50 px band, and the Fit control on the grown box asks nothing new; a canvas without a reserve asks nothing. 1 of 2 fails without the fix.

Tests run locally (one file per run)

DOM: DiagramBlock.engine 25/25 (with the new fit test), peleRowSpaces 3/3, diagramAnchorPele 18/18, pele-labels 26, pele-render 8, pele-hostile 16, diagramAnchor 26, diagramMathLabels 2, diagramLabelScrub 9, diagramRemoteLoads 10, DiagramBlock.anchor 7, DiagramBlock.askAI 5, DiagramBlock.lazyRetry 16, DiagramBlock.copySource 2, MermaidBlock.theme 3, DiagramViewer 28, Viewer.diagramLazyRestore 3, Viewer.diagramAnchorHostile 1, useAnnotationHighlighter.diagramSkip 2, Viewer.diagramClosure 9, Viewer.textComments 9, LazyBlockBoundary 4, guideChapterDiagram 6, guideOverviewMermaid 4, spaceFaceDiagram 3, overviewDiagram 4, App.diagramDocument 3, MarkdownFilePreview 15.
Plain: pele 8, peleTheme 120, peleAuthorTheme 9, diagramShadowSetting 4, parser.diagramDocument 4, review diagramEngine 7, annotate.diagram 8, entry-assets 31 (41 skipped: they need built output), published-package-floors 23.
Fourth commit: peleSankeyHeader 3/3 (2 fail without the fix), pele-render 8/8, pele-hostile 16/16, dom-test-allowlist 1/1, tsc ui and strict-consumer clean. All pass. Left to CI: packages/server/diagram-engine-assets.test.ts, which needs generated Pi files a fresh worktree lacks, and the browser suites.
Seventh commit: fitInHost 5/5, DiagramCanvas.controlsReserve 2/2, DiagramViewer 28/28, DiagramBlock.engine 26/26, DiagramComposer.card 4/4, DiagramBlock.anchor 7/7, guideChapterDiagram 6/6, dom-test-allowlist 1/1, tsc ui and strict-consumer clean.

Pele 1.13.0 wraps Chinese and Japanese labels between characters, so the
space we put between wrapped rows (and the comment label read from them)
now skips row breaks inside such text, as Mermaid reads the same label.
A class label like "Odd & <x>" is now drawn as written; the anchor test
states that and checks a Mermaid-made comment still restores on it.
The inline fit scaled every diagram up to fill its box. Pele lays diagrams
out at the page's text size and tighter than Mermaid, so a small one came
out with words two to three times the page's, and a short one ran under
the zoom controls. Fit now stops at 1 for an inline Pele diagram, and the
box is sized for that. The popout and Mermaid's fit are unchanged.
Pele 1.13.0 names the flowchart-v2 diagram id in its own detect table,
so that text no longer shows that Mermaid is in the engine. Look for
registerExternalDiagrams, a name on Mermaid's API object, instead.
Pele 1.10 and later stop at a sankey row whose value is not a number,
so a CSV header row (Source,Target,Value) made the diagram fall back to
Mermaid. Read the first row as a header when its value is not a number,
leaving its line empty so later errors keep their line numbers.
The plan page and the Inbox window pack Pele 1.13, which carries the
flowchart-v2 id, so the checks that Mermaid is packed there passed
without Mermaid. Look for registerExternalDiagrams instead.

A first sankey row with an empty value is a flow missing its number,
not a header: leave it as written.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 27, 2026
A card held at the bottom edge of the diagram's box entered with its
usual rise from 4 px below, so its first frames ran past the edge and
were cut off. Inline Pele diagrams are now drawn at their own size, so
their box is shorter and a card on a low part is held there more often.
When the fitted drawing would reach the zoom strip, the inline box grows
by the strip's measured band (its height and margin), only as far as the
drawing needs, and the drawing, at the same scale, is centred above the
strip. A drawing already clear keeps its place and its box. Hosts that
pass no reserve (the full-screen viewer) are unchanged.
@backnotprop
backnotprop marked this pull request as ready for review November 27, 2026 02:49
@backnotprop
backnotprop merged commit b43e095 into main Nov 27, 2026
91 of 92 checks passed
backnotprop added a commit that referenced this pull request Nov 27, 2026
…n accept with remote loads off

The check a host passes (accept) is never handed the final svg, and down the
Mermaid fallback with diagramRemoteLoads off Mermaid's label pass has already
removed a label's picture, so the check may see nothing to refuse: the notes
say so, and the browser test now pins it with real Mermaid. Any Pele failure
other than a refusal falls back, a failed load of Pele included. What loaded
nothing is stated as observed for the sources tested, with the enforced CSP
still required; a Report-Only policy does not block. The #4113 items are
marked merged and not yet published. The Mermaid-path accept tests now pin
only that the check runs before the clean-up and that a refusal is refused.
yermakoffivan pushed a commit to yermakoffivan/plannotator that referenced this pull request Nov 27, 2026
…d Pele 1.13

core 0.25.35 carries what merged after 0.25.34 went to npm: exact-phrase
search in inbox-search (words in double quotes, backnotprop#4117, backnotprop#4124) and the
agent-gone event in external-annotation's ExternalAnnotationEvent (backnotprop#3698).
No exports subpath changes.

ui handles that agent-gone event, so its pin follows and core goes first.
ui 0.67.0 is a minor: DiagramSourceAcceptContext lets a host refuse a fence
by its source before any engine runs (backnotprop#4146), DIAGRAM_REFUSED_RESULT is
exported, Pele 1.13.0 with the inline fit changes (backnotprop#4113), the agent-gone
send failures (backnotprop#3698) and the plan header seams (backnotprop#3905). README and HANDOFF
name the new pair and the order (core first), and the hook and Pele notes
now name ui 0.67.0 instead of "the first ui after 0.66.0".

bun.lock is bun install's own output: the two package version lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant