Skip to content

An open-source, faster Devin alternative

TypeScript

add checkpoint page

Brian Reardon67cceac8dbc5
diff --git a/internal/api/dashboard.go b/internal/api/dashboard.go
index 7638ee3e..a394b2d7 100644
--- a/internal/api/dashboard.go
+++ b/internal/api/dashboard.go
@@ -9,6 +9,7 @@ import (
"log"
"net/http"
"net/url"
+ "strconv"
"strings"
"time"
@@ -1287,3 +1288,68 @@ func (s *Server) proxyWorkerHTTP(c echo.Context, session *db.SandboxSession, met
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), respBody)
}
+
+// dashboardListCheckpoints returns all checkpoints for the org with fork counts.
+func (s *Server) dashboardListCheckpoints(c echo.Context) error {
+ if s.store == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{"error": "database not configured"})
+ }
+
+ orgID, ok := auth.GetOrgID(c)
+ if !ok {
+ return c.JSON(http.StatusUnauthorized, map[string]string{"error": "org context required"})
+ }
+
+ // Pagination
+ page := 1
+ perPage := 20
+ if p := c.QueryParam("page"); p != "" {
+ if v, err := strconv.Atoi(p); err == nil && v > 0 {
+ page = v
+ }
+ }
+ if pp := c.QueryParam("per_page"); pp != "" {
+ if v, err := strconv.Atoi(pp); err == nil && v > 0 && v <= 100 {
+ perPage = v
+ }
+ }
+ offset := (page - 1) * perPage
+
+ checkpoints, total, err := s.store.ListOrgCheckpoints(c.Request().Context(), orgID, perPage, offset)
+ if err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+ if checkpoints == nil {
+ checkpoints = []db.CheckpointWithForks{}
+ }
+
+ return c.JSON(http.StatusOK, map[string]any{
+ "checkpoints": checkpoints,
+ "total": total,
+ "page": page,
+ "perPage": perPage,
+ })
+}
+
+// dashboardDeleteCheckpoint deletes a checkpoint for the authenticated org.
+func (s *Server) dashboardDeleteCheckpoint(c echo.Context) error {
+ if s.store == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{"error": "database not configured"})
+ }
+
+ orgID, ok := auth.GetOrgID(c)
+ if !ok {
+ return c.JSON(http.StatusUnauthorized, map[string]string{"error": "org context required"})
+ }
+
+ cpID, err := uuid.Parse(c.Param("id"))
+ if err != nil {
+ return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid checkpoint ID"})
+ }
+
+ if err := s.store.DeleteCheckpoint(c.Request().Context(), orgID, cpID); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+
+ return c.NoContent(http.StatusNoContent)
+}
diff --git a/internal/api/router.go b/internal/api/router.go
index 8d2ac88c..2251944e 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -210,6 +210,8 @@ func NewServer(mgr sandbox.Manager, ptyMgr *sandbox.PTYManager, apiKey string, o
dash.POST("/org/custom-domain/refresh", s.dashboardRefreshCustomDomain)
dash.GET("/templates", s.dashboardListTemplates)
dash.DELETE("/templates/:id", s.dashboardDeleteTemplate)
+ dash.GET("/checkpoints", s.dashboardListCheckpoints)
+ dash.DELETE("/checkpoints/:id", s.dashboardDeleteCheckpoint)
// Session detail + stats
dash.GET("/sessions/:sandboxId", s.dashboardGetSession)
diff --git a/internal/db/store.go b/internal/db/store.go
index aa3f6f9f..28a7aa2b 100644
--- a/internal/db/store.go
+++ b/internal/db/store.go
@@ -815,6 +815,61 @@ func (s *Store) ListCheckpoints(ctx context.Context, sandboxID string) ([]Checkp
return checkpoints, rows.Err()
}
+// CheckpointWithForks extends Checkpoint with a count of active forked sandboxes.
+type CheckpointWithForks struct {
+ Checkpoint
+ ActiveForks int `json:"activeForks"`
+ TotalForks int `json:"totalForks"`
+}
+
+// ListOrgCheckpoints returns all checkpoints for an org with fork counts, paginated.
+func (s *Store) ListOrgCheckpoints(ctx context.Context, orgID uuid.UUID, limit, offset int) ([]CheckpointWithForks, int, error) {
+ // Total count for pagination
+ var total int
+ if err := s.pool.QueryRow(ctx,
+ `SELECT COUNT(*) FROM sandbox_checkpoints WHERE org_id = $1`, orgID).Scan(&total); err != nil {
+ return nil, 0, err
+ }
+
+ rows, err := s.pool.Query(ctx,
+ `SELECT c.id, c.sandbox_id, c.org_id, c.name, c.rootfs_s3_key, c.workspace_s3_key,
+ c.sandbox_config, c.status, c.size_bytes, c.created_at,
+ (SELECT COUNT(*) FROM sandbox_sessions ss WHERE ss.based_on_checkpoint_id = c.id AND ss.status IN ('running', 'hibernated')) AS active_forks,
+ (SELECT COUNT(*) FROM sandbox_sessions ss WHERE ss.based_on_checkpoint_id = c.id) AS total_forks
+ FROM sandbox_checkpoints c WHERE c.org_id = $1
+ ORDER BY c.created_at DESC LIMIT $2 OFFSET $3`, orgID, limit, offset)
+ if err != nil {
+ return nil, 0, err
+ }
+ defer rows.Close()
+
+ var results []CheckpointWithForks
+ for rows.Next() {
+ var cf CheckpointWithForks
+ if err := rows.Scan(&cf.ID, &cf.SandboxID, &cf.OrgID, &cf.Name, &cf.RootfsS3Key, &cf.WorkspaceS3Key,
+ &cf.SandboxConfig, &cf.Status, &cf.SizeBytes, &cf.CreatedAt,
+ &cf.ActiveForks, &cf.TotalForks); err != nil {
+ return nil, 0, err
+ }
+ results = append(results, cf)
+ }
+ return results, total, rows.Err()
+}
+
+// GetCheckpointByName looks up a checkpoint by sandbox-scoped name.
+func (s *Store) GetCheckpointByName(ctx context.Context, sandboxID, name string) (*Checkpoint, error) {
+ cp := &Checkpoint{}
+ err := s.pool.QueryRow(ctx,
+ `SELECT id, sandbox_id, org_id, name, rootfs_s3_key, workspace_s3_key, sandbox_config, status, size_bytes, created_at
+ FROM sandbox_checkpoints WHERE sandbox_id = $1 AND name = $2`, sandboxID, name,
+ ).Scan(&cp.ID, &cp.SandboxID, &cp.OrgID, &cp.Name, &cp.RootfsS3Key, &cp.WorkspaceS3Key,
+ &cp.SandboxConfig, &cp.Status, &cp.SizeBytes, &cp.CreatedAt)
+ if err != nil {
+ return nil, fmt.Errorf("checkpoint not found: %w", err)
+ }
+ return cp, nil
+}
+
// CountCheckpoints returns the number of checkpoints for a sandbox.
func (s *Store) CountCheckpoints(ctx context.Context, sandboxID string) (int, error) {
var count int
diff --git a/web/src/App.tsx b/web/src/App.tsx
index cb765349..93d3e959 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -6,7 +6,7 @@ import Login from './pages/Login'
import Dashboard from './pages/Dashboard'
import Sessions from './pages/Sessions'
import APIKeys from './pages/APIKeys'
-import Templates from './pages/Templates'
+import Checkpoints from './pages/Checkpoints'
import Settings from './pages/Settings'
import SessionDetail from './pages/SessionDetail'
@@ -20,7 +20,7 @@ export default function App() {
<Route index element={<Dashboard />} />
<Route path="sessions" element={<Sessions />} />
<Route path="sessions/:sandboxId" element={<SessionDetail />} />
- <Route path="templates" element={<Templates />} />
+ <Route path="checkpoints" element={<Checkpoints />} />
<Route path="api-keys" element={<APIKeys />} />
<Route path="settings" element={<Settings />} />
</Route>
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index 9feea4af..2e629538 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -57,6 +57,12 @@ export const getTemplates = () => apiFetch<Template[]>('/templates')
export const deleteTemplate = (id: string) =>
apiFetch<void>(`/templates/${id}`, { method: 'DELETE' })
+export const getCheckpoints = (page = 1, perPage = 20) =>
+ apiFetch<CheckpointsResponse>(`/checkpoints?page=${page}&per_page=${perPage}`)
+
+export const deleteCheckpointDashboard = (id: string) =>
+ apiFetch<void>(`/checkpoints/${id}`, { method: 'DELETE' })
+
export const getSessionDetail = (sandboxId: string) =>
apiFetch<SessionDetail>(`/sessions/${sandboxId}`)
@@ -166,6 +172,25 @@ export interface SandboxStats {
pids: number
}
+export interface CheckpointItem {
+ id: string
+ sandboxId: string
+ orgId: string
+ name: string
+ status: string
+ sizeBytes: number
+ activeForks: number
+ totalForks: number
+ createdAt: string
+}
+
+export interface CheckpointsResponse {
+ checkpoints: CheckpointItem[]
+ total: number
+ page: number
+ perPage: number
+}
+
export interface Org {
id: string
name: string
diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsx
index 70f99f98..0efda33a 100644
--- a/web/src/components/Layout.tsx
+++ b/web/src/components/Layout.tsx
@@ -48,7 +48,7 @@ const icons = {
const navItems = [
{ to: '/', label: 'Dashboard', end: true, icon: icons.grid },
{ to: '/sessions', label: 'Sessions', icon: icons.clock },
- { to: '/templates', label: 'Templates', icon: icons.layers },
+ { to: '/checkpoints', label: 'Checkpoints', icon: icons.layers },
{ to: '/api-keys', label: 'API Keys', icon: icons.key },
{ to: '/settings', label: 'Settings', icon: icons.gear },
]
diff --git a/web/src/pages/Checkpoints.tsx b/web/src/pages/Checkpoints.tsx
new file mode 100644
index 00000000..f41a3675
--- /dev/null
+++ b/web/src/pages/Checkpoints.tsx
@@ -0,0 +1,175 @@
+import { useState } from 'react'
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { getCheckpoints, deleteCheckpointDashboard, type CheckpointItem } from '../api/client'
+
+function formatBytes(bytes: number): string {
+ if (bytes === 0) return '-'
+ const mb = bytes / 1024 / 1024
+ if (mb < 1) return `${(bytes / 1024).toFixed(0)} KB`
+ if (mb >= 1024) return `${(mb / 1024).toFixed(1)} GB`
+ return `${mb.toFixed(1)} MB`
+}
+
+export default function Checkpoints() {
+ const queryClient = useQueryClient()
+ const [page, setPage] = useState(1)
+ const perPage = 20
+
+ const { data, isLoading } = useQuery({
+ queryKey: ['checkpoints', page],
+ queryFn: () => getCheckpoints(page, perPage),
+ })
+
+ const deleteMutation = useMutation({
+ mutationFn: (id: string) => deleteCheckpointDashboard(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ['checkpoints'] })
+ },
+ })
+
+ const checkpoints = data?.checkpoints ?? []
+ const total = data?.total ?? 0
+ const totalPages = Math.ceil(total / perPage)
+
+ return (
+ <div>
+ {/* Header */}
+ <div style={{ marginBottom: 28 }}>
+ <h1 className="page-title">Checkpoints</h1>
+ <p className="page-subtitle">Sandbox snapshots across your organization</p>
+ </div>
+
+ {/* Table */}
+ {isLoading ? (
+ <div style={{ display: 'flex', justifyContent: 'center', padding: 48 }}>
+ <div className="loading-spinner" />
+ </div>
+ ) : (
+ <div className="glass-card animate-in stagger-1" style={{ overflow: 'hidden' }}>
+ <table className="data-table">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Sandbox</th>
+ <th>Status</th>
+ <th>Size</th>
+ <th style={{ textAlign: 'right' }}>Active Forks</th>
+ <th style={{ textAlign: 'right' }}>Total Forks</th>
+ <th>Created</th>
+ <th style={{ width: 80 }}></th>
+ </tr>
+ </thead>
+ <tbody>
+ {checkpoints.map((cp: CheckpointItem) => (
+ <tr key={cp.id}>
+ <td style={{ fontWeight: 500, color: 'var(--text-primary)' }}>{cp.name}</td>
+ <td>
+ <code style={{ fontSize: 12 }}>{cp.sandboxId}</code>
+ </td>
+ <td>
+ <span style={{
+ fontSize: 11,
+ fontWeight: 600,
+ padding: '2px 8px',
+ borderRadius: 10,
+ background: cp.status === 'ready'
+ ? 'rgba(34, 197, 94, 0.08)'
+ : cp.status === 'failed'
+ ? 'rgba(251, 113, 133, 0.08)'
+ : 'rgba(234, 179, 8, 0.08)',
+ color: cp.status === 'ready'
+ ? 'var(--accent-green)'
+ : cp.status === 'failed'
+ ? 'var(--accent-rose)'
+ : '#eab308',
+ border: `1px solid ${
+ cp.status === 'ready'
+ ? 'rgba(34, 197, 94, 0.15)'
+ : cp.status === 'failed'
+ ? 'rgba(251, 113, 133, 0.15)'
+ : 'rgba(234, 179, 8, 0.15)'
+ }`,
+ }}>
+ {cp.status === 'ready' ? 'Ready' : cp.status === 'failed' ? 'Failed' : 'Processing'}
+ </span>
+ </td>
+ <td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>
+ {formatBytes(cp.sizeBytes)}
+ </td>
+ <td style={{ textAlign: 'right', fontFamily: 'var(--font-mono)', fontSize: 12 }}>
+ {cp.activeForks > 0 ? (
+ <span style={{ color: 'var(--accent-emerald)' }}>{cp.activeForks}</span>
+ ) : (
+ <span style={{ color: 'var(--text-tertiary)' }}>0</span>
+ )}
+ </td>
+ <td style={{ textAlign: 'right', fontFamily: 'var(--font-mono)', fontSize: 12, color: 'var(--text-secondary)' }}>
+ {cp.totalForks}
+ </td>
+ <td style={{ fontFamily: 'var(--font-mono)', fontSize: 12 }}>
+ {new Date(cp.createdAt).toLocaleString()}
+ </td>
+ <td>
+ <button
+ className="btn-danger"
+ onClick={() => {
+ if (confirm(`Delete checkpoint "${cp.name}"? Active forks will not be affected.`)) {
+ deleteMutation.mutate(cp.id)
+ }
+ }}
+ >
+ Delete
+ </button>
+ </td>
+ </tr>
+ ))}
+ {checkpoints.length === 0 && (
+ <tr>
+ <td colSpan={8} style={{ textAlign: 'center', padding: 32, color: 'var(--text-tertiary)' }}>
+ No checkpoints yet
+ </td>
+ </tr>
+ )}
+ </tbody>
+ </table>
+
+ {/* Pagination */}
+ {totalPages > 1 && (
+ <div style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ padding: '12px 16px',
+ borderTop: '1px solid var(--border-subtle)',
+ fontSize: 12,
+ color: 'var(--text-secondary)',
+ }}>
+ <span>{total} checkpoint{total !== 1 ? 's' : ''}</span>
+ <div style={{ display: 'flex', gap: 6 }}>
+ <button
+ className="btn-ghost"
+ disabled={page <= 1}
+ onClick={() => setPage(p => p - 1)}
+ style={{ padding: '4px 10px', fontSize: 12 }}
+ >
+ Prev
+ </button>
+ <span style={{ padding: '4px 8px', lineHeight: '24px' }}>
+ {page} / {totalPages}
+ </span>
+ <button
+ className="btn-ghost"
+ disabled={page >= totalPages}
+ onClick={() => setPage(p => p + 1)}
+ style={{ padding: '4px 10px', fontSize: 12 }}
+ >
+ Next
+ </button>
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/web/tsconfig.tsbuildinfo b/web/tsconfig.tsbuildinfo
index dd132900..8708ac61 100644
--- a/web/tsconfig.tsbuildinfo
+++ b/web/tsconfig.tsbuildinfo
@@ -1 +1 @@
-{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/components/terminal.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessiondetail.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}
\ No newline at end of file
+{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/api/client.ts","./src/components/layout.tsx","./src/components/protectedroute.tsx","./src/components/terminal.tsx","./src/hooks/useauth.tsx","./src/pages/apikeys.tsx","./src/pages/checkpoints.tsx","./src/pages/dashboard.tsx","./src/pages/login.tsx","./src/pages/sessiondetail.tsx","./src/pages/sessions.tsx","./src/pages/settings.tsx","./src/pages/templates.tsx"],"version":"5.6.3"}
\ No newline at end of file