Skip to content

fix(web): improve generated media retry and sizing - #1666

Open
techotaku39 wants to merge 3 commits into
tiann:mainfrom
techotaku39:fix/web-display-image-retry-ux
Open

fix(web): improve generated media retry and sizing#1666
techotaku39 wants to merge 3 commits into
tiann:mainfrom
techotaku39:fix/web-display-image-retry-ux

Conversation

@techotaku39

@techotaku39 techotaku39 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace raw HTTP error text in generated media cards with localized, user-friendly unavailable states.
  • Add an accessible retry action that re-fetches failed generated media.
  • Make generated media cards and image frames size to their content while preserving maximum width constraints.
  • Reserve layout space for scaled tiny previews so enlarged images do not overlap adjacent chat content.
  • Add English and Simplified Chinese retry/unavailable labels.
  • Add regression coverage for retry behavior, localized errors, and tiny image sizing.

No backend, API, RPC, persistence, database schema, dependency, or shared tool-card changes are included.

Validation

  • bun typecheck
  • pwsh -NoProfile -File .\scripts\Invoke-HapiTaskPlaywright.ps1 -Name display-image-retry-ux -Suite Root terminal-wrap-fidelity.spec.ts — 2/2 passed
  • bun 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 passed
  • bun run build — passed
  • Isolated live Web smoke test — passed; verified 64×64 generated images, content-sized media cards, and visibility of text, code-block, tool-call, and CLI-output bubbles
  • Review follow-up: tiny-image layout regression test passed (16x32 scaled to 32x64 without CSS transform)
  • git diff --check

Related Issues

Refs #927

AI Disclosure

OpenAI Codex (GPT-5.6) assisted with implementation, testing, validation, review follow-up, and PR drafting.

@github-actions github-actions 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.

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. Evidence web/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)]">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions github-actions 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.

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

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