Skip to content

fix(react): pass freshly streamed content to onComplete in useStreaming (#308) - #318

Open
KrazyArcher wants to merge 1 commit into
hanzoai:mainfrom
KrazyArcher:fix-issue-308
Open

KrazyArcher wants to merge 1 commit into
hanzoai:mainfrom
KrazyArcher:fix-issue-308

Conversation

@KrazyArcher

Copy link
Copy Markdown

Fixes #308

Summary

  • Accumulates streamed chunks locally (accumulatedContent) during streamMessage execution so onComplete(completeMessage) receives the exact text produced by the current stream instead of reading the stale currentMessage closure value.
  • Removes currentMessage from the useCallback dependency array so streamMessage stays referentially stable across chunk updates.
  • Adds unit tests (pkg/react/src/hooks/useStreaming.test.mjs) verifying sequential stream calls ("Hel" + "lo" followed by "By" + "e").

Verification

  • node --test pkg/react/src/hooks/useStreaming.test.mjs -> Passed ✅

This branch has not been deployed

No deployments
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.

useStreaming passes the previous reply to onComplete, not the one just streamed

1 participant