fix(ai): simplify resume-stream status flash fix#12679
Closed
Conversation
| body, | ||
| }); | ||
|
|
||
| if (reconnect == null) { |
Contributor
Collaborator
Author
There was a problem hiding this comment.
🤔 hm this might be legit
Contributor
|
Responding here to #12102 (comment) Candidly: I want the behavior change where |
Collaborator
Author
Sounds good, and haven't seen any complaints, we should be good. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
PR #12102 fixed a bug where
useChatwithresume: truewould briefly flash status tosubmittedon page load when there is no active stream to resume (ready → submitted → ready).However, the fix was more complex than necessary: it moved
reconnectToStreamout of the existing try-finally block, introduced a separate try-catch, aresumeStreamclosure variable with a non-null assertion (resumeStream!), and changedonFinishbehavior (no longer called when there's nothing to resume).Summary
This PR replaces the #12102 implementation with a simpler approach (net +3 lines changed in
chat.tsvs +28/-13):setStatus('submitted')forresume-streamtriggers — defer it until afterreconnectToStreamconfirms there's an active streamsubmittedonly after reconnect succeeds — inside the existing try block, right afterstream = reconnectThis keeps
reconnectToStreaminside the existing try-finally block, so:onFinishstill fires in all cases (no behavior change vs pre-fix(ai): avoid status flash to 'submitted' during stream resumption with no active stream #12102)resumeStreamvariable or non-null assertion neededAll tests from #12102 are preserved and pass.
Checklist
pnpm changesetin the project root)Related Issues
Simplifies #12102