Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: distinguish source reuploads from processing incidents

Richie McIlroy4f4820f6f41d
diff --git a/apps/web/__tests__/unit/desktop-recording-health.test.ts b/apps/web/__tests__/unit/desktop-recording-health.test.ts
index 76d25e5c4..ba010a011 100644
--- a/apps/web/__tests__/unit/desktop-recording-health.test.ts
+++ b/apps/web/__tests__/unit/desktop-recording-health.test.ts
@@ -16,6 +16,7 @@ const counts = {
retryLoops: 0,
blockedCommittedSources: 0,
changedSources: 0,
+ awaitingSourceReupload: 0,
};
beforeEach(() => {
@@ -25,6 +26,15 @@ beforeEach(() => {
});
describe("recording health", () => {
+ it("reports inspected uploads awaiting their original source separately from processing incidents", async () => {
+ where.mockResolvedValue([{ ...counts, awaitingSourceReupload: 12 }]);
+ expect(await getDesktopRecordingHealth()).toMatchObject({
+ status: "healthy",
+ awaitingSourceReupload: 12,
+ blockedCommittedSources: 0,
+ });
+ });
+
it("returns aggregate counts without recording identities or content", async () => {
where.mockResolvedValue([{ ...counts, retryLoops: 2, ownerId: "private" }]);
expect(await getDesktopRecordingHealth()).toMatchObject({
diff --git a/apps/web/lib/desktop-recording-health.ts b/apps/web/lib/desktop-recording-health.ts
index 208e71d2c..610b00cb1 100644
--- a/apps/web/lib/desktop-recording-health.ts
+++ b/apps/web/lib/desktop-recording-health.ts
@@ -2,6 +2,7 @@ import { db } from "@cap/database";
import { videoProcessingJobs } from "@cap/database/schema";
import { inArray, sql } from "drizzle-orm";
import { z } from "zod";
+import { DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED } from "@/lib/desktop-recording-jobs";
const RECOVERY_GRACE_MS = 30 * 60 * 1_000;
@@ -11,6 +12,7 @@ const countsSchema = z.object({
retryLoops: z.number().int().nonnegative(),
blockedCommittedSources: z.number().int().nonnegative(),
changedSources: z.number().int().nonnegative(),
+ awaitingSourceReupload: z.number().int().nonnegative(),
});
export async function getDesktopRecordingHealth({
@@ -35,13 +37,17 @@ export async function getDesktopRecordingHealth({
Number,
),
blockedCommittedSources:
- sql<number>`COALESCE(SUM(CASE WHEN ${job.state} = 'source-blocked' AND ${job.source} IS NOT NULL AND COALESCE(${job.errorCode}, '') NOT IN ('output-replaced', 'video-deleting') THEN 1 ELSE 0 END), 0)`.mapWith(
+ sql<number>`COALESCE(SUM(CASE WHEN ${job.state} = 'source-blocked' AND ${job.source} IS NOT NULL AND COALESCE(${job.errorCode}, '') NOT IN ('output-replaced', 'video-deleting', ${DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED}) THEN 1 ELSE 0 END), 0)`.mapWith(
Number,
),
changedSources:
sql<number>`COALESCE(SUM(CASE WHEN ${job.state} = 'source-blocked' AND ${job.errorCode} = 'source-changed' THEN 1 ELSE 0 END), 0)`.mapWith(
Number,
),
+ awaitingSourceReupload:
+ sql<number>`COALESCE(SUM(CASE WHEN ${job.state} = 'source-blocked' AND ${job.errorCode} = ${DESKTOP_RECORDING_SOURCE_REUPLOAD_REQUIRED} THEN 1 ELSE 0 END), 0)`.mapWith(
+ Number,
+ ),
})
.from(job)
.where(
@@ -53,7 +59,7 @@ export async function getDesktopRecordingHealth({
"source-blocked",
]),
);
- const counts = countsSchema.parse(row);
+ const { awaitingSourceReupload, ...counts } = countsSchema.parse(row);
return {
status: Object.values(counts).some((count) => count > 0)
? ("degraded" as const)
@@ -61,5 +67,6 @@ export async function getDesktopRecordingHealth({
checkedAt: now.toISOString(),
scope: "unresolved" as const,
...counts,
+ awaitingSourceReupload,
};
}