Skip to content

fix(library): preserve install filter state during force refresh (#8)#11

Open
abduznik wants to merge 8 commits intomainfrom
claude/review-open-issues-FztAZ
Open

fix(library): preserve install filter state during force refresh (#8)#11
abduznik wants to merge 8 commits intomainfrom
claude/review-open-issues-FztAZ

Conversation

@abduznik
Copy link
Owner

  • Save _local_exists flags before clearing all_games on force refresh so
    installed games aren't lost when the first batch arrives
  • Call apply_filters() instead of populate_grid() for the first batch so
    the active install filter (Installed / Not Installed) is respected from
    the moment data starts loading, not just after the full fetch completes

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk

claude added 8 commits March 22, 2026 22:29
- Save _local_exists flags before clearing all_games on force refresh so
  installed games aren't lost when the first batch arrives
- Call apply_filters() instead of populate_grid() for the first batch so
  the active install filter (Installed / Not Installed) is respected from
  the moment data starts loading, not just after the full fetch completes

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
…ter (#8)

Three bugs fixed:
- populate_grid now receives the full platform-filtered set (base_filtered)
  instead of the install-filtered subset, so _all_cards/_pending_games always
  hold all games for the platform. Switching between Installed / Not Installed
  now uses show/hide on the full set rather than rebuilding from an empty list.
- Show/hide path detects when new server batches contain games not yet in
  _all_cards or _pending_games and triggers a full rebuild so those games
  aren't silently dropped.
- Scroll-triggered lazy loads now re-apply the active install filter after
  _render_next_batch so newly added cards aren't shown when they shouldn't be.
- base_filtered is now sorted alphabetically before being passed to
  populate_grid, keeping card order consistent with the filtered view.

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
…ancellation (#8)

Two follow-up issues from the previous filter fix:

Cover images not loading after refresh:
- The recursive apply_filters() call after populate_grid() was incrementing
  _filter_generation, which caused the race-condition guard in _render_next_batch
  to abort the image-fetch loop before any images were queued.
- Replaced all post-populate_grid apply_filters() calls with a new
  _apply_install_filter_to_rendered() helper that does the same show/hide
  reflow but never touches _filter_generation or _render_generation.

Performance lag during server fetch:
- The previous "new games check" called populate_grid() on every server batch,
  destroying and recreating all card widgets each time (O(N × batches)).
- Now server-batch arrivals add new games to _pending_games (sorted) and
  re-sort _all_cards in-place — no widget recreation at all.
- A single clean rebuild (force_library_rebuild) runs once when the full fetch
  completes, called from _on_library_fetched via a new force_library_rebuild()
  method that resets _current_platform to force one populate_grid pass.

_apply_install_filter_to_rendered() also re-adds the load-more label after
reflow so scroll-triggered lazy loading stays functional with install filters.

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
…le-refresh (#8)

Three bugs fixed:

fetch_generation incremented per scroll batch (root cause of images not loading):
- _render_next_batch() bumped fetch_generation on every call, including lazy
  scroll loads. When _on_image_fetched() ran its queue-drain chain, the stored
  generation no longer matched fetch_generation, so it silently aborted — only
  the first ~12 cards of the most-recently-rendered batch ever got images.
- Fix: increment fetch_generation once in populate_grid() (when the card set is
  fully replaced and old fetches become irrelevant). _render_next_batch() now
  reads the generation without changing it, so the drain chain is never
  interrupted by a scroll-triggered batch load.

is_first_batch condition caused duplicate / reset batches:
- The condition (len(all_games) == len(batch)) fired whenever two consecutive
  server batches happened to be the same size, resetting all_games to just the
  new batch instead of appending — causing data loss and a visible grid reset.
- Fix: only len(all_games) == 0 is a true first batch.

force_library_rebuild() triggered a second full populate_grid at fetch-complete:
- _on_library_fetched called force_library_rebuild() which deleted _current_platform
  to force a full populate_grid rebuild — a second one after the first-batch
  rebuild, producing the "runs twice" feeling users noticed.
- Fix: use apply_filters() instead; it takes the show/hide + add-to-pending path
  so any remaining games are added without destroying and recreating all cards.

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
Two root causes were permanently killing image-fetch drain-chain slots:

1. ImageFetcher never emitted 'finished' on failure (network error, timeout,
   non-200 status, or bad image data). When a fetch failed the slot was dead
   forever — nothing would ever drain that position in the queue again.
   Fix: always emit finished(), using a null QPixmap() as the failure sentinel.
   set_image() now guards with pixmap.isNull() and returns early on failure so
   the card keeps its placeholder.

2. _on_image_fetched didn't loop past games with no cover URL. When the queue
   drain popped a card whose start_image_fetch() returned None (no URL), that
   slot also died permanently.
   Fix: loop in _on_image_fetched until a card with a cover URL is found (or the
   queue is empty), so the slot stays alive across any number of no-cover games.

In the original code fetch_generation was bumped on every scroll-triggered
_render_next_batch() call, which "re-seeded" 12 fresh chains per visible batch
and inadvertently masked these two bugs. After our gen-fix (bump only in
populate_grid) chains are long-lived and a single dead slot is permanent for the
whole session — making the bugs critical. These fixes address the root cause
directly so all cover images load regardless of network hiccups or missing art.

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
…ring (#8)

- Add _visible_card_count to track cards actually in the grid layout (vs hidden)
- Add _matches_install_filter() helper for consistent install filter checks
- Rewrite _render_next_batch() to position cards using _visible_card_count so
  hidden cards don't create empty grid slots when an install filter is active
- Apply install filter per-card inside _render_next_batch() so refreshing while
  on 'Installed' or 'Not Installed' never shows unmatched games
- Update apply_filters() show/hide path to sync _visible_card_count after reflow
- Remove now-redundant _apply_install_filter_to_rendered() calls from the
  platform-change branch and _do_load_batch

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
…ading_batch leak (#8)

- apply_filters show/hide reflow clears the entire grid layout (removing
  the load-more label), but never re-added it — causing scroll-triggered
  batch loads to silently stop after any background fetch updated filters.
  Now re-adds the label with the correct pending count after the reflow.
- _render_next_batch race-condition guard inside the card loop returned
  without resetting _is_loading_batch, permanently blocking future loads.
  Fixed by resetting the flag before returning.

https://claude.ai/code/session_01Qi46myt5pXjZKwURthT9yk
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