Skip to content

TT-7583 fix: write the remote artifact type id into phrase BT step settings - #501

Open
nabalone wants to merge 5 commits into
developfrom
TT-7583_part2_pbt-autosave-hardening
Open

TT-7583 fix: write the remote artifact type id into phrase BT step settings#501
nabalone wants to merge 5 commits into
developfrom
TT-7583_part2_pbt-autosave-hardening

Conversation

@nabalone

@nabalone nabalone commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

TT-7583 — PBT Auto Save fails in the Desktop Application.

1. Write the remote artifact type id into phrase BT step settings.
PhraseBackTranslateStepSettings seeded its artifact type from getTypeId, which
returns the local Orbit record id. That value was emitted into the step settings JSON
and persisted verbatim, but every reader decodes settings.artifactTypeId with
remoteIdGuid (and SelectArtifactType hands the other step-settings dialogs remote
ids). The ?? id fallback in those readers hid it locally; once the step synced,
peers could not resolve the GUID.

Now the local id is translated to its remote id when seeding, keeping the local id
when there is no mapping (offline-only artifact types have no remote id).

2. Guard auto-segmentation against two crash paths.
Both are throws hit while auto-segmenting a passage on the way into phrase back
translation, and both are behavior-preserving apart from the crash:

  • mergeVerses absorbed a too-short gap into the previous region, but the first
    gap has no previous region — result[result.length - 1].end threw on undefined.
    It now skips that fixup when result is empty, leaving start put so the short
    leading gap folds into the next region (the same outcome as the existing
    fromVerses(start) skip path).
  • extractRegions spliced away a too-short trailing region unconditionally, so a
    clip shorter than minRegionLenSeconds was left with an empty array and then threw
    on sRegions[sRegions.length - 1]. It now only drops the trailing region when more
    than one remains, keeping the single segment for a very short clip.

A comment in useGuidedPhraseSegments also records a related case that is not
fixed here: auto-segment can legitimately yield nothing, and returning false leaves
the 250 ms bootstrap poll in PassageDetailGuidedPhraseRecord spinning. Left as a
note rather than a behavior change.

Files touched

  • src/renderer/src/components/StepEditor/PhraseBackTranslateStepSettings.tsx — seed with the remote artifact type id
  • src/renderer/src/components/StepEditor/PhraseBackTranslateStepSettings.test.tsx — coverage for the translation
  • src/renderer/src/crud/useWavesurferRegions.tsx — the two auto-segmentation crash guards
  • src/renderer/src/components/PassageDetail/carefulSpeech/useGuidedPhraseSegments.ts — comment only, no behavior change

Test plan

  • PhraseBackTranslateStepSettings.test.tsx covers the id translation and the
    offline-only fallback.
  • Manual: create a phrase BT step, confirm the persisted artifactTypeId is the
    remote GUID.
  • Manual: auto-segment audio whose first gap is shorter than the minimum region
    length, and audio whose whole clip is shorter than the minimum — neither should
    throw; the short clip keeps one segment.

Notes

  • The branch also carries TT-7583 fix: only warn of a network issue when the upload never completed and its revert, so those two cancel out and contribute no net
    diff. That work (UploadFailureReason / suggestsConnectionProblem) is not part of
    this PR's behavior — it can be dropped from history or reland separately.
  • Rebased onto the latest develop; the earlier duplicate of Retry rejected phrase save on reconnect (already merged as fix: retry rejected phrase save on reconnect #499) was dropped by the rebase.

🤖 Generated with Claude Code

@nabalone nabalone changed the title TT-7583 fix: only warn of a network issue when the upload never completed TT-7583 fix: report real PBT save failures and sync-safe phrase BT artifact type ids Aug 18, 2026
nabalone and others added 3 commits August 18, 2026 09:27
…eted

A failed upload item told its callback nothing but success: false, so both
itemComplete handlers responded to every failure by calling setOrbitRetries --
raising a "possible network issue" retry banner for a file we rejected locally
or a 4xx the server deliberately returned.

Give the callback a reason instead. UploadFailureReason names why the item
failed (unsupported type, too big, local write, 4xx, 5xx, timeout, no
response); suggestsConnectionProblem is the single place that decides which of
those is evidence about the user's connection, and only a request that never
completed qualifies. A status number alone could not carry this: local
rejections never reach the network and have no status, and undefined already
means "no response" to isRetryableUploadStatus.

This narrows the warning: 5xx and 429 no longer raise it, since both mean we
reached the server. Retry policy is unchanged -- isRetryableUploadStatus still
governs the retry loop, and is now separate from the connectivity question.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ttings

PhraseBackTranslateStepSettings seeded its artifact type from getTypeId, which
returns the local Orbit record id. That value was emitted into the step settings
JSON and persisted verbatim, but every reader decodes settings.artifactTypeId
with remoteIdGuid (and SelectArtifactType hands the other step-settings dialogs
remote ids). The `?? id` fallback in those readers hid it locally; once the step
synced, peers could not resolve the GUID.

Translate the local id to its remote id when seeding, keeping the local id when
there is no mapping (offline-only artifact types have no remote id).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nabalone
nabalone force-pushed the TT-7583_part2_pbt-autosave-hardening branch from c53837d to ba9802d Compare August 18, 2026 13:27
@nabalone nabalone changed the title TT-7583 fix: report real PBT save failures and sync-safe phrase BT artifact type ids TT-7583 fix: write the remote artifact type id into phrase BT step settings Aug 18, 2026
Comment on lines +46 to +52
// Step settings store the *remote* artifact type id (every reader decodes with
// remoteIdGuid, and SelectArtifactType hands the other step-settings dialogs
// remote ids), so translate the local id getTypeId returns. Offline-only types
// have no remote id — keep the local id there — TT-7583.
const [artifactTypeId, setArtifactTypeId] = useState<string>(() => {
const localId = getTypeId(ArtifactTypeSlug.PhraseBackTranslation) ?? '';
if (!localId) return '';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Seed always uses the Phrase BT slug even for a Retell BT preset

The seed is hard-coded to ArtifactTypeSlug.PhraseBackTranslation, while the comment says the artifact type is fixed by the workflow step preset (Phrase BT vs Retell BT). For a brand-new Retell BT step with empty settings, the dialog will write the Phrase BT artifact type. This is pre-existing behavior (the same hard-coded slug existed before), but the remote-id translation now makes that seeded value durable across peers, so it is worth confirming Retell BT steps always arrive with settings already populated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Devin left this comment. Can someone confirm whether this preexisting behavior is intentional?

nabalone and others added 2 commits August 18, 2026 19:39
…cases

- useWavesurferRegions: a too-short first gap indexed result[-1] and threw;
  skip it so the gap joins the next region instead.
- useWavesurferRegions: don't drop the only region when the whole clip is
  shorter than the minimum length.
- useGuidedPhraseSegments: note the remaining case where auto-segment
  legitimately yields nothing and the bootstrap poll keeps spinning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…autosave-hardening

# Conflicts:
#	src/renderer/src/crud/useWavesurferRegions.tsx
@nabalone
nabalone marked this pull request as ready for review August 19, 2026 00:08
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.

1 participant