fix: prevent confirming state from immediately reverting in stream creation - #1360
Merged
Merged
Conversation
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.
Problem
After successfully submitting a stream creation, the UI was supposed to show a "Finalizing Stream..." state for 2 seconds before navigating to the dashboard. However, the
finallyblock in thehandleSubmitfunction was executing synchronously immediately after thetryblock completed, resettingsetLoading(false)andsetTxState("idle")before React could even render the confirming state.This caused the button to flash past "Finalizing Stream..." and instantly revert to "Start Streaming", creating a glitchy user experience.
Root Cause
In
create-stream-content.tsx:179-194, thefinallyblock at lines 190-193 was placed outside thesetTimeoutcallback, causing it to execute immediately after the async operation completed rather than waiting for the 2-second delay.Solution
Moved the state reset logic from the
finallyblock to the appropriate locations:Success path: Moved
setLoading(false)andsetTxState("idle")inside thesetTimeoutcallback, just beforerouter.push("/dashboard"). This ensures the confirming state persists for the full 2 seconds before cleaning up and navigating.Error path: Added the same state reset to the
catchblock so loading state is properly cleared on failure.Changes
frontend/src/app/streams/create/create-stream-content.tsx:179-194finallyblocksetTimeoutcallback (success path)catchblock (error path)Testing
All existing tests pass (286/286 across 32 test files). The change is minimal and focused on the state management timing, which is now correctly handled.
Impact
Fixes a visibly glitchy state transition on the primary stream-creation flow, improving the user experience by ensuring the "Finalizing Stream..." message is visible for the intended duration.
Closes #1231