Skip to content

🛟 refactor: Move Resumable Transport Failure Handling Into the Chat Core - #17120

Merged
berry-13 merged 1 commit into
devfrom
refactor/chat-resumable-failure
Oct 15, 2026
Merged

berry-13 merged 1 commit into
devfrom
refactor/chat-resumable-failure

Conversation

@berry-13

Copy link
Copy Markdown
Collaborator

Pull Request

Before submitting, please review the Contributing Guide.

Documentation changes belong in the LibreChat documentation repository.

Summary

When a resumable stream's connection fails, useResumableSSE decides what the failure means: a 409 hands the attachment to a newer generation, a 404 settles the run from persisted history unless a status read shows it still live, an error the server wrote into the stream becomes the error card, and a dropped connection climbs a backoff ladder until a status read at the retry ceiling either keeps waiting on the run or settles it. That 630-line handler was one closure in the hook, writing to the query client, Recoil and Jotai directly.

This moves it into packages/chat/src/core/resumable/: failure.ts dispatches and owns the backoff and served-error paths, missing.ts the 404 recovery, ceiling.ts the retry-ceiling settle. The host interface gains the few operations they need by intent (the conversation snapshot read and its cache writes, the balance refresh, the pane's conversation update, the detached-run end, the error card and the message list), which the hook supplies from what it already reads. No behavior changes. Stacked on #17119.

Type of change

  • Refactor

Testing

Tested environments/configuration:

Not applicable: the handling is moved, not changed; the hook specs exercise every failure path through the host the hook builds.

Automated tests:

  • Added packages/chat/src/core/__tests__/failure.spec.ts against a fake host and scheduler: a failure after the final is ignored, a dropped connection backs off and re-attaches, a served error writes the error card and run end once the status proves the run over, a 404 settles from persisted history or keeps a still-live generation attached, and the retry ceiling either waits on a live run or settles a terminal one.
  • npx jest src/core in packages/chat (162 pass), and in client the hooks/SSE and hooks/Chat specs plus data-provider/SSE (1148 pass, existing specs unchanged).
  • npx tsc --noEmit in packages/chat and client, eslint, prettier and sort-imports on the changed files: clean.

Screenshots / recordings

No user-facing change.

Risk / compatibility

None.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T16:16:58.934933Z 2ea07cc New commits
🔒 Security Review ✅ Completed 2026-10-15T06:21:28.510392Z 9815753 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codegraph-librechat codegraph-librechat Bot added the 🗺️ Chat State codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) label Oct 15, 2026
@berry-13
berry-13 added this pull request to stack #17153 October 15, 2026 13:49
Copilot AI balanced review requested due to automatic review settings October 15, 2026 15:22
@berry-13
berry-13 force-pushed the refactor/chat-resumable-failure branch from 9815753 to 2f56b6d Compare October 15, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Base automatically changed from refactor/chat-resumable-terminal to dev October 15, 2026 15:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f56b6db95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};

/** The status route's answer for a conversation's generation. */
export interface StreamStatusResponse {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move the stream-status contract back to data-provider

StreamStatusResponse is an API response contract consumed by the client data-provider query layer, but this change moves its ownership into @librechat/chat, reversing the intended dependency and requiring API consumers to depend on the chat package. Keep the response type—and ideally the associated stream URL definition—in packages/data-provider, then consume or inject it from chat so the shared transport contract has one owner.

AGENTS.md reference: AGENTS.md:L203-L205

Useful? React with 👍 / 👎.

@berry-13
berry-13 force-pushed the refactor/chat-resumable-failure branch from 2f56b6d to 2ea07cc Compare October 15, 2026 16:12
@berry-13
berry-13 merged commit d4e52ac into dev Oct 15, 2026
39 checks passed
@berry-13
berry-13 deleted the refactor/chat-resumable-failure branch October 15, 2026 17:05
@codegraph-librechat codegraph-librechat Bot added the 🗺️ Async Run Streaming codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) label Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗺️ Async Run Streaming codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) 🗺️ Chat State codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants