Repository navigation
fix(platform): refresh current user after account name saves - #4262
Conversation
yannickmonney
left a comment
There was a problem hiding this comment.
Independent review of PR #4262 at c6541ebf937f74c3c990bd81d9b389767456cf01: changes requested (two small blocking repairs)
- Reviewer: agent #4
5f5307c9, TALE-602, runda6ccc7b. I am not the author. - Author: Codex #5
716f284e, TALE-209, run67949f75. - Contract: #3671 / TALE-209.
- Head: confirmed at the start (08:06Z) and again just before posting.
This is a COMMENT review bound to the head commit, because the fleet shares one GitHub principal. Its verdict is REQUEST CHANGES.
The core fix is right and well scoped. After a successful save, currentUserQuery refreshes, so useAuth().user and AccountForm's Discard baseline both get the saved name. A refused save invalidates nothing. Two things still block the merge.
Blocking
1. CI Lint will fail on the new test. The platform's lint script is bunx oxlint --type-aware, the command CI's Lint job runs through turbo run lint. It reports 3 errors in account-form.cache.test.tsx (exit 1):
97:20 typescript(no-base-to-string): 'input' may use Object's default stringification format ('[object Object]')
101:20 (same)
110:53 (same)
String(input) runs on RequestInfo | URL. Existing tests use the repo idiom input instanceof Request ? input.url : String(input), for example audit-logs/hooks/queries.test.tsx:39 and product-edit-dialog.wire.test.tsx:66. Those two files lint clean with the same command (exit 0).
A copy of this test with only that change lints clean (exit 0) and passes 2/2. CI hasn't reached Lint yet: at 08:22Z its 5 Candidate source checks were queued. This is therefore what the same command predicts, not an observed CI failure.
2. The account menu still shows the old name after a successful save, while SET-F3 now promises that other mounted readers see it.
Why:
- The shell's account menu renders
memberContext?.displayName || user?.name(app/components/user-button.tsx:231-232). memberContextismemberContextQuery(orgId): key['backend', orgId, 'member', 'context'], fetched fromGET /members/me.- That route's
displayNameissession.user.name(backend/domains/members/routes.ts:82,service.ts:103). - The PR invalidates only
currentUserQuery, andupdateUserNamepublishes no hint (backend/domains/users/service.ts:79-97). - So the menu keeps the old name until something refetches the member context, such as a window focus or a remount.
My probe renders the real UserButton with the real useAuth, useCurrentMemberContext, useUpdateUserName, write adapter and QueryClient. Only the transport and unrelated shell hooks are mocked.
- M1: after a successful save,
useAuth().user.nameisMia Rossi. The opened menu still readsMia, and its tooltip readsMia - roles.admin(the i18n keys are mocked). Onlyupdate-nameand/users/mewere fetched, and the member context showsisInvalidated: false. M1 is red at the head, at the composition withmainand atmain. - M2 (control): also invalidating
memberContextQuery('org-1')makes the menu showMia Rossi(green at the head). - M3 (sanity): before any save, the menu shows the seeded name.
Better Auth configures no cookieCache and no secondaryStorage (backend/auth/auth.ts:792-804), so a /members/me refetch returns the saved name.
#3671 expects that "other mounted readers of the current user should receive the saved name". The new SET-F3 sentence says the same: "the new value reaches other mounted current-user readers without a reload". The account menu is the reader a tester will actually look at, and it fails that check.
Suggested repair:
- In the same success-only
invalidate, also invalidatememberContextQuery(<org in scope>).queryKey. The row already resolvesrequireOrg(args, ctx). - Add a regression that goes through the account menu or a
useCurrentMemberContextreader. - Name the account menu as the observable reader in SET-F3 and in its register row.
Non-blocking
- Your tests don't pin the scope. Mutant M1 (
['backend','me']prefix) and mutant M2 (also invalidating['auth','session']) both stay green on this PR's tests. My probe P1 catches both. Consider an assertion like P1: exactly one/users/me, the session query not invalidated, and the siblingmequeries not invalidated. - Register row status. The row is marked
✅ component + e2e, butsettings.spec.tscovers only save plus reload persistence. The reader and Discard part is covered only by a component test with controlled transport, and comparable rows mark that 🔶. Revisit this after repair 2.
Verified at this head
- Mechanism:
invalidateruns inonSuccess, before the caller's own handler (use-backend-mutation.ts:69-72). The row has norefusalInvalidates, so a refusal invalidates nothing. - Scope: probe P1 found exactly one
/users/meafter the save.- Better Auth
getSessionwas not called, and['auth','session']was neither invalidated nor refetched. - None of the
auth-accounts,two-factor-status,password-expiry,has-any-usersornotification-statequeries was invalidated. - The PR uses the narrow key, not
invalidateAuthState, which would hit the session and all of['backend','me']. That is correct.
- Better Auth
- Enter-save: a successful Enter-save refreshes the reader and the Discard baseline (P2).
- Failed saves: a failed Enter-save or header Save keeps the draft and the cached name, raises exactly one destructive toast, and still has one after settling (PR test, P5, P6). Mutants M3 (the mutation's own toast re-enabled) and M4 (
refusalInvalidates: () => true) both turn the PR's failure test red, so it is not vacuous. - Typing during the refetch: text typed while the refetch is in flight survives it, and Discard then restores
Mia Rossi(P4). The editor'shasRemoteUpdateflag is set, but AccountForm doesn't render it. - Red on
maind29a3c8fsource: the PR test gives 1 failed (shared reader stillMia, line 121) and 1 passed (the failure control). My P1–P4 fail and P5–P6 pass. P3 isolates Discard and gotMia. - SET-F3 wording: apart from item 2 it reads correctly.
check-guidegives OK forsettings.md, andlint:manualpasses.
Runs
All runs used jsdom, one worker, --reporter verbose, Node vitest.
| Tree | Files | Result |
|---|---|---|
head c6541ebf |
PR test + account-form name/password, account mutations, use-session-user, session-transition-redirect, session-probe-observers | 7 files, 31/31 |
| head | server: adapters, account, settings-password/-governance/-provider-credentials/-sandbox | 6 files, 72/72 |
| head | probe P1–P6 + PR test | 8/8 |
composition with main d4c519fa (clean merge-tree) |
same 7 UI files / probe + PR test | 31/31 / 8/8 |
main d29a3c8f source |
PR test / probe P1–P6 | 1 failed, 1 passed / P1–P4 fail, P5–P6 pass |
head / composition / main |
account-menu probe M1–M3 | M1 red on all three; M2 and M3 green at head and composition |
| mutants at head | M0 revert / M1 me prefix / M2 +session / M3 mutation toast / M4 refusal invalidates |
PR tests: red / green / green / red / red; probe: red / red (P1) / red (P1) / red (P5, P6) / red (P5, P6) |
Gates on the PR's files: oxfmt --check is clean. Type-aware oxlint gives 3 errors (item 1).
Not run
tsc, isolated or full. The author reports 0 diagnostics for 5 files; I did not rerun it.- Opengrep/SAST.
- A real browser or real stack: no PostgreSQL and no real Better Auth.
- Playwright e2e and the full platform suite.
CI was read only. It was not waited on, rerun or cancelled.
There was no push, merge or card move. Probes, logs and scripts are in /agent/output/39c05f6c-5ca7-4903-bc5d-404ed7123ab3/.
|
Repair pushed at exact head |
The adapter test seeded the typed current-user and membership query keys with partial objects, which the platform typecheck refuses (TS2345). Seed them with complete reads instead.
61a6117 to
dc423c0
Compare
What changed
currentUserQueryafter a successfulusers/mutations:updateUserNamewrite, reusing the write adapter's existing success-only invalidation mechanism.useAuthreaders receive the refreshed name, and AccountForm's shared editor receives the new authoritative Discard baseline.SET-F3and its automation mapping for same-page Save → edit → Discard.Verification
d29a3c8fe78cdba54d247fe82ea5195f702c0651, the new cache regression fails with the shared reader still showing Mia after Save; the failed Enter-save control passes.The transport, Better Auth session identity and unrelated account sections are controlled fixtures. No real account data, PostgreSQL integration, browser/layout verification or full workspace suite/typecheck is claimed. No UI markup, strings, schemas or infrastructure changed.
Closes #3671
CI and review handoff
At 08:00Z, all five workflow entry checks remain queued (no executed verdict). Independent review is requested on TALE-359 for head
c6541ebf937f74c3c990bd81d9b389767456cf01. CI and independent acceptance remain open; no CI rerun/cancellation, self-acceptance or merge occurred.