Nico Albanese 0dd202b0c1
Add sandbox snapshot support with Vercel Blob storage (#71)
* add plan for docs sandbox

* update plan

* Fix sandbox update condition for recreation

* Add snapshot schema and migration

* Add snapshot types to sandbox interface

* Implement snapshot and restore in Vercel sandbox

* Add snapshot API endpoints

* Add snapshot UI and state management

* Fix snapshot security and error handling issues

- Add sandbox ownership check to PUT restore endpoint
- Clean up temporary archive file after snapshot upload
- Add error state and UI feedback for restore failures
- Extract shared snapshot save logic to reduce duplication

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix snapshot restore option not appearing after first save

Update task state in React context after saving a snapshot so the
restore option appears immediately without requiring a page refresh.
Also sync sandboxId state between frontend and database to prevent
stale state issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Use scoped client token for blob uploads

Generate a short-lived, scoped client token instead of passing the
full BLOB_READ_WRITE_TOKEN to the sandbox. This mitigates token
exposure in shell commands and logs.

The client token is:
- Scoped to the specific snapshot pathname
- Valid for only 5 minutes
- Limited to 500MB uploads
- Restricted to gzip content types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix snapshot restore failing for unpushed branches

For isNewBranch tasks, the branch only exists locally in the sandbox.
When restoring a snapshot, the code was trying to clone from that branch
which doesn't exist on origin, causing git clone to fail.

Now uses prNumber as a proxy for "branch exists on origin" - if no PR
was created, the branch was never pushed, so we clone the default branch
and create the new branch locally instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix chat route security and error handling

- Require taskId in chat route to ensure sandbox ownership is always verified
- Add JSON parse error handling for malformed request bodies
- Improve error message when blob upload returns non-JSON response

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:20:25 +00:00
..
2025-12-26 10:54:28 +01:00
2025-12-26 10:54:28 +01:00
2025-12-31 19:01:47 +01:00
2025-12-26 10:54:28 +01:00
2025-12-26 10:54:28 +01:00
2025-12-26 11:00:09 +01:00