feat: show subtitles, part labels and edition years on book cards #4

Merged
chris-paganon merged 9 commits from feat/better-card-metadata into master 2026-11-14 18:23:07 +00:00

Summary

Book cards now show which publication they present, so a split volume (e.g. Words of Radiance, Part Two) no longer looks like the complete novel. The card still uses the preferred-language edition's title and cover.

No extra upstream requests: only the fields list of the existing /search.json call is extended (subtitle, editions.subtitle, editions.publish_year).

What a card shows now

  • Subtitle (new line under the title, heading font, muted, first letter capitalized, clamped to 2 lines with the full text in title):
    • the presented edition's subtitle;
    • the work's subtitle only when the edition's title is the work's title, so it can't mix languages with the edition;
    • omitted when the title already contains it.
  • Part badge (shadcn Badge, secondary, inline after the title). A normalized label such as Part 2, Part 2 of 2 or Vol. 1. It is shown only when the presented title and subtitle hide the part, e.g. the German edition Die Türme der Mitternacht of the work Towers of Midnight 2/2. When the title or subtitle already shows the part (Words of Radiance / Part two), nothing is repeated.
    • Detects Part/Pt/Teil/Parte/Partie/Deel N, Volume/Vol/Tome/Tomo N (digits, number words, roman numerals), N of M, ordinal-first forms (1re partie, Erster Teil, Second part) and a trailing 1/2.
    • Book N is deliberately ignored because it is a series position (already shown on the series line). Book 1 of 3, 24/7 and 9/11 are not matched either.
  • Dates: Published 2019 becomes First published 2019 (the work's first publication). A separate This edition 2025 appears when the presented edition's year differs. This keeps the original publication date separate from a particular edition's date.
  • Accessible names (cover alt, "View on Open Library" label, bulk-select checkbox, remove dialog) use the full composed title (Title: Subtitle (Part 2)) via bookFullTitle().

Persistence

library_book gains three nullable columns: subtitle, part_label, edition_publish_year (migration 0008). Search-result saves and Goodreads imports store them, so saved books render the same way. The fields are optional on BookSearchResult, so the existing jsonb snapshots (imports/recommendations) and other producers keep working. Library identity and dedup are untouched.

Import matching

bestImportMatch now requires the part labels to agree. A Goodreads row titled Words of Radiance no longer auto-matches OL19913851W, whose edition is titled "Words of Radiance" with the subtitle "part two". Such rows fall through to the other candidates or to manual review.

Commits

  • feat: add subtitle, part label and edition year to book metadata
  • feat: normalize subtitles, part labels and edition years from Open Library
  • feat: detect ordinal and fraction part labels
  • feat: show subtitles, part labels and edition years on book cards
  • fix: avoid auto-matching imports to a different part of a split book

Verification

  • pnpm lint-full (typecheck + eslint) passes on every commit; the migration was applied to the worktree DB.
  • Ran the extractor on sample titles (true positives above; no match for Book Two of…, Part of Your World, Le parti pris, Books 1-3, 24/7, 9/11, Book 1 of 3).
  • Browser (dev server, test account):
    • Words of Radiance: the OL19913851W card now reads Words of Radiance / Part two instead of a bare "Words of Radiance". The 2023 leather edition shows its subtitle and First published 2015 · This edition 2023. Box sets show their contents as subtitles.
    • House in the Cerulean Sea (API data): the main card shows First published 2019 · This edition 2025. The TJ Klune collection shows its contents as a subtitle.
    • Towers of Midnight (German): Die Türme der Mitternacht Part 2 of 2, Das Rad der Zeit 34. Der Traum des Wolfs Part 1 of 2.
    • Saved Die Türme der Mitternacht: the DB row has part_label = 'Part 2 of 2' and the library card shows the same badge.

Demo

41 s. Covers "Words of Radiance" (subtitle + edition-year cards), "Towers of Midnight" with German filter (part badges), and the saved book in My library.

demo

better-card-metadata-demo.mp4

## Summary Book cards now show which publication they present, so a split volume (e.g. *Words of Radiance, Part Two*) no longer looks like the complete novel. The card still uses the preferred-language edition's title and cover. No extra upstream requests: only the `fields` list of the existing `/search.json` call is extended (`subtitle`, `editions.subtitle`, `editions.publish_year`). ## What a card shows now - **Subtitle** (new line under the title, heading font, muted, first letter capitalized, clamped to 2 lines with the full text in `title`): - the presented edition's subtitle; - the work's subtitle only when the edition's title is the work's title, so it can't mix languages with the edition; - omitted when the title already contains it. - **Part badge** (shadcn `Badge`, `secondary`, inline after the title). A normalized label such as `Part 2`, `Part 2 of 2` or `Vol. 1`. It is shown **only when the presented title and subtitle hide the part**, e.g. the German edition *Die Türme der Mitternacht* of the work *Towers of Midnight 2/2*. When the title or subtitle already shows the part (*Words of Radiance* / *Part two*), nothing is repeated. - Detects `Part/Pt/Teil/Parte/Partie/Deel N`, `Volume/Vol/Tome/Tomo N` (digits, number words, roman numerals), `N of M`, ordinal-first forms (`1re partie`, `Erster Teil`, `Second part`) and a trailing `1/2`. - `Book N` is deliberately ignored because it is a series position (already shown on the series line). `Book 1 of 3`, `24/7` and `9/11` are not matched either. - **Dates**: `Published 2019` becomes **`First published 2019`** (the work's first publication). A separate **`This edition 2025`** appears when the presented edition's year differs. This keeps the original publication date separate from a particular edition's date. - Accessible names (cover alt, "View on Open Library" label, bulk-select checkbox, remove dialog) use the full composed title (`Title: Subtitle (Part 2)`) via `bookFullTitle()`. ## Persistence `library_book` gains three nullable columns: `subtitle`, `part_label`, `edition_publish_year` (migration `0008`). Search-result saves and Goodreads imports store them, so saved books render the same way. The fields are optional on `BookSearchResult`, so the existing jsonb snapshots (imports/recommendations) and other producers keep working. Library identity and dedup are untouched. ## Import matching `bestImportMatch` now requires the part labels to agree. A Goodreads row titled *Words of Radiance* no longer auto-matches OL19913851W, whose edition is titled "Words of Radiance" with the subtitle "part two". Such rows fall through to the other candidates or to manual review. ## Commits - feat: add subtitle, part label and edition year to book metadata - feat: normalize subtitles, part labels and edition years from Open Library - feat: detect ordinal and fraction part labels - feat: show subtitles, part labels and edition years on book cards - fix: avoid auto-matching imports to a different part of a split book ## Verification - `pnpm lint-full` (typecheck + eslint) passes on every commit; the migration was applied to the worktree DB. - Ran the extractor on sample titles (true positives above; no match for `Book Two of…`, `Part of Your World`, `Le parti pris`, `Books 1-3`, `24/7`, `9/11`, `Book 1 of 3`). - Browser (dev server, test account): - **Words of Radiance**: the OL19913851W card now reads *Words of Radiance* / *Part two* instead of a bare "Words of Radiance". The 2023 leather edition shows its subtitle and *First published 2015 · This edition 2023*. Box sets show their contents as subtitles. - **House in the Cerulean Sea** (API data): the main card shows *First published 2019 · This edition 2025*. The TJ Klune collection shows its contents as a subtitle. - **Towers of Midnight (German)**: *Die Türme der Mitternacht* `Part 2 of 2`, *Das Rad der Zeit 34. Der Traum des Wolfs* `Part 1 of 2`. - Saved *Die Türme der Mitternacht*: the DB row has `part_label = 'Part 2 of 2'` and the library card shows the same badge. ## Demo 41 s. Covers "Words of Radiance" (subtitle + edition-year cards), "Towers of Midnight" with German filter (part badges), and the saved book in My library. ![demo](https://forgejo.chrispaganon.com/attachments/1e2a6f03-d134-4501-960c-04a423d9591f) [better-card-metadata-demo.mp4](https://forgejo.chrispaganon.com/attachments/1e2a6f03-d134-4501-960c-04a423d9591f)
Author
Owner

Reviewed feat/better-card-metadata against master (5 commits), using the full-code-review skill and the product notes.

Important

  1. Require stronger evidence before interpreting ordinary prose as a part label — must fix before merge. shared/utils/book-search.ts:46 (used by server/utils/open-library.ts:92-99). Running the actual extractor returns Part 1 for both The Part I Played and The Part One Plays, and Vol. 5 for Vol. V. Smith: A Biography. These are valid ordinary-title/name constructions, not evidence of a split publication. If an edition has a translated/different title, normalization adds that invented part badge to its card and persists it on save. The same false positives also participate in import matching. Constrain detection to clearer label contexts, treating ambiguous prose/initials as unknown.

  2. Do not treat Goodreads series annotations as split-publication labels — must fix before merge. server/utils/import-matching.ts:64-69. For a row titled A Book (Series, Vol. 1) and a candidate titled A Book by the same author with no split-part metadata, comparable() deliberately removes the Goodreads suffix, but samePart() scans the unstripped title and compares Vol. 1 with null. This previously valid match now becomes manual review, including when the candidate was found by the row's ISBN. A volume position inside a Goodreads series qualifier does not establish that the book is a fragment of a larger publication. Separate series annotations from publication-part evidence before applying this guard.

  3. Compare part identity rather than the complete display string — must fix before merge. server/utils/import-matching.ts:65. A Goodreads row A Book (Part 1) and a normalized candidate { title: "A Book", partLabel: "Part 1 of 2" } by the same author matched on master, but now fail because Part 1 !== Part 1 of 2. Both identify the same first part; only one supplies the total. This is reproducible through the normalizer with work title A Book, Part 1 of 2 and edition title A Book. Compare structured part numbers, checking totals when both are known, while continuing to reject conflicting part numbers and whole-book/fragment mismatches.

Other categories and validation

  • Nit picks: 0. Pre-existing: 0. Security: 0 findings.
  • pnpm lint-full passed. Evaluated the actual extraction, normalization and matching functions in memory; no test files or repository code were added or changed.
  • The PR expands fields on existing Open Library requests; it adds no upstream request calls. Incorrect manual-review fallbacks above can prompt extra user-initiated searches.
Reviewed `feat/better-card-metadata` against `master` (5 commits), using the full-code-review skill and the product notes. ### Important 1. **Require stronger evidence before interpreting ordinary prose as a part label — must fix before merge.** `shared/utils/book-search.ts:46` (used by `server/utils/open-library.ts:92-99`). Running the actual extractor returns `Part 1` for both `The Part I Played` and `The Part One Plays`, and `Vol. 5` for `Vol. V. Smith: A Biography`. These are valid ordinary-title/name constructions, not evidence of a split publication. If an edition has a translated/different title, normalization adds that invented part badge to its card and persists it on save. The same false positives also participate in import matching. Constrain detection to clearer label contexts, treating ambiguous prose/initials as unknown. 2. **Do not treat Goodreads series annotations as split-publication labels — must fix before merge.** `server/utils/import-matching.ts:64-69`. For a row titled `A Book (Series, Vol. 1)` and a candidate titled `A Book` by the same author with no split-part metadata, `comparable()` deliberately removes the Goodreads suffix, but `samePart()` scans the unstripped title and compares `Vol. 1` with `null`. This previously valid match now becomes manual review, including when the candidate was found by the row's ISBN. A volume position inside a Goodreads series qualifier does not establish that the book is a fragment of a larger publication. Separate series annotations from publication-part evidence before applying this guard. 3. **Compare part identity rather than the complete display string — must fix before merge.** `server/utils/import-matching.ts:65`. A Goodreads row `A Book (Part 1)` and a normalized candidate `{ title: "A Book", partLabel: "Part 1 of 2" }` by the same author matched on `master`, but now fail because `Part 1 !== Part 1 of 2`. Both identify the same first part; only one supplies the total. This is reproducible through the normalizer with work title `A Book, Part 1 of 2` and edition title `A Book`. Compare structured part numbers, checking totals when both are known, while continuing to reject conflicting part numbers and whole-book/fragment mismatches. ### Other categories and validation - Nit picks: 0. Pre-existing: 0. Security: 0 findings. - `pnpm lint-full` passed. Evaluated the actual extraction, normalization and matching functions in memory; no test files or repository code were added or changed. - The PR expands fields on existing Open Library requests; it adds no upstream request calls. Incorrect manual-review fallbacks above can prompt extra user-initiated searches.
chris-paganon force-pushed feat/better-card-metadata from a5f5cc53bd to df286e6523 2026-11-14 18:22:48 +00:00 Compare
Author
Owner

Thanks. I accepted all three findings and fixed them in separate commits (pnpm lint-full passes on each):

  1. Prose false positives (169dd6a fix: require a clear label context before detecting part labels). Number words, roman numerals, ordinal-first forms and N of M now count only when they end the title or a clause: end of string, , ; : ) ] / –, or a final period. Digits after an explicit Part/Vol keyword keep the old boundary rule, since that context is unambiguous (Naruto, Vol. 3: …). The Part I Played, The Part One Plays, Vol. V. Smith: A Biography and The first part of the tale now return nothing. Words of Radiance, Part Two, Part II: The Fall, Words of Radiance (1 of 5), Der Tragödie erster Teil and Towers of Midnight 2/2 are still detected. The extractor now returns a structured PublicationPart { kind, number, total }, and extractPartLabel formats it.
  2. Goodreads series annotations (3b88a96 fix: ignore Goodreads series annotations when comparing import parts). A trailing parenthetical containing , or # ((Series, #1), (Series, Vol. 1)) is stripped before reading the row's part. A Book (Series, Vol. 1) matches A Book again. A bare (Part 1) is still read as a part.
  3. Structured comparison (9f55804 fix: compare structured part numbers when matching imports). samePublicationPart compares part numbers and checks totals only when both sides know them. A Book (Part 1) matches a candidate with Part 1 of 2. Part 2 vs Part 1 of 2, Part 1 of 3 vs Part 1 of 2, and whole book vs fragment are still rejected.

Rebase on master (PR #3): the only conflicts were the bookSearchIdentity comment and the migration journal. I dropped my old 0008 and regenerated it as 0009_lame_dust (adds subtitle, part_label, edition_publish_year), chained to master's 0008_blushing_prism. Migrations 0000–0009 apply cleanly to a fresh DB clone. Saving through master's one-entry-per-work flow persists the new fields (checked: Der Traum des Wolfs → part_label = 'Part 1 of 2'). I also added df286e6, which uses the full title (subtitle and part) in master's new "Saved as another edition" note. A browser re-check after the rebase shows subtitles, part badges and "This edition" years as before.

Thanks. I accepted all three findings and fixed them in separate commits (`pnpm lint-full` passes on each): 1. **Prose false positives** (`169dd6a` fix: require a clear label context before detecting part labels). Number words, roman numerals, ordinal-first forms and `N of M` now count only when they end the title or a clause: end of string, `, ; : ) ] / –`, or a final period. Digits after an explicit Part/Vol keyword keep the old boundary rule, since that context is unambiguous (`Naruto, Vol. 3: …`). `The Part I Played`, `The Part One Plays`, `Vol. V. Smith: A Biography` and `The first part of the tale` now return nothing. `Words of Radiance, Part Two`, `Part II: The Fall`, `Words of Radiance (1 of 5)`, `Der Tragödie erster Teil` and `Towers of Midnight 2/2` are still detected. The extractor now returns a structured `PublicationPart { kind, number, total }`, and `extractPartLabel` formats it. 2. **Goodreads series annotations** (`3b88a96` fix: ignore Goodreads series annotations when comparing import parts). A trailing parenthetical containing `,` or `#` (`(Series, #1)`, `(Series, Vol. 1)`) is stripped before reading the row's part. `A Book (Series, Vol. 1)` matches `A Book` again. A bare `(Part 1)` is still read as a part. 3. **Structured comparison** (`9f55804` fix: compare structured part numbers when matching imports). `samePublicationPart` compares part numbers and checks totals only when both sides know them. `A Book (Part 1)` matches a candidate with `Part 1 of 2`. `Part 2` vs `Part 1 of 2`, `Part 1 of 3` vs `Part 1 of 2`, and whole book vs fragment are still rejected. Rebase on master (PR #3): the only conflicts were the `bookSearchIdentity` comment and the migration journal. I dropped my old `0008` and regenerated it as `0009_lame_dust` (adds `subtitle`, `part_label`, `edition_publish_year`), chained to master's `0008_blushing_prism`. Migrations 0000–0009 apply cleanly to a fresh DB clone. Saving through master's one-entry-per-work flow persists the new fields (checked: `Der Traum des Wolfs` → `part_label = 'Part 1 of 2'`). I also added `df286e6`, which uses the full title (subtitle and part) in master's new "Saved as another edition" note. A browser re-check after the rebase shows subtitles, part badges and "This edition" years as before.
chris-paganon deleted branch feat/better-card-metadata 2026-11-14 18:23:07 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
chris-paganon/chrisp-books!4
No description provided.