Skip to content

🚰 refactor: Move the Pure Stream Code into the @librechat/chat Core - #16979

Merged
berry-13 merged 1 commit into
devfrom
berry-13/chat-stream-core
Oct 11, 2026
Merged

berry-13 merged 1 commit into
devfrom
berry-13/chat-stream-core

Conversation

@berry-13

Copy link
Copy Markdown
Collaborator

Summary

The stream code that turns server frames into message content is pure TypeScript, yet it lives in client/src/hooks/SSE, so another host cannot reuse it and nothing stops it from picking up app imports. This is link 5 of the @librechat/chat stack: the step appliers (steps/*), normalizeFrame (transport/frames.ts) and the SSE transport (transport/sse.ts) move with git mv into the package core, together with their four specs, and the client imports them from @librechat/chat. This is the first link where the client depends on the package, so the client build, its jest mapping, the lockfile and the CI jobs that typecheck, test or build the client now build or download the package's dist; the Dockerfiles already build it before the client.

The content applier read two ask-user-question predicates from ~/utils/approval. They move to core/ask.ts with the answered-actions set they read, and utils/approval.ts re-exports them, so its consumers are unchanged. Behavior is unchanged: the moved files differ only in that import and one return type the package's isolatedDeclarations requires.

Open PRs #16508 (steps/content.ts, steps/tools.ts, steps.spec.ts) and #16092 (useStepHandler.ts imports) will need to follow the rename to packages/chat/src/core.

Type of change

  • Refactor
  • Tests / tooling / CI

Testing

Tested environments/configuration:

  • Node 24, npm ci from the public registry, full turbo build including the client

Automated tests:

  • packages/chat: tsc --noEmit clean, jest 88 of 88 under the node environment, including the moved frames, sse, steps and transport specs unchanged
  • client: src/hooks/SSE 12 suites, 423 tests (useStepHandler, useResumableSSE, useResumeOnLoad among them), resolving @librechat/chat from packages/chat/dist; related tests of utils/approval.ts and ChatTransportContext.tsx, 549 suites; tsc --noEmit clean
  • Added a scenario to chat-package.spec.ts that resolves @librechat/chat from the client workspace to dist/index.cjs and loads the stream API through CJS and ESM with every UI module blocked; the step-reducer, tool-steps and chat-facade-transport mock scenarios stream through the built client
  • npm run build: the client bundle builds against the package dist

Screenshots / recordings

No user-facing change.

Risk / compatibility

sse.js becomes a dependency of the package; the client keeps its own entry because useSubagentActivityStream imports it directly. The package's lint block gains the _-prefix convention for unused names that the moved specs used under the client config. The lockfile only records the two new dependency edges.

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
  • Required dependency changes have been merged/published
  • Required documentation PR: N/A

Copilot AI balanced review requested due to automatic review settings October 10, 2026 23:05

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.

The step appliers, frame normalizer and SSE transport move from client/src/hooks/SSE into packages/chat/src/core with their specs, and the client imports them from @librechat/chat. The ask-user-question predicates the content applier reads move with them, and the client's approval module re-exports them so its consumers are unchanged.
@berry-13
berry-13 force-pushed the berry-13/chat-stream-core branch from f14b30c to 2ed7c6c Compare October 10, 2026 23:13
@berry-13
berry-13 marked this pull request as ready for review October 11, 2026 16:07
@berry-13
berry-13 requested a review from danny-avila as a code owner October 11, 2026 16:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T16:13:54.004431Z 2ed7c6c Draft marked ready
🔒 Security Review ✅ Completed 2026-10-11T16:10:34.949950Z 2ed7c6c Draft marked ready
ℹ️ 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.

@berry-13
berry-13 merged commit bdc4baf into dev Oct 11, 2026
47 checks passed
@berry-13
berry-13 deleted the berry-13/chat-stream-core branch October 11, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants