fix(web): size the chat image slot from server-reported dimensions#10200
1 unresolved thread ยท Jump to file
0 / 3 viewed3 files changedLine totals unavailable
apps/web/src/components/ChatMarkdown.tsx ยท Earlier revision f3bcde21 ยท right 1549
Original diff
@@ -1538,6 +1538,17 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props const reference = path ? mediaFileReference(path, props.workspaceRoot) : undefined; const relativePath = reference?.relativePath; const src = assetUrl._tag === "Success" ? assetUrl.url + (props.srcFragment ?? "") : null; + // The server reads the pixel size from the file header, so the slot can be + // the image's final box instead of a 16:9 guess. An authored size, or a + // caller's cap such as the viewed-image row's max height, layers on top. + const knownSize = assetUrl._tag === "Success" ? assetUrl.imageDimensions : undefined; + const knownSizeStyle = knownSize + ? authoredImageSizeStyle(knownSize.width, knownSize.height) + : undefined; + const style = + knownSizeStyle && props.style
macroscopeappSep 5, 2026
๐ก Medium components/ChatMarkdown.tsx:1549
The viewed-image { maxHeight: "16rem" } override leaves width/maxWidth sized for authoredImageSizeStyle's 30rem cap, so portrait images reserve a box with excess horizontal space instead of preserving their aspect ratio. Recompute the width constraint from the effective height cap, or use sizing that preserves the ratio under both limits.
๐ Reply "fix it for me" or copy this AI Prompt for your agent:
text
| 1 | In file @apps/web/src/components/ChatMarkdown.tsx around line 1549: |
| 2 | |
| 3 | The viewed-image `{ maxHeight: "16rem" }` override leaves `width`/`maxWidth` sized for `authoredImageSizeStyle`'s `30rem` cap, so portrait images reserve a box with excess horizontal space instead of preserving their aspect ratio. Recompute the width constraint from the effective height cap, or use sizing that preserves the ratio under both limits. |
Julius MarmingeSep 5, 2026
Fixed in b1c674214b. The cap is passed as maxHeightRem and folded into the width bound (max-width: min(100%, 30rem, 16ยทw/h rem)), so a 720ร1400 image capped at 16rem gets a 132px-wide box rather than a 30rem-wide one. Test added.