Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add aiGenerationSkipped flag to video metadata and status

Richie McIlroyb7dade2e9742
diff --git a/apps/web/actions/videos/generate-ai-metadata.ts b/apps/web/actions/videos/generate-ai-metadata.ts
index 3c15e2ab1..9bfa72d69 100644
--- a/apps/web/actions/videos/generate-ai-metadata.ts
+++ b/apps/web/actions/videos/generate-ai-metadata.ts
@@ -138,6 +138,7 @@ export async function generateAiMetadata(
metadata: {
...metadata,
aiProcessing: false,
+ aiGenerationSkipped: true,
},
})
.where(eq(videos.id, videoId));
@@ -166,6 +167,7 @@ export async function generateAiMetadata(
metadata: {
...metadata,
aiProcessing: false,
+ aiGenerationSkipped: true,
},
})
.where(eq(videos.id, videoId));
diff --git a/apps/web/actions/videos/get-status.ts b/apps/web/actions/videos/get-status.ts
index 9cb951b36..efe07214e 100644
--- a/apps/web/actions/videos/get-status.ts
+++ b/apps/web/actions/videos/get-status.ts
@@ -21,6 +21,7 @@ export interface VideoStatusResult {
transcriptionStatus: TranscriptionStatus | null;
aiTitle: string | null;
aiProcessing: boolean;
+ aiGenerationSkipped: boolean;
summary: string | null;
chapters: { title: string; start: number }[] | null;
error?: string;
@@ -61,10 +62,10 @@ export async function getVideoStatus(
return {
transcriptionStatus: "PROCESSING",
aiProcessing: false,
+ aiGenerationSkipped: metadata.aiGenerationSkipped || false,
aiTitle: metadata.aiTitle || null,
summary: metadata.summary || null,
chapters: metadata.chapters || null,
- // generationError: metadata.generationError || null,
};
} catch (error) {
console.error(
@@ -74,10 +75,10 @@ export async function getVideoStatus(
return {
transcriptionStatus: "ERROR",
aiProcessing: false,
+ aiGenerationSkipped: metadata.aiGenerationSkipped || false,
aiTitle: metadata.aiTitle || null,
summary: metadata.summary || null,
chapters: metadata.chapters || null,
- // generationError: metadata.generationError || null,
error: "Failed to start transcription",
};
}
@@ -87,10 +88,10 @@ export async function getVideoStatus(
return {
transcriptionStatus: "ERROR",
aiProcessing: false,
+ aiGenerationSkipped: metadata.aiGenerationSkipped || false,
aiTitle: metadata.aiTitle || null,
summary: metadata.summary || null,
chapters: metadata.chapters || null,
- // generationError: metadata.generationError || null,
error: "Transcription failed",
};
}
@@ -129,10 +130,10 @@ export async function getVideoStatus(
transcriptionStatus:
(updatedVideo.transcriptionStatus as TranscriptionStatus) || null,
aiProcessing: false,
+ aiGenerationSkipped: updatedMetadata.aiGenerationSkipped || false,
aiTitle: updatedMetadata.aiTitle || null,
summary: updatedMetadata.summary || null,
chapters: updatedMetadata.chapters || null,
- // generationError: updatedMetadata.generationError || null,
error: "AI processing timed out and was reset",
};
}
@@ -142,9 +143,9 @@ export async function getVideoStatus(
if (
video.transcriptionStatus === "COMPLETE" &&
!metadata.aiProcessing &&
+ !metadata.aiGenerationSkipped &&
!metadata.summary &&
!metadata.chapters
- // !metadata.generationError
) {
console.log(
`[Get Status] Transcription complete but no AI data, checking feature flag for video owner ${video.ownerId}`,
@@ -216,10 +217,10 @@ export async function getVideoStatus(
transcriptionStatus:
(video.transcriptionStatus as TranscriptionStatus) || null,
aiProcessing: true,
+ aiGenerationSkipped: false,
aiTitle: metadata.aiTitle || null,
summary: metadata.summary || null,
chapters: metadata.chapters || null,
- // generationError: metadata.generationError || null,
};
} else {
const videoOwner = videoOwnerQuery[0];
@@ -233,9 +234,9 @@ export async function getVideoStatus(
transcriptionStatus:
(video.transcriptionStatus as TranscriptionStatus) || null,
aiProcessing: metadata.aiProcessing || false,
+ aiGenerationSkipped: metadata.aiGenerationSkipped || false,
aiTitle: metadata.aiTitle || null,
summary: metadata.summary || null,
chapters: metadata.chapters || null,
- // generationError: metadata.generationError || null,
};
}
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index b23fd6379..880af01ce 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -145,6 +145,7 @@ interface ShareProps {
summary?: string | null;
chapters?: { title: string; start: number }[] | null;
processing?: boolean;
+ generationSkipped?: boolean;
} | null;
aiGenerationEnabled: boolean;
}
@@ -159,6 +160,7 @@ const useVideoStatus = (
summary?: string | null;
chapters?: { title: string; start: number }[] | null;
processing?: boolean;
+ generationSkipped?: boolean;
} | null;
},
) => {
@@ -178,6 +180,7 @@ const useVideoStatus = (
| "ERROR"
| null,
aiProcessing: initialData.aiData?.processing || false,
+ aiGenerationSkipped: initialData.aiData?.generationSkipped || false,
aiTitle: initialData.aiData?.title || null,
summary: initialData.aiData?.summary || null,
chapters: initialData.aiData?.chapters || null,
@@ -204,6 +207,10 @@ const useVideoStatus = (
return false;
}
+ if (data.aiGenerationSkipped) {
+ return false;
+ }
+
if (data.aiProcessing) {
return true;
}
@@ -265,7 +272,7 @@ export const Share = ({
summary: videoStatus?.summary || null,
chapters: videoStatus?.chapters || null,
processing: videoStatus?.aiProcessing || false,
- // generationError: videoStatus?.generationError || null,
+ generationSkipped: videoStatus?.aiGenerationSkipped || false,
}),
[videoStatus],
);
@@ -296,9 +303,9 @@ export const Share = ({
}
if (transcriptionStatus === "COMPLETE") {
- // if (aiData.generationError) {
- // return false;
- // }
+ if (aiData.generationSkipped) {
+ return false;
+ }
if (aiData.processing === true) {
return true;
}
diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx
index 3e5d7a9b1..5814c7d83 100644
--- a/apps/web/app/s/[videoId]/page.tsx
+++ b/apps/web/app/s/[videoId]/page.tsx
@@ -508,6 +508,7 @@ async function AuthorizedContent({
summary: metadata.summary || null,
chapters: metadata.chapters || null,
processing: metadata.aiProcessing || false,
+ generationSkipped: metadata.aiGenerationSkipped || false,
};
} else if (metadata.aiProcessing) {
initialAiData = {
@@ -515,15 +516,24 @@ async function AuthorizedContent({
summary: null,
chapters: null,
processing: true,
+ generationSkipped: false,
+ };
+ } else if (metadata.aiGenerationSkipped) {
+ initialAiData = {
+ title: null,
+ summary: null,
+ chapters: null,
+ processing: false,
+ generationSkipped: true,
};
}
if (
video.transcriptionStatus === "COMPLETE" &&
!currentMetadata.aiProcessing &&
+ !currentMetadata.aiGenerationSkipped &&
!currentMetadata.summary &&
!currentMetadata.chapters &&
- // !currentMetadata.generationError &&
aiGenerationEnabled
) {
try {
diff --git a/packages/database/types/metadata.ts b/packages/database/types/metadata.ts
index 06ddde4d6..c4c76beda 100644
--- a/packages/database/types/metadata.ts
+++ b/packages/database/types/metadata.ts
@@ -28,6 +28,7 @@ export interface VideoMetadata {
*/
chapters?: { title: string; start: number }[];
aiProcessing?: boolean;
+ aiGenerationSkipped?: boolean;
}
/**