Skip to content

revert(v2): hydrate gallery cards per-card via /roms/{id}/simple#3789

Merged
gantoine merged 3 commits into
masterfrom
posthog-code/v2-gallery-per-card-fetch
Jul 17, 2026
Merged

revert(v2): hydrate gallery cards per-card via /roms/{id}/simple#3789
gantoine merged 3 commits into
masterfrom
posthog-code/v2-gallery-per-card-fetch

Conversation

@gantoine

Copy link
Copy Markdown
Member

Description
Explain the changes or enhancements you are proposing with this pull request.

The v2 gallery previously hydrated each visible card with its own GET /roms/{id}/simple request. Because that endpoint was slow at the time, a prior change (#3765) switched hydration to batched 72-item window fetches through the paginated /roms list endpoint.

Now that /roms/{id}/simple is fast (lightweight eager-load), this reverts the gallery back to per-card hydration:

  • galleryRoms store — reintroduces fetchRomAt(position) (per-card GET /roms/{id}/simple) and cancelFetchAt(position). Removes the now-unreachable window-fetch machinery: fetchWindowAt, syncVisibleWindows, cancelWindow, the window auto-retry (retryTimers/retryCounts/backoff), the batched-apply helpers (applyItemsBatched/nextFrame), alignToWindow, the loadedWindows/pendingWindows/failedWindows state, and the unused hasInitial getter.
  • GalleryShell — grid-mode viewport sync fires fetchRomAt for entered positions and cancelFetchAt for departed ones, restoring the visiblePositions tracking set.
  • GameListRow — row mount fires fetchRomAt, unmount aborts via cancelFetchAt.

Kept from the intervening work, as intended:

  • the withCharIndex / withFilterValues skip params on the roms API (services/api/rom.ts untouched),
  • the abortInFlight store action, still wired into the shell's unmount.

The lightweight fetchInitialMetadata bootstrap (seeds total / charIndex / romIdIndex / filter_values) is unchanged.

AI assistance disclosure: This PR was written with AI assistance (PostHog Code / Claude). The change was reviewed by the author.

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots (if applicable)

No UI/visual change; behavior-only revert of the hydration path.


Created with PostHog Code

The v2 gallery had been switched from per-card GET /roms/{id}/simple
hydration to batched window fetches because the /simple endpoint was
slow. Now that /simple is fast (lightweight eager-load), revert the
gallery back to per-card hydration: onMount fetches a single rom by id
and onUnmount aborts if the card scrolled out of view.

Reintroduces fetchRomAt / cancelFetchAt and drops the now-unreachable
window-fetch machinery (fetchWindowAt, syncVisibleWindows, the window
auto-retry, and the batched-apply helpers). Keeps the later
improvements: the withCharIndex / withFilterValues skip params on the
roms API and the abortInFlight store action.

Generated-By: PostHog Code
Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
Copilot AI review requested due to automatic review settings July 17, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores per-card hydration for the v2 gallery. The main changes are:

  • Fetches visible grid cards through /roms/{id}/simple.
  • Starts and cancels hydration from list-row lifecycle hooks.
  • Removes window batching, retry, and window-state bookkeeping.

Confidence Score: 4/5

The per-card hydration lifecycle can leave visible grid and list cards stuck as skeletons.

  • Cancelled requests can delete the controller owned by a newer request for the same position.
  • Transient request failures have no retry while the viewport remains still.
  • Mounted list rows do not refetch after gallery state is invalidated at an unchanged position.

frontend/src/v2/stores/galleryRoms.ts and frontend/src/v2/components/Gallery/GameListRow.vue

Important Files Changed

Filename Overview
frontend/src/v2/stores/galleryRoms.ts Adds per-position hydration and cancellation, but controller cleanup and failed-request handling can leave visible cards unhydrated.
frontend/src/v2/components/Gallery/GalleryShell.vue Replaces window synchronization with debounced per-position fetching and cancellation for the grid.
frontend/src/v2/components/Gallery/GameListRow.vue Moves list hydration to mount and unmount hooks, which misses refreshes when a position-keyed row remains mounted.

Fix All in Claude Code

Reviews (1): Last reviewed commit: "revert(v2): hydrate gallery cards per-ca..." | Re-trigger Greptile

Comment thread frontend/src/v2/stores/galleryRoms.ts
Comment thread frontend/src/v2/stores/galleryRoms.ts
Comment thread frontend/src/v2/components/Gallery/GameListRow.vue Outdated
gantoine added 2 commits July 17, 2026 07:48
A list row fetched its rom only in onMounted. A filter / search / sort /
scan refresh clears byPosition and repopulates romIdIndex while the row
stays mounted at the same position, so it was stranded on skeletons until
it scrolled out and remounted.

Replace the onMounted fetch with a watch that fires fetchRomAt whenever
the position is missing its rom but the store knows its id. Guarding on
the id (not just a null rom) also refetches when a resort lands a
different rom at the same position. The store still dedupes against
in-flight + already-loaded, so re-runs are cheap.

Generated-By: PostHog Code
Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
An aborted per-card fetch's finally deleted the inFlightControllers entry
unconditionally. If the position was cancelled and quickly re-entered the
viewport, a replacement request could store a new controller under the
same rom:${position} key before the aborted request reached finally; the
unconditional delete then removed the new controller, so its response
failed the ownership check and the card stayed a skeleton.

Compare controller identity in both the success re-check and the finally
delete (mirroring fetchInitialMetadata) so a request only ever clears its
own entry.

Generated-By: PostHog Code
Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
@gantoine
gantoine merged commit 04c000e into master Jul 17, 2026
11 checks passed
@gantoine
gantoine deleted the posthog-code/v2-gallery-per-card-fetch branch July 17, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants