Repository navigation
feat(session-ui): maximize Mermaid diagrams to zoom and pan them - #59250
Conversation
There was a problem hiding this comment.
Looks good. I opened the Mermaid diagrams story in Chromium on the base and on this branch. On the base there is no maximize button. Here the button shows on hover, opens the diagram over the page at its drawn size with the zoom controls, and Escape closes it and returns focus to the button. The new mermaid-preview.spec.ts, plus markdown.spec.ts and session-timeline.spec.ts, all pass (63). bun test src in session-ui and image-zoom.test.ts in ui pass. tsc is clean in packages/ui and packages/session-ui.
The cloned SVG is safe: each render gets its own ID prefix, so the copy's markers still resolve. Escape goes through the dialog stack's existing data-owns-escape, like the image preview, and the shared zoom helpers keep the image preview's behaviour.
Public API: unchanged. The additions are internal UI pieces: a component, an icon, two translation keys and a story.
No blocking concerns.
9535282 to
9f5386b
Compare
There was a problem hiding this comment.
Since my last review this was only rebased onto beta: the commit's own changes are identical to the version I reviewed, and no earlier points were open. On the new base, tsc is clean in packages/ui and packages/session-ui. The mermaid-preview, markdown and session-timeline component tests pass (63), and so does bun test src in session-ui.
Public API: unchanged.
No new concerns.
|
@thdxr please merge this !! it is really really really really useful ! |
|
Guys, please don't let this feature MR to die, i need it. |
A rendered diagram gets a maximize button that opens it over the page. The maximized view zooms and pans like the image preview: pinch or Cmd/Ctrl + wheel, wheel and drag, double-click, Cmd/Ctrl + =, - and 0, plus arrow keys to move around. The diagram stays a live SVG, so labels stay sharp at any zoom.
9f5386b to
ba6456e
Compare



Mermaid diagrams in a message are fitted to the column, so a wide graph like a state machine ends up with labels too small to read and no way to get closer. This adds a maximize button to every rendered diagram that opens it over the page, where it can be zoomed and moved around.
.mmdartifacts, which render through the same Markdown path.−/+controls, Cmd/Ctrl +=/-, and double-click to zoom into a spot (again to fit). Clicking the percentage,0, or the first Escape goes back to fit.The maximized diagram is a copy of the live SVG, not an image, so it keeps the app's fonts and theme and stays sharp at every zoom. It fits to the window without enlarging past the size it was drawn at, and zooms up to 4× that. The gestures, controls, and shortcuts match the image preview: the shared wheel and shortcut helpers moved from
image-preview.tsxintoimage-zoom.ts, and image preview behavior is unchanged.Other changes:
--pele-*theme variables apply to both the inline and the maximized diagram.outline-maximizeicon.Conversation/Mermaid diagrams → State graphstory with a wide state diagram.Screenshots
The GitHub App can't upload attachments, so the before/after screenshots (dark, light, and narrow) and a short demo video are in the Slack thread for this request. They were taken from the
State graphstory at 1000×720 @2x, withorigin/dev(ed74ec82ce) as the before and this branch as the after.Visual
Verified
bun run typecheckinpackages/ui,packages/session-uiandpackages/appbun run lint:changedbun test srcinpackages/session-ui(313 pass) andimage-zoom.test.tsinpackages/uimermaid-preview.spec.ts, plusmarkdown.spec.tsandsession-timeline.spec.tsinpackages/session-ui(44 passed), andimage-preview.spec.tsinpackages/app(6 passed)Requested by: @neriousy (Filip via Slack)
Added by the opencode bot (AI-generated).
Fixes #57620
Related: #54800