Skip to content

Fix caption translation request ownership - #3469

Open
vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:fix/web-caption-translation-ownership
Open

vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:fix/web-caption-translation-ownership

Conversation

@vedanth-jadhav

@vedanth-jadhav vedanth-jadhav commented Oct 27, 2026 •

Copy link
Copy Markdown

Problem

Caption translation starts the server action inside a React state updater. Under Strict Mode two simultaneous requests for the same language can trigger four translation calls; concurrent languages also clear the loading indicator as soon as the first request finishes. A rejected server action leaves its caller's promise unresolved, and a late result for one video can populate the next video's caption cache.

Changes

  • Start translation outside the state updater, reuse in-flight requests per language, and keep the loading indicator active until all requests settle.
  • Resolve failed requests to null so callers can retry, and cache successful translations synchronously.
  • Scope the provider to the video ID and ignore state updates after unmount. Changing videos remounts the provider's children along with their caption state.

Validation

  • 19 focused tests pass, including five mounted Strict Mode regression cases and existing transcript tests. The duplicate request, concurrent loading, and video-switch cases fail against the current main branch.
  • Scoped strict TypeScript check of the provider and tests, using declarations matching the two server-action signatures; Biome and workflow YAML checks pass.

The tests mock the translation server actions; they do not exercise a live AI provider or a full web build.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

This PR moves caption translation requests out of React state updaters and keeps each video's caption state separate.

  • Caption requests share translations and stay separate for each video.

No actionable issues were found. Tests were inspected, not run during this review.

Reviews (1) · Last reviewed commit: "Fix caption translation request ownershi..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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