Skip to content

feat(vercel-sandbox,sandbox): introduce snapshot tree#165

Draft
marc-vercel wants to merge 3 commits intonamed-sandboxesfrom
named-sandboxes-snapshot-tree
Draft

feat(vercel-sandbox,sandbox): introduce snapshot tree#165
marc-vercel wants to merge 3 commits intonamed-sandboxesfrom
named-sandboxes-snapshot-tree

Conversation

@marc-vercel
Copy link
Copy Markdown
Collaborator

@marc-vercel marc-vercel commented Apr 27, 2026

Required #163 to be merged first, so that we can rebase and reuse the same methods.

Introduce a new sandbox snapshots tree command (CLI) and Snapshot.tree method (SDK), so that customers and agents can visualize and walk the ancestry of snapshots, backed by the new GET /v2/sandboxes/snapshots/tree API in api-sandboxes.

CLI

A new subcommand renders the lineage of a sandbox's current snapshot, with ancestors (older) and descendants (newer) on a single tree. Pagination follows the same shape as #163:

  • --limit (1–10, default 10): per-direction page size. Validated client-side; server enforces a max of 10.
  • --cursor + --direction asc|desc: continue walking from a previous "More …" hint. --direction defaults to desc (ancestors).
> sandbox snapshots tree my-sandbox --limit 3
│
● snap_8f3a2b1c   expires: 5d
│
● snap_7d2c9a4b   expires: 3d
│   ├── sbx_sibling_1
│   ╰── sbx_sibling_2
│
● snap_5a0d7e2c   expires: 12h  ◂ current
│
● snap_4c9b6d1e   expires: 8h
│
● snap_3b8a5c0f   expires: 2h
More ancestors:   sandbox snapshots tree my-sandbox --direction desc --limit 3 --cursor snap_3b8a5c0f
More descendants: sandbox snapshots tree my-sandbox --direction asc --limit 3 --cursor snap_8f3a2b1c

Following a hint renders a single-direction continuation (no "current" marker, no other side).

SDK

A new Snapshot.tree method exposes the tree endpoint:

const ancestors = await Snapshot.tree({
  snapshotId: "snap_5a0d7e2c",
  sortOrder: "desc", // "desc" = ancestors, "asc" = descendants
  limit: 10,
});

if (ancestors.pagination.next) {
  const more = await Snapshot.tree({
    snapshotId: ancestors.pagination.next,
    sortOrder: "desc",
    limit: 10,
  });
}

Parameters:

  • snapshotId (required): anchor for the walk.
  • sortOrder: "desc" walks ancestors, "asc" walks descendants. Server default is "desc".
  • limit: page size. Max is 10 (server-enforced).

Each response includes per-node siblings and count (e.g. "3", or "10+" when truncated) so callers can render branching, plus pagination.next (a snapshot id) to continue walking in the same direction.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 27, 2026

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

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 9:31am
sandbox-cli Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 9:31am
sandbox-sdk Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 9:31am
sandbox-sdk-ai-example Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 9:31am
workflow-code-runner Ready Ready Preview, Comment, Open in v0 Apr 27, 2026 9:31am

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant