fix(sdk-react): clear stale stream values after joinStream history refresh#2010
Conversation
…fresh Reset local stream state after join completion so hook values fall back to fresh /history data. Add a regression test for the stale-values case when joinStream refetches history but no final values event is applied. Fix langchain-ai#1969
|
|
Thank you for raising the PR, we are currently working on new SDK packages to integrate in different frontend frameworks, see #2001. I will incorporate your PR in there manually. |
|
Hi Christian Bromann (@christian-bromann) thanks for that info, I forgot for a moment about that PR |
Summary
This PR fixes a stale state issue in useStream/useStreamLGP after joinStream completes.
When joinStream succeeds and history is refetched, the hook could keep showing stale local stream
values if no final values event was applied.
This change clears local stream state after a successful history refresh so the hook falls back to the
latest /history values.
What Changed
history.mutate(threadId) returns a latest head.
Issue Fixed
Fixes a bug where joinStream could leave UI state stale (e.g. generating: true, outdated messages) even
after history was successfully refreshed.
Relevant Context
This is most visible in slow/interrupted stream flows where joinStream returns but no terminal values
event updates local stream state.
Testing
Fix #1969