This repository was archived by the owner on Jul 7, 2026. It is now read-only.
Commit 30df8fe
feat(story): auto-generate chapter titles for continuations
Phase 5 PR-E. Now that stories can grow chapter-by-chapter (PR-D Lite),
each new chapter benefits from its own title for navigation.
Changes:
- /api/stories/[id]/continue now calls gpt-4o-mini after writing the
body to produce a 4-10 character poetic chapter title; saves it
alongside the chapter and surfaces it in the SSE complete event
- The continuation dialog already shows the message, so users see
"第 2 章「夜半潮声」已添加" in the success toast
- /api/stories no longer copies the story title onto the first chapter
— that was creating a duplicate h2 in the reader
- StoryReader skips the chapter h2 entirely for single-chapter stories
(the page h1 already serves as the title) and defensively hides
chapter titles that equal the story title for legacy data
The chapter title prompt is intentionally conservative (no spoilers,
poetic but short, no "第 X 章" prefix) and falls back to null on any
failure; the reader handles untitled chapters as "第 N 章".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4055be0 commit 30df8fe
3 files changed
Lines changed: 57 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
23 | 58 | | |
24 | 59 | | |
25 | 60 | | |
| |||
158 | 193 | | |
159 | 194 | | |
160 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
161 | 199 | | |
162 | 200 | | |
163 | 201 | | |
164 | 202 | | |
165 | 203 | | |
166 | 204 | | |
167 | 205 | | |
168 | | - | |
| 206 | + | |
169 | 207 | | |
170 | 208 | | |
171 | 209 | | |
| |||
179 | 217 | | |
180 | 218 | | |
181 | 219 | | |
182 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
183 | 223 | | |
184 | 224 | | |
| 225 | + | |
185 | 226 | | |
186 | 227 | | |
187 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
169 | 172 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| |||
0 commit comments