Repository navigation
fix: materialize chapters from outlines instead of claiming all are generated - #291
Merged
Merged
Conversation
…enerated
The batch entry point only scanned existing chapter rows for an empty body, so a
project with 70 outlines but 58 chapter rows reported "all chapters generated"
and the 12 outlined-but-unbuilt chapters were unreachable.
- `GET /project/{id}/stats` now also reports `outline_total`,
`max_outline_number` and `missing_from_outlines`.
- `POST /project/{id}/materialize-outlines` creates the missing chapter rows from
their outlines (idempotent, never overwrites, keeps the outline link and title,
empty content, draft status).
- The batch entry point materialises them first and then continues, instead of
stopping at the "all generated" toast.
Verified on the affected project: stats reported 12 missing, materialisation
created chapters 59-70, stats then reported 0 missing and 70 total.
Refs #290
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #290.
Symptom
A project with 70 outlines and 58 chapter rows answered "所有章节都已生成内容" when the user tried to batch-generate, so the 12 outlined-but-unbuilt chapters were unreachable from the UI.
Cause
handleOpenBatchGeneratelooked for the first chapter with empty content among existing chapter rows:An outline without a chapter row is invisible to that scan. Deleting chapters (rows removed, outlines kept as the plan) produces exactly this state; so does any import that created outlines without chapters. The backend had the same blind spot — stats reported only chapter count and max chapter number, and nothing could build a chapter from its outline.
Change
GET /project/{id}/statsnow returnsoutline_total,max_outline_numberandmissing_from_outlines.POST /project/{id}/materialize-outlinescreates the missing chapter rows from their outlines: idempotent, never overwrites an existing chapter, keeps the outline link and its title, empty content,status=draft.Verification (real project)
Test plan
Tests cover the stats gap, idempotency, "never overwrites an existing chapter", and outlines without an
order_indexbeing skipped.Desensitized per repository policy: no source text, titles or character names are included.