Repository navigation
fix(members): commit the roster display order per membership, not per refetch - #9537
Conversation
… refetch The Crew Members roster moved into the React Query cache, which refetches on every server refresh frame, on window focus and on staleness. `orderedMembers` kept sorting by `last_active_ts` on each render, so a refetch landing between the user aiming at a row and clicking it moved the active member to row 1, shifted every row below, and the click opened a different member's durable pinned thread -- the misroute the page's exact-name keying exists to prevent. The comment above the sort still claimed the order was taken once from a snapshot; that stopped being true when the data became live. The display order is now committed per MEMBERSHIP in a ref: it re-sorts from scratch only when the set of member names changes (add / remove / rename), and otherwise maps the committed order over the fresh rows, so star, last-message preview and presence keep updating live while positions hold. Refs kirodotdev#9524
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Removes the self-reordering roster (rows jumping under the cursor) with zero visual or copy delta — no new user-visible control, so no evidence gap. [UX-REVIEWED] 0f48e72 |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Real, user-visible misroute fixed at its cause — the moving sort key — while keeping row content live; proportionate, well-tested, alternative honestly weighed. [DESIGN-REVIEWED] 0f48e72 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All evidence is in. The fix itself is well-derived (linked issue, mutation-proven test, and the mechanism is verifiable in base: First-Principles-Verdict: CONCERNS The identical live-activity re-sort still moves click targets one panel over ( What this change shipsIntent: stop background refetches from reordering the Crew Members roster so a click can't land on the wrong member's durable thread — a FIX. Inventory (4 items)
Watch
[FIRST-PRINCIPLES-REVIEWED] 0f48e72 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
iamwhatever
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, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: roster display order now committed per membership instead of per refetch, so a refresh-frame last_active_ts bump no longer re-sorts rows under the cursor mid-click; row content still updates live. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 annotations.
… refetch (kirodotdev#9537) The Crew Members roster moved into the React Query cache, which refetches on every server refresh frame, on window focus and on staleness. `orderedMembers` kept sorting by `last_active_ts` on each render, so a refetch landing between the user aiming at a row and clicking it moved the active member to row 1, shifted every row below, and the click opened a different member's durable pinned thread -- the misroute the page's exact-name keying exists to prevent. The comment above the sort still claimed the order was taken once from a snapshot; that stopped being true when the data became live. The display order is now committed per MEMBERSHIP in a ref: it re-sorts from scratch only when the set of member names changes (add / remove / rename), and otherwise maps the committed order over the fresh rows, so star, last-message preview and presence keep updating live while positions hold. Refs kirodotdev#9524 Co-authored-by: LuisBrel <193017400+LuisBrel@users.noreply.github.com>
Problem / Motivation
On the Crew Members page the roster re-sorted itself while the user was pointing at
it. The list now lives in the React Query cache and refetches on every server
refresh frame, on window focus and on staleness, but
orderedMembersstill sortedby
last_active_tson each render. A refetch landing between aiming at a row andclicking it moved the active member to row 1 and shifted every row below, so the
click opened a different member's durable pinned thread.
Why it matters
Opening the wrong member's durable thread is a trust-level failure for this page,
and the trigger needs no unusual conditions -- an active crew and a user browsing
the roster is enough. The comment that documented the guarantee was DELETED by
the same migration:
af52805f7(#6616) added the two lines saying the list wassorted once from the roster snapshot because live re-sorting mid-session would
move rows under the cursor, and
f3d739546(#9442) removed exactly those lineswhile keeping the per-render sort they described. Base therefore carried the
behaviour with no warning left in the file.
What changed (motivation -> approach -> change)
Symptom: rows move under the cursor and the click lands on the wrong member.
Root cause: the sort key advances with member activity, and the sort re-runs on
every refetch, so ordering is a function of refetch timing rather than of the
roster.
The change makes the display order a function of MEMBERSHIP instead of of time.
The committed order is held in a ref: it re-sorts from scratch only when the set
of member names changes (add / remove / rename), and otherwise maps the committed
name order over the fresh rows. Row CONTENT stays live -- star, last-message
preview and presence all still update from every refetch -- while positions hold.
Rejected alternative: freezing the query (longer
staleTime, or refetch off).That would fix the movement by making the roster stale, losing the live presence
and preview the refetch exists to deliver. Ordering and content have different
requirements here, so only ordering is pinned.
Tests
a refresh-frame refetch never reorders the roster; a membership change re-sorts itin
website/src/pages/members/MembersPage.test.tsxlocks both halves: after arefetch that advances a lower row's
last_active_tsand changes its preview text,the new content is on screen while the order is unchanged; then a new member
appears and the roster re-sorts by recency.
The test is mutation-proven: with the previous per-render sort restored it fails
with
expected [ 'beta', 'alpha' ] to deeply equal [ 'alpha', 'beta' ]-- therow swap that causes the misroute.
Manual verification
N/A -- the defect is a timing race between a background refetch and a click, which
the test reproduces deterministically by invalidating the query mid-assertion; a
manual attempt would be less reliable than the test, not more.
Screenshots / video
Why no screenshot: there is no visual delta to capture. No styling, layout,
markup or component changes -- the roster renders the same rows, with the same
classes, in the same positions at first paint. What changes is purely temporal:
whether a BACKGROUND REFETCH is allowed to reorder those rows afterwards. A still
of before and after is byte-identical, and a recording would have to reproduce a
refetch landing inside a click, which is exactly what the regression test does
deterministically (and it is mutation-proven: with the old sort restored it fails
on the row swap).
Disclosed rather than omitted: I also could not produce a recording locally even
had one been meaningful --
npm ciin this environment failsE401against theconfigured package registry, so the dev server cannot build a complete bundle. If
a maintainer wants a capture anyway, say so and I will get one from a working
environment.
Related Issues
Fixes #9524
Pattern harvest
Rule candidate: review-prompt
Pattern: a comment asserting an invariant ("sorted once from the snapshot") that a
later migration silently invalidated -- when data moves from a one-shot fetch to a
live cache, every derived value whose comment claims stability needs re-deriving,
because nothing fails when the claim stops being true.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Correction (post-merge). An earlier revision of this description said the
comment above the sort still promised that, which implied it was present in base.
It was not, and the First Principles lane was right to grep for it: the comment was
added in
af52805f7(#6616) and removed byf3d739546(#9442). The paragraph abovenow cites both commits instead of quoting base. The fix itself rests on #9524 and
the mutation-proven test, neither of which depended on that quote.