fix(sdk,webapp): stop chat losing a message sent right after an action#4234
Conversation
🦋 Changeset detectedLatest commit: 96e5ad3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📜 Recent review details⏰ Context from checks skipped due to timeout. (41)
WalkthroughRealtime append methods now return the appended sequence number, and both append routes include it in successful responses. The chat SDK propagates this value through message and action sends, passes it to stream subscriptions, and skips earlier 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
206e7f5 to
00dce9a
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
00dce9a to
f8da664
Compare
f8da664 to
96e5ad3
Compare
Summary
Sending a chat message immediately after an action (for example an undo) could make the message's response vanish from the UI. The transport opened a response stream that closed on the earlier turn's completion instead of waiting for the send's own turn. The agent still produced and persisted the answer, so it reappeared on refresh. Same "disappearing message" class as #4176, different cause.
Fix
A send's response stream had no way to tell whether a
turn-completebelonged to its turn.POST /realtime/v1/sessions/:id/in/appendnow returns the appended record's sequence number, and the transport skips any turn-complete whosesession-in-event-id(the agent's committed.incursor) is below that seq, closing only on its own turn. Older webapps omit the seq, in which case the transport falls back to the previous behavior, so the SDK and server can ship independently.Because the fix spans the SDK and the server, both a webapp deploy and an SDK release are needed for the full effect.
Verified end to end with the ai-chat reference app: undo-then-immediate-send loses the follow-up's answer before the fix and streams it inline after, with a revert-the-guard run reproducing the loss on the same script. Unit tests cover the skip and the no-seq fallback.