Give a resumed sandbox its Daytona API key back

Merged
AR
13d ago
+48-6

Why

Pull request review turns can't push fixes when they resume a paused sandbox. Checking out the pull request fails with Daytona API key is unavailable for file upload, and update_pull_request then refuses to push.

This is the case for every review turn that resumes: tag mode threads and automation runs. In production, 5 review turns on customer pull requests hit it since #257 shipped (stacksyncdata workflows-frontend#1737, connectors#2076, event-forward#85). A test with Codex reviewing superloglabs/otel-helpers#1 failed the same way.

Cause

When a sandbox pauses, its saved state drops apiKey so the key isn't stored in the database. On resume, DaytonaSandboxClient.resume uses the client's key to reach Daytona, but the session's state keeps apiKey empty. uploadRepositoryArchive and downloadRepositoryFile read the key from session.state, so they throw.

Change

  • resumeDaytonaSandbox in sandbox.ts deserializes the saved state and resumes it with apiKey set from the worker's Daytona configuration.
  • Tag mode (investigate.ts) and automation runs (automation-sandbox.ts) resume through it.
  • The key is still left out of the saved state.

Validation

  • New test for resumeDaytonaSandbox. The automation sandbox resume test now checks the key is passed.
  • pnpm typecheck, pnpm lint (no new warnings), pnpm test (2053 passed).

Summary by cubic

Fixes resumed sandboxes in review turns losing their Daytona API key, which broke pull request file transfers and prevented pushing fixes.

On pause, the saved state drops apiKey. On resume, resumeDaytonaSandbox restores it from the worker's Daytona configuration; tag mode (investigate.ts) and automation runs (automation-sandbox.ts) both resume through it. The key still never lands in saved state.

  • resumeDaytonaSandbox deserializes the saved state and resumes with the worker's daytonaApiKey.
  • Added a test for the resume path and updated the automation sandbox resume test to assert the key is passed.