Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): retry segment finalization from get-status

Richie McIlroy7adea8ac3b89
diff --git a/apps/web/actions/videos/get-status.ts b/apps/web/actions/videos/get-status.ts
index 880557696..4d3bc5c4f 100644
--- a/apps/web/actions/videos/get-status.ts
+++ b/apps/web/actions/videos/get-status.ts
@@ -8,6 +8,10 @@ import { provideOptionalAuth, VideosPolicy } from "@cap/web-backend";
import { Policy, type Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Exit } from "effect";
+import {
+ isRetryableDesktopSegmentsFinalizationError,
+ queueDesktopSegmentsFinalization,
+} from "@/lib/desktop-segments-finalization";
import { startAiGeneration } from "@/lib/generate-ai";
import * as EffectRuntime from "@/lib/server";
import { transcribeVideo } from "../../lib/transcribe";
@@ -58,12 +62,33 @@ export async function getVideoStatus(
if (!video.transcriptionStatus && serverEnv().DEEPGRAM_API_KEY) {
const activeUpload = await db()
- .select({ videoId: videoUploads.videoId })
+ .select({
+ videoId: videoUploads.videoId,
+ phase: videoUploads.phase,
+ processingError: videoUploads.processingError,
+ })
.from(videoUploads)
.where(eq(videoUploads.videoId, videoId))
.limit(1);
if (activeUpload.length > 0) {
+ const upload = activeUpload[0];
+ if (
+ video.source?.type === "desktopSegments" &&
+ upload?.phase === "error" &&
+ isRetryableDesktopSegmentsFinalizationError(upload.processingError)
+ ) {
+ queueDesktopSegmentsFinalization({
+ videoId,
+ userId: video.ownerId,
+ }).catch((error) => {
+ console.error(
+ `[Get Status] Error queueing segment finalization for video ${videoId}:`,
+ error,
+ );
+ });
+ }
+
return {
transcriptionStatus: null,
aiGenerationStatus: