perf(desktop): prefetch the channel window on sidebar hover intent - #6459
Conversation
c804417 to
8858a0d
Compare
6fdfcb4 to
ad98485
Compare
8858a0d to
ea195be
Compare
49e260e to
10212a5
Compare
ea195be to
b08413d
Compare
10212a5 to
d3f30e7
Compare
|
🤖 Comment from Maxwell's AI agent. Adversarial review found one P1, fixed and pushed: P1 — prefetch/gap-refresh dedupe could drop a live-window event. TanStack Query never re-fetches a query whose initial fetch is in flight — Fix in Also strengthened the spec per the P2: the mock bridge now exposes a head-fetch completion counter, and the spec requires the prefetch to complete and a message row to paint from the warmed cache — a pending or failed prefetch can no longer pass. |
d3f30e7 to
67a39e6
Compare
A deliberate hover on a sidebar channel row (100ms dwell, so pointer scrubbing never fires) warms that channel's message window, making the subsequent click a cache hit instead of paying the relay fetch on the switch path. The window query options move into a shared factory so the prefetched entry is byte-identical to what the mounted query reads; the prefetch respects the window's staleTime, so hovering a fresh channel never refetches. The mock bridge gains a head-fetch probe (cursorless window reads) so the regression spec can assert dwell-fetches-once / scrub-fetches-never. Signed-off-by: Max Lampert <maxwell@squareup.com>
67a39e6 to
9f0d73e
Compare
b08413d to
a5e8e53
Compare
wesbillman
left a comment
There was a problem hiding this comment.
Carl, an automated reviewer, commenting via Wes’s GitHub account.
Reviewed stacked exact head 9f0d73ea2431f8f5e8a87b05a54ca0dc59b5614a against base a5e8e530b9be277691589b616a1264953cc79799. No blocking defect found in hover-intent cleanup, forum exclusion, shared query options, subscription establishment, cancellation, or post-subscription invalidation. Focused window/dwell validation passed 14/14 and the exact-head diff check was clean.
|
🤖 Comment from Maxwell's AI agent. Heads-up: this merge landed on the stacked base |
Based on
perf/switch-tracing— retarget to main after it merges. (Shares the message-window queryFn hunk with the tracing instrumentation.)A deliberate hover on a sidebar channel row (100ms dwell — pointer scrubbing never fires) warms that channel's message window, so the subsequent click paints from cache instead of paying the relay fetch on the switch path. Live traces measured that fetch at 180–310ms per cold channel entry on a real community — this moves it into the hover dwell, ahead of the click.
The window's query options move into a shared factory so the prefetched entry is byte-identical to what the mounted query reads; the prefetch respects the window's staleTime (hovering a fresh channel never refetches) and dedupes with in-flight fetches. Forum channels are excluded, matching the window query's own gating.
The mock bridge gains a head-fetch probe (cursorless window reads) and a regression spec asserts both directions: dwell fetches exactly once before any click; scrubbing across rows fetches nothing.