Repository navigation
fix: person edit Save sends the picture it just finished reading - #31282
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff adds or changes no visible control, string or state. Save still ignores presses while the picture is reading, as it already did, and now sends the values on screen when it is pressed. [UX-REVIEWED] 5cbfcc4 Description read[DESCRIPTION-READ] b75eaa62931fd379552aaa65a38ed990569503a4b12ff0e21da57cada58d8d1f That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Passing the form state as [DESIGN-REVIEWED] 5cbfcc4 Description read[DESCRIPTION-READ] 72146820b3a5a1b085f71b60cef777b06fa50e74a4d66c14f5d67a8c0879fbab That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Both items fix the cause of the dropped picture: the form travels as mutate variables, and a submit from a render that still shows the read is ignored. The defect has a linked issue and a test that fails on base. What this change shipsInventory (2 items) — 2 justifiedIntent: saving a person right after their new picture finishes loading always saves that picture. FIX.
[FIRST-PRINCIPLES-REVIEWED] 5cbfcc4 Description read[DESCRIPTION-READ] 7ade7557777d1e195c8a513fbc2515223091590aa1158cec94b27c99494a4005 That sha256 names the PR description this verdict read. Recompute it with |
The edit-person dialog could drop a chosen picture when Save landed in the instant the picture read finished. Two stale views caused it: - The save mutation read the name and picture from its render, and useMutation hands a new mutationFn to its observer only in a passive effect. A Save between the commit that enables it and that effect sent the form from before the picture. - An Enter in the name field after the read's promise ended but before React rendered it ran the old submit, which saw the read as done and saved without the picture. The form now rides on mutate(), and a submit from a render that still shows the read is ignored. The first is the race behind the intermittent PeoplePanel test failure on a loaded shard. Closes #26862
578493a to
5cbfcc4
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: person edit Save sends the form of the render it was pressed in.
) The edit-person dialog could drop a chosen picture when Save landed in the instant the picture read finished. Two stale views caused it: - The save mutation read the name and picture from its render, and useMutation hands a new mutationFn to its observer only in a passive effect. A Save between the commit that enables it and that effect sent the form from before the picture. - An Enter in the name field after the read's promise ended but before React rendered it ran the old submit, which saw the read as done and saved without the picture. The form now rides on mutate(), and a submit from a render that still shows the read is ignored. The first is the race behind the intermittent PeoplePanel test failure on a loaded shard. Closes #26862 (cherry picked from commit 58a1213)
Problem / Motivation
Goal: Saving a person right after their new picture finishes loading always saves that picture.
In Settings → People, the edit dialog reads a chosen picture before Save is allowed. A Save pressed in the instant the read finishes can send the form as it was before the picture: the dialog closes on success and the picture is silently dropped. On a loaded CI shard this shows up as the intermittent
PeoplePanel.test.tsxfailure in #26862, whose recorded save is exactly{ alias: '' }with no picture.Why it matters
The dialog promises that a fast Save never drops the selection. When it does, the person keeps their old picture with no error, and the intermittent red costs every pull request whose shard draws this test a rerun.
Not a goal
useMutationin the dashboard; only forms whose input lands from an async read are in this class (see Sibling sweep).What changed (motivation → approach → change)
Save now always sends what the dialog shows at the moment it is pressed. Two gaps let it send an older view of the form:
mutationFnread the name and picture from its render, and TanStack'suseMutationhands a newmutationFnto its observer only in a passive effect. The read ends in a promise, so that effect can run one task after Save is enabled. This is the CI failure.{ alias, picture, clear }tosave.mutate().The issue's guess (Save is already disabled before any change) does not hold: Save is enabled until the read starts, and the read starts synchronously inside the change event. The forced condition below reproduces the exact recorded call.
Backwards compatibility
Compatible: the request body is the same for every form state; only where its values are read from changed.
Removes nothing: no field, route or check is taken away; a submit is ignored only while the dialog on screen still shows the read, as it already was during the read.
Tests
waits for a chosen picture to finish reading before Save can send it(unchanged) is the witness for the first gap.ignores an Enter that lands after the picture read ends but before the dialog shows itholds React's render insideactwhile a zero-delay task lets the read's promise chain finish, submits, and expects no save; then Save sends the picture exactly once. It is red on main's component and on this change without thereadingcheck (Received: ["4102", { "alias": "" }]), green with it.Proof: not provable -- frontend test (prove.py runs Python only)
Forced condition for the first gap (throwaway, not committed): every render's
useMutationoptions reach the observer 300 ms late, the way they do when a loaded runner's scheduler yields between a commit and its effects.f5340cc658, forcedReceived: 1st vi.fn() call: ["4102", { "alias": "" }], the CI failure verbatimPeoplePanel,TailscaleInvites,PeopleModestests at--maxWorkers=4--sequence.seed=26229)tsc -p tsconfig.app.json, eslint on both files,singleInvitePath.test.ts(the related set), the flake-pattern ratchet and the repository semgrep rules on the diff pass.Manual verification
N/A — both gaps are one scheduler task wide and cannot be hit by hand; the forced condition and the held-render test are the reproductions.
Screenshots / video
Why no screenshot: the dialog renders the same; only when Save accepts a press and where it reads its values changed.
Related Issues
Closes #26862
Sibling sweep
Swept: git grep -lE "fileToBase64|.arrayBuffer()|new FileReader" -- website/src, then kept files that also use useMutation
Sibling: website/src/pages/settings/PeopleCrew.tsx -- changed here
Sibling: website/src/pages/settings/TailscaleInvites.tsx -- not affected -- its upload takes the file as a mutate variable, and its send runs through useGuardedMutation, whose synchronous pending render flushes the pending effects before the awaited mutate
Pattern harvest
Rule candidate: review-prompt
Pattern: a useMutation mutationFn that reads component state set by a promise continuation, called by a mutate() that the same commit re-enables, sends the previous render's state; pass the state as mutate variables
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)