fix(web): preserve predictor results after rank flush#24
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Co-authored-by: sh <su6u@users.noreply.github.com>
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.
Bug and impact
When a user edits the focused rank field and clicks Predict before the URL-backed state catches up, the app flushes the draft rank and submits the prediction with that new rank. If the API responds before
router.replaceupdatesrankin the URL, the subsequent URL sync changes the hook input key after the request has already cleared its in-flight marker, causing the successful result to be reset tonull. This can make a successful prediction appear empty for a common predictor flow.Root cause
usePredictorQueryonly protected input-key changes that matched the currently in-flight request. It did not remember that a just-settled response belonged to the same input key that the URL was about to adopt.Fix
Track the latest settled prediction input key and treat it as valid during input-key reconciliation, so URL catch-up for the same flushed rank does not clear the response. The normal reset behavior is preserved for genuinely different inputs.
Validation
pnpm --filter @ejam/web typecheckpnpm --filter @ejam/web lintpnpm --filter @ejam/web build