Skip to content

fix(ui): fit a Markdown image on the screen, and a zoomed screenshot in the view - #478

Merged
vite-hub[bot] merged 8 commits into
mainfrom
fix/zoom-image-fits-screen
Nov 21, 2026
Merged

vite-hub[bot] merged 8 commits into
mainfrom
fix/zoom-image-fits-screen

Conversation

@onmax

@onmax onmax commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

A tall image filled the whole column. In a 48rem column on a 1280×800 window, a portrait painting came out 768×1038, so it covered the screen while you scrolled past it.

Typeset now caps a Markdown image at min(70svh, 40rem) and centers a captioned one over its caption. A click still zooms it whole.

  • Only plain images get the cap: alone or in a line in a paragraph, list item, quote, definition or figure, or in a link there. Blocks' own images keep their size, such as a screenshot's image under its marks.
  • An image with width and height set (comark-zoom measures data URIs) keeps its room and fits the picture inside with object-fit: contain, rather than squashing it.

Measured on three paintings at 1280×800 in a 48rem column:

image before after
landscape, 960×775 768×620 694×560
portrait, 960×1194 768×955 450×560
portrait, 960×1298 768×1038 414×560

e2e/typeset.e2e.ts checks a 2:5 image fits 70% of the window, centered at its own ratio, and a screenshot's image keeps the column's width.

Zooming a screenshot

Zooming this PR's own evidence screenshot looked broken: the note above it was cut off at the left edge, and the painting ran past the bottom of the view. Two causes in comark-zoom, one in comark-annotate:

  • The zoom fitted the screenshot's box, but its notes sit outside that box, so they landed off-screen. It now measures everything the copy draws (anything a clipping parent hides doesn't count), fits that, and centers it.
  • An item only a little taller than the view jumped to the full width and scrolled, about twice the size, cropping most of it. Now only an item that would shrink below 85% of its fit-by-width size scrolls; one a little taller shrinks a little and shows whole. A long page still scrolls as fix(zoom): an item taller than the screen fills the width and scrolls instead of shrinking #367 wanted.
  • In a narrow column, annotate stacks the notes under the screenshot, but .ca-callout-west outranked the stacked rule, so a note kept its translateX(-100%) and sat a whole width left, under the other column of a compare.

e2e/zoom.e2e.ts covers the slightly tall item and the notes outside the box; e2e/annotate.e2e.ts covers the stacked notes. Each fails on the old code.

Before/after: https://drop.vitehub.dev/d/8b6pvn5aspvd/comark-ui-image-fits-screen

🤖 Generated with Claude Code

A tall image filled the whole column, over 1,000px in a 48rem one, so it
covered the screen while you scrolled past. Typeset now caps an image at
70% of the window's height (40rem at most) and centers a captioned one.
A click still zooms it whole. Blocks' own images, such as a screenshot's
under its marks, keep their size.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-21T16:19:03.928779Z
We couldn’t complete this review. Comment @codex review to try again.
bb00c7e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/comark-annotate@478

comark-badge

pnpm add https://pkg.pr.new/comark-badge@478

comark-bundle

pnpm add https://pkg.pr.new/comark-bundle@478

comark-cards

pnpm add https://pkg.pr.new/comark-cards@478

comark-carousel

pnpm add https://pkg.pr.new/comark-carousel@478

comark-cast

pnpm add https://pkg.pr.new/comark-cast@478

comark-charts

pnpm add https://pkg.pr.new/comark-charts@478

comark-chat

pnpm add https://pkg.pr.new/comark-chat@478

comark-chips

pnpm add https://pkg.pr.new/comark-chips@478

comark-cjk

pnpm add https://pkg.pr.new/comark-cjk@478

comark-code

pnpm add https://pkg.pr.new/comark-code@478

comark-code-notes

pnpm add https://pkg.pr.new/comark-code-notes@478

comark-colors

pnpm add https://pkg.pr.new/comark-colors@478

comark-comments

pnpm add https://pkg.pr.new/comark-comments@478

comark-critic

pnpm add https://pkg.pr.new/comark-critic@478

comark-deflist

pnpm add https://pkg.pr.new/comark-deflist@478

comark-details

pnpm add https://pkg.pr.new/comark-details@478

comark-diagrams

pnpm add https://pkg.pr.new/comark-diagrams@478

comark-diff

pnpm add https://pkg.pr.new/comark-diff@478

comark-embed

pnpm add https://pkg.pr.new/comark-embed@478

comark-fields

pnpm add https://pkg.pr.new/comark-fields@478

comark-figure

pnpm add https://pkg.pr.new/comark-figure@478

comark-file-tree

pnpm add https://pkg.pr.new/comark-file-tree@478

comark-footnotes

pnpm add https://pkg.pr.new/comark-footnotes@478

comark-git-graph

pnpm add https://pkg.pr.new/comark-git-graph@478

comark-github

pnpm add https://pkg.pr.new/comark-github@478

comark-icon

pnpm add https://pkg.pr.new/comark-icon@478

comark-include

pnpm add https://pkg.pr.new/comark-include@478

comark-keys

pnpm add https://pkg.pr.new/comark-keys@478

comark-links

pnpm add https://pkg.pr.new/comark-links@478

comark-linter

pnpm add https://pkg.pr.new/comark-linter@478

comark-magic-move

pnpm add https://pkg.pr.new/comark-magic-move@478

comark-mark

pnpm add https://pkg.pr.new/comark-mark@478

markdown-it-to-comark

pnpm add https://pkg.pr.new/markdown-it-to-comark@478

marked-to-comark

pnpm add https://pkg.pr.new/marked-to-comark@478

comark-mathml

pnpm add https://pkg.pr.new/comark-mathml@478

comark-media

pnpm add https://pkg.pr.new/comark-media@478

comark-metrics

pnpm add https://pkg.pr.new/comark-metrics@478

migrate-to-comark

pnpm add https://pkg.pr.new/migrate-to-comark@478

comark-motion

pnpm add https://pkg.pr.new/comark-motion@478

comark-outline

pnpm add https://pkg.pr.new/comark-outline@478

comark-properties

pnpm add https://pkg.pr.new/comark-properties@478

comark-qr

pnpm add https://pkg.pr.new/comark-qr@478

comark-quiz

pnpm add https://pkg.pr.new/comark-quiz@478

comark-reading-time

pnpm add https://pkg.pr.new/comark-reading-time@478

remark-to-comark

pnpm add https://pkg.pr.new/remark-to-comark@478

comark-sources

pnpm add https://pkg.pr.new/comark-sources@478

comark-steps

pnpm add https://pkg.pr.new/comark-steps@478

comark-table

pnpm add https://pkg.pr.new/comark-table@478

comark-tabs

pnpm add https://pkg.pr.new/comark-tabs@478

comark-tests

pnpm add https://pkg.pr.new/comark-tests@478

comark-time

pnpm add https://pkg.pr.new/comark-time@478

comark-ui

pnpm add https://pkg.pr.new/comark-ui@478

comark-xref

pnpm add https://pkg.pr.new/comark-xref@478

comark-zoom

pnpm add https://pkg.pr.new/comark-zoom@478

commit: 1270603

@onmax

onmax commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Before/after on Drop

@vite-hub

vite-hub Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-11-21T18:55:50.473Z 10m 49s
View session Cancelled 2026-11-21T18:33:43.357Z 10m 23s
View session Cancelled 2026-11-21T18:19:28.533Z 8m 40s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

View session

PR #478 is ready to merge. The reviewed head contains the fixes for Markdown image sizing, screenshot zoom, and scroll restoration. All review threads are resolved, hosted checks passed, and no repair push was needed. Local lint exited successfully with warnings, but a pnpm SQLite error blocked the prerequisite build for focused local tests.

Session

Pull request evidence changed.

Session

Pull request evidence changed.

Session

Pull request evidence changed.

Session

Pull request evidence changed.

Session

Pull request evidence changed.

Session

Pull request evidence changed.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The height cap works for the new test case, but it misses some ordinary Markdown images and makes measured portraits jump when zoom opens.

Approach: Shared Typeset CSS is the right place for the inline height cap, but the rule needs to preserve the image element’s aspect ratio and cover the markup Comark actually emits.

Reviewed changes — I reviewed the shared styles, the documented behavior, and the browser coverage.

  • Image sizing: Caps selected Markdown images at min(70svh, 40rem), uses object-fit: contain, and centers captioned images.
  • Coverage: The build and 72 Typeset, zoom, annotate, and carousel tests passed in Chromium. Two existing zoom-motion assertions failed; their first-frame geometry reproduced without the new CSS too.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/ui/src/typeset-css.ts Resolved
Comment thread packages/ui/src/typeset-css.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new sizing rule fails the published CSS compatibility check, and the generated stylesheet drops the fallback for supported Safari versions that lack typed attr().

Reviewed changes — I reviewed e15dbfa, the commit since the previous Pullfrog review.

  • Fitted sized Markdown images using their declared aspect ratio and added coverage before and after image load.
  • Extended the cap to linked quotes and definitions, emphasized images, table cells, and unwrapped images inside the comments wrapper. The screenshot still keeps its size.
  • Verified 73 Chromium browser tests and 25 UI unit tests. The compiled CSS compatibility failure reproduced locally and in CI.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/ui/src/typeset-css.ts Resolved
Comment thread packages/ui/src/typeset-css.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new sizing rule fixes the delayed-load layout, but it overrides a Markdown image’s authored percentage width when the image also has a height attribute.

Approach: Providing pixel dimensions as custom properties fixes the fallback without relying on typed attr(), but the width rule needs to preserve authored sizing when it can’t compute a fitted width.

Reviewed changes — I reviewed 269e7a4, the commit since the previous Pullfrog review.

  • Preserved the fitted box before load by emitting dimensions as custom properties and using typed attr() where available.
  • Verified both sizing paths in Chromium, including with the feature query disabled. All 74 focused browser tests and 106 unit and stylesheet checks passed.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/ui/src/typeset-css.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The percentage-width fix works, but the new width cap lets fitted images claim extra column space in ordinary Markdown tables, squeezing the text beside them.

Approach: Keeping the authored width when there’s no pixel ratio is right; valid pixel ratios still need to constrain how much width the image requests from its container.

Reviewed changes — I reviewed acb69cf, the commit since the previous Pullfrog review.

  • Preserved authored widths by moving the fitted width to max-width and adding a 50% regression test alongside the delayed-load tests.
  • Updated dimension parsing to use the shared text helper while keeping the guard for nonnumeric dimensions.
  • Verified both sizing paths in Chromium: 74 browser tests and 104 UI and stylesheet checks passed. A separate rendered Markdown probe reproduced the table regression in Chromium and Firefox.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/ui/src/typeset-css.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The table layout fix works, but the new regression test fails in Chromium and Firefox before it checks the Notes column.

Reviewed changes — I reviewed 77f6343, the commit since the prior Pullfrog review.

  • Restored intrinsic table sizing by giving each image a fitted pixel width while letting it shrink to its cell. The fitted and control tables now give Notes the same width, and authored 50% widths still work.
  • Added a browser regression test for the two layouts. Its 140px assertion is the only failure in either browser run; 123 focused UI and stylesheet checks passed.

The two zoom and annotation commits pushed during this run are outside the reviewed range.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread e2e/typeset.e2e.ts Resolved
@onmax onmax changed the title fix(ui): fit a Markdown image on the screen, centered over its caption fix(ui): fit a Markdown image on the screen, and a zoomed screenshot in the view Nov 21, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Zooming a block with closed details can create several screens of blank scroll, and resizing while reading a long screenshot note can skip part of the note.

Approach: Fitting the screenshot and its margin notes together is the right goal, but the bounds need to exclude hidden content and preserve the reader’s position when those bounds change.

Reviewed changes — I reviewed 422b2de and 3f1fb73 since the previous Pullfrog review.

  • Measured the zoomed copy’s overflow and used it to fit and center slightly tall items and outlying notes.
  • Kept stacked annotation notes inside their screenshot column on narrow layouts.
  • Verified 88 passing Chromium tests across zoom, annotate, carousel, motion, and Typeset. The previously reported Typeset table-width assertion still fails. Both new findings reproduced in Chromium and Firefox.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/zoom/src/script.ts Resolved
Comment thread packages/zoom/src/script.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. No P0 or P1 findings remain.

Reviewed changes — I reviewed 1270603 since the prior Pullfrog review.

  • Excluded collapsed disclosure content from zoom bounds so a closed ::details no longer creates blank scrolling.
  • Preserved reading position when resizing while scrolled into a note above a screenshot, while keeping an unscrolled view at the top.
  • Corrected the Typeset table test to compare fitted images with controls without dropping the Notes column check.

The package build and 111 browser tests passed across Chromium and Firefox. The three regression cases passed in both browsers.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub
vite-hub Bot merged commit 0e5b392 into main Nov 21, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the fix/zoom-image-fits-screen branch November 21, 2026 19:17
@github-actions github-actions Bot mentioned this pull request Nov 21, 2026
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.

1 participant