Skip to content

feat(workspaces): store snapshot build facts in SQL - #1580

Merged
dcramer merged 5 commits into
mainfrom
feat/snapshot-build-duration
Aug 15, 2026
Merged

feat(workspaces): store snapshot build facts in SQL#1580
dcramer merged 5 commits into
mainfrom
feat/snapshot-build-duration

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Record Workspace snapshot operator facts in SQL and show build time on the Workspace details page.

Why
Build duration is durable dashboard data. Redis is the hot snapshot registry and can TTL out, so it is a weak source of truth for the UI.

What

  • Add snapshot_id, snapshot_generated_at, snapshot_build_duration_ms, and snapshot_profile_hash on junior_workspaces
  • After a successful Workspace prepare, write those fields from the resolved snapshot (including cache hits)
  • Clear them when the recipe changes
  • Serve Workspace detail snapshot metadata from SQL; hide it if the profile hash no longer matches
  • Keep Redis for locks and profile-hash reuse; still store buildDurationMs there for the hot path
  • Show Build time on the Workspace details page

Verify

  • tests/integration/api/workspaces/routes.test.ts
  • tests/component/sandbox/snapshot/resolve.test.ts
  • tests/component/misc/sandbox-executor.test.ts
  • tests/unit/sandbox/snapshot/profile.test.ts

Requested by David Cramer.

--

View Junior Session [Sentry]

sentry-junior Bot and others added 2 commits August 15, 2026 01:41
Record how long each Sandbox snapshot build takes in the Redis cache
and surface it on the Workspace details page.

Co-Authored-By: David Cramer <david@sentry.io>
Record buildDurationMs on every cached snapshot and show it on the
Workspace details page. Bump the Redis cache key so old entries miss
cleanly instead of carrying a nullable fallback.

Co-Authored-By: David Cramer <david@sentry.io>
@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 15, 2026 3:30am

Request Review

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown

Dashboard visual evidence

Mode: path-selected
Selected: conversations, conversation-detail, system

Triggered by:

  • packages/junior-dashboard/e2e/system.spec.ts
  • packages/junior-dashboard/src/client/conversations/ConversationPage.tsx
  • packages/junior-dashboard/src/client/conversations/PendingMailboxStack.tsx
  • packages/junior-dashboard/src/client/conversations/transcriptBottomPinning.ts
  • packages/junior-dashboard/src/client/pages/system/WorkspaceDetails.tsx

Conversations · desktop

Conversations · desktop

Conversations · mobile

Conversations · mobile

Conversation detail · desktop

Conversation detail · desktop

Conversation detail · mobile

Conversation detail · mobile

System · desktop

System · desktop

Full-page screenshots from the mock dashboard. Not a pixel-diff gate.

Record snapshot id, generation time, build duration, and profile hash
on the Workspace row after a successful prepare. Serve the dashboard
details page from SQL so Redis TTL misses do not erase operator facts.
Clear the recorded snapshot when the recipe changes.

Co-Authored-By: David Cramer <david@sentry.io>
@sentry-junior sentry-junior Bot changed the title feat(sandbox): store snapshot build duration feat(workspaces): store snapshot build facts in SQL Aug 15, 2026
@dcramer
dcramer marked this pull request as ready for review August 15, 2026 03:23
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 15, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fcdbb75. Configure here.

Comment thread packages/junior/src/chat/sandbox/session.ts
Comment thread packages/junior/src/chat/workspaces/store.ts Outdated
@dcramer
dcramer merged commit 5e74d03 into main Aug 15, 2026
36 checks passed
@dcramer
dcramer deleted the feat/snapshot-build-duration branch August 15, 2026 04:32
Comment on lines 279 to 280
await replaceWorkspaceRepos(db, id, recipe.repos);
return rows[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing rows[0] guard after workspace update allows FK violation on concurrent delete

updateWorkspace does not verify that UPDATE ... RETURNING produced a row before calling replaceWorkspaceRepos. If the workspace is concurrently deleted between the earlier SELECT and the UPDATE, the update affects zero rows. replaceWorkspaceRepos then attempts to insert repo rows for a nonexistent workspace, violating the junior_workspace_repos.workspace_id foreign key and raising a 500 instead of the expected 404.

Evidence
  • updateWorkspace has an initial SELECT guard (if (!existing) return undefined) but does not check the UPDATE ... RETURNING result before invoking replaceWorkspaceRepos.
  • Under PostgreSQL READ COMMITTED (the executor’s default BEGIN isolation), a concurrent DELETE that commits before the UPDATE causes the update to affect zero rows, leaving rows[0] undefined.
  • replaceWorkspaceRepos deletes existing repos and inserts new ones with the same workspaceId; because the workspace no longer exists, the FK from junior_workspace_repos.workspace_id to junior_workspaces.id throws error 23503.
  • The PUT /:id route expects updateWorkspace to return undefined when the workspace does not exist so it can emit a 404; the unhandled FK violation instead propagates as a 500.

Identified by Warden · code-review · 2WW-BTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant