Skip to content

Conversation

@ameer2468
Copy link
Contributor

@ameer2468 ameer2468 commented Sep 10, 2025

Summary by CodeRabbit

  • New Features

    • Added “Retry Transcription” button for video owners when a transcript is missing or errored, with spinner and “Retrying…” state.
  • Improvements

    • More robust, automatic retry handling when videos aren’t yet ready.
    • Clearer messages when transcripts aren’t available.
    • Support for silent videos with valid, empty transcripts.
    • UI refreshes after retry to reflect latest status.
  • Bug Fixes

    • Prevented unintended form submission from the “Edit transcript” button.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a retry-transcription API route, updates the transcript UI to expose a retry button for eligible users, adjusts transcript fetching noise (removes a log), expands transcribeVideo with retry-aware prechecks and error classification, and reorders an interface property in get-status without behavioral changes.

Changes

Cohort / File(s) Summary
API route: retry transcription
apps/web/app/api/videos/[videoId]/retry-transcription/route.ts
New POST handler: authenticates, validates ownership, sets transcriptionStatus to null to trigger retry, revalidates path, and returns JSON with appropriate HTTP codes.
Transcription core logic
apps/web/lib/transcribe.ts
Extends transcribeVideo(signature adds isRetry). Adds HEAD precheck to signed URL, retry semantics (temporary vs permanent), updates DB status accordingly, supports empty/silent transcripts in VTT, and logs outcomes.
Transcript UI and hooks
apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx, apps/web/hooks/use-transcript.ts
UI: Adds useMutation to POST retry route, shows Retry button for owners when status is ERROR/null/timeout, adjusts messages, adds type="button" to edit. Hook: removes console.error on not-ready path; behavior unchanged.
Video status interface
apps/web/actions/videos/get-status.ts
Reorders aiProcessing property within VideoStatusResult; removes a commented line; no runtime logic changes.

Sequence Diagram(s)

sequenceDiagram
autonumber
actor U as User
participant UI as Transcript Tab (UI)
participant API as POST /api/videos/:id/retry-transcription
participant DB as DB (videos)
participant ISR as Revalidate Path

U->>UI: Click "Retry Transcription"
UI->>API: POST with videoId
API->>API: Auth & ownership checks
API->>DB: Update transcriptionStatus = null
API->>ISR: revalidatePath(/s/:id)
API-->>UI: { success: true, message }
note over UI: Invalidate transcript query
Loading
sequenceDiagram
autonumber
participant WRK as Transcription Worker
participant TR as transcribeVideo(videoId, userId, ..., isRetry)
participant VOD as Signed Video URL (HEAD)
participant DB as DB (videos)
participant ST as Storage (VTT)

WRK->>TR: Invoke (isRetry may be true)
TR->>VOD: HEAD check availability
alt Not ready / inaccessible
  TR->>DB: Set transcriptionStatus = null
  TR-->>WRK: { ok: false, message: "Video not ready - will retry" }
else Ready
  TR->>TR: Generate transcription
  alt Silent / empty
    TR->>ST: Upload empty valid WEBVTT
  else With utterances
    TR->>ST: Upload WEBVTT
  end
  TR->>DB: Set transcriptionStatus = "COMPLETE"
  TR-->>WRK: { ok: true }
end
opt Error during transcription
  TR->>TR: Classify error (temporary vs permanent, using isRetry/message)
  alt Temporary
    TR->>DB: Set transcriptionStatus = null
    TR-->>WRK: { ok: false, retryable }
  else Permanent
    TR->>DB: Set transcriptionStatus = "ERROR"
    TR-->>WRK: { ok: false, permanent }
  end
end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

A rabbit taps “retry” with gentle might,
Nudging words to surface from silent night.
Routes awaken, workers check the stream,
If not yet ready—back to dream.
When captions land like dew at dawn,
The transcript sings—then hops along. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 736ff6c and f4f114c.

📒 Files selected for processing (5)
  • apps/web/actions/videos/get-status.ts (1 hunks)
  • apps/web/app/api/videos/[videoId]/retry-transcription/route.ts (1 hunks)
  • apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx (4 hunks)
  • apps/web/hooks/use-transcript.ts (0 hunks)
  • apps/web/lib/transcribe.ts (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-transcript-race-condition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ameer2468 ameer2468 merged commit d9c4961 into main Sep 10, 2025
13 of 15 checks passed
@ameer2468 ameer2468 deleted the fix-transcript-race-condition branch September 10, 2025 17:19
@coderabbitai coderabbitai bot mentioned this pull request Oct 7, 2025
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