Repository navigation
fix(mermaid): fit wide diagrams, span full width when toc is hidden - #61
Merged
Merged
Conversation
Diagrams wider than the content column re-render with tighter spacing until they fit, falling back to the tightest render. CodeBlock, the search projection, and row estimates all read the fitted text, and a committed search re-runs when the width changes. The Viewer's inner box no longer caps at contentMaxWidth, which included its right padding and cost blocks one column at the reading cap. Adds test/mermaid-width.md for manual checks.
Startup benchmark (
|
| build | mean | ratio | verdict |
|---|---|---|---|
| baseline (main@bade4ae) | 233.0ms ± 5.8ms | — | |
| PR | 240.1ms ± 16.9ms | 1.03× | ✅ ok |
Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.
First-frame (large.md, runs=10)
| metric | baseline (main@bade4ae) | PR | ratio | verdict |
|---|---|---|---|---|
| first-frame | 157.3ms | 157.1ms | 1.00× | ✅ ok |
Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.
Scroll (large.md)
| metric | baseline (main@bade4ae) | PR | ratio | verdict |
|---|---|---|---|---|
| full_mount | 7637.0ms | 5365.0ms | 0.70× | ✅ ok |
| step_p50 | 18.1ms | 19.7ms | 1.08× | ✅ ok |
| step_search_p50 | 17.5ms | 18.7ms | 1.07× | ✅ ok |
| stepMatch_p50 | 13.3ms | 14.0ms | 1.05× | ✅ ok |
| commit | 4784.9ms | 3953.6ms | 0.83× | ✅ ok |
Thresholds: warn ≥ 1.1×, fail ≥ 1.25×. Baseline built from main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wide mermaid and DOT diagrams no longer clip on the right. A diagram too wide for its column renders again with tighter spacing until it fits. With the TOC hidden, diagrams can also use the free columns past the reading width.
CleanShot.2026-10-29.at.9.27.06.PM.mp4
src/app/ ├── App.tsx # derives breakoutWidth ├── components/ │ ├── Viewer.tsx # spans breakoutWidth; prose box stays at contentWidth │ └── blocks/CodeBlock.tsx # renders the fitted diagram └── lib/ + ├── diagram-fit.ts # picks the loosest render that fits ├── preprocess.ts # keeps the mermaid source on the node ├── visible-text.ts # projects the fitted text for search └── commands.ts # re-runs search on width changeRoot Cause
Diagrams render to ASCII once, at load, before any width is known. ASCII art can't wrap. The Viewer clipped anything wider than the content column.
The content column is capped at the reading width (
widthconfig, default 100). Hiding the TOC adds only the sidebar's own columns. On a wide terminal, the space right of the TOC stayed empty either way.The Viewer's inner box also had
maxWidthset to the content cap. That width included its 1-column right padding. At the cap, blocks got one column less thancontentWidth.Changes
codeTextreturns the default render when it fits. Otherwise it tries four tighter spacing presets and takes the first that fits.CodeBlock, row estimates, and the search Projection (the text model that search and highlights run on) all readcodeText. Highlights stay on the right characters at every width.breakoutWidthin app state. It equalscontentWidthwith the TOC shown and the whole Viewer column with it hidden.contentWidth. A diagram's box setsminWidthto the diagram's width and overflows the prose box.contentWidth + 1wide, padding included. Blocks get the fullcontentWidthat the cap.test/mermaid-width.mdcovers each fit case for manual checks.Design Decisions
paddingX,boxBorderPadding). This fits most flowcharts at any terminal width. Horizontal scroll was the alternative; it would add a second scroll axis to the Viewer.contentWidth. Breaking out with the TOC shown would dock the TOC to the right edge and need a new drag model.Overall Flow
Similar Issues
🤖 Written with AI