LibreChat/client
Danny Avila 2f50e38217
📎 fix: Never Let a Stalled Attachment Disable the Composer (#15013)
* 🖼️ fix: Keep Composer Send Enabled When an Attachment Stalls

The composer's send button is gated on `hasIncompleteFiles(files)`, so any
attachment that can never reach `progress: 1` reads as "still uploading" and
disables send for the rest of the session — draft text intact, no error, no
way out but removing the chip or reloading. Two paths could park an
attachment there:

- `loadImage` starts the upload from `img.onload` and had no `onerror`, so an
  image the browser refuses to decode (unsupported codec, truncated bytes, a
  revoked object URL) never uploaded at all and stranded the file at
  `progress: 0.2`. Drop the file and surface the error instead.
- Upload completion reconciled against `temp_file_id`, the server's echo of
  the id the request was sent with, while every client-side handle for that
  upload — file map key, delayed-toast timer, recovery callbacks — is keyed by
  the id the client owns. A mismatch applied the completion update to a key
  that does not exist, leaving the attachment at `progress: 0.9`.

Covered by unit regressions in the file-handling suite and a composer-level
spec that drives a real upload through `ChatForm`, plus a render-bound guard
on typing (react-scan measures one ChatForm render per keystroke in a browser;
the guard fails on a multiplier).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cq3tev2rPbc2pWyVJwnh6u

* 🧹 fix: Stop the Draft Restore From Clobbering Live Composer Attachments

`restoreFiles` runs on every `QueryKeys.files` write — an upload landing, an
SSE attachment mid-run — not just on a conversation swap, and it was written
as if the draft were always the whole truth:

- An empty draft cleared the composer outright. On the swap path that is
  redundant (the effect already clears explicitly one line earlier); on the
  cache path an empty draft only means the draft write has not caught up, so
  clearing there discards an attachment the user just added — and with no text
  typed, the send button has nothing left to submit. Restoring now only adds.
- A match replaced the composer's entry with the persisted record, dropping the
  local `File`, the blob preview the chip renders from (`FileRow` falls back to
  refetching `filepath`), and the tool resource the upload was staged under,
  and stamping `attached: true` so removing a chip the composer still owns
  leaves the file orphaned server-side. It now layers the record over the live
  entry and leaves `attached` to files actually adopted from a draft.

Confirmed against a real browser run: the entry is at `progress: 0.9` when this
restore fires, so it — not the upload's own completion — is what was re-enabling
send. react-scan render counts are unchanged (typing 20 keystrokes: 111 renders,
ChatForm=20; attaching an image: 1373, FileRow=6).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cq3tev2rPbc2pWyVJwnh6u

* 🔗 fix: Keep an Attachment's Stored Temporary Id Equal to Its Map Key

Two follow-ups from review on the upload reconciliation.

Completion stored the server's `temp_file_id` echo in the entry's value while
keying the map by the id the request was sent with. `useFileDeletion` deletes
map entries by the value's own `file_id` and `temp_file_id`, so where the two
disagreed — the exact case the reconciliation exists to tolerate — Remove would
delete the file server-side and leave the chip behind, and the draft restore
could not correlate its saved key with the cached record. Store the request id.

A refused image decode also left its `uploadScope.recent` reservation behind:
reservations are released by the render that observes the file in the shared
state, which a decode failing before that render never reaches, and once the
file is deleted no later render can either. The ghost is merged into every
later batch's validation, so re-picking the same file reads as a duplicate and
its size keeps counting against the composer's limits.

Both covered; both new guards fail without their fix. Also sorts the composer
spec's imports, which the static-checks import-order gate flagged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cq3tev2rPbc2pWyVJwnh6u

* 🧷 fix: Normalize an Upload's Temporary Id at the Cache Boundary

The composer keys its file map — and the draft it saves — by the `file_id` the
upload request was sent with; `temp_file_id` is only the server's echo of that
id. The previous commit reconciled the composer's own entry against the request
id but left the record the mutation inserts into `QueryKeys.files` carrying the
raw echo, and `restoreFiles` can only correlate a saved draft id by matching a
cached record's `file_id` or `temp_file_id`. Where the echo disagreed the draft
matched neither, so the attachment was silently dropped on the next conversation
switch or reload — the same class of loss, one layer further out.

Normalize once where the response enters client state, and hand the normalized
record to the mutation's callers, so the cache, the composer entry and the draft
all agree on one id. An agreeing response is passed through untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cq3tev2rPbc2pWyVJwnh6u

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-19 14:24:11 -04:00
..
public 🪢 feat: Langfuse Fanout Connection Setting (#14108) 2026-07-29 18:33:10 -04:00
scripts
src 📎 fix: Never Let a Stalled Attachment Disable the Composer (#15013) 2026-08-19 14:24:11 -04:00
sw
test 🔒 chore: Upgrade react-router-dom to v7.18.2 (security) (#14582) 2026-08-01 17:19:52 -04:00
babel.config.cjs
check_updates.sh
index.html 📡 feat: add rum browser page-load diagnostics (#14106) 2026-07-05 11:32:53 -04:00
jest.config.cjs 🚀 chore: Prepare v0.8.8-rc1 (#14394) 2026-08-14 03:24:59 -04:00
jest.resolver.cjs
nginx.conf
package.json 🚀 chore: Prepare v0.8.8-rc1 (#14394) 2026-08-14 03:24:59 -04:00
postcss.config.cjs
tailwind.config.cjs 🎨 feat: Color the Context Gauge by Category and Collapse its Breakdown (#14855) 2026-08-14 22:46:10 -04:00
tsconfig.json
vite.config.ts 🎨 refactor: adopt the @librechat/client design system (semantic color tokens + component migration) (#13879) 2026-08-06 09:15:17 -04:00