Skip to content

[Generated Chapters] Refresh an episode's generated transcript flag when it's opened - #6336

Open
sztomek wants to merge 6 commits into
mainfrom
fix/generated-transcript-flag-refresh
Open

sztomek wants to merge 6 commits into
mainfrom
fix/generated-transcript-flag-refresh

Conversation

@sztomek

@sztomek sztomek commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Episodes added by the hourly refresh always have has_generated_transcript = false, because the refresh payload doesn't include that field. The flag was only updated when you opened the podcast page. Until then, the generated transcript wasn't added for the episode, so the Transcript button stayed disabled and generated chapters didn't show.

Now, when show notes are processed for an episode on a screen the user opened (player, shelf, Notes, episode details, bookmarks), and the episode's flag is false, the app re-reads the full podcast JSON and sets the flag for every episode the server marks as having a generated transcript. The generated transcript row is then added in the same pass.

  • Only for podcast episodes published in the last 60 days (the server only generates transcripts for those).
  • At most once per podcast every 30 minutes. A failed fetch (network or HTTP error) can be retried right away.
  • Failures are logged and ignored.
  • Background show notes downloads (auto-download) never trigger it.
  • Cost: The Daily's full podcast JSON is 343 KB over the wire (gzip, CloudFront cached; 2.1 MB decoded). OkHttp requests gzip transparently. With the 30-minute throttle that's at most one fetch per podcast per 30 minutes, and only while a recent episode's flag is still false.

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

Testing Instructions

Needs a debug build (staging), a device or emulator, and sqlite3 on your computer (macOS ships one). Signed out is fine.

Setup

./gradlew :app:installDebug
PKG=au.com.shiftyjelly.pocketcasts.debug
PODCAST=4eb5b260-c933-0134-10da-25324e2a541d # The Daily on staging
  1. Open the app and follow The Daily. Leave its podcast page.

Make the flag stale (what the hourly refresh leaves behind)

  1. Pull the database, reset the flag and transcripts for The Daily, and push it back:
    adb shell am force-stop $PKG
    rm -f pocketcasts pocketcasts-wal pocketcasts-shm
    for f in pocketcasts pocketcasts-wal pocketcasts-shm; do adb exec-out run-as $PKG cat databases/$f > $f; done
    sqlite3 pocketcasts "
      UPDATE podcast_episodes SET has_generated_transcript = 0 WHERE podcast_id = '$PODCAST';
      DELETE FROM episode_transcript WHERE episode_uuid IN (SELECT uuid FROM podcast_episodes WHERE podcast_id = '$PODCAST');
      PRAGMA wal_checkpoint(TRUNCATE);"
    adb push pocketcasts /data/local/tmp/pocketcasts
    adb shell run-as $PKG sh -c "'rm -f databases/pocketcasts-wal databases/pocketcasts-shm && cp /data/local/tmp/pocketcasts databases/pocketcasts'"
    adb shell rm /data/local/tmp/pocketcasts
  2. Check the newest episodes are stale:
    sqlite3 pocketcasts "SELECT uuid, title, has_generated_transcript FROM podcast_episodes WHERE podcast_id = '$PODCAST' ORDER BY published_date DESC LIMIT 3;"
    ✅ has_generated_transcript is 0.

Before: offline

  1. Run adb shell cmd connectivity airplane-mode enable, then start the app.
  2. Go to Filters → New Releases (don't open the podcast page) and play the newest The Daily episode. Open the full-screen player.
  3. Open ⋮ in the player shelf. ✅ Transcript is disabled.

After: online

  1. Start logging in a second terminal:
    adb logcat -c && adb logcat | grep -E "mobile/podcast/full|generated transcript flags"
  2. Run adb shell cmd connectivity airplane-mode disable and adb shell am force-stop $PKG, then start the app and open the full-screen player again.
  3. ✅ Logcat shows:
    I/OkHttp: --> GET https://podcast-api.pocketcasts.net/mobile/podcast/full/4eb5b260-c933-0134-10da-25324e2a541d
    I/BgTask: Refreshed generated transcript flags for podcast 4eb5b260-…, N episodes have one
    
  4. Open ⋮ in the player shelf. ✅ Transcript is enabled and opens the generated transcript.
  5. Optional, check the database:
    adb shell am force-stop $PKG
    rm -f pocketcasts pocketcasts-wal pocketcasts-shm
    for f in pocketcasts pocketcasts-wal pocketcasts-shm; do adb exec-out run-as $PKG cat databases/$f > $f; done
    sqlite3 pocketcasts "SELECT p.uuid, p.has_generated_transcript, t.url, t.is_generated FROM podcast_episodes p LEFT JOIN episode_transcript t ON t.episode_uuid = p.uuid WHERE p.podcast_id = '$PODCAST' ORDER BY p.published_date DESC LIMIT 3;"
    ✅ The episode you played has flag 1 and a …/generated_transcripts/…/<episode>.vtt row with is_generated = 1.

No repeat fetch

  1. Close and reopen the full-screen player, then play another recent The Daily episode.
  2. ✅ No new mobile/podcast/full request in logcat. The flags are already 1, and the same podcast isn't fetched again within 30 minutes.

Unit tests (cover the 30-minute throttle, retry after a failed fetch, the 60-day window and the background download skip)

./gradlew :modules:services:repositories:testDebugUnitTest --tests '*GeneratedTranscriptFlagRefresherTest' --tests '*ShowNotesProcessTest'

Screenshots or Screencast

Before (stale flag) After (flag refreshed)
Transcript disabled Transcript enabled

Logcat on a staging debug build, after opening the player:

11-03 14:48:09.723 I/OkHttp: --> GET https://podcast-api.pocketcasts.net/mobile/podcast/full/4eb5b260-c933-0134-10da-25324e2a541d
11-03 14:48:10.440 I/BgTask: BgTask: Refreshed generated transcript flags for podcast 4eb5b260-c933-0134-10da-25324e2a541d, 355 episodes have one

App database before and after opening the player:

before: 379bcaf4-…|has_generated_transcript=0   episode_transcript: (no rows)
after:  379bcaf4-…|has_generated_transcript=1   episode_transcript: …/generated_transcripts/4eb5b260-…/379bcaf4-….vtt|is_generated=1

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

@sztomek sztomek added this to the 8.25 milestone Nov 3, 2026
@sztomek sztomek added [Type] Feature Adding a new feature. [Area] Chapters Episode chapters labels Nov 3, 2026
@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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


The approach works. It runs off the UI path in ApplicationScope, only sets the flag (never clears it) and is throttled per podcast. There's one blocking issue: an HTTP error response is throttled as if the refresh had succeeded, which breaks the "failed fetch can be retried right away" behaviour this PR describes.

Blocking

Non-blocking

@sztomek sztomek added [Type] Bug Not functioning as intended. and removed [Type] Feature Adding a new feature. labels Nov 3, 2026
@sztomek
sztomek marked this pull request as ready for review November 3, 2026 15:09
@sztomek
sztomek requested a review from a team as a code owner November 3, 2026 15:09
@sztomek
sztomek requested review from geekygecko and removed request for a team November 3, 2026 15:09
@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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


I reviewed the two commits pushed since my last review (bd4084f background download skip, 834836d throttle only on success and lock per podcast) and found no new issues. Both earlier findings are fixed: a non-2xx or empty response now returns before lastRefreshes is set, which a new 503 test covers, and the global Mutex is now one lock per podcast. downloadToCacheShowNotes (auto-download) no longer triggers the fetch. The background path still reads the flag from the database, so it won't drop a generated transcript row that a user-opened screen already added.

@wpmobilebot wpmobilebot modified the milestones: 8.25, 8.26 Nov 9, 2026
@wpmobilebot

Copy link
Copy Markdown
Collaborator

Version 8.25 has now entered code-freeze, so the milestone of this PR has been updated to 8.26.

@wpmobilebot wpmobilebot modified the milestones: 8.26, 8.27 Nov 23, 2026
@wpmobilebot

Copy link
Copy Markdown
Collaborator

Version 8.26 has now entered code-freeze, so the milestone of this PR has been updated to 8.27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Chapters Episode chapters [Type] Bug Not functioning as intended.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants