Repository navigation
🚎 feat: Connect the Chat Transport to Live Generations - #18188
Conversation
c803582 to
d8803d1
Compare
d8803d1 to
944b6c1
Compare
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 944b6c10dc
ℹ️ 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".
| const close = (): void => { | ||
| controller.abort(); | ||
| finish(); | ||
| }; |
There was a problem hiding this comment.
Settle the opening promise when cancellation closes the stream
If the caller aborts while the SSE transport is refreshing a token after an initial 401, close() marks the iterable done but never settles the pending openStream() promise. In this scenario, createSSETransport has an already-closed XHR, and its refresh handler returns without emitting an event once the signal is aborted, so the onEvent branches that resolve this promise never run. Consequently, callers awaiting reconnectToStream() can remain pending indefinitely after cancellation. Resolve the unopened attachment to null directly on cancellation rather than relying on the wire to emit an abort event.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid. Fixed in fe2472c: closing the stream now resolves an attachment that has not opened to null itself instead of waiting for the wire to report an abort. Pinned by resolves null when the caller aborts an attachment whose wire reports nothing more in generation.spec.ts, which uses a wire that emits nothing on abort; it fails with the line removed (1 failed, 15 passed) and passes with it (16 passed).
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
The
Chatclass in@librechat/chathas no transport that talks to LibreChat. ItsChatTransportcontract (sendMessages,reconnectToStream,abort) is implemented only by in-memory fakes in tests, so nothing outside a spec can construct aChatand have it follow a real generation. The app's own chat runs on the hooks session instead, which is tied to the URL, the sidebar and the pane index and cannot be mounted a second time for a different conversation.This adds
createGenerationTransport, aChatTransportover the generation routes.reconnectToStreamasks the status route what is running for the chat, and when something is, opens that generation's stream withresume=trueand the generation'screatedAt, so the stream replays from its start and is fenced on that generation. AChatthat joins late therefore ends up holding what one that watched from the first frame holds. When nothing is running, or a different generation than the one named is running, it resolvesnulland opens no connection.Sending and stopping are supplied by the app as optional members. Without them the transport is view-only and refuses both with
ERR_VIEW_ONLY, which is the shape a subagent child thread needs: its stream is observed, never controlled.Second in a stack: it sits on #18187 (child thread read routes) and is the transport the child-thread pane will construct its
Chatwith. Related to #18169, which gave each background child its own generation job to attach to.How it works
The wire transport (
createSSETransport) reports events through a callback;Chatreads an async iterable.openStreambridges the two and decides what the first event means:The stream URL was assembled inline in
StreamSubscription.url(). It moves togenerationStreamUrlincore/protocol.ts, next to the protocol headers, and both the hooks session and the new transport build it there.Type of change
Testing
Tested environments/configuration:
Unit level only in this PR. The transport is exercised against a hand-driven wire, and once through the real
Chatclass:chat.resumeStream()reattaches, reads a step and a final frame, merges the final frame's messages and settlesready. Nothing in the app constructs it yet; the pane that does is the next PR in the stack and is where it is verified against a running server.Automated tests:
packages/chat/src/core/__tests__/generation.spec.ts(15 cases): inactive status, URL and headers of the attachment, frame order, dropped connection, 404/409 before attaching, other failures before attaching, a mismatched generation,close(), the caller's abort signal, view-only refusals, pass-through of a supplied send and stop, and the twoChatcases.subscription.spec.tsandchat.spec.tsstill pass (273 tests across the three files).npx tsc --noEmitinpackages/chat;npm run static-checks -- --against origin/dev.Screenshots / recordings
No user-facing change.
Risk / compatibility
The only behavior touched on an existing path is where the stream URL is built;
subscription.spec.tspins its path and query and is unchanged. The transport itself is new and unreferenced by the app.