feat(series): flat series sequence + cosmetic chapter dividers (#789 Phase 1)
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 21s
CI / backend-lint-and-test (push) Successful in 35s
CI / integration (push) Successful in 3m13s

Reframe a series from "ordered chapters that own pages" to ONE flat,
series-global ordered run of pages with optional cosmetic chapter DIVIDERS
over it. A chapter no longer wraps content — it's a labeled divider anchored
to the page that begins it; a page's chapter is derived as the nearest
preceding divider. This is what lets installments assembled from multiple
sources sit in one continuous, correctly-numbered sequence (operator's
Goblin Juice case).

- migration 0047: flatten each series to a series-global page_number
  (preserving today's reading order); convert each existing chapter to a
  divider anchored at its first page (keeping title/stated_part); drop
  series_page.chapter_id; reshape series_chapter (anchor_page_id UNIQUE FK,
  drop chapter_number/is_placeholder/stated_page_start/end). Loss-safe for
  content; drops empty placeholder chapters + a redundant page-1 divider.
- series_page: page_number is now the series-global order; no chapter_id.
- series_chapter: anchored divider (anchor_page_id, title, stated_part).
- series_service: flat list_pages (one run + derived dividers + per-page
  source_post + part_gaps), series-wide reorder/renumber, divider CRUD
  (create/update/move/delete); retired per-chapter reorder/merge/placement.
- api/tags: drop chapter_id from add; /chapters endpoints are divider
  create/update/delete (removed chapter reorder/merge/page-reorder).
- series_match_service: series "end" reads max(series_page.stated_page);
  accept appends via add_post. tag_service series-merge appends src's pages
  after tgt's max so the merged series stays one clean run.
- frontend: seriesManage store + SeriesManageView → one continuous
  drag-reorder grid with inline divider bars + series-global page numbers;
  reader walks the flat run, headings from dividers; PostSeriesMenu copy.
- tests reworked across the series suite for the divider model.

Phase 2 (pending staging for add-from-post) is separate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-11 21:30:01 -04:00
parent 3610ba495f
commit 59746d213d
18 changed files with 914 additions and 1141 deletions
+19 -10
View File
@@ -178,14 +178,21 @@ def test_find_unused_tags_excludes_fandom_referenced_by_character(db_sync):
assert "NobodysFandom" in names # genuinely orphaned → still swept
def test_find_unused_tags_excludes_series_with_only_chapters(db_sync):
# An all-placeholder series has chapters but no pages yet — not unused.
series = _make_tag(db_sync, name="EmptySeries", kind=TagKind.series)
db_sync.add(SeriesChapter(series_tag_id=series.id, chapter_number=1))
def test_find_unused_tags_excludes_series_with_a_divider(db_sync):
# A series with a chapter divider (which anchors to a page) is in use.
a = _make_artist(db_sync)
series = _make_tag(db_sync, name="DivSeries", kind=TagKind.series)
img = _make_image(
db_sync, artist=a, path="/tmp/fc_divser.jpg", sha256="e" * 64,
)
page = SeriesPage(series_tag_id=series.id, image_id=img.id, page_number=1)
db_sync.add(page)
db_sync.flush()
db_sync.add(SeriesChapter(series_tag_id=series.id, anchor_page_id=page.id))
db_sync.commit()
names = [t.name for t in cleanup_service.find_unused_tags(db_sync)]
assert "EmptySeries" not in names
assert "DivSeries" not in names
# --- unlink_image_files ---------------------------------------------
@@ -391,7 +398,12 @@ def test_prune_unused_tags_commit_spares_fandom_and_chaptered_series(
image_record_id=img.id, tag_id=char.id,
))
series = _make_tag(db_sync, name="EmptySeries", kind=TagKind.series)
db_sync.add(SeriesChapter(series_tag_id=series.id, chapter_number=1))
simg = _make_image(
db_sync, artist=a, path=str(tmp_path / "s.jpg"), sha256="e" * 64,
)
db_sync.add(SeriesPage(
series_tag_id=series.id, image_id=simg.id, page_number=1
))
_make_tag(db_sync, name="GenuinelyUnused")
db_sync.commit()
@@ -480,11 +492,8 @@ def test_reset_content_tagging_deletes_content_keeps_fandom_series(db_sync, tmp_
{"image_record_id": img.id, "tag_id": c.id},
{"image_record_id": img.id, "tag_id": s.id}, # series membership
]))
ch = SeriesChapter(series_tag_id=s.id, chapter_number=1)
db_sync.add(ch)
db_sync.flush()
db_sync.add(SeriesPage(
series_tag_id=s.id, chapter_id=ch.id, image_id=img.id, page_number=1
series_tag_id=s.id, image_id=img.id, page_number=1
))
db_sync.commit()