Skip to content

TT-7596 TT-7609 fix: tag PBT takes with their language and load an existing take mid-navigation - #522

Merged
sarahentzel merged 1 commit into
developfrom
TT-7596_pbt-take-language-tag-and-mid-load
Aug 21, 2026
Merged

TT-7596 TT-7609 fix: tag PBT takes with their language and load an existing take mid-navigation#522
sarahentzel merged 1 commit into
developfrom
TT-7596_pbt-take-language-tag-and-mid-load

Conversation

@nabalone

@nabalone nabalone commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

Takes uploaded untagged (TT-7596). The media upload payload sent the language attribute as 'language-bcp47'. The API expects the single lowercase token languagebcp47 — unlike the other multi-word attributes it is not dasherized — and silently drops the unknown key. Every Phrase BT take was therefore stored with no language.

Anything that scopes rows by step language then failed to match them:

  • the PBT Transcribe step reported "Some Phrase Back Translation segments are missing recordings" (TT-7596);
  • navigating back to an already-recorded segment showed an empty recorder, because recordingRow — and so MediaRecord's mediaId — never resolved.

Both cleared once the record was re-read from the server, which is why leaving the step and returning "fixed" it.

Load dropped mid-navigation. On top of that, MediaRecord loaded an existing take only on a mediaId change, and skipped it outright while a load or save was in flight (if (!loading) handleLoadAudio()), with nothing to retry it. Changing clause during that window lost the load until the step was remounted. An in-flight load was also never abandoned, so a late-resolving fetch could hand the previous clause's audio to the clause just navigated to.

Changes

  • store/upload: send languagebcp47; the type carries a comment about the non-dasherized key so it does not regress.
  • MediaRecord: defer the load instead of dropping it — a new effect keyed on [loading, mediaId] runs the skipped load once the recorder is idle, guarded by the id a load was started for so it runs at most once per take.
  • MediaRecord: handleLoadAudio captures the id it was started for and bails at each await if mediaId has moved on, so a stale fetch cannot paint the wrong take.
  • MediaRecord: a just-uploaded id is marked as already present, so saving no longer blanks the take and re-fetches it.
  • The reset() stays tied to a real mediaId change (not to loading), so a take whose upload failed is not wiped out from under the TT-7583 retry.

Test plan

  • Manually tested in the app by the author — recording successive Phrase BT segments and returning to an earlier one now shows that segment's take.
  • New MediaRecord.load.test.tsx. Verified failing-before / passing-after against unfixed source: pre-fix the mid-load case never loads the second take (loadCalls stays at the abandoned url) and hands the stale blob to the waveform; post-fix both assertions hold.
  • npx jest src/components/MediaRecord → 12/12 pass, including the pre-existing suite (the TT-7583 "keeps save available so the same take can be retried" test guards the reset behavior above).
  • tsc --noEmit clean; Prettier clean on the touched files. actions.tsx has a pre-existing formatting deviation that also fails on develop, left alone to keep the diff to one line.

Note: the cypress-tests check failure is unrelated to this diff — the Cypress binary is missing from the runner cache, so no spec runs. It is failing the same way on other current PRs and on recent develop pushes.

🤖 Generated with Claude Code

…isting take mid-navigation

Phrase BT takes were uploaded with the language attribute keyed
'language-bcp47'. The API expects the single lowercase token
'languagebcp47' and silently drops the dasherized form, so every take
was stored untagged. Any consumer that scopes rows by step language
then failed to match them: the PBT Transcribe step reported segments as
missing recordings, and returning to an already-recorded segment showed
an empty recorder, both clearing once the record was re-read from the
server.

MediaRecord also dropped its load when mediaId changed while a load or
save was in flight, with no retry, so the take of the segment navigated
to stayed invisible until the step was remounted. The load is now
deferred rather than dropped, and an in-flight load that is overtaken by
navigation is abandoned instead of handing the previous segment's audio
to the new one. The reset stays tied to a real mediaId change so a take
whose upload failed is not wiped out from under the TT-7583 retry.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@nabalone
nabalone marked this pull request as ready for review August 21, 2026 13:22
@sarahentzel
sarahentzel merged commit dd9f1d6 into develop Aug 21, 2026
2 of 4 checks passed
@sarahentzel
sarahentzel deleted the TT-7596_pbt-take-language-tag-and-mid-load branch August 21, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants