An open-source, faster Devin alternative
TypeScript
ensure checkpoint name gets to edge
Brian Reardond01a6e997b69
diff --git a/cloudflare-workers/api-edge/src/dashboard.ts b/cloudflare-workers/api-edge/src/dashboard.tsindex bfdcfa9a..46be32d1 100644--- a/cloudflare-workers/api-edge/src/dashboard.ts+++ b/cloudflare-workers/api-edge/src/dashboard.ts@@ -680,12 +680,13 @@ async function handleListCheckpoints(req: Request, env: DashboardEnv, caller: Caconst offset = (page - 1) * perPage;const { results } = await env.OPENCOMPUTER_DB.prepare(- `SELECT id, sandbox_id, owner_cell_id, s3_url, size_bytes, golden_hash, workspace_size, created_at, expires_at+ `SELECT id, sandbox_id, owner_cell_id, s3_url, size_bytes, golden_hash, workspace_size, created_at, expires_at, nameFROM checkpoints_index WHERE org_id = ?1 ORDER BY created_at DESC LIMIT ?2 OFFSET ?3`,).bind(caller.orgID, perPage, offset).all<{id: string; sandbox_id: string; owner_cell_id: string; s3_url: string | null;size_bytes: number | null; golden_hash: string | null; workspace_size: number | null;created_at: number; expires_at: number | null;+ name: string | null;}>();const totalRow = await env.OPENCOMPUTER_DB.prepare(`SELECT COUNT(*) AS c FROM checkpoints_index WHERE org_id = ?1`).bind(caller.orgID).first<{ c: number }>();return json({@@ -693,7 +694,11 @@ async function handleListCheckpoints(req: Request, env: DashboardEnv, caller: Caid: r.id,sandboxId: r.sandbox_id ?? "",orgId: caller.orgID,- name: (r.s3_url ?? "").split("/").filter(Boolean).pop() || r.id,+ // Prefer the user-set name. Pre-fix this derived from s3_url which+ // always ended in "rootfs.tar.zst" (every row showed the same name);+ // the column was added + backfilled from cell PG sandbox_checkpoints+ // so this now surfaces what customers actually called the checkpoint.+ name: r.name && r.name.length > 0 ? r.name : r.id.slice(0, 8),status: "ready",sizeBytes: r.size_bytes ?? 0,activeForks: 0,diff --git a/cloudflare-workers/events-ingest/src/index.ts b/cloudflare-workers/events-ingest/src/index.tsindex 25db4425..e8ec921a 100644--- a/cloudflare-workers/events-ingest/src/index.ts+++ b/cloudflare-workers/events-ingest/src/index.ts@@ -211,14 +211,15 @@ export default {// would rebase the delta onto the wrong base and break restore.const checkpointUpsert = env.OPENCOMPUTER_DB.prepare(`INSERT INTO checkpoints_index- (id, sandbox_id, org_id, owner_cell_id, s3_url, size_bytes, golden_hash, workspace_size, created_at)- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, NULL, ?8)+ (id, sandbox_id, org_id, owner_cell_id, s3_url, size_bytes, golden_hash, workspace_size, created_at, name)+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, NULL, ?8, ?9)ON CONFLICT(id) DO UPDATE SETsandbox_id = excluded.sandbox_id,owner_cell_id = excluded.owner_cell_id,s3_url = excluded.s3_url,size_bytes = excluded.size_bytes,- golden_hash = CASE WHEN checkpoints_index.golden_hash = '' THEN excluded.golden_hash ELSE checkpoints_index.golden_hash END`,+ golden_hash = CASE WHEN checkpoints_index.golden_hash = '' THEN excluded.golden_hash ELSE checkpoints_index.golden_hash END,+ name = CASE WHEN excluded.name IS NULL OR excluded.name = '' THEN checkpoints_index.name ELSE excluded.name END`,);const checkpointDelete = env.OPENCOMPUTER_DB.prepare(`DELETE FROM checkpoints_index WHERE id = ?1`,@@ -232,6 +233,7 @@ export default {workspace_s3_key?: string;size_bytes?: number;golden_hash?: string;+ name?: string;};if (!p.checkpoint_id) return [];if (e.type === "checkpoint_deleted") {@@ -239,7 +241,9 @@ export default {}// checkpoint_ready — use rootfs_s3_key as the canonical s3_url since// it's the rootfs delta the worker pulls at spawn time. The workspace- // key is reachable from the rootfs metadata.+ // key is reachable from the rootfs metadata. `name` is the user-set+ // label; pre-fix the dashboard derived it from rootfs_s3_key, which+ // always ended in "rootfs.tar.zst".const tsSec = Math.floor((Date.parse(e.timestamp) || Date.now()) / 1000);return [checkpointUpsert.bind(@@ -251,6 +255,7 @@ export default {p.size_bytes ?? null,p.golden_hash ?? "",tsSec,+ p.name ?? null,),];});diff --git a/internal/api/sandbox.go b/internal/api/sandbox.goindex 3f09ae2f..6ce8da5c 100644--- a/internal/api/sandbox.go+++ b/internal/api/sandbox.go@@ -2189,6 +2189,10 @@ func (s *Server) createCheckpoint(c echo.Context) error {// checkpoints_index rows created from this event are spawn-routable// (matches what the backfill stores from sandbox_sessions.golden_version)."golden_hash": golden,+ // User-set name. Without this, dashboard's checkpoints page+ // fell back to deriving from rootfs_s3_key, which always ends+ // in "rootfs.tar.zst" — every row showed the same name.+ "name": req.Name,})}()} else if s.manager != nil {@@ -2218,6 +2222,7 @@ func (s *Server) createCheckpoint(c echo.Context) error {"workspace_s3_key": workspaceKey,"size_bytes": sizeBytes,"golden_hash": golden,+ "name": req.Name,})}()} else {