fix(sdk): reset skipToTurnComplete when a new chat turn starts - #4744
fix(sdk): reset skipToTurnComplete when a new chat turn starts#4744wuweiweiwu wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: ffa693e The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @wuweiweiwu, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
WalkthroughThe chat transport resets 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for your contribution! We require all external PRs to be opened in draft status first so you can address CodeRabbit review comments and ensure CI passes before requesting a review. Please re-open this PR as a draft. See CONTRIBUTING.md for details. |
|
Thanks for your contribution! We require all external PRs to be opened in draft status first so you can address CodeRabbit review comments and ensure CI passes before requesting a review. Please re-open this PR as a draft. See CONTRIBUTING.md for details. |
|
Thanks for your contribution! We require all external PRs to be opened in draft status first so you can address CodeRabbit review comments and ensure CI passes before requesting a review. Please re-open this PR as a draft. See CONTRIBUTING.md for details. |
|
Added regression tests in The |
Co-authored-by: Wei-Wei Wu <wei-wei@momentic.ai>
Head branch was pushed to by a user without write access
9902a08 to
ffa693e
Compare
✅ Checklist
Testing
Reproduced with
useTriggerChatTransport+useChatand the stop pattern from the ai-chat frontend docs:transport.stopGeneration(chatId), thenuseChat'sstop().Before this change the second turn never renders: no parts arrive,
statusstaysstreaming, and the session staysisStreaming: true, so a stop button stays on screen until the page is reloaded. The run itself is fine and everything persists, so a reload shows the full response.Cause:
stopGenerationsetsstate.skipToTurnComplete = true, and the read loop only clears that when it sees aTURN_COMPLETErecord. The abort closes the reader before that record arrives, so the flag survives into the next turn and every record of that turn is skipped, including its ownTURN_COMPLETE.After this change the same sequence streams the second turn normally. Verified against 4.5.11 and 4.5.12 (both affected) with the equivalent patch applied to the built SDK.
Changelog
Reset
skipToTurnCompletewhen a new chat turn or action is sent, so a message sent afterstopGenerationstreams normally instead of leaving the chat stuck in a streaming state.