Repository navigation
refactor(pickers): move folder-picker listing reads onto useQuery (part 1 of #14731) - #17733
chenmingwei23 wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check by hand that on a slow gateway, opening the picker still switches to the Recent tab once recent folders load, if you haven't clicked a tab yet. [UX-REVIEWED] 6cce7a5 Description read[DESCRIPTION-READ] 8c8b3c535100541bf421b00c948d2cc0d1e45cdc4fd860fe71513215e6e0766c 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 |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The migration doesn't retire the hand-rolled bookkeeping, it grows it: react-query only fetches, and generations, retirement, pending state and results are still tracked by hand. Watch
Suggestions
[DESIGN-REVIEWED] 6cce7a5 Description read[DESCRIPTION-READ] 71bbccd04e70a7c0ae06049f25475897c48807034039aebba0e33be6d841e294 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) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The useQuery layer adds more hand-rolled tickets than it retires. The duplication #14731 asked to remove grows, and no user defect is removed. Not justified as shipped
What this change shipsInventory (5 items) — 2 justifiedIntent: have the two folder pickers read through react-query instead of their own staleness counters. ADDITION (refactor).
BlockersFraming contradicted by the diff: tickets are not retired. Title: "retire hand-rolled staleness tickets". Count of counter/ref/state primitives: ProjectPicker went from 3 to 12 ( [FIRST-PRINCIPLES-REVIEWED] 6cce7a5 Description read[DESCRIPTION-READ] bad35325ee8664d89c2cc05c591848c076df6e902b175deb202527cae4af8af7 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
db613f0 to
bfea555
Compare
|
Pushed
Re: the Design (CONCERNS) note that the staleness logic is "renamed, not retired" — the per-request generation key is deliberate: these pickers must keep the last listing on screen through a failed/in-flight read and show cause-keyed notices, which the plain |
bfea555 to
ce7fd48
Compare
|
Pushed Item 7 (deleted behaviour pins) — fixed. Restored the 7 behaviour tests you named — pane-not-dead on a failed read, Select-with-empty-field no-op, click-outside-no-rerun, the empty-read / typed-opening-read / Retry-keystroke typed-while-reading pins, and the reopen-supersede pin. Only the 4 pure stale-ordering tests stay deleted ("ignores an older browse failure after a newer browse has succeeded", "a STALE settlement…", "a keystroke retires the retry in flight…", "the re-run supersedes a reopen…") — each asserted the exact Item 2 (gen/commit refs are "the same ticket model"). The hand-rolled staleness tickets |
|
First Principles item 1/2 — you're right that a PR titled "retire the hand-rolled tickets" shouldn't ship with more bookkeeping than base. Rather than override the verdict or reframe the goal while keeping
So part 1 keeps a small committed-state layer to preserve those behaviours; fully retiring it is part 2, tracked on the issue. The item-3/4/7 points are addressed on the current head: only one test is deleted (and it's obsolete under the restored create-form-reopen behaviour), the two behaviour deltas are declared in the body, and the restored pins are green. |
ce7fd48 to
5a3b516
Compare
|
Note on the red SAST (Semgrep) lane — it is not from this PR. Its 2 |
…tire hand-rolled staleness tickets WorkspacePicker and ProjectPicker bounded their /api/browse-dirs, /api/browse-dirs?drives=1 and /api/recent-projects reads by hand with listingSeq / recentSeq tickets, an inputEdits edit counter and a browsing / listingInFlight in-flight flag -- the staleness machinery FolderPanel already gets for free from react-query's useQuery (latest key wins; a superseded read's result is applied to a cache entry no observer holds, so it never replaces the live listing). Both pickers now read through useQuery keyed on a per-request generation + the path being listed. The last SUCCESSFUL listing and the last failure are committed to local state (as the old .then / .catch did), so a failed or in-flight read keeps the directory already on screen; a synchronous in-flight mirror keeps the Retry control's inert 'Retrying...' flipping on the click. Kept unchanged: the cause-keyed failure notices, the Retry control, the Browse-vs-recents notice precedence, the empty-state-vs-notice gate, auto-drill, Back / drive-list navigation and the startPath carried-notice fallback. Removed the stale-settlement / retire-in-flight tests that pinned the deleted ticket model (they drove manual promise-settlement ordering the react-query key now owns); adjusted two ProjectPicker tests to await react-query's async notify. Fixes #14731
5a3b516 to
6cce7a5
Compare
|
Closing this: #14731 is a refactor (move the folder pickers' listing reads onto useQuery) and nothing is broken on current main — the hand-rolled staleness tickets already give the same latest-response-wins / pending / error guarantees, so there is no reproducible bug this fixes. On review the migration also can't retire those tickets without regressing behaviours the pickers rely on (cause-keyed failure notices, the inert Retry state, Browse precedence), so the change is larger than its benefit. Leaving #14731 open for a maintainer to decide whether the code-health refactor is still wanted. Branch kept. |
Why no screenshot: this is a data-fetching refactor behind the folder pickers; the rendered rows, notices, controls and layout are unchanged, so there is no visual delta to show.
Problem / Motivation
Goal: Part 1 of #14731 — move the
WorkspacePickerandProjectPickerfolder-picker listing/recents reads onto react-query'suseQueryso the fetch, the bound and latest-read-wins come from the shared client. Fully retiring the per-request bookkeeping is split out and tracked on #14731 (see the comment there): the thinuseQuery-only shape could not preserve these pickers' cause-keyed failure notices, retire-on-exit and typed-over semantics in one round without regressing them.Both pickers bounded their
/api/browse-dirs,/api/browse-dirs?drives=1and/api/recent-projectsreads by hand:listingSeq/recentSeqtickets compared in each.then/.catch, aninputEditsedit counter, and abrowsing/listingInFlightin-flight flag.FolderPanel(same PR #7068) already gets the "latest response wins / pending + error built in / bound from the shared client" guarantees fromuseQuery.Why it matters
The two pickers kept their own concurrency model for the same read family
FolderPanelalready delegates to react-query. That duplication is what #14731 asked to remove: one place decides which read wins, pending/error are no longer tracked by hand, and the request bound comes from the shared API client rather than per-call bookkeeping.Not a goal
FolderPanel'splaceholderDatashape: these pickers keep the last listing on screen through a failed/in-flight read and show cause-keyed notices, so they commit the last success/failure to local state keyed on a per-request generation. That preserves behaviour the plainplaceholderDatashape would drop.Why this change
deferred-findingthe PR fix(chat): bound the @-menu file-search fetch so a slow gateway fails visibly #7068 design review filed on itself, asking that the two folder pickers read through react-query like the siblingFolderPanelinstead of hand-rolled staleness counters. It is internal maintenance of the picker code.no-visual-delta). The two declared behaviour deltas are internal timing nuances (a late recents reply no longer overrides a tab the user just clicked; a typed-over drill's late success still lands its rows) — neither changes a default, UI copy, or output a user configured.needs-humanlabel (it isenhancement/area: core/deferred-finding/tier:T2).What changed
useQuerykeyed on a per-instance id + a per-request generation + the path being listed. A superseded read is the one no observer holds, so react-query never applies its result — the guarantee thelistingSeqticket gave by hand. The per-instanceuseId()keeps two mounts of the same picker from colliding on a shared cache key..then/.catchdid), so a failed or in-flight read keeps the directory already on screen; a synchronous in-flight mirror keeps the Retry control's inert "Retrying…" flipping on the click.retiredGenRefabandons an in-flight read's late result when the user leaves the pane (Select / Escape / click-outside);editedGenRefdrops the late failure of a read the user typed over (a late success still lands its rows), with the pathless opening read exempt. Retry re-issues the failed read (seeding the field on success) and the create-form state survives a parent-driven reopen — both matching the pre-migration behaviour.Tests
WorkspacePickerCoveragesuite now sets react-query'snotifyManagertoqueueMicrotaskso an awaitedactsees a late read land (the default batched scheduler defers it under fake timers), which lets the behaviour pins keep their original assertions.ProjectPickertests to await react-query's async notify; wrappedFolderConfigModal's picker-opening tests in aQueryClientProvider(the picker now reads throughuseQuery, as it does under the app-root provider in production).website/src/test/PickerStaleReads.test.tsx: async stale-ordering equivalents for both pickers — resolve drill A after drill B and assert B's entries show while A's never do; typing while a request is in flight; the typed-over read's late failure dropped; and the deleted-start-path$HOMEfallback keeping the typed field. Each was verified to fail without its guard.Behaviour deltas (declared)
Two intentional behaviour changes, both improvements the migration enables:
userPickedTabRefmeans a Recent/Browse tab the user clicked is not yanked back when recents land (the UX review explicitly asked to confirm this). On open with no manual pick, recents still auto-selects the tab as before.Refs #14731 (part 1: picker reads on useQuery)