openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

List carousels on collection pages should preserve the curator's picks: every edition, readable or not

Open lokesh opened this issue 1 month ago • 3 comments

Problem / Opportunity

Collection pages (/collections/*) are editorial. Someone sat down, picked specific books, put them in a list, and dropped a ListCarousel onto the page so other readers could enjoy that curation. Right now the carousel quietly second-guesses them in two ways:

  1. Editions collapse into works. The list carousel maps every edition in the list to its parent work and asks Solr for works. A list of 15 Bibles that belong to 3 works renders as 3 cards, and the cover shown is whatever Solr considers the representative edition, not the one the curator chose. (Reported in #6470.)
  2. Non-readable books vanish. ListCarousel defaults to has_fulltext_only=True, so any list entry without a borrowable or readable edition is dropped unless the page author knows to turn the filter off.

Both are surprises for the curator ("where did my books go?") and for patrons (the header says 15 books, the carousel shows 3). A query carousel has a good reason to filter: a subject or author query can match thousands of works and "readable only" is what makes it useful. A list is different. It's a finite, hand-picked set. There is nothing to filter down, and every entry hidden is a decision the curator already made being undone.

This also lines up with how lists themselves behave: a list page shows every item you added, as the edition you added it. The list carousel should be a faithful window onto the same list, not a different interpretation of it.

Impact. I surveyed all 194 live collection pages:

Macro Carousels has_fulltext_only=False explicit True unset (defaults to True)
ListCarousel 208 196 1 11
QueryCarousel 1202 845 51 306

196 of 208 list carousels already turn the readable-only filter off by hand. Curators are telling us what the default should be. Flipping the default for ListCarousel changes 12 carousels on a handful of pages, and anyone who wants the filter can still pass has_fulltext_only=True. The 357 query carousels that rely on the default are untouched.

Also worth noting: ListCarousel is only ever invoked from wiki page bodies. No template in the repo uses it, so this change is scoped to collection pages and similar wiki pages.

Success looks like: a list carousel shows one card per list entry, in list order, with the edition the curator picked, and the count matches the list. A page author who wants readable-only can still ask for it.

Proposal

For ListCarousel only:

  • Default has_fulltext_only to False. Lists are curated; keep what the curator added.
  • Preserve editions. Paginate over the list's seeds in list order and emit one card per seed, using the listed edition's doc rather than Solr's representative edition. Work seeds keep working as they do today.
  • Leave QueryCarousel defaults and the search page's list handling (rewrite_list_query) as they are.

A side benefit: this also fixes the "random extra items" pagination quirk described in #6470, since load-more would paginate over seeds rather than over a deduped Solr result.

Gotcha: load-more must paginate on seed index, not on cards rendered

This is the same bug as #9342 (a work showing up twice in a collection carousel), and it is easy to carry over into the new per-seed branch, so it is called out here explicitly.

How it breaks today. The carousel runs in "offset" page mode, and the client sets the next offset to the number of cards currently on screen (Carousel.js, loadMore.page = totalSlides). For a list query the server applies that offset to the seeds (rewrite_list_query slices get_work_keys()), then asks Solr for those works with the readable-only filter. Every seed the filter drops, and every pair of editions that collapse into one work, makes "cards rendered" smaller than "seeds consumed". The next request's window slides backward and re-fetches seeds that were already shown.

Reproduced on prod against /collections/understanding_politics (list OL201892L, 20 edition seeds, all distinct works):

Step Seeds consumed Cards rendered
Initial load 20 15 (5 have no readable edition)
Load more sends offset=15 seeds 15–19 again 4, all already on screen

Wealth of Nations is seed 19, which is the duplicate reported in #9342. Three other works duplicate too.

Why flipping the default is not enough. Turning off readable-only and emitting one card per seed makes the two counts line up in the default case, so the duplicates on that page go away. They come straight back for any page that passes has_fulltext_only=True explicitly, and for any seed that resolves to nothing in Solr (unindexed or redirected edition). The fix has to be structural, not a happy coincidence of counts.

What the per-seed branch needs to do.

  • Paginate on seed index on the server. The offset the client sends must mean "resume from seed N", and the server must advance through the seed list even when a seed produces no card.
  • Return the resume point. The load-more response should tell the client the next seed offset (or that it is done), rather than the client inferring it from how many cards it has. Either add a nextOffset to the CarouselLoadMore partial response for list queries, or give list carousels a page mode where the server owns the cursor. The existing page mode in Carousel.js is close but counts pages, not seeds.
  • Treat the explicit has_fulltext_only=True path as the test case. If a readable-only list carousel with unreadable seeds in the middle of the list renders no duplicates and still reaches the end of the list, the fix is right.

Closes #6470. Closes #9342.

Implementation Details (for maintainers)

Related files

  • openlibrary/macros/ListCarousel.html — flip the has_fulltext_only default
  • openlibrary/plugins/openlibrary/partials.py — gather_lazy_carousel_data_async; add a list-key branch that walks seeds in order and builds one card per seed (the card builder already prefers editions.docs[0] when present)
  • openlibrary/plugins/worksearch/code.py — rewrite_list_query; current work-collapsing path, keep for search
  • openlibrary/core/lists/model.py — List.get_seeds(), get_work_keys(), get_editions()
  • openlibrary/plugins/upstream/utils.py — get_collection_book_count sums seed_count, so the header already expects the carousel to show every seed
  • openlibrary/plugins/openlibrary/js/carousel/Carousel.js — loadMore.page = totalSlides in offset mode; this is where the client assumes cards rendered == items consumed (see the gotcha above and #9342)

Requirements Checklist

  • [ ] ListCarousel defaults to has_fulltext_only=False; explicit True still filters
  • [ ] A list with multiple editions of the same work shows one card per edition, with that edition's cover
  • [ ] Cards appear in list order and load-more continues from the right seed
  • [ ] Work seeds and mixed lists still render
  • [ ] QueryCarousel behaviour is unchanged
  • [ ] Load-more paginates on seed index and the server reports the resume point; the client never infers the offset from cards rendered (#9342)
  • [ ] A list carousel with has_fulltext_only=True and unreadable seeds mid-list shows no duplicate works and reaches the last seed
  • [ ] A list containing a seed that is missing from Solr does not cause duplicates on the next page
  • [ ] Spot-check /collections/[A_Bible_Collection] and /collections/Schweizer_Buchpreis_Gewinner
  • [ ] Spot-check /collections/understanding_politics: scroll to the end, no work appears twice (#9342)

Stakeholders

  • @mekarpeles — collections / lists direction
  • @cdrini — Solr query shape for the per-seed edition lookup

Instructions for Contributors

lokesh avatar Oct 07 '26 06:10 lokesh

Hi @lokesh , I would like to work on this issue. I worked with the carousel code in my earlier PRs, so I'm familiar with that part of the codebase. I'll open a PR once ready.

Nehant18 avatar Oct 07 '26 06:10 Nehant18

@Nehant14 go for it!

lokesh avatar Oct 07 '26 06:10 lokesh

Hi, Is this issue still active? Also, is the previous PR still under review, or would it be okay for someone else to pick this up?

Ved-sketch avatar Oct 24 '26 20:10 Ved-sketch