Text chat 22: Attachments, stickers, lightbox, audio player (#272) #379

Manually merged
charles merged 3 commits from textchat-22-ui-attachments-media into textchat 2026-11-13 02:14:20 +00:00
Owner

Stacked on: origin/textchat-16-core-navigation-read

What this builds (spec §3.5, §9.3, §9.4)

  • widgets/message_content/ (new): attachments (model + view: mosaic, single picture fit(w, h, 550, 350), ThumbHash placeholder until the picture loads, GIFs playing with gif_auto_play or on hover, video poster + play that opens externally via OpenUrl, ALT badge with the alt text as tooltip, hover toolbar with Download, expired attachments dimmed under "This attachment has expired"), mosaic (layout(n) -> Vec<Tile { col, row, col_span, row_span, aspect }> for 1–10 on one 6-column grid, place at the available width, max 550 px, 4 px gaps), file_card (400 px card, extension icon as getFileTypeIcon, formatFileSize, download / "Attachment expired"), spoiler (cover + "SPOILER" pill, render_spoilers incl. if-moderator), audio (card bound to PlayAttachment / StopAttachment via media_playback), sticker (10 rem, 320 px URLs, animate_stickers). MediaPolicy { downloads } (default true) hides Download / Open in browser / Copy link. inline_attachment_media off → file cards.
  • screens/main/media_viewer.rs (new): lightbox over everything from app.chat.media.lightbox: backdrop 78 %, prev/next wrapping (step), zoom 1–5, step 1.25, double click 2.5 at the pointer, drag-pan clamped to the overhang, quarter-turn rotation, reset (Transform, pure); toolbar Close, Open in browser, Copy link, Download, rotate ×2, reset, zoom in/out, Reply. Escape closes it.
  • message_row draws attachments + stickers under the text (no more "[n attachments]" placeholder) and includes them in the height estimate; media::wanted loads the pictures, stickers and the lightbox picture; 22 Phosphor icons added through theme::icons.

Fork sources for dimensions: MessageAttachmentUtils.ts, AttachmentLayoutGrid.module.css, AttachmentMosaic.module.css, MediaDimensionConfig.ts, Attachment.tsx/Attachment.module.css, AttachmentFile.tsx/AttachmentFile.module.css, SpoilerOverlay.module.css, AltTextBadge.module.css, MediaButtons.module.css, InlineAudioPlayer.tsx, MediaViewerModal.tsx, MediaModal.module.css, MediaControls.tsx, PanZoomMath.ts, MediaRotationMath.ts. No Electron reference screenshots were taken (no live instance from this task).

Tests

  • tests/attachments.rs: mosaic_layout_table_1_to_10, single_image_fit_550x350, spoiler_hidden_until_clicked_and_setting_always, expired_overlay, file_card_icon_by_extension, audio_card_emits_play, plus media_clicks_open_the_lightbox_or_the_browser, stickers_are_160px_squares (data from fixtures/textchat/history.json).
  • tests/media_viewer.rs: lightbox_zoom_bounds_and_step, lightbox_prev_next.
  • Screenshots (goldens rendered on lavapipe in the Ubuntu 22.04 fluxer-native-shots image): attachments_mosaic_4, attachments_mosaic_7, attachment_file_card, attachment_spoiler, media_viewer. The whole fluxer-ui screenshot suite (37) passes there; host cargo xtask ci green (screenshot step run in the container because this host has no lavapipe).

Deviations

  • Touched outside the Files list, minimally: screens/main/messages.rs (route Message::Attachment to UserActions, revealed attachment spoilers as view state), widgets/mod.rs (module), app.rs (Copy link via iced::clipboard::write, Escape closes the lightbox), README.md, docs/screenshots/README.md.
  • Lightbox view state lives in media::State::viewer (no new Local field).
  • Not built (no store action / fetch path yet), follow-ups opened: Delete / Favorite / Copy image / Forward (#376), text-file inline preview (#377: text files get the file card), inline video and audio seek/rate (#378: track static, the engine reports no position).
  • No 0.2 s fade from placeholder to picture.
  • Expect a mechanical conflict with Text chat 23 in widgets/message_content/mod.rs, message_row.rs, messages.rs, media.rs, icons.rs (both add modules/arms; keep both). attachments::fit duplicates embed_media::fit from 23 (same algorithm); one can call the other after both merge.

Closes #272

🤖 Generated with Claude Code

Stacked on: origin/textchat-16-core-navigation-read ## What this builds (spec §3.5, §9.3, §9.4) - `widgets/message_content/` (new): `attachments` (model + view: mosaic, single picture `fit(w, h, 550, 350)`, ThumbHash placeholder until the picture loads, GIFs playing with `gif_auto_play` or on hover, video poster + play that opens externally via `OpenUrl`, ALT badge with the alt text as tooltip, hover toolbar with Download, expired attachments dimmed under "This attachment has expired"), `mosaic` (`layout(n) -> Vec<Tile { col, row, col_span, row_span, aspect }>` for 1–10 on one 6-column grid, `place` at the available width, max 550 px, 4 px gaps), `file_card` (400 px card, extension icon as `getFileTypeIcon`, `formatFileSize`, download / "Attachment expired"), `spoiler` (cover + "SPOILER" pill, `render_spoilers` incl. if-moderator), `audio` (card bound to `PlayAttachment` / `StopAttachment` via `media_playback`), `sticker` (10 rem, 320 px URLs, `animate_stickers`). `MediaPolicy { downloads }` (default true) hides Download / Open in browser / Copy link. `inline_attachment_media` off → file cards. - `screens/main/media_viewer.rs` (new): lightbox over everything from `app.chat.media.lightbox`: backdrop 78 %, prev/next wrapping (`step`), zoom 1–5, step 1.25, double click 2.5 at the pointer, drag-pan clamped to the overhang, quarter-turn rotation, reset (`Transform`, pure); toolbar Close, Open in browser, Copy link, Download, rotate ×2, reset, zoom in/out, Reply. Escape closes it. - `message_row` draws attachments + stickers under the text (no more "[n attachments]" placeholder) and includes them in the height estimate; `media::wanted` loads the pictures, stickers and the lightbox picture; 22 Phosphor icons added through `theme::icons`. Fork sources for dimensions: `MessageAttachmentUtils.ts`, `AttachmentLayoutGrid.module.css`, `AttachmentMosaic.module.css`, `MediaDimensionConfig.ts`, `Attachment.tsx`/`Attachment.module.css`, `AttachmentFile.tsx`/`AttachmentFile.module.css`, `SpoilerOverlay.module.css`, `AltTextBadge.module.css`, `MediaButtons.module.css`, `InlineAudioPlayer.tsx`, `MediaViewerModal.tsx`, `MediaModal.module.css`, `MediaControls.tsx`, `PanZoomMath.ts`, `MediaRotationMath.ts`. No Electron reference screenshots were taken (no live instance from this task). ## Tests - `tests/attachments.rs`: `mosaic_layout_table_1_to_10`, `single_image_fit_550x350`, `spoiler_hidden_until_clicked_and_setting_always`, `expired_overlay`, `file_card_icon_by_extension`, `audio_card_emits_play`, plus `media_clicks_open_the_lightbox_or_the_browser`, `stickers_are_160px_squares` (data from `fixtures/textchat/history.json`). - `tests/media_viewer.rs`: `lightbox_zoom_bounds_and_step`, `lightbox_prev_next`. - Screenshots (goldens rendered on lavapipe in the Ubuntu 22.04 `fluxer-native-shots` image): `attachments_mosaic_4`, `attachments_mosaic_7`, `attachment_file_card`, `attachment_spoiler`, `media_viewer`. The whole fluxer-ui screenshot suite (37) passes there; host `cargo xtask ci` green (screenshot step run in the container because this host has no lavapipe). ## Deviations - Touched outside the Files list, minimally: `screens/main/messages.rs` (route `Message::Attachment` to `UserAction`s, revealed attachment spoilers as view state), `widgets/mod.rs` (module), `app.rs` (Copy link via `iced::clipboard::write`, Escape closes the lightbox), `README.md`, `docs/screenshots/README.md`. - Lightbox view state lives in `media::State::viewer` (no new `Local` field). - Not built (no store action / fetch path yet), follow-ups opened: Delete / Favorite / Copy image / Forward (#376), text-file inline preview (#377: text files get the file card), inline video and audio seek/rate (#378: track static, the engine reports no position). - No 0.2 s fade from placeholder to picture. - Expect a mechanical conflict with Text chat 23 in `widgets/message_content/mod.rs`, `message_row.rs`, `messages.rs`, `media.rs`, `icons.rs` (both add modules/arms; keep both). `attachments::fit` duplicates `embed_media::fit` from 23 (same algorithm); one can call the other after both merge. Closes #272 🤖 Generated with [Claude Code](https://claude.com/claude-code)
# Conflicts:
#	crates/fluxer-proto/README.md
#	crates/fluxer-proto/src/gateway/events.rs
#	crates/fluxer-proto/src/models/channel.rs
#	crates/fluxer-proto/src/models/mod.rs
#	crates/fluxer-proto/src/models/settings.rs
#	crates/fluxer-proto/tests/models_roundtrip.rs
Refs #266

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts:
#	crates/fluxer-proto/tests/models_roundtrip.rs
Auto-ack of the channel being read (#60), new-messages marker and bar,
jump to a message (FetchMessages around) with a 2000 ms highlight, jump
to present, the 200/100 history cap, inline audio playback through the
clip path and the lightbox state.

Refs #266

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Navigation::being_read also requires the settings screen and the lightbox closed (the
  original's blockingModalOpen/textChatVisible), so messages arriving under them stay
  unread until they close.
- on_around counts the older side on its own (limit - 1 - limit/2, as
  MessagePaginationUtils.ts) instead of treating any short answer as the start.
- new_messages_bar shows whenever the channel is unread, marker or not
  (ChannelMessages.tsx unreadCount > 0).
- Plan, Task 21: attachment playback is FetchMedia + PlayClip; PlaybackSource::Attachment
  is unused (also noted on the variant).

Refs #266

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Refs #266

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review: Text chat 22 (attachments, stickers, lightbox, audio player)

Reviewed git diff eee47d56..origin/textchat-22-ui-attachments-media (ea4e439), read cold.

Gate: local cargo xtask ci in the review worktree: all steps passed (fmt, clippy, deny, core-isolation, parity, tests). The screenshot step was skipped (FLUXER_SCREENSHOT_TESTS not set, no lavapipe on this host). I looked at the attachments_mosaic_7 and media_viewer goldens and they look right. The Linux runner has to confirm the screenshot suite.

Checks

  1. Plan tests: all 8 named tests exist (mosaic_layout_table_1_to_10, single_image_fit_550x350, spoiler_hidden_until_clicked_and_setting_always, expired_overlay, file_card_icon_by_extension, audio_card_emits_play, lightbox_zoom_bounds_and_step, lightbox_prev_next), and so do the 5 screenshot tests and goldens. The mosaic table matches spec §3.5 for 2–10 (1:1 pair; 2fr + 1fr; 2 × 2 at 3:2; 3:2 over 1:1; 3 × 2; 16:9 hero + 3 × 2; 2 + 3 × 2; 3 × 3; hero + 3 × 3) with 4 px gaps at 550 px. The single image fits 550 × 350 and never grows. Zoom is 1–5, step 1.25, double click 2.5.
  2. Interfaces: mosaic::layout(n) -> Vec<Tile { col, row, col_span, row_span, aspect }> and attachments::fit(w, h, max_w, max_h) exist as written. PlayAttachment, StopAttachment, SaveAttachment, OpenMedia/CloseMedia, OpenUrl and media_playback are used as Task 16 provides them. The lightbox index uses core's is_visual numbering, which matches core.
  3. Invariants: the diff touches only fluxer-ui, docs and goldens. There are no fluxer-core changes, no new dependencies and no new fixtures (the tests use the existing textchat/history.json). Pictures go only through Images/ImageLoader. "Copy link" uses iced's own clipboard. The hand-written Debug on Download, Media and ViewerModel leaves out signed URLs. Server data: fit/place/step/format_size/format_duration handle zero, huge and non-finite values. OpenUrl drops anything that does not parse as a URL.
  4. Review Focus: no item belongs to Task 22 directly. #5 (no URL leaks): ui has no logging. Nothing in the diff writes URLs to logs or --record.

Findings

  • minor: Part of the Interfaces list is not delivered: text-file preview, hover toolbar Delete/Favorite, lightbox Copy image/Favorite/Delete/Forward, and audio seek/rate. Each one has a follow-up issue (#376, #377, #378). The code comments call the text preview and audio seek/rate a "divergence (spec §15)", but §15 lists only video. Either add them to §15 or reword the comments to "deferred (#377/#378)". Task 34 (parity) should know these are open.
  • minor: message_row::estimate_height now subtracts a line for every message with empty content. Messages with embeds only, and system messages, still draw their placeholder line, so their estimate is one line short. Scroll estimates only; nothing breaks.
  • minor: The lightbox opens visual attachments that have no width or height (core is_visual counts them; the row draws them as file cards). fitted then draws them at 1 × 1 px. Nothing panics. A fallback size for the image's own decoded size would be better.
  • minor: The lightbox has no backdrop-click-to-close and no arrow keys for previous/next, both of which the original has. Escape works.
  • nit: attachments::fit duplicates embed_media::fit (Task 23), as the implementer said. Dedupe when the branches meet.

Verdict: approve. No blocking findings and local CI is green. The screenshot suite still needs to pass on the Linux runner.

## Independent review: Text chat 22 (attachments, stickers, lightbox, audio player) Reviewed `git diff eee47d56..origin/textchat-22-ui-attachments-media` (ea4e439), read cold. **Gate:** local `cargo xtask ci` in the review worktree: **all steps passed** (fmt, clippy, deny, core-isolation, parity, tests). The screenshot step was skipped (`FLUXER_SCREENSHOT_TESTS` not set, no lavapipe on this host). I looked at the `attachments_mosaic_7` and `media_viewer` goldens and they look right. The Linux runner has to confirm the screenshot suite. ### Checks 1. **Plan tests:** all 8 named tests exist (`mosaic_layout_table_1_to_10`, `single_image_fit_550x350`, `spoiler_hidden_until_clicked_and_setting_always`, `expired_overlay`, `file_card_icon_by_extension`, `audio_card_emits_play`, `lightbox_zoom_bounds_and_step`, `lightbox_prev_next`), and so do the 5 screenshot tests and goldens. The mosaic table matches spec §3.5 for 2–10 (1:1 pair; 2fr + 1fr; 2 × 2 at 3:2; 3:2 over 1:1; 3 × 2; 16:9 hero + 3 × 2; 2 + 3 × 2; 3 × 3; hero + 3 × 3) with 4 px gaps at 550 px. The single image fits 550 × 350 and never grows. Zoom is 1–5, step 1.25, double click 2.5. 2. **Interfaces:** `mosaic::layout(n) -> Vec<Tile { col, row, col_span, row_span, aspect }>` and `attachments::fit(w, h, max_w, max_h)` exist as written. `PlayAttachment`, `StopAttachment`, `SaveAttachment`, `OpenMedia`/`CloseMedia`, `OpenUrl` and `media_playback` are used as Task 16 provides them. The lightbox index uses core's `is_visual` numbering, which matches core. 3. **Invariants:** the diff touches only `fluxer-ui`, docs and goldens. There are no `fluxer-core` changes, no new dependencies and no new fixtures (the tests use the existing `textchat/history.json`). Pictures go only through `Images`/`ImageLoader`. "Copy link" uses iced's own clipboard. The hand-written `Debug` on `Download`, `Media` and `ViewerModel` leaves out signed URLs. Server data: `fit`/`place`/`step`/`format_size`/`format_duration` handle zero, huge and non-finite values. `OpenUrl` drops anything that does not parse as a URL. 4. **Review Focus:** no item belongs to Task 22 directly. #5 (no URL leaks): `ui` has no logging. Nothing in the diff writes URLs to logs or `--record`. ### Findings - **minor:** Part of the Interfaces list is not delivered: text-file preview, hover toolbar Delete/Favorite, lightbox Copy image/Favorite/Delete/Forward, and audio seek/rate. Each one has a follow-up issue (#376, #377, #378). The code comments call the text preview and audio seek/rate a "divergence (spec §15)", but §15 lists only video. Either add them to §15 or reword the comments to "deferred (#377/#378)". Task 34 (parity) should know these are open. - **minor:** `message_row::estimate_height` now subtracts a line for every message with empty content. Messages with embeds only, and system messages, still draw their placeholder line, so their estimate is one line short. Scroll estimates only; nothing breaks. - **minor:** The lightbox opens visual attachments that have no width or height (core `is_visual` counts them; the row draws them as file cards). `fitted` then draws them at 1 × 1 px. Nothing panics. A fallback size for the image's own decoded size would be better. - **minor:** The lightbox has no backdrop-click-to-close and no arrow keys for previous/next, both of which the original has. Escape works. - **nit:** `attachments::fit` duplicates `embed_media::fit` (Task 23), as the implementer said. Dedupe when the branches meet. **Verdict: approve.** No blocking findings and local CI is green. The screenshot suite still needs to pass on the Linux runner.
charles manually merged commit a8c9c3f4fd into textchat 2026-11-13 02:14:20 +00:00
Sign in to join this conversation.
No description provided.