Text chat 21: apps/fluxer text chat runtime wiring (#271) #368
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-21-app-textchat-runtime"
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
ApiRequestis executed (runtime::perform_chat): rich sends and edits (now in the ordered write queue), manual ack, attachment delete and URL refresh, reactions and reactors, pins, search (retried like a GET), bookmarks and mentions, group DMs, relationships, user settings, GIFs, saved media, guild emoji and stickers, threads. Before this they all failed with 501.Effect::Upload→apps/fluxer/src/upload_rt.rs: one task per job. Multipart (send_message_with_files) or presigned (presign,PUTper singlepart file or per part with 4 parts at once, 4 attempts, 500 ms doubling to 8000 ms;completefor multipart uploads; then the send withupload_filename/file_size/content_type). Progress is throttled to 100 ms and always reports the end.UploadCommand::Cancelaborts the task (the body stream is dropped); a session change aborts every job. Files are read throughUploadReader(defaultFileReader: paths in 1 MiB chunks throughfluxer_platform::upload_files,FileSource::ClipboardfromPastedImages,FileSource::Textas UTF-8).Runtime::with_upload_readeris for tests.Effect::Clipboard/Effect::OpenFileDialog→apps/fluxer/src/desktop_rt.rs(Desktop,Runtime::with_desktop): text goes to the window throughwindow_clipboard()and the window writes it with iced's clipboard; images are downloaded and written withClipboardImages(ArboardClipboard); Attach/GroupIcon open dialogs come back asCoreEvent::Fileswith freshFileRefids (Desktop::file_id); SaveAttachment opens the save dialog, downloads and writes the file.main.rsbuilds theDesktop(RfdDialogs,ArboardClipboard, the window clipboard) and passes the dialogs, clipboard images and copy receiver intofluxer_ui::run.--record: the query (signatureex/is/hm/uc) of a signed attachment URL is replaced by<redacted>wherever it appears. Upload exchanges were already hidden from the observer, andupload_urlis already a secret key.How it was tested
apps/fluxer/tests/textchat_runtime.rs(devservertextchat/textchat_presigned):send_with_two_files_multipart_progress_and_done(progress total = both files, the bytes downloaded back match),presigned_scenario_uploads_parts(21 MiB file = 3 parts plus a singlepart file, reassembled bytes match),cancel_aborts_upload(a reader that stalls after the first chunk; Cancel drops the body, no Done/Failed, no message),react_round_trip_through_gateway(PUT, then the gateway echo, counted once),search_indexing_then_results({indexing:true}, then results),record_mode_never_contains_upload_or_signed_urls,clipboard_text_effect_executes(fakeTextClipboard, "Copy ID pair").upload_rt); dialogs answered withFileRefs with unique ids and no path inDebug, a cancelled dialog reports nothing, window clipboard (desktop_rt); signed URL redaction (record).FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally (Linux). No real-desktop test was added: the platform's real dialog and clipboard tests are Text chat 7's.Deviations from the plan
crates/fluxer-uitouched (app.rs,message.rs, README):runtakesclipboard: Option<Arc<dyn ClipboardImages>>andcopied: Option<UnboundedReceiver<String>>. The plan says the runtime injects them intofluxer_ui::run, and text has to go through iced's clipboard, which only the window can reach. Theclipboardfield is unused until the composer's paste (Text chat 26, #365).play_audio_attachment_reaches_mixeris not in the test file. The store does not play attachments before Text chat 16 (chat/media.rsis a stub). An#[ignore]d test fails CI, because the Linux step runs ignored tests. Follow-up #364 also covers the 30 s / 20 MiB clip limit (socrates/fluxer-audio/src/clip.rsis unchanged) and the 32 MiBfetch_mediacap for "Save".search_indexing_then_resultscallsfluxer::runtime::perform_chatdirectly (it is public and#[doc(hidden)]), because the store's search is a stub until Text chat 17.ApiRequest::DeleteRecentMentionstill fails with 501 becausefluxer-apihas no endpoint for it (#362).ApiResult::TypingCooldownis not mapped becauseApiClient::typingdiscards the 200 body (#363).futures-utildependency inapps/fluxer(already a workspace dependency), for reading a file part by part.Closes #271
🤖 Generated with Claude Code
Note from the review of PR #350 (Text chat 19):
fluxer-corethere addsApiRequest::EditGroupDmIcon { channel_id, name, icon: FileRef }(group DM icon, sent as a data URI). The chat request match inapps/fluxer/src/runtime.rshere ends in_ => return Err(not_a_chat_request()), so once both merge, setting a group DM icon answers 501 CLIENT_NOT_WIRED. Tracked as follow-up #372.Review: Text chat 21 (app-textchat-runtime), independent reviewer
Reviewed
git diff 173ee747..origin/textchat-21-app-textchat-runtime(b09adbe) cold.Findings
1. BLOCKING: signed attachment URLs reach the log files (
apps/fluxer/src/desktop_rt.rs:156-160and:202).ClipboardWrite::ImageandFileDialog::SaveAttachmentcallclient.fetch_media(&url)and on failure logtracing::warn!(%error, …).fetch_media(fluxer-api/src/soundboard.rsfetch_capped) turnssend()/chunk()failures intoApiError::Transport(reqwest::Error)with the URL.ApiError's Display istransport error: {0}, and reqwest 0.12.28'sDisplayappendsfor url ({url})(reqwest/src/error.rs:267-268). A DNS, connect, TLS, timeout or mid-body failure while saving or copying an attachment therefore writes…/attachments/…?ex=…&is=…&hm=…atwarnintofluxer.<date>.log. That breaks the Global Constraint "No … signed attachment URL … in logs" and Review Focus 5, which is this task's. (runtime::core_erroralready strips the URL withwithout_url();desktop_rtskips that step.) Fix: logerrorafter mappingApiError::Transport(e)toe.without_url(), or log only a kind/status. Add a unit test: pointfetch_mediaat an unroutable signed URL and assert that the logged/Display text holds nohm=.2. Minor: the signed-URL check in
record_mode_never_contains_upload_or_signed_urlstests nothing (apps/fluxer/tests/textchat_runtime.rs:515-518). The devserver never signs attachment URLs (noex=/hm=anywhere incrates/fluxer-devserver/src), so!content.contains("hm=")cannot fail. The unit testrecord::signed_attachment_urls_lose_their_signaturedoes cover the redaction. Either make the devserver sign/media/attachments/URLs or note in the test that the check only guards against regressions.3. Minor: plan items deferred, each with a follow-up.
play_audio_attachment_reaches_mixeris missing andPlaybackSource::Attachmentis not executed: the variant is not on the base yet, although it is in Text chat 10's Produces list (#364). TheSaveAttachmentdownload is capped atMAX_MEDIA_BYTES= 32 MiB, while spec §8 says to raise it to the instance's attachment limit (#364). On that failure the user sees nothing, only awarn.DeleteRecentMentionstill returns 501 (#362) andTypingCooldownis not produced (#363). These are acceptable as deferrals.4. Minor:
PastedImagesis never emptied and nothing can fill it yet (upload_rt.rs:95-126). The doc says images are kept "until the upload that sends them has read them (or the session ends)", but nothing callsforget, andcancel_allon a session change leaves them in place. Pasted PNGs would stay in memory for the life of the process and could outlive the account switch. The UI also has no path toDesktop::pasted_images()(fluxer_ui::runonly getsClipboardImages). #365 owns the producer. When it lands, please also clear the images on a session change and after a job ends.5. Minor:
perform_chatends with_ => Err(not_a_chat_request())(runtime.rs). When Text chat 38 adds the Phase 5ApiRequestvariants, the compiler will not point Task 42 at them; they will fail at runtime with 501 instead.UploadCommandis matched exhaustively, as the Phase 5 note asks. Consider listing the non-chat variants explicitly.6. Minor (process): the task touched two crates and the commit trailer is wrong. The task touches
crates/fluxer-ui(runsignature,Copiedsubscription), which the plan's Files list does not name. The deviation is declared and justified, and the newrunparameters match what the Interfaces block requires ("injectsDialogsandClipboardImagesintofluxer_ui::run"). The commit trailer isClaude Opus 5.5, but the repo's CLAUDE.md requiresClaude Fable 5.2; it cannot be amended without a force-push.Checked and fine
Indexing, thenResults. Record has no upload URL or path. Clipboard ID pair is{channel}-{message}.PROGRESS_INTERVAL100 ms,PARALLEL_PARTS4,PART_ATTEMPTS4, backoff 500 ms doubling, capped at 8000 ms.upload_rt::multiis correct. The plan's part count is checked againstdiv_ceil(size, part_size), only the last part may be short, a file that is too long or too short is an error, at most 4 parts are in flight (JoinSet), and a failed part aborts the others when the set is dropped. Singlepart retries reopen the file and hand back the counted progress.Uploads::cancel_all()runs when the token changes, alongside the epoch bump, and stale reports are dropped by epoch.Copiedsubscription influxer-ui/src/app.rs: it has a fixed identity and is always in the batch. The receiver is taken once and the text is written withiced::clipboard::write, sofluxer-uigains no I/O path.SecretString, PUT errors usewithout_url(), presign/PUT/complete are not observed,--recordstrips signatures, and errors carry no file paths (unit test).fluxer-core,fluxer-emojiand the fixtures are untouched. No new dependency beyondfutures-util, which is already a workspace dependency.CI
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin the review worktree (b09adbe, Linux): green ("xtask ci: all steps passed", exit 0).Verdict: changes requested. One blocking finding (#1, a signed attachment URL can reach the log files); everything else is minor or already tracked.
Review round 1, fixed in
bb1409c:desktop_rt.rs(signed URL in the log): fixed. Copying an image and SaveAttachment now logloggable(error), which strips the URL fromApiError::Transportwithreqwest::Error::without_url(). New testa_failed_media_download_logs_no_signed_urldownloads...?ex=..&is=..&hm=signaturefrom a refused port and asserts the logged text has nohm=, signature or path. Without the fix it fails and printserror sending request for url (http://127.0.0.1:1/attachments/...&hm=signature).tests/textchat_runtime.rs(hm=check cannot fail): removed that assert. A comment now says the redaction is checked byrecord's unit test, because the devserver does not sign URLs.runtime.rs(deferred items): no change. They are already tracked in #362, #363 and #364.upload_rt.rs(PastedImages::forgetnever called): the doc now says what happens today: images are kept while the runtime runs. Forgetting them after the upload and on a session change stays with #365.runtime.rs(perform_chatwildcard): replaced with an explicit list of the requestsperformhandles. A newApiRequestvariant (Phase 5, Task 42) now fails to compile until someone places it.Claude Fable 5.2trailer. Fixing the trailer onb09adbewould need a history rewrite, and force-pushing is not allowed, so that commit keeps it.Local
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green.Independent review: Text chat 21 (round 2, at
bb1409c)I reviewed
git diff 173ee74..origin/textchat-21-app-textchat-runtimecold, without relying on the implementer's notes.Checks
apps/fluxer/tests/textchat_runtime.rsand assert what the plan asks. They cover multipart progress total and the bytes downloaded back, presigned 3 parts plus a singlepart file reassembled in order, cancel dropping the body with no Done or Failed, the reaction echo counted once, indexing then results,--recordwithout upload URLs or paths, and a fake text clipboard.play_audio_attachment_reaches_mixeris missing; see finding 1.ApiRequestis executed byperform_chat, and the explicit list of other variants makes a new variant a compile error. The constants match the plan: 100 ms throttle,PARALLEL_PARTS = 4,PART_ATTEMPTS = 4, 500 to 8000 ms backoff. Cancel aborts the job, a session change aborts every job, and uploads report only within their epoch. Text goes to iced's clipboard and images toArboardClipboard.OpenFileDialoggoes toRfdDialogsand comes back asCoreEvent::Fileswith unique ids. Save attachment downloads and writes the file.DialogsandClipboardImagesare injected intofluxer_ui::run.fluxer-coreis untouched.fluxer-uigains no I/O: the copy receiver is a channel subscription, the text is written withiced::clipboard::write, andClipboardImagesis only stored for #365. The uploadPUTs, presign and complete requests are unobserved and their errors carry no URL (without_url). Thefetch_mediaerrors indesktop_rtnow go throughloggable(), which fixes the blocking finding of round 1, anda_failed_media_download_logs_no_signed_urlcovers it. Reader errors carry no path.--recordstripsex/is/hm/ucfrom/attachments/URLs in both REST and gateway bodies. No new fixtures were added.--record): satisfied.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a fresh review worktree: all steps passed (fmt, clippy, deny, core-isolation, parity, test, vendored-tests, screenshot-tests, livekit-interop).Findings
play_audio_attachment_reaches_mixerand thePlaybackSource::Attachmentfetch-and-play wiring are not delivered.audio_rt.rsstill maps attachments to a hashed clip tag. The deferral is justified becausechat/media.rson the base is a 44-line stub until Text chat 16. It is tracked in #364 (follow-up), which Text chat 16 and 22 must pick up.fetch_media, which is capped at 32 MiB. Spec §8 asks for the instance's attachment limit, so saving a larger attachment fails with only a warn log line. Tracked in #364.search_indexing_then_resultscallsperform_chatdirectly instead of going through the store, because the store's search is a stub until Text chat 17. This is documented as a deviation in the PR body.RateLimitedsleeps the fixed backoff and ignoresretry_after.PastedImagesare never forgotten, so pasted images stay in memory for the life of the runtime. Tracked in #365.b09adbeends withCo-Authored-By: Claude Opus 5.5, butCLAUDE.mdrequiresClaude Fable 5.2. Force-push is denied, so this cannot be fixed now;bb1409cis correct.origin/textchat(the CI release workflow and thevoice_rt.rsPipeWire init).git merge-treeshows a clean merge.crates/fluxer-uiis touched outside the task's file list (runsignature,UiMessage::Copy). The Interfaces block requires this, and the PR documents it.Verdict: approved. There are no blocking findings, and local ci is green.