Text chat 12: core-uploads (#262) #311

Manually merged
charles merged 7 commits from textchat-12-core-uploads into textchat 2026-11-12 20:59:04 +00:00
Owner

What

fluxer-core attachments and uploads (spec §6.2 "Uploads", §3.3), in chat/uploads.rs and Composers::send_with_files:

  • Upload tray per composer: AddFiles, CoreEvent::Files (Attach; AttachAndSend sends at once), RemoveAttachment, MoveAttachment (clamped), SetAttachmentSpoiler, EditAttachment (blank name keeps the old one; alt text only for images/videos, trimmed, <= 4096; name <= 512), OpenFileDialog(Attach) -> Effect::OpenFileDialog.
  • Refusals as the original's handleFileUpload/canAttachFilesInChannel: NoPermission (ATTACH_FILES, DMs always allowed), then TooMany { max } (whole batch), then TooLarge { max } (whole batch), limits from the instance's resolved limits; the next successful add clears refusal.
  • Spoilers: a SPOILER_ file name arrives as a spoiler shown without the prefix; on send the name gets SPOILER_ + flag 8 (title = filename, as MessageAttachmentUtils.ts:29-38).
  • Send with files -> Effect::Upload(UploadCommand::Start(UploadJobSpec)): multipart, or presigned when discovery says features.presigned_attachment_uploads (new session.presigned_uploads); payload ids = tray index; presigned payloads carry file_size/content_type (the runtime adds upload_filename). The draft is emptied (inline edit kept).
  • The job's message is a real pending record of Messages under the job's nonce (nonce allocated with Messages' own provisional-id rule, so it never collides with a plain send). Progress updates UploadJob { sent, total }; Done or the gateway echo replaces the pending record; Failed marks job + record failed and keeps the files; RetrySend { nonce } starts the same spec again; CancelUpload emits UploadCommand::Cancel (only while uploading) and puts the draft back (files before any added since; text/reply/sticker unless new ones were written).
  • PasteLongText turns the draft's text into message.txt (FileSource::Text, text/plain, ids with the top bit set so they never meet runtime ids), subject to the same checks.
  • Selectors: selectors::upload_tray(&App, channel) -> Vec<TrayItem { name, size, kind: FileKind, spoiler, description }> (FileKind follows getFileIcon), selectors::upload_progress(&App, nonce) -> Option<f32>.

Tests

crates/fluxer-core/tests/chat_uploads.rs: all 13 named in the plan plus file_dialog_and_picked_files, file_kinds_follow_the_original_icons, logout_forgets_jobs_and_tray. Written first and seen failing, then passing. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally (Linux). No desktop tests in this task.

Deviations / for the reviewer

  • Follow-ups from review: #185 (premium/traits), #335 (PasteLongText should carry the pasted text), #336 (cancel/Done race).
  • Outside the Files list, kept minimal: session.rs (presigned_uploads from discovery), chat/state.rs (resolve_limits(session, guilds, channels, channel) so reducers can resolve limits for the target channel), messages.rs (provisional, show_upload, and upload Done/Failed/Cancel/Retry on the pending record), app.rs (hands the started job's message to Messages after chat::reduce), chat/mod.rs (uploads reducer gets &mut Composers), selectors/mod.rs (re-exports), tests/chat_ports.rs (the stub test skips the actions this task fills in).
  • UploadJob gains spec and draft (for retry and cancel) and loses Eq (SendMessageRequest is not Eq).
  • Premium: size_limit_from_resolved_limits_and_premium checks the instance's resolved limit and that a premium rule does NOT apply: UserPrivate has no traits/premium yet (follow-up #185).
  • There is no separate action for "Upload your message as a file": PasteLongText { channel_id } carries no text, so it files the whole draft text (both cases). The original files only the pasted part on a long paste; with iced the UI can let the paste land first, then emit it.
  • SendDraft reaches send_with_files from the composer's stub reduce (Text chat 11's function), not from the uploads reducer (review fix, 4705987). Text chat 11 (PR #309) replaces that function, so the merge conflicts textually there and its send (after the inline-edit, slowmode, @everyone and length checks) becomes the only SendDraft caller. CoreEvent::Files with AttachAndSend still calls send_with_files from the uploads reducer; with #309 it should go through the composer's send checks too. Merging with #309: content here is the trimmed draft text; it should become Text chat 11's converted wire content (and allowed_mentions), and the two limits helpers (limits_of there, resolve_limits here) should become one. Both use the same 'started this event, drained in app.rs' pattern.
  • No dismiss action for the refusal modals exists in the ports; the next successful add clears it (Text chat 26 may want a DismissUploadRefusal).

Closes #262

🤖 Generated with Claude Code

## What `fluxer-core` attachments and uploads (spec §6.2 "Uploads", §3.3), in `chat/uploads.rs` and `Composers::send_with_files`: - Upload tray per composer: `AddFiles`, `CoreEvent::Files` (`Attach`; `AttachAndSend` sends at once), `RemoveAttachment`, `MoveAttachment` (clamped), `SetAttachmentSpoiler`, `EditAttachment` (blank name keeps the old one; alt text only for images/videos, trimmed, <= 4096; name <= 512), `OpenFileDialog(Attach)` -> `Effect::OpenFileDialog`. - Refusals as the original's `handleFileUpload`/`canAttachFilesInChannel`: `NoPermission` (ATTACH_FILES, DMs always allowed), then `TooMany { max }` (whole batch), then `TooLarge { max }` (whole batch), limits from the instance's resolved limits; the next successful add clears `refusal`. - Spoilers: a `SPOILER_` file name arrives as a spoiler shown without the prefix; on send the name gets `SPOILER_` + flag 8 (`title` = filename, as `MessageAttachmentUtils.ts:29-38`). - Send with files -> `Effect::Upload(UploadCommand::Start(UploadJobSpec))`: multipart, or presigned when discovery says `features.presigned_attachment_uploads` (new `session.presigned_uploads`); payload ids = tray index; presigned payloads carry `file_size`/`content_type` (the runtime adds `upload_filename`). The draft is emptied (inline edit kept). - The job's message is a real pending record of `Messages` under the job's nonce (nonce allocated with Messages' own provisional-id rule, so it never collides with a plain send). `Progress` updates `UploadJob { sent, total }`; `Done` or the gateway echo replaces the pending record; `Failed` marks job + record failed and keeps the files; `RetrySend { nonce }` starts the same spec again; `CancelUpload` emits `UploadCommand::Cancel` (only while uploading) and puts the draft back (files before any added since; text/reply/sticker unless new ones were written). - `PasteLongText` turns the draft's text into `message.txt` (`FileSource::Text`, `text/plain`, ids with the top bit set so they never meet runtime ids), subject to the same checks. - Selectors: `selectors::upload_tray(&App, channel) -> Vec<TrayItem { name, size, kind: FileKind, spoiler, description }>` (`FileKind` follows `getFileIcon`), `selectors::upload_progress(&App, nonce) -> Option<f32>`. ## Tests `crates/fluxer-core/tests/chat_uploads.rs`: all 13 named in the plan plus `file_dialog_and_picked_files`, `file_kinds_follow_the_original_icons`, `logout_forgets_jobs_and_tray`. Written first and seen failing, then passing. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally (Linux). No desktop tests in this task. ## Deviations / for the reviewer - Follow-ups from review: #185 (premium/traits), #335 (`PasteLongText` should carry the pasted text), #336 (cancel/`Done` race). - Outside the Files list, kept minimal: `session.rs` (`presigned_uploads` from discovery), `chat/state.rs` (`resolve_limits(session, guilds, channels, channel)` so reducers can resolve limits for the target channel), `messages.rs` (`provisional`, `show_upload`, and upload Done/Failed/Cancel/Retry on the pending record), `app.rs` (hands the started job's message to `Messages` after `chat::reduce`), `chat/mod.rs` (uploads reducer gets `&mut Composers`), `selectors/mod.rs` (re-exports), `tests/chat_ports.rs` (the stub test skips the actions this task fills in). - `UploadJob` gains `spec` and `draft` (for retry and cancel) and loses `Eq` (`SendMessageRequest` is not `Eq`). - Premium: `size_limit_from_resolved_limits_and_premium` checks the instance's resolved limit and that a premium rule does NOT apply: `UserPrivate` has no traits/premium yet (follow-up #185). - There is no separate action for "Upload your message as a file": `PasteLongText { channel_id }` carries no text, so it files the whole draft text (both cases). The original files only the pasted part on a long paste; with iced the UI can let the paste land first, then emit it. - `SendDraft` reaches `send_with_files` from the composer's **stub** `reduce` (Text chat 11's function), not from the uploads reducer (review fix, 4705987). Text chat 11 (PR #309) replaces that function, so the merge conflicts textually there and its `send` (after the inline-edit, slowmode, `@everyone` and length checks) becomes the only `SendDraft` caller. `CoreEvent::Files` with `AttachAndSend` still calls `send_with_files` from the uploads reducer; with #309 it should go through the composer's send checks too. Merging with #309: content here is the trimmed draft text; it should become Text chat 11's converted `wire` content (and `allowed_mentions`), and the two limits helpers (`limits_of` there, `resolve_limits` here) should become one. Both use the same 'started this event, drained in app.rs' pattern. - No dismiss action for the refusal modals exists in the ports; the next successful add clears it (Text chat 26 may want a `DismissUploadRefusal`). Closes #262 🤖 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
Upload tray, refusals (permission, count, size from the resolved
limits), spoilers, attachment edits, message.txt from text, and sends
with files as upload jobs (multipart or presigned per discovery) with
progress, done, failure, retry and cancel. The job's message is a
pending record of Messages under its nonce.

Refs #262

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

Independent review: Text chat 12 (core-uploads)

I reviewed git diff 53fbd6f..origin/textchat-12-core-uploads (commit 19baf68) without reading the implementer's notes first.

Checks

  1. Plan tests: all 13 tests the plan names are in tests/chat_uploads.rs, and each asserts what the plan says. The values match the spec: 25 MiB default, 10 files, SPOILER_ with flag 8, attachments[i].id = i, presigned file_size/content_type, and message.txt as text/plain. There are 3 extra tests. size_limit_from_resolved_limits_and_premium asserts that the premium rule does not apply, because UserPrivate has no traits yet. Task 10 already documents this gap; see minor finding 3.
  2. Interfaces: UploadRefusal::{TooLarge{max}, TooMany{max}, NoPermission} is in chat.uploads.refusal. selectors::upload_tray(&App, channel) -> Vec<TrayItem{name,size,kind: FileKind,spoiler,description}> and selectors::upload_progress(&App, &str) -> Option<f32> exist as written. UploadPath comes from features.presigned_attachment_uploads, which is in the server's InstanceController.ts:109. Cancel emits UploadCommand::Cancel. UploadJob loses Eq; nothing downstream needs it.
  3. Invariants: there are no new dependencies and no Cargo changes. fluxer-core holds only FileRefs, and FileSource::Text is the sanctioned Task 10 form. Logs carry no paths, URLs or text: the only tracing is debug! lines that name channel ids. There are no new fixtures; the tests use the existing server-shaped well_known/ready/message_attachments fixtures. Out-of-range indexes, unknown nonces and unknown channels are no-ops; the tests cover them.
  4. Review Focus 4: limits come from the instance's resolved limits, resolve_limits with the target channel's guild features. Payload id = tray index. The presigned fields are left for the runtime, as Task 5 expects.
  5. Local CI: see the CI line below.

Findings

  • [blocking] The SendDraft arm in uploads.rs (on_user) bypasses Text chat 11's send checks once #309 merges. The plan says Task 12 coordinates with Task 11 "by touching only the send_with_files function it leaves as a stub". This PR also makes the uploads reducer call composers.send_with_files on every UserAction::SendDraft. On origin/textchat-11-core-composer, Composers::send returns early in four cases and leaves the files in the draft:

    • an inline edit is active, where Enter saves the edit and "the draft waits";
    • a slowmode cooldown is running;
    • an @everyone/@here confirm is pending (Confirm::Everyone);
    • the wire length is over the limit.

    chat::reduce runs composer.reduce and then uploads.reduce in the same event. So after the merge, the uploads arm sends the files in every one of those cases. That means an upload during slowmode, a draft sent while the user is editing another message, and an @everyone message sent with no confirm and with raw content instead of to_wire content. This sits in uploads.rs, which #309 does not touch, so it will merge without a textual conflict and nobody will notice it.

    Fix: drop the SendDraft arm, or gate it on the legacy path, e.g. only when ctx.legacy_send, which #309 introduces. Make Composers::send the only caller of send_with_files, and have the tests reach it through the SendDraft path that remains. At minimum, the PR body and a follow-up issue must say that the integrator has to remove this arm when #309 lands. A note about resolve_limits/limits_of alone is not enough.

  • [minor] PasteLongText files the whole draft, not just the pasted text. The action carries no text, so the draft text the user already wrote moves into message.txt as well. The original converts only the pasted part. No text is lost, because it ends up in the file, but this differs from the original. A follow-up should give PasteLongText the pasted text, which is a Task 10 port change.

  • [minor] Before #309 lands, one SendDraft can send two messages. Foundation's Messages::send_draft sends the ui.drafts text and the uploads job sends the files. This is transitional; the PR body already notes it.

  • [minor] Premium-aware size limit not applied. The spec says "premium aware" for this rule, so it needs a follow-up issue linked from this PR if none exists yet: the user's traits are not modelled, so a premium user is refused above the default rule's limit.

  • [minor] Cancel/Done race. If the runtime's Done arrives after CancelUpload has restored the draft, the message exists on the server and the files are back in the tray, so the user may resend them. Ignoring a Done for a cancelled nonce, or dropping the restored files on Done, would avoid a duplicate. This is low priority.

CI: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci was green locally on 19baf68 ("all steps passed"; livekit-interop was skipped, as by default).

Verdict: Changes requested. One blocking finding: the SendDraft arm in uploads.rs bypasses Text chat 11's send checks. Everything else is minor.

## Independent review: Text chat 12 (core-uploads) I reviewed `git diff 53fbd6f..origin/textchat-12-core-uploads` (commit 19baf68) without reading the implementer's notes first. **Checks** 1. **Plan tests:** all 13 tests the plan names are in `tests/chat_uploads.rs`, and each asserts what the plan says. The values match the spec: 25 MiB default, 10 files, `SPOILER_` with flag 8, `attachments[i].id = i`, presigned `file_size`/`content_type`, and `message.txt` as `text/plain`. There are 3 extra tests. `size_limit_from_resolved_limits_and_premium` asserts that the premium rule does **not** apply, because `UserPrivate` has no traits yet. Task 10 already documents this gap; see minor finding 3. 2. **Interfaces:** `UploadRefusal::{TooLarge{max}, TooMany{max}, NoPermission}` is in `chat.uploads.refusal`. `selectors::upload_tray(&App, channel) -> Vec<TrayItem{name,size,kind: FileKind,spoiler,description}>` and `selectors::upload_progress(&App, &str) -> Option<f32>` exist as written. `UploadPath` comes from `features.presigned_attachment_uploads`, which is in the server's `InstanceController.ts:109`. Cancel emits `UploadCommand::Cancel`. `UploadJob` loses `Eq`; nothing downstream needs it. 3. **Invariants:** there are no new dependencies and no Cargo changes. fluxer-core holds only `FileRef`s, and `FileSource::Text` is the sanctioned Task 10 form. Logs carry no paths, URLs or text: the only tracing is `debug!` lines that name channel ids. There are no new fixtures; the tests use the existing server-shaped `well_known`/`ready`/`message_attachments` fixtures. Out-of-range indexes, unknown nonces and unknown channels are no-ops; the tests cover them. 4. **Review Focus 4:** limits come from the instance's resolved limits, `resolve_limits` with the target channel's guild features. Payload `id` = tray index. The presigned fields are left for the runtime, as Task 5 expects. 5. **Local CI:** see the CI line below. **Findings** - **[blocking] The `SendDraft` arm in `uploads.rs` (`on_user`) bypasses Text chat 11's send checks once #309 merges.** The plan says Task 12 coordinates with Task 11 "by touching only the `send_with_files` function it leaves as a stub". This PR also makes the uploads reducer call `composers.send_with_files` on every `UserAction::SendDraft`. On `origin/textchat-11-core-composer`, `Composers::send` returns early in four cases and leaves the files in the draft: - an inline edit is active, where Enter saves the edit and "the draft waits"; - a slowmode cooldown is running; - an `@everyone`/`@here` confirm is pending (`Confirm::Everyone`); - the wire length is over the limit. `chat::reduce` runs `composer.reduce` and then `uploads.reduce` in the same event. So after the merge, the uploads arm sends the files in every one of those cases. That means an upload during slowmode, a draft sent while the user is editing another message, and an `@everyone` message sent with no confirm and with raw content instead of `to_wire` content. This sits in uploads.rs, which #309 does not touch, so it will merge **without a textual conflict** and nobody will notice it. Fix: drop the `SendDraft` arm, or gate it on the legacy path, e.g. only when `ctx.legacy_send`, which #309 introduces. Make `Composers::send` the only caller of `send_with_files`, and have the tests reach it through the `SendDraft` path that remains. At minimum, the PR body and a follow-up issue must say that the integrator has to remove this arm when #309 lands. A note about `resolve_limits`/`limits_of` alone is not enough. - **[minor] `PasteLongText` files the whole draft, not just the pasted text.** The action carries no text, so the draft text the user already wrote moves into `message.txt` as well. The original converts only the pasted part. No text is lost, because it ends up in the file, but this differs from the original. A follow-up should give `PasteLongText` the pasted text, which is a Task 10 port change. - **[minor] Before #309 lands, one `SendDraft` can send two messages.** Foundation's `Messages::send_draft` sends the `ui.drafts` text and the uploads job sends the files. This is transitional; the PR body already notes it. - **[minor] Premium-aware size limit not applied.** The spec says "premium aware" for this rule, so it needs a `follow-up` issue linked from this PR if none exists yet: the user's traits are not modelled, so a premium user is refused above the default rule's limit. - **[minor] Cancel/Done race.** If the runtime's `Done` arrives after `CancelUpload` has restored the draft, the message exists on the server and the files are back in the tray, so the user may resend them. Ignoring a `Done` for a cancelled nonce, or dropping the restored files on `Done`, would avoid a duplicate. This is low priority. **CI:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` was green locally on 19baf68 ("all steps passed"; livekit-interop was skipped, as by default). **Verdict:** **Changes requested.** One blocking finding: the `SendDraft` arm in `uploads.rs` bypasses Text chat 11's send checks. Everything else is minor.
The uploads reducer no longer calls send_with_files on every SendDraft,
which would have bypassed Text chat 11's send checks (inline edit,
slowmode, the @everyone confirm, the length limit) without a textual
conflict. The composer's stub reducer calls it instead; Text chat 11
replaces that function, so its send becomes the only caller.

Refs #262

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

Review addressed in 4705987 (plus a merge of current origin/textchat):

  • [blocking] fixed: the SendDraft arm is gone from uploads.rs. The composer's stub reduce (the function Text chat 11 replaces) now calls send_with_files on SendDraft, so merging #309 conflicts textually there and #309's send is the only caller after its checks. Tests still reach it through SendDraft. AttachAndSend still calls it from the uploads reducer; noted in the PR body for the #309 merge.
  • Premium: #185 already tracks traits; linked in the body.
  • PasteLongText whole draft: follow-up #335.
  • Cancel/Done race: follow-up #336.
  • Double send before #309: transitional, unchanged.

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally on 4705987.

Review addressed in 4705987 (plus a merge of current `origin/textchat`): - **[blocking] fixed:** the `SendDraft` arm is gone from `uploads.rs`. The composer's stub `reduce` (the function Text chat 11 replaces) now calls `send_with_files` on `SendDraft`, so merging #309 conflicts textually there and #309's `send` is the only caller after its checks. Tests still reach it through `SendDraft`. `AttachAndSend` still calls it from the uploads reducer; noted in the PR body for the #309 merge. - Premium: #185 already tracks traits; linked in the body. - `PasteLongText` whole draft: follow-up #335. - Cancel/Done race: follow-up #336. - Double send before #309: transitional, unchanged. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally on 4705987.
Author
Owner

Independent review: Text chat 12 (core-uploads)

Scope: git diff 9fcc13d..origin/textchat-12-core-uploads (head 2c32af2), read cold.

(1) Plan tests. All 13 named tests exist in crates/fluxer-core/tests/chat_uploads.rs. They assert what the plan asks, using the spec's values: 25 MiB default, a whole batch refused when one file is over the limit, 10 files, count checked before size, SPOILER_ prefix plus flag 8, id = tray index in payload_json, presigned mode from features.presigned_attachment_uploads, progress 0.25 and 1.0, Done and gateway echo, Failed then Retry with the same spec, Cancel, message.txt / text/plain. There are also 3 extra tests (dialog, file kinds, logout). size_limit_..._premium checks that the premium rule does not apply, because UserPrivate has no traits yet. That is deferred to #185 and fine.

(2) Interfaces. UploadRefusal::{TooLarge { max }, TooMany { max }, NoPermission} is in app.chat.uploads.refusal. selectors::upload_tray(&App, channel) -> Vec<TrayItem { name, size, kind: FileKind, spoiler, description }> and selectors::upload_progress(&App, nonce) -> Option<f32> exist exactly as written. UploadPath comes from discovery. Cancel emits UploadCommand::Cancel. UploadJob gains spec/draft and loses Eq. No consumer exists yet, so this breaks nothing.

(3) Invariants. fluxer-core gains no dependency. It holds only FileRefs, and FileSource::Text is the sanctioned port shape. No bytes, upload URLs or paths are in logs: the tracing::debug! calls print only channel ids. No new fixture (the tests reuse message_attachments.json). Server-provided data cannot cause a panic: indices are bounds-checked, moves are clamped, progress is clamped, and an unknown nonce or channel is ignored. The presigned payload carries file_size/content_type, and the platform falls back to application/octet-stream, so it is never empty (the server's createStringType(1,255) would reject an empty string).

(4) Review Focus 4. In the payload, attachments[i].id = i follows the order of files[n]. The presigned path is chosen by features.presigned_attachment_uploads. Limits come from the instance's resolved limits via resolve_limits for the target channel's guild. OK for the core side.

Findings

  • minor. Until Text chat 11 lands, SendDraft is handled twice: Messages::send_draft (text from ui.drafts) and Composers::send_with_files (files from chat.composer). With text in ui.drafts and files in the tray, the user gets two messages: the text alone, then the files with empty content. Nothing is lost, there is no UI path yet, and #309 replaces the stub. Recording it so the #309 merge removes the Foundation path for this case.
  • minor. FilePurpose::AttachAndSend calls send_with_files directly and skips Text chat 11's send checks (slowmode, inline edit, @everyone confirm). The PR body already notes this. Fold it into the #309 merge, together with merging resolve_limits and limits_of.
  • minor. No action clears uploads.refusal. Two identical refusals in a row (e.g. two NoPermission drops) leave the value unchanged, so a UI that opens the modal when the value changes cannot see the second one. Text chat 26 will want DismissUploadRefusal. Already noted in the PR body. Suggest filing it as a follow-up linked here.
  • minor. ChannelDelete and logout drop jobs that are still uploading without emitting UploadCommand::Cancel, so the runtime may finish a transfer nobody tracks. Logout probably tears the runtime down anyway. The runtime side (Text chat 21) should cancel on channel delete, or core should emit the cancel.

No blocking findings.

(5) CI. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a fresh review worktree at 2c32af2: green (all steps passed, exit 0; livekit-interop skipped as usual).

Verdict: approve (0 blocking, 4 minor; the minor items belong to the #309 merge and Text chat 21/26).

## Independent review: Text chat 12 (core-uploads) Scope: `git diff 9fcc13d..origin/textchat-12-core-uploads` (head 2c32af2), read cold. **(1) Plan tests.** All 13 named tests exist in `crates/fluxer-core/tests/chat_uploads.rs`. They assert what the plan asks, using the spec's values: 25 MiB default, a whole batch refused when one file is over the limit, 10 files, count checked before size, `SPOILER_` prefix plus flag 8, `id` = tray index in `payload_json`, presigned mode from `features.presigned_attachment_uploads`, progress 0.25 and 1.0, Done and gateway echo, Failed then Retry with the same spec, Cancel, `message.txt` / `text/plain`. There are also 3 extra tests (dialog, file kinds, logout). `size_limit_..._premium` checks that the premium rule does **not** apply, because `UserPrivate` has no traits yet. That is deferred to #185 and fine. **(2) Interfaces.** `UploadRefusal::{TooLarge { max }, TooMany { max }, NoPermission}` is in `app.chat.uploads.refusal`. `selectors::upload_tray(&App, channel) -> Vec<TrayItem { name, size, kind: FileKind, spoiler, description }>` and `selectors::upload_progress(&App, nonce) -> Option<f32>` exist exactly as written. `UploadPath` comes from discovery. Cancel emits `UploadCommand::Cancel`. `UploadJob` gains `spec`/`draft` and loses `Eq`. No consumer exists yet, so this breaks nothing. **(3) Invariants.** fluxer-core gains no dependency. It holds only `FileRef`s, and `FileSource::Text` is the sanctioned port shape. No bytes, upload URLs or paths are in logs: the `tracing::debug!` calls print only channel ids. No new fixture (the tests reuse `message_attachments.json`). Server-provided data cannot cause a panic: indices are bounds-checked, moves are clamped, progress is clamped, and an unknown nonce or channel is ignored. The presigned payload carries `file_size`/`content_type`, and the platform falls back to `application/octet-stream`, so it is never empty (the server's `createStringType(1,255)` would reject an empty string). **(4) Review Focus 4.** In the payload, `attachments[i].id = i` follows the order of `files[n]`. The presigned path is chosen by `features.presigned_attachment_uploads`. Limits come from the instance's resolved limits via `resolve_limits` for the target channel's guild. OK for the core side. **Findings** - **minor.** Until Text chat 11 lands, `SendDraft` is handled twice: `Messages::send_draft` (text from `ui.drafts`) and `Composers::send_with_files` (files from `chat.composer`). With text in `ui.drafts` and files in the tray, the user gets two messages: the text alone, then the files with empty content. Nothing is lost, there is no UI path yet, and #309 replaces the stub. Recording it so the #309 merge removes the Foundation path for this case. - **minor.** `FilePurpose::AttachAndSend` calls `send_with_files` directly and skips Text chat 11's send checks (slowmode, inline edit, `@everyone` confirm). The PR body already notes this. Fold it into the #309 merge, together with merging `resolve_limits` and `limits_of`. - **minor.** No action clears `uploads.refusal`. Two identical refusals in a row (e.g. two `NoPermission` drops) leave the value unchanged, so a UI that opens the modal when the value changes cannot see the second one. Text chat 26 will want `DismissUploadRefusal`. Already noted in the PR body. Suggest filing it as a follow-up linked here. - **minor.** `ChannelDelete` and logout drop jobs that are still uploading without emitting `UploadCommand::Cancel`, so the runtime may finish a transfer nobody tracks. Logout probably tears the runtime down anyway. The runtime side (Text chat 21) should cancel on channel delete, or core should emit the cancel. No blocking findings. **(5) CI.** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a fresh review worktree at 2c32af2: green (all steps passed, exit 0; livekit-interop skipped as usual). Verdict: **approve** (0 blocking, 4 minor; the minor items belong to the #309 merge and Text chat 21/26).
Task 11 (composer) is not on origin/textchat yet; origin/textchat itself
was already merged. The composer's send runs its checks (inline edit,
slowmode, @everyone confirm, length limit) and hands a draft with files
to send_with_files, which now uses the converted wire content and
allowed_mentions, returns whether the job started, and does the send's
bookkeeping (typing, autocomplete, draft save; slowmode in send).
Uploads::reduce takes the ComposerEnv so a Shift-drop send converts too.
The Foundation SendDraft path still uploads tray files. limits_of is
folded into resolve_limits(channel).

Refs #262

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charles manually merged commit eaafba96a5 into textchat 2026-11-12 20:59:04 +00:00
Author
Owner

Independent review, Task 12 (core-uploads), reviewed after merge (PR already merged into textchat as eaafba9). Diff reviewed: 79af1e1...origin/textchat-12-core-uploads (fluxer-core only; the two-dot diff also shows textchat commits the branch predates, which are not this task).

  1. Tests: all 13 tests the plan names exist in crates/fluxer-core/tests/chat_uploads.rs and assert the spec values (25 MiB default, 10-file cap, ATTACH_FILES, SPOILER_ + flag 8, tray order, multipart vs presigned from features.presigned_attachment_uploads, progress 0.25, Done/echo replace pending, Failed keeps files for RetrySend, Cancel emits UploadCommand::Cancel and restores the draft, message.txt / text/plain).
  2. Interfaces: UploadRefusal::{TooLarge{max},TooMany{max},NoPermission}, app.chat.uploads.refusal, selectors::upload_tray -> Vec<TrayItem{name,size,kind:FileKind,spoiler,description}>, selectors::upload_progress(&App,&str)->Option, Composers::send_with_files present as written.
  3. Invariants: no new deps; no iced/wgpu/winit/reqwest/tungstenite in fluxer-core; no file bytes or upload URLs in core (FileRef only, Debug redacts path/text); the presigned feature key matches fluxer_api InstanceController.ts:109; server data paths do not panic (saturating/min/clamp, unknown channel ignored).
  4. Review Focus 4: limits come from resolve_limits (instance resolved limits); wire shape of multipart/presigned is the runtime task, not this one.
  5. cargo xtask ci in the review worktree: green (exit 0).

Findings:

  • minor: premium-aware size limit (spec 6.2) is not applied, since user traits are not modelled; the test documents it. Already a Text chat 10 follow-up; no new issue needed.
  • minor: CancelUpload on a Failed job removes it without UploadCommand::Cancel (correct, nothing in flight), worth a line in the runtime task so it does not expect a Cancel for failed jobs.

Verdict: APPROVED (no blocking findings, local CI green).

Independent review, Task 12 (core-uploads), reviewed after merge (PR already merged into textchat as eaafba9). Diff reviewed: 79af1e1...origin/textchat-12-core-uploads (fluxer-core only; the two-dot diff also shows textchat commits the branch predates, which are not this task). 1. Tests: all 13 tests the plan names exist in crates/fluxer-core/tests/chat_uploads.rs and assert the spec values (25 MiB default, 10-file cap, ATTACH_FILES, SPOILER_ + flag 8, tray order, multipart vs presigned from features.presigned_attachment_uploads, progress 0.25, Done/echo replace pending, Failed keeps files for RetrySend, Cancel emits UploadCommand::Cancel and restores the draft, message.txt / text/plain). 2. Interfaces: UploadRefusal::{TooLarge{max},TooMany{max},NoPermission}, app.chat.uploads.refusal, selectors::upload_tray -> Vec<TrayItem{name,size,kind:FileKind,spoiler,description}>, selectors::upload_progress(&App,&str)->Option<f32>, Composers::send_with_files present as written. 3. Invariants: no new deps; no iced/wgpu/winit/reqwest/tungstenite in fluxer-core; no file bytes or upload URLs in core (FileRef only, Debug redacts path/text); the presigned feature key matches fluxer_api InstanceController.ts:109; server data paths do not panic (saturating/min/clamp, unknown channel ignored). 4. Review Focus 4: limits come from resolve_limits (instance resolved limits); wire shape of multipart/presigned is the runtime task, not this one. 5. cargo xtask ci in the review worktree: green (exit 0). Findings: - minor: premium-aware size limit (spec 6.2) is not applied, since user traits are not modelled; the test documents it. Already a Text chat 10 follow-up; no new issue needed. - minor: CancelUpload on a Failed job removes it without UploadCommand::Cancel (correct, nothing in flight), worth a line in the runtime task so it does not expect a Cancel for failed jobs. Verdict: APPROVED (no blocking findings, local CI green).
Sign in to join this conversation.
No description provided.