Text chat 7: fluxer-platform files, dialogs, clipboard; SVG and thumbhash images (#257) #292
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-7-platform-files-clipboard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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'sDebugleaves the path out.images::LoadedImage::Svg(Arc<[u8]>)→Picture::Svg(svg::Handle::from_memory);Images::svg(&url)gives the handle,Images::getstays raster-only (Nonefor an SVG).Picture::first/frame_atreturn a shared transparent pixel for an SVG so existing callers keep their signatures.images::placeholder_from_thumbhash(&str) -> Option<RgbaImage>(base64 STANDARD, padding optional likeatob).CLAUDE.md: the sanctioned-exception list now namesfiles::{SoundFileReader, Dialogs, ClipboardImages}, worded likeImageLoader.fluxer-platformdialogs::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,UnexpectedEofif the file shrinks, error messages never contain the path),thumbhash::decode(delegates to the UI decoder),ImageCache→LoadedImage::Svgforimage/svg+xml(or SVG markup when it comes back from disk).cargo denyresult.Soundboard: the upload dialog has a "Browse…" button (
upload::Message::Browse→Outcome::Pick(PickRequest)→ shell runsDialogs::pick_files(false)→PickRequest::answer); the path field stays.Checks recorded (README)
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.How it was tested
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_referencewith vectors computed by the web app's ownthumbhash0.1.1 npm package, unpadded base64, 2000 random inputs + truncations never panic),tests/images.rs::svg_response_becomes_svg_variant(network,; charsetparam, non-image error, disk tier),fluxer-uiunit tests for SVG handles and placeholders,tests/soundboard.rs::browse_opens_the_system_dialog_and_takes_the_picked_file.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.FLUXER_DESKTOP_TESTS=1, not in CI):clipboard_image_round_trippassed on KDE Plasma 6, Wayland (data-control).pick_and_paste_round_tripwas 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
rfd0.18 has notokiofeature any more (its futures need no runtime); it is added withdefault-features = false, features = ["xdg-portal"].fluxer-ui/Cargo.tomlgainsthumbhashandbase64(not in the Files list):placeholder_from_thumbhashlives in the UI (the UI cannot depend on the platform), andfluxer_platform::thumbhash::decodedelegates to it.fluxer-ui/src/app.rs(rungainsdialogs: Option<Arc<dyn Dialogs>>beforeimages),screens/main/soundboard/{mod,upload}.rs,tests/soundboard.rs,apps/fluxer/src/main.rs(injectsRfdDialogs). Text chat 21 then only addsClipboardImagestorun.platform/tests/images.rsexisting matches gained theSvgarm;tokioinfluxer-platformenablesfs+io-util;bytesandfutures-util(existing workspace deps) added tofluxer-platform.write_imageaccepts PNG or any formatimagedecodes.Closes #257
🤖 Generated with Claude Code
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
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 giveFileError::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) andpick_and_paste_round_trip(behindFLUXER_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.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 aStream<io::Result<Bytes>>,CHUNK_SIZE= 1 MiB) andthumbhash::decodeall match the plan exactly.Task::perform. CLAUDE.md's exception list is extended in the same wording as the image one. Error messages and logs carry no paths, andPickedFile's Debug omits the path and name.upload_filesanddialogserrors carry only the system's message, without the path.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a clean review worktree: green (all steps passed).On the implementer's questions
run()gainsdialogs: Option<Arc<dyn Dialogs>>: acceptable. Text chat 21's interface already says it "injectsDialogsandClipboardImagesintofluxer_ui::run". Text chat 21 addsClipboardImagesthe same way.PickedFileDebug that leaves out the path: correct, and consistent with Global Constraints "no file path in logs".tokiofeature (it no longer exists in 0.18) is a documented, sanctioned deviation. cargo deny is green.Findings
fluxer-platform/src/images.rsdecode: any body that looks like SVG becomesLoadedImage::Svg, whatever the URL (avatar, attachment, embed), not only Twemoji from the static CDN. iced'ssvg::Handlerenders with usvg's default options. usvg 0.45'sdefault_string_resolverreads<image href="/abs/path">from the local disk withstd::fs::readand 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 declaredimage/svg+xmlor comes from the emoji path, or strip<image>elements without adata:href before building the handle.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.Images::state(url)isReadyfor an SVG whileImages::get(url)isNone. A caller that usesgetalone shows the placeholder forever. This is documented onget. Consumers in Text chat 8 must useImages::svg.None of these is blocking.
Verdict: APPROVED (0 blocking, 3 minor; local ci green)