fix: seed AnnotationRowPage form during render, not from an effect - #37
Open
duncankmckinnon wants to merge 1 commit into
Open
fix: seed AnnotationRowPage form during render, not from an effect#37duncankmckinnon wants to merge 1 commit into
duncankmckinnon wants to merge 1 commit into
Conversation
The form was seeded from an effect keyed on the current row object. Since entries starts null and is fetched, the commit that first paints the form is the same commit that queues the seeding effect, leaving a window where the form is interactive before it's been seeded. On a loaded CI runner a test's click landed in that window and got clobbered when the effect finally flushed, producing an intermittent failure in "saves the checked labels and description". Keying the seed on row_id and doing it during render (not useEffect) closes the window instead of narrowing it: React re-renders immediately on a render-phase update, so the form is never committed un-seeded. Keying on row_id rather than the row object also fixes a second, user-visible instance of the same bug -- a save's own response replaces entries, which was silently reverting an edit made while that save was still in flight. Added a regression test for the in-flight-edit case, which is deterministic (unlike the original scheduler race). Verified it fails without the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.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.
What broke
main'stestworkflow flaked on thewebjob: AnnotationRowPage.test.tsx:117 — "saves the checked labels and description" — failed intermittently with:The tagged v0.2.0 release itself succeeded (PyPI + Homebrew tap both published) — this was a separate CI job on the same commit.
Root cause
AnnotationRowPageseeded its form (labels,value,description) from auseEffectkeyed on thecurrentrow object. Sinceentriesstartsnulland is fetched async, the commit that first paints the form is the same commit that queues the seeding effect — so the form is interactive before it's been seeded. Under CI load, a test's click landed in that window and got overwritten when the effect finally flushed:labels: ["good"]setLabels(annotation?.labels ?? [])→[]labels: []Fix
Seed the form during render instead of in an effect, keyed on
row_id. React re-renders immediately on a render-phase state update, so the form is never committed un-seeded — this closes the race window rather than narrowing it.Keying on
row_idinstead of the row object also fixes a second, user-visible instance of the same bug: a save's own response replacesentries, which was silently reverting an edit made while that save was still in flight.Testing
npx tsc --noEmitclean🤖 Generated with Claude Code