Skip to content

feat(lessons): make intro subtitles from the recording, per language - #1104

Merged
sydevs-bot merged 69 commits into
mainfrom
claude/feat-1016-intro-subtitles
Nov 13, 2026
Merged

sydevs-bot merged 69 commits into
mainfrom
claude/feat-1016-intro-subtitles

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A recording's transcript belongs to its file, not to the Path Step. Every step and language using a file shares one transcript, and swapping the file swaps the subtitles. A step can no longer show subtitles for a recording it doesn't use.
  • It's made automatically. An MP3 is transcribed when it is saved. A video is transcribed when Cloudflare Stream reports it ready. The run detects the spoken language where nobody stated one, and writes it to the file.
  • The language belongs to the file too (acc09aa). files.spokenLanguage is a stored column — stated on upload, or filled in by the first run — and transcripts.language is gone, because a meditation's was always a copy of its own locale and a copy can disagree. The run and the glossary pass read the recording, through one table naming the column each kind of recording states it in (29e8bec).
  • One pipeline for every recording. Meditations and files share the queued job, the re-request flow and the panel. This rework removes the synchronous POST /api/files/:id/subtitles endpoint, its 90 s bound, and the IntroSubtitles control (modal, Undo, "already made" message) that this PR first shipped.
  • One panel, under one name (2683764). src/components/admin/TranscriptPanel/ holds the body every surface renders, two field components and the language warning; useTranscript is the one read and useRetryTranscript the one retry, for a meditation and a file alike. Spoken language needs no component of its own (adc0d6f).
  • The intro recording stays per locale, as before.
  • The live-preview playhead is shared, not borrowed (0c46c05). usePlaybackTime, useSeekToTime and the store behind them move from FrameEditor/ to src/components/admin/helpers/, because the transcript panel reads the same clock and was reaching through the frame editor's barrel for it.
  • Every banner's action has one shape (4f05960). InfoBanner's action took any ReactNode, so five banners drew theirs three ways. It is now { label, href } or { label, onClick, disabled? }, always a small secondary Button after the text, and JobStageView's Check again moves inside its banner. Joined here because this PR's Transcribe-again is one of the five, and useRetryTranscript replaces the RetryTranscript component on the way.
  • The app is a separate PR. It reads the subtitles off the file: sydevs/WeMeditateApp#452. lessons.introSubtitles stays as a read-only computed copy for app releases that still read it, and refactor(lessons): drop the computed introSubtitles copy #1133 removes it after that release is out. panels[].subtitles is dropped now, because production holds no data in it.

Closes #1016

What an editor sees

  • Path Step, Meditation tab: Intro Audio (MP3 only). Below it, a read-only Intro Subtitles preview of the file's transcript, with one of these states:

    • transcribing
    • failed, with Try again
    • "28 lines · English" with the first lines and Open transcript

    It warns when the recording states a different language than the one being edited. Panels show the same preview under a video.

  • File, edit view: a Spoken language select — shown for an audio or video file only — and below it a Transcript panel (the meditation one, generalised). Saving a change to the language transcribes the recording again, for every page using the file, superseding a run in flight as a replaced recording always has: its cues would be in a language the recording no longer claims. The cost bounds feat(meditations): give an editor a way to ask for a transcript again #984 Decision 2 asks for sit on the Transcribe button instead — the control one click reaches — which refuses a run in flight, a finished transcript, and a second request inside the cooldown.

  • A recording with no transcript yet is transcribed from that button, in the language just saved: a video's first run belongs to Stream's ready webhook, so a save cannot start one. The recording plays beside the transcript once a run has settled, a failed one included. Uploaded At sits last, and only on a saved file.

  • Who may change it: every editor role holds files: create and no update, so an editor states the language on upload and an admin corrects it after.

  • Launch Readiness: intro-subtitles-set means the locale's intro file has a finished transcript and states that locale's language. A recording in another language is the mismatch the editor is warned about, so it does not read green here.

Change outline

 transcripts                                   src/collections/Transcripts/
-  language   a copy of the recording's        # the recording states it now
+  provider   + 'imported'
   beforeChange applyGlossaryToSegments        # reads the recording's language
 files                                         src/collections/Files/
+  afterChange syncTranscriptOnSave('files')
+  subtitles        virtual, the transcript's cues  # batched per request
+  spokenLanguage   stored select, admin.condition on the staged or stored type
+  transcriptPanel  ui → TranscriptPanel#FileTranscriptField
+  createdAt        relabelled Uploaded At, hidden until there is an upload
+  POST /:id/transcribe                        # gated on files: create; admin panel only
-  POST /:id/subtitles
 Stream webhook 'ready' → transcribeStreamVideo  # a video's MP4 exists only then
 lessons
   introAudio  localized (unchanged from this PR)
+  introAudio  beforeInput → RecordingLanguageWarning
+  introTranscript  ui → FileTranscriptField    # its own field under the upload
-  introSubtitles  stored, localized JSON + IntroSubtitles control
+  introSubtitles  virtual copy of introAudio.subtitles  # shortcut: #1133
-  panels[].subtitles
+  panels[].mediaTranscript  ui → FileTranscriptField
 jobs/TranscribeMeditation → jobs/TranscribeRecording  # slug unchanged: an enum value
+  files: R2 for audio, Stream MP4 for video (waits for it), language detected
+  every recording stores ≤30-char cues from word timings, cut at a 3 s pause
+  the row is matched by id after the vendor call, not by filename
 wm-app-status
   intro-subtitles-set  also requires the recording to state the locale's language
 src/lib/transcripts/  schema · bounds · cues · sync · request · read · language · media
+  sync.ts   both triggers: a saved recording or language, and Stream's ready
+  read.ts   the row lookup, the file `source` clause, the finished-row rule,
+            one batched cue read per tick, and which column each kind of
+            recording states its language in
+  cues.ts   the cue vocabulary: TimedWord, the 30-character and 3 s bounds, the grouper
+  media.ts  which files carry a transcript, and the Spoken language condition
 src/components/admin/FrameEditor/ → src/components/admin/helpers/
+  livePreviewPlayback.ts · playbackTimeStore.ts  # two owners; FrameEditor keeps useAvailableFrames
 src/components/admin/RecordingTranscript/ → src/components/admin/TranscriptPanel/
+  TranscriptPanel · FileTranscript(Field) · MeditationTranscriptField
+  RecordingLanguageWarning
+  useTranscript · useRetryTranscript · useTranscriptPhase
 src/lib/lemonfox/transcribe.ts → src/jobs/TranscribeRecording/lemonfoxClient.ts  # one caller now

Migration

Three migrations ship, in this order.

  1. 20261112_184359_file_transcripts_replace_intro_subtitles — the Path Step rework. It moves lessons.intro_audio_id into lessons_locales, drops lessons.intro_subtitles and lessons_panels.subtitles, rebuilds the provider enum to add imported, backfills the 28 hand-made English cue sets as their files' transcripts, and drops NOT NULL from transcripts.language. Three hand edits, all approved: the en locale copy (INSERT … ON CONFLICT DO UPDATE, because a step created under another admin locale has no en row to update), the cue backfill (one transcript per file, from the lowest-numbered step using it, and a file that already has one keeps it), and the enum rebuild instead of ADD VALUE, so the same transaction can use imported. 8535a41 squashed this PR's six into it — two carried schema, four were snapshot-only repairs after main merges.
  2. 20261112_213652_files_spoken_language — the language moving onto the recording. It adds files.spoken_language and its enum, copies each file's language off its transcript, then drops transcripts.language and enum_transcripts_language. Two hand edits, one each way: up reads the transcript's language before the column goes, which the generated delta does not; down restores it from the file, or from a meditation's own locale, so migration 1's down finds a language on every row it keeps.
  3. 20261112_234150_merge_main_snapshot_9 — snapshot only, no DDL. The ninth main merge brought 20261112_211802_drop_mailing_list_enabled, whose snapshot was generated on main and knows nothing of this branch, while this branch's own newer snapshot still carried clients.mailing_list_enabled — so migrate:create re-emitted a drop main already ships. The file keeps only its .json, generated on the merged tree, which heals the chain (src/migrations/AGENTS.md, "The out-of-order snapshot trap"). A probe migrate:create afterwards writes nothing.

Why 1 and 2 are stacked and not squashed. src/migrations/AGENTS.md refuses a regenerated migration once its branch has deployed — the preview keeps the old columns with no payload_migrations row naming the new file, and crash-loops on its first ADD COLUMN. The chain between them is also load-bearing: migration 1's backfill writes language = 'en' on the imported rows, and migration 2 reads exactly that into files.spoken_language, so one file would have to re-derive both halves. What the stack costs is one DROP NOT NULL on a column the next migration removes.

Verified on a scratch database migrated to main, seeded with shared, already-transcribed, non-English-only and subtitle-only steps: up, down and up again, each with the expected rows.

⚠ The PR preview ran the six pre-squash migrations, so its Railway environment needs resetting — its boot otherwise replays DDL it already carries (src/migrations/AGENTS.md). Production has run none of them and is unaffected.

After deploy: pnpm seed file-transcripts queues a transcript for the roughly 49 audio and video files uploaded before this. It costs one paid Lemonfox run per file and needs a production sign-in link (seeds/AGENTS.md). It has not been run.

Test results

Lean gate re-measured on 0c46c05, this branch's head: ✓ lint, format:check, typecheck, typecheck:tests, test:unit (273 files, 3733 tests), 126 s. Everything below is adc0d6f, which 0c46c05 moves two admin hooks out of FrameEditor/ and changes no behaviour in.

  • Lean gate on adc0d6f: ✓ the same, 3732 tests, 117 s.
  • Integration specs — 7 files, 160 cases, all passing: file-transcripts (23), meditation-transcription (40), meditation-transcripts-seed (11), and meditation-transcripts, wemeditateAppStatus, cleanup-orphaned-media, lessons (86 together). cloudflare-stream-webhook is a unit spec, and ran in the lane above.
  • The batch is measured, not argued. file-transcripts reads a page of three transcribed files and counts the transcripts queries: 1 with readFileSubtitles's batch, 3 with it removed.
  • The Spoken language condition is pinned against the function, not a mount — the same five cases SpokenLanguageField's spec held, watched failing with the staged-file read removed.
  • App contract, checked against a local server as an API client on db5488c. Nothing since has touched the subtitles field or readFileSubtitles. The app's own Path Step query returns introAudio.subtitles and panels[].media.subtitles on the populated files, and the old panels][subtitles select key is ignored rather than refused.
  • Not checked in a browser. The admin components render (pages return 200, nothing errors in the dev log), but no one has clicked through them. The Spoken language condition is the one thing that costs: it reads the staged File that the form-state server action carries, which buildFormState was read to confirm but no browser has exercised. A create form that hid the select would hide it from the only role that states a language on upload.

Notes for reviewer

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjVL5Ajna7LdYyeJPpz

…es them

Localize `lessons.introAudio` and `lessons.introSubtitles` so each of the 19
languages carries its own recording and its own cues, and add the manager-only
`POST /api/files/:id/subtitles` that turns an attached MP3 into cues.

The Lemonfox HTTP client moves to `src/lib/lemonfox/` now that it has a second
consumer — `tests/unit/lib-boundary.spec.ts` refused it there with one — and
gains an opt-in `timestamp_granularities[]` so the meditation job's request body
stays byte-identical. `words.ts` reads the vendor's word timings out of either
`verbose_json` layout; `groupWordsIntoCues` turns them into cues of at most 30
characters, the length the 1,102 stored cues already measure.

The migration and the field component follow in the next commits.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
…e migration

The field component sits above the subtitles editor and fills it from the
recording in the language being edited. Three things the prototype did not
need and a real endpoint does: one request in flight at a time, an
`AbortController`, and a latch on (file id, locale) so a resolve the field has
moved on from is discarded rather than written into another language.

`intro-subtitles-set` joins the Path Lessons readiness section, testing the
array's length because an empty array is truthy. Both it and `intro-audio-set`
answer per locale now that the fields do, with no change to `prepare`.

The migration is hand-augmented, and is wrong without it: the generated delta
adds the two `lessons_locales` columns and drops the base ones without reading
them. Measured on a scratch Postgres seeded with 28 recordings and 28 cue sets:
the generated DDL keeps 0 of each, this one keeps 28 of each, and an up/down
round trip restores every lesson's own file id and cue text. The backfill
upserts rather than updates, so a step whose only locale row is Czech gains an
English one instead of losing its recording.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
…grouper

The grouper, the word reader and the two admin URL builders get unit specs;
the endpoint and the two newly localized fields get `tests/int/intro-subtitles`,
which drives the real REST pipeline so the per-locale 403 is visible at all.

Every assertion was watched failing first. Two of them caught real defects
rather than fixture mistakes: the 415 message said "Attach one and try again"
where the ticket asks for no offer to retry, and `normalizeLemonfoxWords`
reached `assignWordsToSegments` with an empty segment list by a coincidence of
two conditions rather than by a guard.

The word reader now shares `normalize.ts` rather than taking a module of its
own: with one consumer, `tests/unit/lib-boundary.spec.ts` refuses it in
`src/lib`, and `KNOWN_SINGLE_CONSUMER` is closed to anything written after that
spec. Both readers share one raw schema and one seconds-to-milliseconds
conversion, which were about to be duplicated.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
A jsdom spec for the field component, because the latch lives between renders
and no pure spec can state it: a resolve whose file id or starting locale is no
longer the field's is discarded, and the cues reach form state and never the
server. Each run's cues are traceable to the file that produced them, so
"nothing was written" cannot pass for the wrong reason when swapping the
recording legitimately starts a second run.

`wemeditateAppStatus` gains `intro-subtitles-set` beside `intro-audio-set`, in
English and in French, which is the whole of what "they answer per locale now"
means. Its partial-lesson fixture carries an empty cue array rather than none,
since an empty array is truthy and nothing else would catch a check reading
truthiness.

`tests/PERF.md` and its three consumers record 255 / 3473, the counts the tree
now has. Timings are untouched — they belong to the sessions their rows name.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
`transcripts.source` is `unique`, so two admins pressing at once race on the
insert and the loser's create is refused. It now re-reads and answers from the
winner's row: those cues are for the same recording, which is what the caller
asked for, and an unhandled refusal there answers 500 for a request that
succeeded in every way the caller can see.

Re-reading rather than matching the constraint's own error. That match is a
Postgres `detail` string for a polymorphic relationship — the meditation
endpoint carries why — and a row that now exists is the same answer whatever
refused the insert.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
Four surfaces. `seeds/storyblok` named only two localized lesson fields and
now names four, and says why the file-attach write agrees with the lesson
upsert despite naming no locale. `.env.example` says what an empty
`LEMONFOX_API_KEY` now costs — the Transcript tab and a 503 from the new
endpoint, not just the tab.

`docs/rules/access.md` gains the counter-example its own rule needs: "any
future endpoint that gates then overrides owes `isOutsideWritableLocale`" is
true only of a collection carrying a top-level `locale` column, and none of
the three this endpoint touches does. Calling it there compares against
`undefined` and narrows nothing, which reads as a guard and is not one.

`docs/architecture.md` was already wrong before this branch: it said nothing
re-requests a transcript, which #984's endpoint and the Transcript tab's
button have done since. It now names both doors and what separates them —
one queues a job, the other answers an admin synchronously under
Cloudflare's 100 s limit.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
…unlocked

**The cues the admin sees are now the cues the row holds.**
`applyGlossaryToSegments` is a `beforeChange` hook on `transcripts`, so it
rewrites the vendor's spellings to ours on the way in (#1084) — answering with
what was sent handed the admin uncorrected words on the first press and the
corrected ones on the second, for one recording.

**A recording with no host is refused rather than sent.** `files.url` falls back
to the relative `/api/files/file/<name>` with no delivery URL configured, which
a non-empty test passes and the vendor cannot resolve. The integration lane was
quietly exercising that path; it now mocks the R2 base, so every case sends the
shape production sends.

**The control no longer transcribes on a language switch.** The auto-start read
"the locale held still since the last render" as a proxy for "a person attached
this file". Payload moves `useLocale()` first and replaces form state in a later
commit, so the new locale's own recording arrives as an audio change with the
locale already settled — and a step with audio and no cues, normal in 18
locales, bought a vendor run on every switch. It now reads `audioChanged`, which
is the question that was meant.

**And a cue row no longer makes its recording immortal.** `transcripts.source`
reads like a reference to `files`, so the orphan sweep counted it in use —
measured, with no lesson referencing it in any locale. A cascade child's pointer
is deleted with its parent, so it can never be why the parent is in use;
`deleteChildren` now publishes its rules and the walk skips exactly those
fields. The file-sourced row this endpoint writes is what made that reachable,
which is why it lands here.

Also from the review: the shared `errorResponse` and `refusalMessage` in place
of three hand-rolled copies, `relationId` in place of a fourth id normaliser,
a bounded `select` on the stored-cues read, and the filename read off the form
value rather than a round trip for one bolded word.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1104 November 10, 2026 20:09 Destroyed
@railway-app

railway-app Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1104 environment in sahajcloud

Service Status Web Updated
SahajCloud ◻️ Removed (View Logs) Web Nov 12, 2026 at 7:24 pm UTC
1 service not affected by this PR
  • mailpit

…o-subtitles

# Conflicts:
#	src/migrations/index.ts
…counts

`main`'s own `20261110_185320_merge_main_snapshot_6` snapshot was generated
there, so it still has `intro_audio_id` and `intro_subtitles` on `lessons`.
Being the newest by filename it is what `migrate:create` diffs against, and the
run re-emitted all eight statements this branch's own migration already ships —
replaying one aborts the boot migration. So `20261110_201010_merge_main_snapshot_7`
keeps only its `.json`, generated on the merged tree, with empty bodies and no
copy of the backfill. A probe run after it writes no files, which is the proof
the chain healed.

`tests/PERF.md` and its three consumers record 3492, the count the merged tree
has.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYzmBS4By2hWUNpeVy
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1104 November 10, 2026 20:14 Destroyed

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/utilities/subtitles.ts Resolved
@sydevs-bot

sydevs-bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 02:50Z resolve-conflicts · attempt 1 · session · done
  • 02:50Z resolve-conflicts · attempt 1 · session
  • 02:36Z address-review · attempt 1 · session · done
  • 02:36Z address-review · attempt 1 · session
  • 23:58Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 10, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

This matches #1016 part for part, and nothing in it looks bigger than the problem. The only unticketed work is the cascade-child fix and the refusalMessage export, both joined. The migration is the real risk and it is handled: up adds the locale FK before the backfill, down adds the base FK after it, and ON CONFLICT covers a step whose only locale row is not en. Every finding below is about where a piece lives, not whether it should exist.

Findings

  • should-fix — deleteChildren's doc block, example and all, now hangs on the new CascadeHook type (cascadeDeletion/index.ts:68).
  • consider — introSubtitlesUrl is the sixth hand-rolled ?locale= admin URL builder (introSubtitlesModel.ts:15).
  • consider — the cascade reader and its structural guard sit in the consumer, not in cascadeDeletion (schemaUtils.ts:351).
  • consider — the endpoint's comments argue with designs that are not there (Files/endpoints/subtitles.ts:32).
  • consider — a segment with words: [] drops its bucketed top-level words (normalize.ts:115).

What was checked

Read whole on the branch: the endpoint, IntroSubtitles.tsx, subtitles.ts, normalize.ts, cascadeDeletion/index.ts, schemaUtils.ts, Lessons.ts, the migration, and requireManagerPermission.ts for the locale scope. Ladder: relationId, originOf, refusalMessage, Payload's filterOptions save-time validator and the @payloadcms/ui banner and modal are reused; groupWordsIntoCues, normalizeLemonfoxWords and CascadeHook are the net-new pieces, and the grouper counts length right. payload-types.ts moves by one description string, and a grep of the three sibling repos finds both field names only inside generated copies. All three preview links answer 200, and this repo seeds none, so the empty list reads as the body says.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/cascadeDeletion/index.ts Resolved
Comment thread src/lib/lemonfox/normalize.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 10, 2026
`segment.words ?? buckets[index]!` fell back only when `words` was absent,
so a segment carrying `words: []` kept the empty list and the top-level
words bucketed into it were dropped. A segment with a present-but-empty
list carries no words, which is the case the fallback is for.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXaoFFWnbcCmcFMF36
The new `CascadeHook` type landed between the function and its own doc
block, so hover on the type showed the function's `## Example` and
`deleteChildren` was undocumented.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXaoFFWnbcCmcFMF36
The structural test for `cascadeRules` sat in `CleanupOrphanedMedia`,
reading a property `src/lib/cascadeDeletion/` publishes from the
consumer's side. `cascadeChildPairs` puts the guard beside the type it
describes, so the job holds no knowledge of how a cascade is spelled and a
second consumer gets the same answer.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXaoFFWnbcCmcFMF36
Three blocks argued against designs that are not here: a `collection`
query parameter nobody wrote, matching the unique constraint's `detail`
string rather than re-reading, and `requireActiveClient`, which
docs/rules/endpoints.md wants one line for. Every ⚠ naming a real
constraint stays — the 100 s bound, the absolute URL, the glossary read,
the race.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXaoFFWnbcCmcFMF36
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1104 November 10, 2026 20:54 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review — 4 adopted, 1 rebutted. Pushed 0ed3ad5.

Adopted

Rebutted

  • One adminLocaleUrl — five builders, not six, and two carry a full query, so it serves three.

Lean gate green: 3493 tests. The security sweep re-ran for Files/endpoints/ — no findings.

The cue-gap question thread stays open. It waits on you.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 10, 2026
Ardnived and others added 3 commits November 12, 2026 14:56
A file's language lived on its transcript row, so it could only be changed
through a custom control posting `?language=` to the transcribe endpoint, and
a meditation's transcript carried a copy of the meditation's own `locale`.

- `files.spokenLanguage` is a stored select. An uploader states it, or the
  first run detects it and writes it back, flagged so the save hook does not
  read it as a correction. Editors hold `files: create` alone, so after upload
  only an admin changes it.
- `transcripts.language` is gone. The run and the glossary pass read the
  language off the recording: a meditation's `locale`, a file's
  `spokenLanguage`.
- `syncTranscriptOnSave` transcribes again when the recording's file or its
  language changes, for both collections. A change supersedes a run in flight,
  as a replaced recording always has; only the one-click endpoint bounds runs
  by cost. A video re-runs for a language change once its run has started.
- `replaceTranscript` is the one delete-and-create, shared by the save hook,
  the Stream trigger, the endpoint and the file-transcripts seed.
- `SpokenLanguageField` and the endpoint's `?language=` are deleted. The
  mismatch warning reads the file's language off the transcript poll, which
  now populates it, and tells an editor what they can do about it.
- Migration 20261112_213652 adds the column, copies each file's language off
  its transcript, and drops the old one; down restores it from the file or the
  meditation. Up, down and up again verified on a scratch database.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…seRetryTranscript

- `RecordingTranscript/` is `TranscriptPanel/`, matching the `transcriptPanel`
  field both collections declare; bare `Transcript` would collide with the
  generated row type the same files import. `useRecordingTranscript` is
  `useTranscript`.
- `useTranscript` only reads: the row, the phase, a `reread`, and where a
  retry posts. The POST, its toasts and which refusals re-read the row move
  into `useRetryTranscript`, its one caller now the Spoken language control
  is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1136 cut change amplification out of the unit lane: it took the file and
test counts out of every doc and spec that quoted them, leaving
`tests/PERF.md` as their one home. This branch had bumped those same
counts. Every doc hunk takes main's side — AGENTS.md, testing-reqs.md,
tests/AGENTS.md, and PERF.md's second-session metric row, which is a
measurement and not this branch's to replace.

`admin-locale-urls.spec.ts` is the same conflict in a docblock: main
stopped counting the call sites, this branch had counted a fifth. Main's
wording stays correct as sites are added, so it wins.

`meditation-transcript-tab.spec.ts` keeps both intents. Main deleted the
standalone stall case as redundant and moved its no-duration assertion
into the fake-timers case it kept; this branch's copy change — these
notices are titles, so no full stop — stays on every assertion.

One semantic consequence, fixed rather than merged: #1136's new
`openapi-endpoint-coverage.spec.ts` requires every client-callable
collection endpoint to be in the OpenAPI document, and this branch adds
`POST /api/files/:id/transcribe`. That endpoint gates on
`requireManagerPermission` and takes no client key, exactly like the
meditations twin already exempted there, so it joins `MANAGER_ONLY` with
its reason.

main added no migration since the merge base, so no snapshot repair.

Lean gate green on the merge: lint, format:check, typecheck,
typecheck:tests, test:unit (272 files, 3712 tests, 52.28 s).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX2b1oZam54PpdTewz
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main (#1136) in. Every conflict was the same one: #1136 took the lane's file and test counts out of the docs and specs that quoted them, and this branch had bumped those counts. Main's side wins each time — tests/PERF.md is their one home now, and this branch adds a row there rather than replacing one.

meditation-transcript-tab.spec.ts keeps both sides: main's deletion of the redundant stall case, with its no-duration assertion moved into the fake-timers case, plus this branch's period-free notice copy.

One consequence the merge could not resolve by itself. #1136 added openapi-endpoint-coverage.spec.ts, which requires every client-callable collection endpoint to be in the OpenAPI document, and this branch adds POST /api/files/:id/transcribe. It gates on requireManagerPermission and takes no client key, like the meditations twin already exempted there, so it joins MANAGER_ONLY.

main added no migration since the merge base, so no snapshot repair this time.

Lean gate green on the merge: 272 files, 3712 tests, 52.28 s.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Ardnived and others added 3 commits November 12, 2026 16:09
…edia

- A save on the recording's own page re-reads its transcript. A save that
  changes the language or replaces the recording replaces the row, and nothing
  polls a finished one, so the panel kept the old cues until a reload and the
  save looked like it did nothing. Keyed on Payload's `lastUpdateTime`, so it
  skips the page load and a Path Step's own save. Meditations' tab gets it too.
- Spoken Language shows only for an audio or video file, the one chosen on the
  create form included. A thin wrapper over Payload's `SelectField` decides,
  since `admin.condition` runs on the server and an upload's type is stored only
  once it is saved; the browser knows the chosen `File`'s type.
- The description says a change applies on save.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moved below the transcript, and hidden on the create form, where it was an
empty box. Its `hideUntilCreated` condition makes Payload generate
`File.createdAt` as optional and nullable, so the orphan sweep's structural
types, which only log the value, accept that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the type list

Main's #1136 keeps a matrix in one home. The mounted field needs only to show it
reads the stored type and the chosen file's, so the video rows go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Ardnived

Copy link
Copy Markdown
Contributor

@sydevs-bot review

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

Fifth look, asked for. Everything pushed since the fourth is the reviewer's own, so I read it for defects, not for scope. The design it lands is smaller than the one it replaces: transcripts.language is gone, a file states its own spokenLanguage, and the glossary pass reads that recording instead of a copy of it.

What is wrong is the body, again, on new facts. Three of its sections describe db5488c, and the branch is seven commits past it — one of them a second migration.

Findings

  • should-fix — ## Migration says one migration. The branch carries two, and the second drops transcripts.language and its enum outright (20261112_213652_files_spoken_language.ts:19).
  • should-fix — ## Change outline wires RecordingTranscript#…, a directory not on this branch, and still calls transcripts.language optional (Files/Files.ts:96).
  • consider — a video with no transcript row ignores a stated language, which the field's own description promises will re-run it (lib/transcripts/sync.ts:112).

What was checked

Read whole on the branch: both migrations, lib/transcripts/{sync,request,read}.ts, Files.ts, applyGlossaryToSegments.ts, glossary.ts, TranscriptPanel/{SpokenLanguageField,useTranscript}. Checked, not read off the body: migration 1's down deletes language IS NULL rows before it restores NOT NULL, so migration 2's COALESCE(spoken_language, locale) returning NULL cannot break the chain down; migration 2's up backfills through a unique transcripts_rels.files_id, so it cannot fan out. git grep RecordingTranscript finds nothing here. Ladder: hideUntilCreated, SelectField, useFormFields, extractID and baseLanguage are reused; files.spokenLanguage and recordingLanguage are net-new. No ## Preview section, so nothing was opened in a browser.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/collections/Files/Files.ts Resolved
Comment thread src/lib/transcripts/sync.ts Resolved
A video's first run belongs to Stream's `ready` webhook, so a saved
`spokenLanguage` starts nothing for a video with no transcript row — every
video uploaded before #1016, and a video between its upload and Stream's
answer. The field's description promised a re-run anyway.

It is not the hook that was wrong. Queueing a run there while Stream is still
preparing the MP4 burns the 100 s wait and then leaves the webhook a row
naming the filename, which `transcribeStreamVideo` skips — so the automatic
first run would be lost to save a click. The panel directly below the select
already offers Transcribe for a recording with no row, in the language just
saved, gated on the `files: create` every uploading role holds.

So the description says that, the hook's docblock says why the arms differ,
and the panel spec pins the offer the answer rests on.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZ2vQkf9Z16HE2c1uL
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Fifth round: three threads, one commit, a body rewrite.

Adopted

  • ## Migration — both named, and what each carries.
  • ## Change outline — TranscriptPanel, transcripts.language dropped rather than optional, spokenLanguage stored, ## Test results re-measured.
  • The saved language — half. 5c556cb stops the description promising a re-run a video with no transcript row never gets.

Also found while rewriting: a saved language supersedes a run in flight, not refused.

Rebutted: the squash, and that thread's other half. A regenerated migration crash-loops a preview that ran the old one (src/migrations/AGENTS.md). The panel offers Transcribe for a recording with no row; the hook would burn the MP4 wait, then leave the webhook a row it skips.

Green on 5c556cb: 3721 unit tests in 272 files, 160 integration cases in 7 specs.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

#1127 made the mailing-list API key write-only and dropped
`clients.mailing_list_enabled`. Two files conflicted, and both took both
sides.

`src/migrations/index.ts`: main's `20261112_211802_drop_mailing_list_enabled`
registers between this branch's two migrations, in timestamp order.

`tests/PERF.md`: the session table is append-only, so the two sides numbered
the same rows differently. Both sets of rows are kept, each side's relative
order preserved, and the ordinals renumbered from the fiftieth.

`20261112_234150_merge_main_snapshot_9` carries the snapshot the merged tree
needs and no DDL. This branch's `20261112_213652_files_spoken_language`
snapshot is the newest by timestamp and still holds
`clients.mailing_list_enabled`, so `migrate:create` re-emitted the drop that
main's migration already ships. A probe run afterwards writes nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZZbcvj2E56uPJHKA1
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main (#1127). Both conflicts took both sides.

src/migrations/index.ts — main's drop_mailing_list_enabled registers between this branch's two migrations, in timestamp order.

tests/PERF.md — the session table is append-only, and the two sides numbered the same rows differently. Every row from both is kept, each side's relative order preserved, and the ordinals renumbered from the fiftieth.

A third migration is new, where the body's Migration section lists two: 20261112_234150_merge_main_snapshot_9, snapshot only, no DDL. This branch's files_spoken_language snapshot is newest by timestamp and still carries clients.mailing_list_enabled, so migrate:create re-emitted the drop main already ships. A probe run afterwards writes nothing.

Lean gate green on the merge: 273 files, 3733 tests, 63 s.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@Ardnived Ardnived left a comment

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.

Additionally, can we streamline any of the new folders or files?

Comment thread src/app/(payload)/admin/importMap.js Resolved
A transcript's recording states its language in a column whose name depends
on the collection, and three readers spelled the pair separately: the glossary
hook branched on `relationTo` and ran its own read per arm, while
`syncTranscriptOnSave` took the column name as an argument.

`RECORDING_LANGUAGE_FIELD` in `src/lib/transcripts/read.ts` is now that pair,
beside `recordingLanguage`, which is one read for either kind — `draft: true`
is a no-op on a collection with no drafts, so the meditation arm needs no
branch. The save hook reads the table instead of taking the name, so its two
call sites cannot pass a column the glossary pass does not read.

In `read.ts` rather than `language.ts` because `language.ts` is imported by a
`'use client'` component, and a database read there would reach the browser
bundle.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVL5Ajna7LdYyeJPpz
`SpokenLanguageField` existed on the belief that `admin.condition` cannot see
the file an editor has just chosen, because an upload's `mimeType` is stored
only on save. It can: the browser writes the chosen `File` to form state's
`file` path, the edit view sends that whole state to the `form-state` server
action, and `buildFormState` reads `formState.file` off it before evaluating
every condition.

So the field is Payload's own select with a condition, one fewer registered
component, and `formIsRecording` is the predicate — the staged file's type, or
the stored one on a saved file. The panel spec keeps the same five cases
against that function rather than a mount.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVL5Ajna7LdYyeJPpz
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Two commits, both generalisations you asked for.

Adopted

Open for you, each with A/B in its thread: renaming spokenLanguage, and pulling the live-preview playhead out of FrameEditor/.

Additionally, can we streamline any of the new folders or files?

TranscriptPanel/ loses a file and a registration. src/lib/transcripts/ keeps its eight: cues.ts cannot fold into bounds.ts, which the panel reads in the browser, and language.ts cannot fold into media.ts, which is dependency-free for the same reason — which is why recordingLanguage went into read.ts.

Lean gate and all 7 integration specs green on adc0d6f. The body gains the third migration it never named, and loses three stale sections.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

`usePlaybackTime`, `useSeekToTime` and the `playbackTimeStore` behind them
sat in `FrameEditor/`, which the transcript panel reached through that
folder's barrel for a module the frame editor does not own. Two component
families share them, which is what `docs/rules/admin-ui.md` keeps
`admin/helpers/` for.

`FrameEditor/hooks.ts` keeps `useAvailableFrames` — frames by narrator is
its own — and the barrel stops exporting the two hooks.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY7UiiKcYb6s492hq6
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both your answers built, in one commit.

Adopted

  • The playhead — A. 0c46c05 moves usePlaybackTime, useSeekToTime and playbackTimeStore out of FrameEditor/ into src/components/admin/helpers/. The frame editor keeps useAvailableFrames, which is its own, and stops exporting the two from its barrel.
  • spokenLanguage — A. The built name stands, so no third migration ships.

Nothing is open for you now: ## Notes for reviewer says so, and ## Change outline carries the move.

Lean gate green on 0c46c05: 273 files, 3733 tests, 126 s. The commit moves two admin hooks and changes no behaviour, so the integration specs stand as measured on adc0d6f.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Two conflicts, both in docs that every PR appends to.

`tests/COVERAGE.md` — `main` renamed `reviewMove` to `SUBMISSION_MACHINE`,
and this branch had added the `POST /api/files/:id/transcribe` row beside
the Proposal review lifecycle row that names it. Both rows are kept, the
lifecycle row in `main`'s wording, which is the symbol the merged tree
exports.

`tests/PERF.md` — both sides appended measurement rows and so renumbered
the ordinals from the fiftieth on. The union is kept in each side's own
order, `main`'s four #1121 rows last, and every ordinal is re-derived from
the merged position. No row is dropped or rewritten.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWCzJrp6J4TFdSuBqv
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main (38bb854). Both conflicts were in docs every PR appends to, and no source file conflicted.

tests/COVERAGE.md — kept this branch's POST /api/files/:id/transcribe row and took main's wording of the Proposal review lifecycle row beside it: main renamed reviewMove to SUBMISSION_MACHINE, which is what the merged tree exports.

tests/PERF.md — both sides appended rows, so the ordinals diverged from the fiftieth on. Kept the union in each side's order, main's four #1121 rows last, and re-derived every ordinal from its merged position.

Lean gate green on the merged tree: 274 files, 3784 tests, 56.9 s. file-transcripts, lessons and user-submissions-review-lifecycle pass together (76 cases).

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(lessons): make intro subtitles from the recording, per language

3 participants