Skip to content

[Generated Chapters] Show a Generate chapters prompt and a loading state - #6293

Merged
sztomek merged 25 commits into
mainfrom
feat/generated-chapters-no-chapters-yet
Nov 5, 2026
Merged

sztomek merged 25 commits into
mainfrom
feat/generated-chapters-no-chapters-yet

Conversation

@sztomek

@sztomek sztomek commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes PCDROID-841 https://linear.app/a8c/issue/PCDROID-841

Plus and Patron users now see generated chapters states in the Chapters tab when an episode has no creator chapters. Free users still see the upsell. User files are not affected.

  • No chapters yet: shown while generated chapters are turned off and none are stored. Tapping Generate chapters turns the setting on and loads them straight away.
  • Generating chapters…: a pulsing sparkle header and a shimmering skeleton while the load runs. The header uses the same colours as the generated list header. The ⋯ menu still offers "Turn off generated chapters". After 5 seconds a note explains it can take a minute. The note restarts when the player moves to another episode.
  • No chapters for this episode: with the body "We couldn't generate chapters for this one."

How the load decides the state:

  • The episode has no generated transcript (hasGeneratedTranscript is false): No chapters for this episode right away. It no longer waits up to a minute for a transcript row.
  • The episode has one: the -meta.json URL is built from the episode, without waiting for the transcript row.
    • Chapters found: the list.
    • 404 or no chapters: No chapters for this episode.
    • Network or server error: keep Generating and retry after 5, 10 and 15 s. If the retry at about 30 s also fails, No chapters for this episode shows. Two more retries run quietly after 40 and 80 s. If one of them works, the list replaces "No chapters for this episode".
  • When the episode's hasGeneratedTranscript flips to true, the tab loads again and moves from "No chapters for this episode" to generating and the list.

Only one -meta.json request runs per episode. The player, its Chapters page and the episode sheet each have their own view model, and each used to fetch and retry on its own. Now TranscriptManagerImpl shares one in-flight load per episode on the application scope. A caller that leaves doesn't cancel the load for the others. A failed result is reused for 3 seconds so retries from several screens collapse into one request. After that the next retry fetches again. If generated chapters are turned off while a request is in flight, its chapters are not saved, so the tab goes back to "No chapters yet".

There is no on-demand generation API. "Generate" enables the setting and loads chapters that were already generated.

TalkBack reads "Generating chapters…" once, as an in-progress header. The skeleton bars are hidden from TalkBack.

generated_chapters_prompt_shown now uses the loaded state of the episode instead of the tab's first default state, and fires once per episode and prompt.

The Generate tap is tracked as settings_general_generated_chapters_toggled with enabled = true and source = chapters_generate_button.

No changelog entry because the feature is behind a remote flag that is off.

Testing Instructions

Use a Plus account with the generated chapters flag on.

  1. Turn off Auto generate chapters in Settings → General.
  2. Open an episode without creator chapters that has a generated transcript and has not been opened before.
  3. Go to Chapters.
  4. ✅ "No chapters yet" shows with the Generate chapters button and the AI footnote. Logcat shows generated_chapters_prompt_shown with prompt=no_chapters_yet once.
  5. Tap Generate chapters.
  6. ✅ "Generating chapters…" shows with the skeleton, then the generated list.
  7. Turn generated chapters off again, open another such episode, turn on airplane mode and tap Generate chapters.
  8. ✅ The skeleton stays and the note fades in after 5 seconds. After about 30 seconds "No chapters for this episode" shows.
  9. Turn airplane mode off and wait up to 40 seconds.
  10. ✅ The list replaces "No chapters for this episode".
  11. With logcat filtered on meta.json, repeat step 7 with the episode playing and its episode sheet open.
  12. ✅ Each retry round makes one request, not one per screen.
  13. Open an episode without a generated transcript (for example an NPR News Now episode).
  14. ✅ "No chapters for this episode" with the new body shows right away.
  15. While generating, open ⋯ and tap Turn off generated chapters.
  16. ✅ The snackbar shows and the tab goes back to "No chapters yet".
  17. Log in with a free account.
  18. ✅ The upsell still shows instead of these states.

Screenshots or Screencast

No chapters yet Generating chapters… No chapters for this episode Chapters ready
No chapters yet Generating chapters No chapters for this episode Generated chapters list

Generate → generating → list:

generate-to-list.mp4

Offline: the skeleton holds while retrying and the slow note fades in:

generate-offline-retry.mp4

No generated transcript: shown right away:

no-generated-transcript-immediate.mp4

Device pass (debug build, staging, Plus account). Each collage: No chapters yet, Generating with the slow note, No chapters for this episode, generated list, ⋯ menu, off state, free upsell.

Light (episode sheet) Dark (episode sheet) Podcast-coloured player
Light theme states Dark theme states Player states
Landscape (player) Font scale 2.0 and display size +20% (player)
Landscape states Large font states

One shared load: offline, with the episode playing and its sheet open. Before, the player and sheet view models fetched on their own, about 2 s apart:

16:43:19.951 --> GET 379bcaf4-…-meta.json
16:43:21.854 --> GET 379bcaf4-…-meta.json
16:43:24.962 --> GET 379bcaf4-…-meta.json
16:43:26.861 --> GET 379bcaf4-…-meta.json
16:43:35.015 --> GET 379bcaf4-…-meta.json
16:43:36.891 --> GET 379bcaf4-…-meta.json

After, one request per retry round. "No chapters for this episode" shows after the 16:51:50 failure (30 s). The network comes back and the quiet retry at 16:52:30 loads the list:

16:51:20.257 --> GET 379bcaf4-…-meta.json
16:51:25.270 --> GET 379bcaf4-…-meta.json
16:51:35.323 --> GET 379bcaf4-…-meta.json
16:51:50.429 --> GET 379bcaf4-…-meta.json
16:52:30.921 --> GET 379bcaf4-…-meta.json
16:52:33.826 <-- 200 379bcaf4-…-meta.json (2897ms)
16:52:34.263 D GeneratedChapters: Saved 9 AI chapters for episode 379bcaf4-…

Online Generate from the player, one request:

16:54:35.804 --> GET 379bcaf4-…-meta.json
16:54:35.868 <-- 200 379bcaf4-…-meta.json (64ms)
16:54:35.874 D GeneratedChapters: Saved 9 AI chapters for episode 379bcaf4-…

Semantics (uiautomator; TalkBack is not installed on the emulator image, so this was not checked with TalkBack itself). Each button is one focusable node with the Button role and its label. The skeleton is one progress element:

View click focus > TextView "Generate chapters" + Button role
View click focus > TextView "Turn on" + Button role
View click focus > TextView "Get generated chapters" + Button role
View click focus (48 dp) > content-desc="More options" + Button role
View click focus (row) > "1" "Warning About Explicit Content" "34 secs"

Opening Chapters on an episode without a generated transcript. The tab opened at 15:07:55.216 and the state was on screen at the next UI dump (15:07:56.215):

11-03 15:07:55.216 I Analytics: 🔵 Event: episode_detail_tab_changed, Properties: {value=chapters}
15:07:56.215 'No chapters for this episode' / "We couldn't generate chapters for this one."

Offline Generate: retries with backoff, then the list once the network is back:

11-03 14:59:35.537 I Analytics: 🔵 Event: settings_general_generated_chapters_toggled, Properties: {enabled=true, source=chapters_generate_button}
11-03 14:59:35.693 E GeneratedChapters: Failed to load generated chapters for episode 4637b75b-… (UnknownHostException)
11-03 14:59:40.699 E GeneratedChapters: Failed to load generated chapters for episode 4637b75b-…
11-03 14:59:50.859 E GeneratedChapters: Failed to load generated chapters for episode 4637b75b-…
11-03 15:00:16.313 D GeneratedChapters: Saved 6 AI chapters for episode 4637b75b-80ca-4a0d-9236-e35fef2224ef

generated_chapters_prompt_shown when opening the Chapters tab:

11-03 14:56:18.870 I Analytics: 🔵 Event: episode_detail_tab_changed, Properties: {value=chapters}
11-03 14:56:18.900 I Analytics: 🔵 Event: generated_chapters_prompt_shown, Properties: {episode_uuid=df3fca8c-4dba-429b-bca8-8ae62825015c, podcast_uuid=4eb5b260-c933-0134-10da-25324e2a541d, prompt=no_chapters_yet, source=episode_details}

Generating state semantics, covered by ChaptersGeneratingTest (Robolectric): one "Generating chapters…" text node with indeterminate progress, and no content description on the skeleton.

Checklist

  • If this is a user-facing change, I have added an entry in CHANGELOG.md
  • Ensure the linter passes (./gradlew spotlessApply to automatically apply formatting/linting)
  • I have considered whether it makes sense to add tests for my changes
  • All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
  • Any jetpack compose components I added or changed are covered by compose previews
  • I have updated (or requested that someone edit) the Event Horizon schema to reflect any new or changed analytics.

I have tested any UI changes...

  • with different themes
  • with a landscape orientation
  • with the device set to have a large display and font size
  • for accessibility with TalkBack

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 59s —— View job


I found nothing blocking. The load and status logic in ChaptersViewModel holds up in the flows I traced: Generate tapped while generated chapters are off, turning them off and undoing while generating, switching episodes in Player mode, a failed load with background retries, and a successful load with saved chapters. Free users still get the upsell, and user files are unchanged. I didn't build the project or run the tests.

@dangermattic

dangermattic commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@sztomek sztomek added [Area] Chapters Episode chapters [Type] Feature Adding a new feature. labels Oct 30, 2026
@sztomek sztomek added this to the 8.25 milestone Oct 30, 2026
@sztomek
sztomek marked this pull request as ready for review October 30, 2026 11:26
@sztomek
sztomek requested a review from a team as a code owner October 30, 2026 11:26
@sztomek
sztomek requested review from geekygecko and removed request for a team October 30, 2026 11:26
@sztomek
sztomek added this pull request to stack #6294 October 30, 2026 11:26
@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 9s —— View job


No commits have landed since my last review (the newest, e7bbe6a, predates it), and that review left no findings open, so I have nothing new to add.

@sztomek
sztomek force-pushed the feat/generated-chapters-no-chapters-yet branch from e7bbe6a to 145c16a Compare October 30, 2026 14:25
@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 41s —— View job


The branch was force-pushed, so I couldn't diff against the commit I last reviewed (e7bbe6a). I re-read the full diff against feat/generated-chapters-opt-in instead, and nothing blocks. I traced the empty-state logic in ChaptersViewModel through Generate, turning chapters off while generating, switching episodes, failed loads with retries, and slow saves after a successful load. Each flow ends in the expected state, and free users and user files are unchanged. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) The !load.isEnabled check can never be true, because line 91 already returns when it's false. Removing it makes the condition easier to read.

@sztomek
sztomek force-pushed the feat/generated-chapters-no-chapters-yet branch from 145c16a to 66db590 Compare October 30, 2026 15:21
@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 30s —— View job


The branch was force-pushed again, this time as a rebase of the whole stack (the base 8d7f370 and all seven PR commits carry the same commit time), so I couldn't diff against what I last reviewed. I re-read the ChaptersViewModel, ChaptersPage, ChaptersFragment and ChaptersHeader changes against feat/generated-chapters-opt-in and found nothing new that blocks. The one nit from my last review is still there. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) Still open from the last review: the !load.isEnabled check can never be true, because line 91 already returns when it's false. Removing it makes the condition easier to read.

@sztomek
sztomek force-pushed the feat/generated-chapters-no-chapters-yet branch from 66db590 to b67e7f9 Compare October 30, 2026 15:44
@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 19s —— View job


The branch was rebased again: all seven commits now carry the same new commit time, and I couldn't diff against the commits I last reviewed. The overall diff against feat/generated-chapters-opt-in is the same size as before (8 files, +788/−97). I re-read the ChaptersViewModel and ChaptersFragment changes and found no new problems. One nit from earlier is still open. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) Still open: the !load.isEnabled check can never be true, because line 91 already returns when it's false. Removing it would make the condition easier to read.

@geekygecko
geekygecko force-pushed the feat/generated-chapters-no-chapters-yet branch from b67e7f9 to d270072 Compare November 2, 2026 07:07
@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @geekygecko's task in 11s —— View job


The branch was rebased again: all seven commits now carry the same new commit time (2026-11-02), so I couldn't diff against what I last reviewed. The overall diff against feat/generated-chapters-opt-in is still 8 files, +788/−97, and the load logic in ChaptersViewModel reads the same as before. I found nothing new, and one earlier nit is still open. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) Still open from earlier reviews: the !load.isEnabled check can never be true because line 91 already returns when it's false, so it can be removed.

@geekygecko
geekygecko force-pushed the feat/generated-chapters-no-chapters-yet branch from d270072 to c1b66c4 Compare November 2, 2026 07:19
@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @geekygecko's task in 12s —— View job


The branch was rebased again. All seven commits now carry the commit time 2026-11-02 17:49 +10:30, so I couldn't diff against what I last reviewed. The overall diff against feat/generated-chapters-opt-in is still 8 files, +788/−97, and loadGeneratedChapters in ChaptersViewModel hasn't changed. Nothing new turned up, and one earlier nit is still open. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) Still open from earlier reviews: you can remove the !load.isEnabled check, because line 91 already returns when it's false.

Base automatically changed from feat/generated-chapters-opt-in to main November 2, 2026 09:08
@sztomek
sztomek force-pushed the feat/generated-chapters-no-chapters-yet branch from c1b66c4 to 7b72419 Compare November 2, 2026 09:08
@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 17s —— View job


The branch was rebased onto the merged #6292 (5478f35), so I couldn't diff against the commits I last reviewed. The PR diff on top of 5478f35 is the same size as before (8 files, +788/−97), and loadGeneratedChapters in ChaptersViewModel reads the same as it did. I found nothing new, and one earlier nit is still open. I didn't build the project or run the tests.

Nits

modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:93 (nit) Still open from earlier reviews: you can remove the !load.isEnabled check, because line 91 already returns when it's false.

@sztomek
sztomek force-pushed the feat/generated-chapters-no-chapters-yet branch from 7b72419 to dad2733 Compare November 2, 2026 13:49
@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 30s —— View job


Two commits have landed since my last review. 3c260a9 removes the redundant !load.isEnabled check, which closes my earlier nit. dad2733 now passes GeneratedChaptersToggleSourceType.ChaptersGenerateButton as the toggle source. Neither commit introduces a problem, and nothing from earlier reviews is still open. I couldn't confirm that the eventhorizon artifact pinned in libs.versions.toml contains ChaptersGenerateButton, because there's no local copy to check; the CI compile will catch it if it doesn't. I didn't build the project or run the tests.

@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 32s —— View job


Since my last review the branch has picked up #6316 (fb2c972) and a merge of main (d525e67). #6316 adds prompt-shown tracking to ChaptersViewModel.trackChaptersShown. The merge removes the unused chapters_generated_disclaimer string, and nothing on this branch still references it. Neither change adds a problem, and no earlier findings are open. I didn't build the project or run the tests.

@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 56s —— View job


Seven commits have landed since my last review (23c8a3d…ee2d609). They don't add a problem, and no earlier findings are open. I read the new load path: hasGeneratedTranscriptFlow, GeneratedChaptersResult, the retry-then-finish loop, and TranscriptManagerImpl building the meta URL from SERVER_SHOW_NOTES_URLS. I also read the once-per-prompt tracking and the slow note that now resets per episode. I didn't build the project or run the tests.

@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 50s —— View job


Nothing blocks in the three commits since my last review (6370fd1, a899b6f, 10fd92d), and no earlier findings are open. The shared per-episode load, the 3-second reuse of a failed load and the quiet retries after 30 seconds work as the tests describe. Moving the fetch into applicationScope means a request no longer stops when the screen's load is cancelled, which leads to the one finding below. I didn't build the project or run the tests.

Non-blocking

  • modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/transcript/TranscriptManagerImpl.kt:178: Turning off generated chapters while a request is in flight can show "Generated chapters are off" instead of "No chapters yet", because the request still finishes and saves the chapters. Check isAllowed() again just before saving. [Generated Chapters] Show a Generate chapters prompt and a loading state #6293 (comment)
  • modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/chapters/ChaptersViewModel.kt:459: Testers following the PR description will expect the wrong offline behaviour. The code now uses 5, 10, 15, 40 and 80 s and shows "No chapters for this episode" after 30 s while it keeps retrying. The description still says 20 s and "only after the retries run out", so update it.

if (!generatedChaptersAvailability.isAllowed()) return GeneratedChaptersResult.Unavailable

val load = generatedChaptersLoads.computeIfAbsent(episodeUuid) {
applicationScope.async(start = CoroutineStart.LAZY) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(non-blocking) A user who taps Turn off generated chapters while the meta request is in flight can end up on "Generated chapters are off" instead of "No chapters yet". Before this change, collectLatest cancelled the request. Now the fetch runs in applicationScope, so it finishes and saveAiChapters writes the chapters. With visibility Hidden, hasHiddenGeneratedChapters becomes true and emptyState resolves to GeneratedChaptersOff. The window is one request long. To fix it, check generatedChaptersAvailability.isAllowed() again just before chapterManager.updateChapters, or cancel the shared job once no callers are waiting.

@claude

claude Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 25s —— View job


The three new commits (4edb8a3, 496b8b2, 7ca05ba) add no problems, and no earlier findings are still open. 4edb8a3 checks isAllowed() again after the meta response arrives, which fixes the turn-off-while-in-flight thread. The Unavailable result it returns is removed from the shared map right away, so an undo starts a fresh load. The PR description now lists the 5/10/15/40/80 s retries, which closes the other earlier finding. I didn't build the project or run the tests.

@geekygecko geekygecko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good from the screenshots, and I was able to see the loading state by switching to airplane mode. I couldn't test it with an episode that has a transcript but no chapters, as I don't think that's currently possible.

…rs-no-chapters-yet

# Conflicts:
#	modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/transcript/TranscriptManagerImpl.kt
#	modules/services/repositories/src/test/java/au/com/shiftyjelly/pocketcasts/repositories/transcript/TranscriptManagerTest.kt
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @sztomek's task in 32s —— View job


The only change since my last review is a merge of main (74abb86), which brings in #6338. It adds no new problems, and no earlier findings are open. In TranscriptManagerImpl.fetchGeneratedChapters the merge swaps getTranscriptOrThrow for #6338's downloadMeta. A non-2xx response from downloadMeta still throws HttpException, so a 404 still gives Unavailable and other errors still give Failed. I didn't build the project or run the tests.

@sztomek
sztomek merged commit c68b779 into main Nov 5, 2026
20 checks passed
@sztomek
sztomek deleted the feat/generated-chapters-no-chapters-yet branch November 5, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Chapters Episode chapters [Type] Feature Adding a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants