Image viewer: covers the screen, closes on a backdrop click, shows failed loads (#609, #610, #611) #626

Merged
charles merged 1 commit from fix/image-viewer into textchat 2026-11-15 09:36:41 +00:00
Owner

What was wrong

  • #610, hover toolbar over the viewer. A message's hover bar is an iced overlay (float, hover_bar.rs:395). The lightbox was stacked over the screen (media_viewer.rs over: stack![screen, lightbox]), and a stack draws the overlays of every layer above all layers, so the bar of the message the pointer was on stayed on top of the picture. Opening the viewer also left that message hovered (and a bar the pointer was on stayed "bar hovered").
  • #611, only Escape closed it. The backdrop was a plain container and the picture's area (mouse_area over the whole window) only started drags, so clicking around the picture did nothing. The X is always shown, at the far left of the bottom toolbar (as in the original), but sat flush against the next button.
  • #609, empty box instead of the picture. Both reporter screenshots show the viewer's placeholder: the 6 % white rounded box (sampled at exactly backdrop + 6 % white in the first screenshot), which is drawn only while Images::picture(url) is None. So the full-size picture never became ready: its load failed or never finished. A failed load was dropped silently: Images::update turns any error into Failed with no log, and the viewer drew Failed exactly like a load in progress.

What changed

  • media_viewer::over wraps the screen in Covered: same widget tree (state kept), drawn as before, but no overlays and the pointer is never over it. main::update clears the hovered message, the bar hover and the quick-reaction hover (both views) when it emits OpenMedia.
  • A tap on the backdrop closes (press + release within 8 px, TAP_MOVE_THRESHOLD, starting outside the picture as drawn: fitted, zoomed, panned, turned) like usePanZoomSurface.ts onBackdropTap. A click on the picture or a drag doesn't close. Beside a video the backdrop closes on click (.nonZoomBackdrop). The original's 0.375 rem gap after the X is added.
  • A failed picture shows a warning and "This image could not be loaded." (the original shows the browser's broken image), and ImageCache's ImageLoader::load logs every failed load at warn (host and error; not the signed URL).

#609 investigation (Linux)

  • Decode: an RGBA PNG with transparent areas, a palette PNG with tRNS, a 4000 × 3000 RGBA PNG, and the WebPs libvips writes for them with the proxy's exact settings (Q=85, smart_subsample, alpha_q=90: VP8+ALPH; also lossless VP8L; the large one at 2048 × 1536) all decode to the right size with their alpha (fixtures/media/transparent).
  • Drawing (wgpu on lavapipe): the same pictures draw in the lightbox with their colours where opaque and the bare backdrop where transparent. A wide dark screenshot-like picture with a transparent background (2400 × 900, sent at 2048 × 768) also draws its own pixels and never looks like the lighter rounded box. Pictures of 2 MiB or more are uploaded to the GPU on iced_wgpu's worker thread and appear one or two frames later. While that upload runs there is no box at all, only the backdrop.
  • Not reproduced: the Windows failure itself. The new error state and the image failed to load log line (host + error: HTTP status, timeout, decode error…) will show which it is.

Tests

  • tests/media_viewer_layers.rs (headless, new): nothing of the screen floats over the lightbox; opening clears the hover; a backdrop click closes, a click on the picture and a drag don't; a click beside a video closes; a failed picture says so. All 5 failed on the base commit.
  • fluxer-platform transparent_pictures_decode_with_their_alpha.
  • Screenshot suite: media_viewer_draws_transparent_pictures and media_viewer_dark_transparent_picture_is_not_the_loading_box assert on pixels and have no goldens. media_viewer and media_viewer_video goldens are regenerated: one change is the gap after the X. The other is a thin blue bar of the screen under the backdrop, which the old golden was missing. The base code renders that bar too, and the old golden had passed within the tolerance.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps passed (Linux). Not run on Windows.

Refs #609, #610, #611

🤖 Generated with Claude Code

## What was wrong - **#610, hover toolbar over the viewer.** A message's hover bar is an iced overlay (`float`, `hover_bar.rs:395`). The lightbox was stacked over the screen (`media_viewer.rs` `over`: `stack![screen, lightbox]`), and a stack draws the overlays of *every* layer above all layers, so the bar of the message the pointer was on stayed on top of the picture. Opening the viewer also left that message hovered (and a bar the pointer was on stayed "bar hovered"). - **#611, only Escape closed it.** The backdrop was a plain container and the picture's area (`mouse_area` over the whole window) only started drags, so clicking around the picture did nothing. The X is always shown, at the far left of the bottom toolbar (as in the original), but sat flush against the next button. - **#609, empty box instead of the picture.** Both reporter screenshots show the viewer's *placeholder*: the 6 % white rounded box (sampled at exactly backdrop + 6 % white in the first screenshot), which is drawn only while `Images::picture(url)` is `None`. So the full-size picture never became ready: its load failed or never finished. A failed load was dropped silently: `Images::update` turns any error into `Failed` with no log, and the viewer drew `Failed` exactly like a load in progress. ## What changed - `media_viewer::over` wraps the screen in `Covered`: same widget tree (state kept), drawn as before, but **no overlays** and the pointer is never over it. `main::update` clears the hovered message, the bar hover and the quick-reaction hover (both views) when it emits `OpenMedia`. - A **tap on the backdrop closes** (press + release within 8 px, `TAP_MOVE_THRESHOLD`, starting outside the picture as drawn: fitted, zoomed, panned, turned) like `usePanZoomSurface.ts` `onBackdropTap`. A click on the picture or a drag doesn't close. Beside a video the backdrop closes on click (`.nonZoomBackdrop`). The original's 0.375 rem gap after the X is added. - A **failed picture** shows a warning and "This image could not be loaded." (the original shows the browser's broken image), and `ImageCache`'s `ImageLoader::load` **logs every failed load** at warn (host and error; not the signed URL). ## #609 investigation (Linux) - Decode: an RGBA PNG with transparent areas, a palette PNG with `tRNS`, a 4000 × 3000 RGBA PNG, and the WebPs libvips writes for them with the proxy's exact settings (`Q=85, smart_subsample, alpha_q=90`: VP8+ALPH; also lossless VP8L; the large one at 2048 × 1536) all decode to the right size with their alpha (`fixtures/media/transparent`). - Drawing (wgpu on lavapipe): the same pictures draw in the lightbox with their colours where opaque and the bare backdrop where transparent. A wide dark screenshot-like picture with a transparent background (2400 × 900, sent at 2048 × 768) also draws its own pixels and **never looks like the lighter rounded box**. Pictures of 2 MiB or more are uploaded to the GPU on iced_wgpu's worker thread and appear one or two frames later. While that upload runs there is no box at all, only the backdrop. - Not reproduced: the Windows failure itself. The new error state and the `image failed to load` log line (host + error: HTTP status, timeout, decode error…) will show which it is. ## Tests - `tests/media_viewer_layers.rs` (headless, new): nothing of the screen floats over the lightbox; opening clears the hover; a backdrop click closes, a click on the picture and a drag don't; a click beside a video closes; a failed picture says so. All 5 failed on the base commit. - `fluxer-platform` `transparent_pictures_decode_with_their_alpha`. - Screenshot suite: `media_viewer_draws_transparent_pictures` and `media_viewer_dark_transparent_picture_is_not_the_loading_box` assert on pixels and have no goldens. `media_viewer` and `media_viewer_video` goldens are regenerated: one change is the gap after the X. The other is a thin blue bar of the screen under the backdrop, which the old golden was missing. The base code renders that bar too, and the old golden had passed within the tolerance. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps passed (Linux). Not run on Windows. Refs #609, #610, #611 🤖 Generated with [Claude Code](https://claude.com/claude-code)
#610: the hover bar of a message is an iced overlay (`float`), and a stack draws the
overlays of every layer above all layers, so the bar of the message the pointer was on
stayed over the lightbox. The screen under the lightbox is now wrapped in a widget that
keeps its tree and drawing but has no overlays and never sees the pointer, and opening the
lightbox clears the hovered message, its bar and its quick reaction.

#611: only Escape and the toolbar's X closed the viewer. A tap (press and release within
8 px, `TAP_MOVE_THRESHOLD`) that starts on the backdrop outside the drawn picture closes it,
as `usePanZoomSurface.ts` `onBackdropTap` does; a click on the picture or a drag does not.
Beside a video, the backdrop itself closes on a click (`.nonZoomBackdrop`). The X, always
shown at the left of the bottom toolbar, gets the original's 0.375 rem gap after it.

#609: the reported box is the viewer's empty placeholder: the full-size picture never became
ready. Loads that fail were dropped silently (the box of a load in progress stayed forever,
and nothing was logged). A failed picture now shows a warning and "This image could not be
loaded.", and the image loader logs every failed load (host and error, not the signed URL).
On Linux, transparent RGBA and palette (tRNS) PNGs, a 4000 x 3000 PNG and the WebPs the media
proxy writes for them (libvips, the proxy's settings) decode with their alpha and are drawn
(wgpu, lavapipe), including a wide dark picture with a transparent background; the Windows
failure itself is not reproduced.

The two lightbox goldens are regenerated: the gap after the X, and a thin blue bar of the
screen under the backdrop that the old golden predated (the base code renders it too; it
had passed within the tolerance).

Refs #609, #610, #611

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charles merged commit c8faabf47b into textchat 2026-11-15 09:36:41 +00:00
Sign in to join this conversation.
No description provided.