Text chat 7: fluxer-platform files, dialogs, clipboard; SVG and thumbhash images (#257) #292

Manually merged
charles merged 3 commits from textchat-7-platform-files-clipboard into textchat 2026-11-12 12:51:06 +00:00
Owner

What this builds

fluxer-ui (interfaces other tasks consume)

  • files::{Dialogs, ClipboardImages, PickedFile, PngBytes} exactly as in the plan's Interfaces block (pick_files(multiple) -> BoxFuture<Vec<PickedFile>>, save_file(suggested) -> BoxFuture<Option<PathBuf>>, read_image() -> BoxFuture<Option<PngBytes>>, write_image(Vec<u8>) -> BoxFuture<Result<(), FileError>>). PickedFile's Debug leaves the path out.
  • images::LoadedImage::Svg(Arc<[u8]>) → Picture::Svg(svg::Handle::from_memory); Images::svg(&url) gives the handle, Images::get stays raster-only (None for an SVG). Picture::first/frame_at return a shared transparent pixel for an SVG so existing callers keep their signatures.
  • images::placeholder_from_thumbhash(&str) -> Option<RgbaImage> (base64 STANDARD, padding optional like atob).
  • CLAUDE.md: the sanctioned-exception list now names files::{SoundFileReader, Dialogs, ClipboardImages}, worded like ImageLoader.

fluxer-platform

  • dialogs::RfdDialogs (rfd 0.18, XDG portal; picked files described on the blocking pool), clipboard::ArboardClipboard (arboard 3.7, one thread owns the clipboard for the client's lifetime, PNG in/out), upload_files::open(path) -> Result<(u64, String, impl Stream<Item = io::Result<Bytes>>), FileError> (exact 1 MiB chunks, content type by extension then magic bytes, stops at the reported size, UnexpectedEof if the file shrinks, error messages never contain the path), thumbhash::decode (delegates to the UI decoder), ImageCache → LoadedImage::Svg for image/svg+xml (or SVG markup when it comes back from disk).
  • README: modules, the winit file-drop finding, the cargo deny result.

Soundboard: the upload dialog has a "Browse…" button (upload::Message::Browse → Outcome::Pick(PickRequest) → shell runs Dialogs::pick_files(false) → PickRequest::answer); the path field stays.

Checks recorded (README)

  • winit 0.30.13 file drop: X11 (XDND) and Windows (OLE) deliver FileHovered/FileDropped/FilesHoveredLeft; the Wayland backend implements no drag and drop, so under Wayland the drop overlay is unreachable (spec §16 fallback: "+" menu, Browse, paste). Read from winit's source, not tried by hand.
  • cargo deny: green. rfd 0.18 no longer pulls ashpd/zbus (it dlopens libdbus), so nothing is added to the #48 exceptions.

How it was tested

  • New tests: tests/upload_files.rs (upload_stream_reads_in_1mib_chunks_and_reports_size, content_type_by_extension_then_magic, missing_file_is_error_not_panic, path-free error, empty file, shrinking file), tests/thumbhash.rs (thumbhash_decodes_reference with vectors computed by the web app's own thumbhash 0.1.1 npm package, unpadded base64, 2000 random inputs + truncations never panic), tests/images.rs::svg_response_becomes_svg_variant (network, ; charset param, non-image error, disk tier), fluxer-ui unit tests for SVG handles and placeholders, tests/soundboard.rs::browse_opens_the_system_dialog_and_takes_the_picked_file.
  • Seen failing first (unresolved modules/variant), then passing.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally.
  • Real desktop (FLUXER_DESKTOP_TESTS=1, not in CI): clipboard_image_round_trip passed on KDE Plasma 6, Wayland (data-control). pick_and_paste_round_trip was not run: it needs a person to pick a file in the portal dialog; it is written to fall back to the clipboard-only round trip when the dialog is cancelled.

Deviations from the plan

  • rfd 0.18 has no tokio feature any more (its futures need no runtime); it is added with default-features = false, features = ["xdg-portal"].
  • fluxer-ui/Cargo.toml gains thumbhash and base64 (not in the Files list): placeholder_from_thumbhash lives in the UI (the UI cannot depend on the platform), and fluxer_platform::thumbhash::decode delegates to it.
  • "Browse…" needed files outside the Files list: fluxer-ui/src/app.rs (run gains dialogs: Option<Arc<dyn Dialogs>> before images), screens/main/soundboard/{mod,upload}.rs, tests/soundboard.rs, apps/fluxer/src/main.rs (injects RfdDialogs). Text chat 21 then only adds ClipboardImages to run.
  • platform/tests/images.rs existing matches gained the Svg arm; tokio in fluxer-platform enables fs + io-util; bytes and futures-util (existing workspace deps) added to fluxer-platform.
  • write_image accepts PNG or any format image decodes.

Closes #257

🤖 Generated with Claude Code

## What this builds **`fluxer-ui` (interfaces other tasks consume)** - `files::{Dialogs, ClipboardImages, PickedFile, PngBytes}` exactly as in the plan's Interfaces block (`pick_files(multiple) -> BoxFuture<Vec<PickedFile>>`, `save_file(suggested) -> BoxFuture<Option<PathBuf>>`, `read_image() -> BoxFuture<Option<PngBytes>>`, `write_image(Vec<u8>) -> BoxFuture<Result<(), FileError>>`). `PickedFile`'s `Debug` leaves the path out. - `images::LoadedImage::Svg(Arc<[u8]>)` → `Picture::Svg(svg::Handle::from_memory)`; `Images::svg(&url)` gives the handle, `Images::get` stays raster-only (`None` for an SVG). `Picture::first`/`frame_at` return a shared transparent pixel for an SVG so existing callers keep their signatures. - `images::placeholder_from_thumbhash(&str) -> Option<RgbaImage>` (base64 STANDARD, padding optional like `atob`). - `CLAUDE.md`: the sanctioned-exception list now names `files::{SoundFileReader, Dialogs, ClipboardImages}`, worded like `ImageLoader`. **`fluxer-platform`** - `dialogs::RfdDialogs` (rfd 0.18, XDG portal; picked files described on the blocking pool), `clipboard::ArboardClipboard` (arboard 3.7, one thread owns the clipboard for the client's lifetime, PNG in/out), `upload_files::open(path) -> Result<(u64, String, impl Stream<Item = io::Result<Bytes>>), FileError>` (exact 1 MiB chunks, content type by extension then magic bytes, stops at the reported size, `UnexpectedEof` if the file shrinks, error messages never contain the path), `thumbhash::decode` (delegates to the UI decoder), `ImageCache` → `LoadedImage::Svg` for `image/svg+xml` (or SVG markup when it comes back from disk). - README: modules, the winit file-drop finding, the `cargo deny` result. **Soundboard**: the upload dialog has a "Browse…" button (`upload::Message::Browse` → `Outcome::Pick(PickRequest)` → shell runs `Dialogs::pick_files(false)` → `PickRequest::answer`); the path field stays. ## Checks recorded (README) - **winit 0.30.13 file drop**: X11 (XDND) and Windows (OLE) deliver `FileHovered/FileDropped/FilesHoveredLeft`; the Wayland backend implements no drag and drop, so under Wayland the drop overlay is unreachable (spec §16 fallback: "+" menu, Browse, paste). Read from winit's source, not tried by hand. - **cargo deny**: green. rfd 0.18 no longer pulls ashpd/zbus (it dlopens libdbus), so nothing is added to the #48 exceptions. ## How it was tested - New tests: `tests/upload_files.rs` (`upload_stream_reads_in_1mib_chunks_and_reports_size`, `content_type_by_extension_then_magic`, `missing_file_is_error_not_panic`, path-free error, empty file, shrinking file), `tests/thumbhash.rs` (`thumbhash_decodes_reference` with vectors computed by the web app's own `thumbhash` 0.1.1 npm package, unpadded base64, 2000 random inputs + truncations never panic), `tests/images.rs::svg_response_becomes_svg_variant` (network, `; charset` param, non-image error, disk tier), `fluxer-ui` unit tests for SVG handles and placeholders, `tests/soundboard.rs::browse_opens_the_system_dialog_and_takes_the_picked_file`. - Seen failing first (unresolved modules/variant), then passing. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. - **Real desktop** (`FLUXER_DESKTOP_TESTS=1`, not in CI): `clipboard_image_round_trip` passed on KDE Plasma 6, Wayland (data-control). `pick_and_paste_round_trip` was **not** run: it needs a person to pick a file in the portal dialog; it is written to fall back to the clipboard-only round trip when the dialog is cancelled. ## Deviations from the plan - `rfd` 0.18 has no `tokio` feature any more (its futures need no runtime); it is added with `default-features = false, features = ["xdg-portal"]`. - `fluxer-ui/Cargo.toml` gains `thumbhash` and `base64` (not in the Files list): `placeholder_from_thumbhash` lives in the UI (the UI cannot depend on the platform), and `fluxer_platform::thumbhash::decode` delegates to it. - "Browse…" needed files outside the Files list: `fluxer-ui/src/app.rs` (`run` gains `dialogs: Option<Arc<dyn Dialogs>>` before `images`), `screens/main/soundboard/{mod,upload}.rs`, `tests/soundboard.rs`, `apps/fluxer/src/main.rs` (injects `RfdDialogs`). Text chat 21 then only adds `ClipboardImages` to `run`. - `platform/tests/images.rs` existing matches gained the `Svg` arm; `tokio` in `fluxer-platform` enables `fs` + `io-util`; `bytes` and `futures-util` (existing workspace deps) added to `fluxer-platform`. - `write_image` accepts PNG or any format `image` decodes. Closes #257 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- fluxer-ui::files: Dialogs, ClipboardImages, PickedFile, PngBytes (injected
  traits, sanctioned in CLAUDE.md like ImageLoader).
- fluxer-ui::images: LoadedImage::Svg / Picture::Svg, Images::svg,
  placeholder_from_thumbhash.
- fluxer-platform: dialogs::RfdDialogs (rfd 0.18, portal), clipboard::
  ArboardClipboard (arboard 3.7, wayland-data-control), upload_files::open
  (1 MiB chunks, content type by extension then magic), thumbhash::decode,
  ImageCache returns Svg for image/svg+xml.
- Thumbhash test vectors computed with the web app's thumbhash 0.1.1 npm
  package; the server encodes placeholders with base64 STANDARD
  (fluxer_media_proxy/src/media_process/placeholder.rs:73-75).

Refs #257

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
fluxer_ui::run takes an Option<Arc<dyn Dialogs>>; apps/fluxer injects
RfdDialogs. The path field stays for typing and drops.

Refs #257

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Text chat 7 (platform files, dialogs, clipboard; SVG and thumbhash)

Scope: git diff 0283642..origin/textchat-7-platform-files-clipboard (7d76440).

What I checked

  1. Plan tests: upload_stream_reads_in_1mib_chunks_and_reports_size (sizes [1 MiB, 1 MiB, 0.5 MiB], bytes match), content_type_by_extension_then_magic, missing_file_is_error_not_panic (missing file and directory both give FileError::Io), thumbhash_decodes_reference (two reference vectors from the web app's thumbhash 0.1.1, with tolerance for the difference between f32 and f64), svg_response_becomes_svg_variant (from the network, with a charset parameter, and from disk) and pick_and_paste_round_trip (behind FLUXER_DESKTOP_TESTS=1): all present and they assert what the plan says. Extra tests cover the shrinking file, the error text naming no path, unpadded base64, and 2000 random or truncated thumbhash inputs that must not panic.
  2. Interfaces: files::{Dialogs, ClipboardImages, PickedFile{path,name,size,content_type}, PngBytes}, LoadedImage::Svg(Arc<[u8]>), placeholder_from_thumbhash(&str) -> Option<RgbaImage>, RfdDialogs, ArboardClipboard, upload_files::open (returns size, content type and a Stream<io::Result<Bytes>>, CHUNK_SIZE = 1 MiB) and thumbhash::decode all match the plan exactly.
  3. Invariants: fluxer-core is untouched. fluxer-ui gains only pure dependencies (base64, thumbhash) and calls Dialogs through Task::perform. CLAUDE.md's exception list is extended in the same wording as the image one. Error messages and logs carry no paths, and PickedFile's Debug omits the path and name.
  4. Review Focus: none of the plan's Review Focus items belongs to this task. On item 5 (no leaks), upload_files and dialogs errors carry only the system's message, without the path.
  5. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a clean review worktree: green (all steps passed).

On the implementer's questions

  • run() gains dialogs: Option<Arc<dyn Dialogs>>: acceptable. Text chat 21's interface already says it "injects Dialogs and ClipboardImages into fluxer_ui::run". Text chat 21 adds ClipboardImages the same way.
  • The PickedFile Debug that leaves out the path: correct, and consistent with Global Constraints "no file path in logs".
  • Dropping rfd's tokio feature (it no longer exists in 0.18) is a documented, sanctioned deviation. cargo deny is green.

Findings

  • [minor] fluxer-platform/src/images.rs decode: any body that looks like SVG becomes LoadedImage::Svg, whatever the URL (avatar, attachment, embed), not only Twemoji from the static CDN. iced's svg::Handle renders with usvg's default options. usvg 0.45's default_string_resolver reads <image href="/abs/path"> from the local disk with std::fs::read and logs the href (a path) when the read fails. This task draws nothing yet, but once Text chat 8 or 22 draws SVGs, server-supplied markup can make the UI read local image files and log paths. Nothing leaves the machine, so this is not a leak. Suggest a follow-up: accept SVG only when it is declared image/svg+xml or comes from the emoji path, or strip <image> elements without a data: href before building the handle.
  • [minor] soundboard/upload.rs: "Browse…" stays enabled while a pick is pending, so a second press opens a second dialog. The answers are matched to the form id, so no data is lost. Cosmetic.
  • [minor] Images::state(url) is Ready for an SVG while Images::get(url) is None. A caller that uses get alone shows the placeholder forever. This is documented on get. Consumers in Text chat 8 must use Images::svg.

None of these is blocking.

Verdict: APPROVED (0 blocking, 3 minor; local ci green)

## Independent review: Text chat 7 (platform files, dialogs, clipboard; SVG and thumbhash) Scope: `git diff 0283642..origin/textchat-7-platform-files-clipboard` (7d76440). **What I checked** 1. Plan tests: `upload_stream_reads_in_1mib_chunks_and_reports_size` (sizes [1 MiB, 1 MiB, 0.5 MiB], bytes match), `content_type_by_extension_then_magic`, `missing_file_is_error_not_panic` (missing file and directory both give `FileError::Io`), `thumbhash_decodes_reference` (two reference vectors from the web app's thumbhash 0.1.1, with tolerance for the difference between f32 and f64), `svg_response_becomes_svg_variant` (from the network, with a charset parameter, and from disk) and `pick_and_paste_round_trip` (behind `FLUXER_DESKTOP_TESTS=1`): all present and they assert what the plan says. Extra tests cover the shrinking file, the error text naming no path, unpadded base64, and 2000 random or truncated thumbhash inputs that must not panic. 2. Interfaces: `files::{Dialogs, ClipboardImages, PickedFile{path,name,size,content_type}, PngBytes}`, `LoadedImage::Svg(Arc<[u8]>)`, `placeholder_from_thumbhash(&str) -> Option<RgbaImage>`, `RfdDialogs`, `ArboardClipboard`, `upload_files::open` (returns size, content type and a `Stream<io::Result<Bytes>>`, `CHUNK_SIZE` = 1 MiB) and `thumbhash::decode` all match the plan exactly. 3. Invariants: fluxer-core is untouched. fluxer-ui gains only pure dependencies (base64, thumbhash) and calls Dialogs through `Task::perform`. CLAUDE.md's exception list is extended in the same wording as the image one. Error messages and logs carry no paths, and `PickedFile`'s Debug omits the path and name. 4. Review Focus: none of the plan's Review Focus items belongs to this task. On item 5 (no leaks), `upload_files` and `dialogs` errors carry only the system's message, without the path. 5. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a clean review worktree: **green** (all steps passed). **On the implementer's questions** - `run()` gains `dialogs: Option<Arc<dyn Dialogs>>`: acceptable. Text chat 21's interface already says it "injects `Dialogs` and `ClipboardImages` into `fluxer_ui::run`". Text chat 21 adds `ClipboardImages` the same way. - The `PickedFile` Debug that leaves out the path: correct, and consistent with Global Constraints "no file path in logs". - Dropping rfd's `tokio` feature (it no longer exists in 0.18) is a documented, sanctioned deviation. cargo deny is green. **Findings** - [minor] `fluxer-platform/src/images.rs` `decode`: any body that *looks* like SVG becomes `LoadedImage::Svg`, whatever the URL (avatar, attachment, embed), not only Twemoji from the static CDN. iced's `svg::Handle` renders with usvg's default options. usvg 0.45's `default_string_resolver` reads `<image href="/abs/path">` from the local disk with `std::fs::read` and logs the href (a path) when the read fails. This task draws nothing yet, but once Text chat 8 or 22 draws SVGs, server-supplied markup can make the UI read local image files and log paths. Nothing leaves the machine, so this is not a leak. Suggest a follow-up: accept SVG only when it is declared `image/svg+xml` or comes from the emoji path, or strip `<image>` elements without a `data:` href before building the handle. - [minor] `soundboard/upload.rs`: "Browse…" stays enabled while a pick is pending, so a second press opens a second dialog. The answers are matched to the form id, so no data is lost. Cosmetic. - [minor] `Images::state(url)` is `Ready` for an SVG while `Images::get(url)` is `None`. A caller that uses `get` alone shows the placeholder forever. This is documented on `get`. Consumers in Text chat 8 must use `Images::svg`. None of these is blocking. **Verdict: APPROVED** (0 blocking, 3 minor; local ci green)
charles manually merged commit 35167503c6 into textchat 2026-11-12 12:51:06 +00:00
Sign in to join this conversation.
No description provided.