Repository navigation
๐๏ธ feat: Apply Stream Metadata Through Shared Chat Handlers - #18398
Merged
Merged
Conversation
โฆ the Chat Event Applier
2 tasks done
Collaborator
Author
|
Codex Review: Didn't find any major issues. Breezy! 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". |
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. |
danny-avila
marked this pull request as ready for review
November 18, 2026 12:51
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A stream changes two kinds of state: the message list, and state kept beside it (token usage, the conversation's title, attachments a tool produced, the composer's steer chips).
createEventApplier, the reducer that lets aChatin@librechat/chatapply a stream the way main chat does, covered only the first. Frames of the second kind reached aChat's consumer as raw events throughonEvent, and a chat that joined a run late got nothing for them at all: a resume snapshot carries the run's usage so far, its title and its still-queued steers as fields, not as events, and only main chat's stream session read those fields.This gives the applier the second kind. It takes the handlers main chat's own stream session uses for that state and calls each one for the frames, live or carried by a snapshot, that main chat calls it for. A
Chathanded main chat's handlers keeps the state main chat keeps, in main chat's own stores, without a parallel copy.First of the steps that turn a followed conversation into a chat a reader can open and drive beside the main one. No user-facing change: nothing passes these handlers yet.
Related to #18190, #18195.
How it works
The handler interfaces already exist in the package core, where main chat's resumable session is defined (
ResumableUsage,ResumableEvents,ResumableSteersincore/resumable/host.ts). The applier's init takes them as optional fields.Two rules carried over from main chat. A steer's chip is settled the moment the server says the steer was taken, before its part can be drawn, because a chip left pending meanwhile could be sent again. And an empty
pendingSteerslist is still seeded, because it is what clears a chip whose steer was applied while the chat was away.A frame that needs its turn (an attachment, a usage event) and arrives before a frame has named the turn is held and applied once one does, the way early step events already are.
useFollowChattakes the same handlers asbesideand forwards each frame to the caller's current ones.Type of change
Testing
Tested environments/configuration:
Unit level. Not exercised in a browser: a background subagent's stream carries only step events and applied steers, so the one consumer of the applier today receives none of these frames.
Automated tests:
packages/chat/src/core/__tests__/apply.spec.ts, new "state beside the message list" (6 cases): each live frame reaches the handler main chat gives it, bound to the turn, in order; a snapshot rebuilds usage, context, the live estimate, chips and title, then applies the usage and attachment events it carries; an empty snapshot list still seeds the chips; a steer chip is settled before its part is drawn and marked when it is; frames that need a turn are held until one is named; with no handlers the messages are applied as before.follow.spec.tsx(1 new): the hook forwards an attachment to the caller's handler, and to the newer handler after a rerender.packages/chat:npx jest(3924 tests),npx tsc --noEmit.npm run static-checks -- --against origin/dev.Risk / compatibility
Every field is optional and absent everywhere today, so the applier behaves as it did. The steer chips are seeded without the generation's timestamp and protocol version, which main chat passes from its stream subscription and the applier is not given; both are optional there.