fix(web): improve generated media retry and sizing - #1666
Conversation
There was a problem hiding this comment.
Findings
- [Minor] Content-sized frame ignores the upscaled image dimensions — CSS transforms change painting but not layout. After the frame becomes
w-fit, a 16×32 image scaled to 32×64 still reserves only a 16×32 box, so it can paint over the header, card edge, or following message. Evidenceweb/src/components/AssistantChat/messages/ToolMessage.tsx:171.
Suggested fix:const scale = computeTinyImageScale(probe.naturalWidth, probe.naturalHeight) setImageStyle(scale === 1 ? undefined : { width: probe.naturalWidth * scale, height: probe.naturalHeight * scale, })
Summary
- Review mode: initial
- One Minor layout regression found in the tiny-image sizing change. The added jsdom test checks classes only, so it does not validate rendered geometry.
Testing
- Not run (automation; PR code was not executed). Add a browser layout test with a real 16×32 image asserting the image rectangle remains inside the frame/card and does not overlap adjacent content.
HAPI Bot
| </a> | ||
| ) : ( | ||
| <div className="flex min-h-32 min-w-[12rem] items-center justify-center rounded-xl bg-[var(--app-subtle-bg)]"> | ||
| <div className="flex w-fit max-w-full items-center justify-center rounded-xl bg-[var(--app-subtle-bg)]"> |
There was a problem hiding this comment.
[MINOR] Reserve layout space for the tiny-image scale
imageStyle still applies transform: scale(...) at line 124. Transforms do not affect the element's layout box. With this frame now using w-fit, a 16×32 image paints at 32×64 but the frame/card reserve only 16×32, which can overlap the header or following chat content. The new jsdom test only checks class names and cannot catch this geometry.
Suggested fix:
const scale = computeTinyImageScale(probe.naturalWidth, probe.naturalHeight)
setImageStyle(scale === 1 ? undefined : {
width: probe.naturalWidth * scale,
height: probe.naturalHeight * scale,
})Please also cover this with a browser layout assertion using an actual tiny image.
There was a problem hiding this comment.
Addressed in e323706. Tiny previews now use explicit width/height based on the computed scale, so the w-fit card reserves the painted dimensions instead of relying on transform. Added a regression test for a 16x32 image scaling to 32x64 without a transform. Focused media tests (11/11), web typecheck, and build:web passed.
There was a problem hiding this comment.
Findings
- None.
Summary
Review mode: follow-up after new commits
No findings in the latest full diff. The new commit resolves the prior Minor: tiny images now reserve explicit width and height in layout instead of using a transform. Residual risk: the regression test validates classes and inline styles in jsdom, not rendered browser geometry.
Testing
Not run (automation; PR code was not executed). GitHub checks at submission: test=IN_PROGRESS; integration=SUCCESS.
HAPI Bot
Summary
No backend, API, RPC, persistence, database schema, dependency, or shared tool-card changes are included.
Validation
bun typecheckpwsh -NoProfile -File .\scripts\Invoke-HapiTaskPlaywright.ps1 -Name display-image-retry-ux -Suite Root terminal-wrap-fidelity.spec.ts— 2/2 passedbun run test:web -- src/components/AssistantChat/messages/ToolMessage.generatedMedia.test.tsx src/lib/generatedInlineMedia.test.ts src/api/client.test.ts— 3 files, 28 tests passedbun run build— passedgit diff --checkRelated Issues
Refs #927
AI Disclosure
OpenAI Codex (GPT-5.6) assisted with implementation, testing, validation, review follow-up, and PR drafting.