Skip to content

fix: person edit Save sends the picture it just finished reading - #31282

Merged
bolichen97 merged 1 commit into
mainfrom
fix/26862-people-panel-picture-save
Nov 6, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/26862-people-panel-picture-save

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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.tsx failure 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

  • No change to the dialog's look, copy or the picture checks (type, size, read failure).
  • No change to the existing test; it already describes the behaviour this restores.
  • No sweep of every useMutation in 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:

Gap Cause Change
Save clicked right after the picture appears The save's mutationFn read the name and picture from its render, and TanStack's useMutation hands a new mutationFn to 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. The dialog passes { alias, picture, clear } to save.mutate().
Enter in the name field after the read ends but before the dialog redraws The submit handler still on screen saw the read as finished (its ref had cleared) and saved without the picture. A submit from a render that still shows the read is ignored, as it is during the read.

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

  • Existing waits for a chosen picture to finish reading before Save can send it (unchanged) is the witness for the first gap.
  • New ignores an Enter that lands after the picture read ends but before the dialog shows it holds React's render inside act while 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 the reading check (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 useMutation options reach the observer 300 ms late, the way they do when a loaded runner's scheduler yields between a commit and its effects.

vi.mock('@tanstack/react-query', async (importOriginal) => {
  const m = await importOriginal<typeof import('@tanstack/react-query')>()
  const R = await import('react')
  return { ...m, useMutation: (options, client) => {
    const held = R.useRef(options)
    R.useEffect(() => { const t = setTimeout(() => { held.current = options }, 300); return () => clearTimeout(t) }, [options])
    return m.useMutation({ ...held.current }, client)
  } }
})
Run Result
main f5340cc658, forced RED: Received: 1st vi.fn() call: ["4102", { "alias": "" }], the CI failure verbatim
This change, forced GREEN, all 70 tests in the file
This change, 20 repeats of both tests 20/20 green
This change, 10 runs of PeoplePanel, TailscaleInvites, PeopleModes tests at --maxWorkers=4 10/10 green
This change, both settings files shuffled (--sequence.seed=26229) 113/113 green

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 08:31
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 08:31
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 08:43
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5cbfcc472371d03b7d05b6d94a39a523e3357d03 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5cbfcc4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5cbfcc472371d03b7d05b6d94a39a523e3357d03 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 5cbfcc472371d03b7d05b6d94a39a523e3357d03 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5cbfcc472371d03b7d05b6d94a39a523e3357d03 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5cbfcc4

Verdict parsed from the review's SHA-scoped output markers for commit 5cbfcc472371d03b7d05b6d94a39a523e3357d03.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5cbfcc472371d03b7d05b6d94a39a523e3357d03 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5cbfcc472371d03b7d05b6d94a39a523e3357d03 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. Passing the form state as mutate() variables fixes the cause, which was a stale mutationFn closure. The change renders nothing new and takes nothing away.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 5cbfcc472371d03b7d05b6d94a39a523e3357d03 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 ships

Inventory (2 items) — 2 justified

Intent: saving a person right after their new picture finishes loading always saves that picture. FIX.

  1. Save sends the name and picture shown when it is pressed, not an earlier render's values — justified
  2. An Enter after the picture read ends but before the dialog redraws is now ignored, as it already was during the read — justified

[FIRST-PRINCIPLES-REVIEWED] 5cbfcc4

Description read

[DESCRIPTION-READ] 7ade7557777d1e195c8a513fbc2515223091590aa1158cec94b27c99494a4005

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
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
@bolichen97
bolichen97 force-pushed the fix/26862-people-panel-picture-save branch from 578493a to 5cbfcc4 Compare November 6, 2026 11:37
@bolichen97

bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files beside website/src/pages/settings/PeopleCrew.tsx and picked up the fix for the unrelated framerMotionMockStableTags red (#31279) since this head's CI ran (f02c887 -> 083e552); the change itself is identical. CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bolichen97
bolichen97 merged commit 58a1213 into main Nov 6, 2026
98 checks passed
@bolichen97
bolichen97 deleted the fix/26862-people-panel-picture-save branch November 6, 2026 13:35
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
buluoray pushed a commit that referenced this pull request Nov 7, 2026
)

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants