LibreChat/client
Danny Avila db675209e8
🧩 refactor: Extend Step Status To Remaining Cards; Separate Cancelled From Failed (#14873)
* 🧩 fix: Extend Explicit Step Status To Specialized Tool Cards

Follow-up to #14871, which covered the generic tool card and the five
sharing `useToolCallState` but left the cards carrying their own
cancellation logic on the whole-message heuristic.

Each needed its own treatment rather than a forwarded prop:

- `RetrievalCall` is the exact analog of the reviewed shape.
- `WebSearch` feeds `effectiveProgress` into `finalizing` and `complete`
  as well, so forcing it terminal naively would strand a cancelled final
  search as "finalizing" forever. A closed step now settles on its own
  status instead of waiting for the submission to end.
- `OpenAIImageGen` resolves through `computeCancelled`, which now
  short-circuits on explicit status ahead of both the agent and legacy
  paths — the legacy path has no submitting signal at all, so this is
  the first real stop signal it has ever had.

In all three the status is authoritative on its own terms: never gated
on the output-parsing error check, a closed step forces progress
complete so it cannot keep animating, and `failed` reports as an error
even when the output text looks benign. The prior heuristic remains the
fallback for messages saved before `on_run_step_closed`.

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

* 🧩 fix: Resolve Subagent Card State From Closed Step Status

`SubagentCall` uses a tri-state (`running`/`cancelled`/`finished`) built
from the subagent's own phase envelopes plus `!isSubmitting`, so it
could not distinguish "this subagent was stopped" from "the parent
stream ended for some other reason" — the distinction `on_run_step_closed`
exists to make.

A closed step now resolves the tri-state directly: `cancelled` maps to
the cancelled state, `completed` and `failed` both count as finished,
and `failed` additionally reports as an error. The phase-and-isSubmitting
inference remains the fallback for messages predating the event.

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

* 🩹 fix: Give `failed` Its Own Terminal Path In Each Card

Codex found the same mistake in three places: I resolved `cancelled`
carefully and let `failed` fall through into a success or in-progress
path. Forcing a closed step's progress to 1 made that visible rather
than latent.

- `OpenAIImageGen`: `hasError` did not account for the status, so a
  failed generation rendered and announced as a finished image. Updated
  to match every other card.

- `WebSearch`: a failed close left `complete` false and dropped the card
  into the streaming branch, shimmering forever. `error` now folds into
  the `cancelled` early-return, which is where an errored search has
  always gone — rather than inventing a failure UI this component has
  never had.

- `RetrievalCall`: the live region did not consult `errorState`, so a
  failed retrieval announced "retrieved files" while the card showed a
  failure. Announces the failure first now, mirroring the same fix made
  to `ToolCall` in #14871.

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

* 🧯 fix: Separate Cancelled From Failed, Stop Terminal-Step Timers

Codex round 2. Two distinct classes, plus the same leak in already-merged
code.

Rendering — cancellation and failure were collapsed:

- `OpenAIImageGen` fed `cancelled` into `ProgressText`'s `error` prop, so
  a user-stopped generation read "image generation failed" visually
  while the live region announced "cancelled". Meanwhile a `failed`
  close reached neither consumer, since `computeCancelled` returns false
  for it — adding the status to `hasError` alone changed nothing.
  `ProgressText` now takes `cancelled` alongside `error`, and both the
  card and the live region resolve the two states independently.

Timers — masking a hook's output does not stop it:

- `useProgress` keeps a 200ms interval alive whenever its input is below
  1, and a closed step usually never receives the completion that would
  raise it. Every site that masked the result now passes the terminal
  value in instead, so a closed card schedules nothing.
- The agent-style image ticker had the same problem one layer up: its
  interval effect ignored the close entirely and its cleanup keyed on
  `cancelled`, so a step closed as `failed` mid-submission kept
  rerendering for up to ~50s. Both effects now observe the close.
- `ToolCall` and `useToolCallState` carried the identical masking from
  #14871; fixed here rather than left as a known leak in merged code.

Also dropped a JSDoc line that narrated its own assignments.

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

*  fix: Failure Outranks Cancellation; Update The Test That Encoded The Conflation

Codex round 3, plus the CI failure it explains.

- Failure now takes precedence over cancellation in both `ProgressText`
  and the image-gen live region. The legacy inference folds `hasError`
  into its cancellation signal, so checking `cancelled` first relabelled
  a genuine failure on an older saved message as a user stop — a
  regression introduced by the previous commit.

- `RetrievalCall` passed `finishedText={intent ?? 'Retrieved files'}`
  regardless of state, so a cancelled retrieval read "Retrieved files"
  beside a cancellation icon while the live region announced
  "Cancelled". The finished label is now cancellation-aware.

- `OpenAIImageGen.test.tsx` asserted `data-error === 'true'` for a
  heuristically cancelled step — the exact conflation this work removes.
  Updated to the new contract and extended with cases for explicit
  cancellation, explicit failure with benign output, and failure
  precedence under the legacy inference.

Verified locally for the first time in this work stream: building the
`@librechat/client` and `data-provider` workspaces made the client suite
runnable here. 15/15 in the image-gen spec, 851/851 across
`Content` and `hooks/SSE`.

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

* 🧹 style: Drop Narrating Comment From Cancellation Test

The test name and the `data-cancelled` / `data-error` expectations state
the contract on their own; the JSDoc above them only restated it.

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

* ⚖️ fix: Explicit Cancellation Outranks Parsed Errors; Force Progress Synchronously

Codex round 5, both findings consequences of round 3's fixes.

- Failure precedence was applied unconditionally, so a step explicitly
  closed as `cancelled` whose output happens to be error-formatted —
  aborting a tool can itself produce one — reported failure despite an
  authoritative status saying otherwise. Precedence is now scoped to the
  legacy inference, which is the only path that folds `hasError` into
  its own cancellation signal. Explicit cancellation wins.

- Passing 1 into `useProgress` stops its interval but does not make the
  returned value 1 on that render: the hook settles through 0.99 and a
  200ms timeout. For a step closing while mounted, that window rendered
  a failed retrieval as "Searching files" and left a completed one
  shimmering. Both halves are needed — pass 1 in to stop the timer, mask
  the result so the terminal value is observable immediately — in
  `RetrievalCall`, `ToolCall`, `useToolCallState` and `OpenAIImageGen`.

Regression test added for the cancellation-outranks-error case.
16/16 in the image-gen spec, 851/851 across Content and hooks/SSE.

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

* 🛑 fix: Explicit Subagent Cancellation Outranks Child Error Phase

Codex round 6.

- `SubagentCall` checked `hasError` before cancellation, so a subagent
  explicitly closed as `cancelled` whose last live envelope carried the
  `error` phase — which aborting a child can produce — rendered "Agent
  errored" instead of cancelled. Scoped the same way as the image path:
  the live error phase is suppressed when the authoritative close says
  cancelled.

- Removed a narrating comment in `WebSearch`; `isClosed`,
  `effectiveProgress`, `finalizing` and `complete` name the flow.

852/852 across Content and hooks/SSE.

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

* 🧽 style: Sweep The Narrating Failure Comments

Codex flagged two; the same one-line paraphrase of `runStepStatus ===
'failed'` had been copied into five files, so all five are removed
rather than leaving three to surface next round. The named `hasError` /
`errorState` / `error` booleans carry it.

The remaining comments in these files explain non-obvious behavior
rather than restating code — why `useProgress` needs both the terminal
argument and the mask, why an errored web search renders as nothing, and
which precedence applies to the legacy inference versus an explicit
close.

852/852 across Content and hooks/SSE. Typecheck baseline is now 1 error
(`useRum.ts`, unrelated) rather than 487, since building the
`@librechat/client` workspace resolved the module errors that were
masking it — identical with this diff and at the branch point.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-16 08:50:20 -04:00
..
public 🪢 feat: Langfuse Fanout Connection Setting (#14108) 2026-07-29 18:33:10 -04:00
scripts
src 🧩 refactor: Extend Step Status To Remaining Cards; Separate Cancelled From Failed (#14873) 2026-08-16 08:50:20 -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
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