From dae25e009f180372c616de15a38ba82ffbde0cab Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Mon, 1 Dec 2025 09:02:05 -0800 Subject: [PATCH] feat: add sourceUrl support for build status updates and downloads --- convex/builds.ts | 29 +++++++++++++++++++++++++++-- convex/http.ts | 1 + convex/schema.ts | 1 + src/pages/BuildProgress.tsx | 5 +++++ src/pages/ProfileFlash.tsx | 5 +++++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/convex/builds.ts b/convex/builds.ts index 1f03ab6..af0f448 100644 --- a/convex/builds.ts +++ b/convex/builds.ts @@ -239,6 +239,7 @@ export const updateBuildStatus = internalMutation({ 'status', 'completedAt', 'artifactPath', + 'sourceUrl', 'githubRunId', ]), buildId: v.id('builds'), @@ -249,6 +250,7 @@ export const updateBuildStatus = internalMutation({ const updateData: BuildUpdateData & { artifactPath?: string + sourceUrl?: string githubRunId?: number } = { status: args.status, @@ -264,6 +266,11 @@ export const updateBuildStatus = internalMutation({ updateData.artifactPath = args.artifactPath } + // Set sourceUrl if provided + if (args.sourceUrl !== undefined) { + updateData.sourceUrl = args.sourceUrl + } + // Set githubRunId if provided if (args.githubRunId !== undefined) { updateData.githubRunId = args.githubRunId @@ -433,7 +440,16 @@ export const generateSourceDownloadUrl = mutation({ const build = await ctx.db.get(args.buildId) if (!build) throw new Error('Build not found') - const objectKey = `${build.buildHash}.tar.gz` + // Use sourceUrl if available, otherwise fall back to constructing from buildHash + let objectKey: string + if (build.sourceUrl) { + // Remove leading slash if present + objectKey = build.sourceUrl.startsWith('/') + ? build.sourceUrl.substring(1) + : build.sourceUrl + } else { + objectKey = `${build.buildHash}.tar.gz` + } return await generateAuthenticatedDownloadUrl( ctx, @@ -454,7 +470,16 @@ export const generateAnonymousSourceDownloadUrl = mutation({ slug: v.string(), }, handler: async (_ctx, args) => { - const objectKey = `${args.build.buildHash}.tar.gz` + // Use sourceUrl if available, otherwise fall back to constructing from buildHash + let objectKey: string + if (args.build.sourceUrl) { + // Remove leading slash if present + objectKey = args.build.sourceUrl.startsWith('/') + ? args.build.sourceUrl.substring(1) + : args.build.sourceUrl + } else { + objectKey = `${args.build.buildHash}.tar.gz` + } return await generateAnonymousDownloadUrlHelper( args.build, diff --git a/convex/http.ts b/convex/http.ts index 462ebba..b0058ef 100644 --- a/convex/http.ts +++ b/convex/http.ts @@ -53,6 +53,7 @@ http.route({ buildId: payload.build_id, status: payload.state, artifactPath: payload.artifactPath, + sourceUrl: payload.sourcePath, githubRunId, }) diff --git a/convex/schema.ts b/convex/schema.ts index 619a772..bd1e155 100644 --- a/convex/schema.ts +++ b/convex/schema.ts @@ -30,6 +30,7 @@ export const buildFields = { // Optional props completedAt: v.optional(v.number()), artifactPath: v.optional(v.string()), + sourceUrl: v.optional(v.string()), githubRunId: v.optional(v.number()), } diff --git a/src/pages/BuildProgress.tsx b/src/pages/BuildProgress.tsx index c9555c7..d9014a7 100644 --- a/src/pages/BuildProgress.tsx +++ b/src/pages/BuildProgress.tsx @@ -220,6 +220,11 @@ export default function BuildProgress() { {downloadError && (

{downloadError}

)} + + )} + + {build.sourceUrl && ( +
+
+ )} + + {build.sourceUrl && ( +