Skip to content

feat: suspend and resume sandboxes, and offer stop and start where they work - #151

Open
Gkrumbach07 wants to merge 3 commits into
ai-openshell:mainfrom
Gkrumbach07:claude/nervous-payne-7bcee3
Open

Gkrumbach07 wants to merge 3 commits into
ai-openshell:mainfrom
Gkrumbach07:claude/nervous-payne-7bcee3

Conversation

@Gkrumbach07

Copy link
Copy Markdown
Contributor

What

SuspendSandbox and ResumeSandbox have been in the gateway since 0.1.6 and the dashboard had no route and no button for them. SUSPENDING and SUSPENDED were missing from the frontend's phase type, so a sandbox suspended from the CLI showed a grey unknown label and could only be deleted.

  • BFF: POST /api/v1/workspaces/{workspace}/sandboxes/{name}/suspend and /resume, through the SDK's SandboxSuspendResume() sub-client. A resume takes restartIfRestoreFails in an optional body, as ResumeSandboxRequest.restart_if_restore_fails. NewSandboxService takes the sub-client as a second argument, which is the one-line change in the other handler tests.
  • Frontend: the two phases, labelled as openshell sandbox list colours them; canSuspendSandbox and canResumeSandbox; Suspend and Resume in the sandbox page's header and in a list row's actions. The mock fixtures get a suspended sandbox (ml-training/long-eval), the only place the phase and Resume can be seen without a gateway that can suspend.
  • Compat: backend/test/compat/sandbox_phases_test.go.
  • Rules: hard fact 1 in .claude/rules/openshell-api.md said there is no suspend. It now says what 0.1.9 has, what was measured and what was only read.

Stop and Start changed too

Read at v0.1.9 (QuiesceOperation::admit, start_sandbox_with_intent in crates/openshell-server/src/compute/mod.rs), then measured against gateway 0.1.9 by the pinned digest, Docker driver, 2026-11-20:

Phase Stop Start Suspend / Resume
PROVISIONING 409 409 409
READY works 200, no change 409 compute driver does not support sandbox suspend
COMPLETED → STOPPED, exit code kept accepted, then 502 and the sandbox ends in ERROR 409
ERROR, main process failed → STOPPED, exit code kept same 502, ends in ERROR 409
ERROR, container exited → STOPPED 409 stop the sandbox before retrying start not tried
ERROR, image pull failed 404, and the sandbox is gone 409 409
STOPPED 200, no change works 409

So the dashboard now offers:

  • Stop from READY, COMPLETED, ERROR, SUSPENDING and SUSPENDED. A sandbox in ERROR had no way on but a delete; a stop, then a start, runs it again.
  • Start from STOPPED only. Before: STOPPED and COMPLETED.
  • Suspend from READY, Resume from SUSPENDED.

For the reviewer to decide

  1. Start is narrower than the gateway allows. Not from COMPLETED: the gateway accepts it and the Docker driver's start then fails (Docker supervisor exited before becoming ready, about 100 ms after the new supervisor starts), six times out of six. Not from SUSPENDED: not measured, my call. The gateway boots the sandbox afresh and discards its memory state, which beside Resume reads as the same thing. Each is one line in frontend/src/utils/sandboxLifecycle.ts.
  2. Suspend fails on every stock gateway. No compute driver upstream ships at 0.1.9 advertises openshell.compute.suspend-resume. The capability is in GET /gateway, which only a platform admin can read, so the button is offered to everyone and the gateway's refusal is shown.
  3. A stop of a sandbox whose image could not be pulled removes it. Measured three times; left alone in that state, the sandbox stays. Stop is offered in ERROR all the same.
  4. restartIfRestoreFails has no control in the UI. The BFF and the API client carry it; the UI sends none, as the CLI's sandbox resume sends false.

Tested

  • make typecheck and make test: green.
  • make lint: eslint and prettier pass, golangci-lint v2.12.2 (the version ci.yml runs) reports 0 issues.
  • Compat, -count=1, against gateway 0.1.9: TestSandboxSuspendResume, TestSandboxStopAfterMainProcessExit and TestSandboxStopStart pass. The whole suite ran once locally on a heavily loaded machine: everything passed but TestSandboxCreateOptions, whose sandbox did not boot, and which passed on its own afterwards.
  • In the browser against that gateway: the row actions per phase, Suspend from the row and from the header (the refusal as a toast), and an ERROR sandbox through Stop, STOPPED, Start, READY. Against the mock fixtures: the SUSPENDED label, Resume and Stop.

Not tested

  • A suspend and a resume that take effect. TestSandboxSuspendResume asserts the Docker driver's refusal, in a workspace of its own. That proves both calls reach the gateway, not that the workspace arrives: the gateway checks the driver before it looks the sandbox up. The round trip is written for a driver that advertises the capability and has never run.
  • SUSPENDING, SUSPENDED and the transitional phases; any compute driver but Docker.

Related

🤖 Generated with Claude Code

…ey work

SuspendSandbox and ResumeSandbox have been in the gateway since 0.1.6 and
had no route and no button, and a sandbox suspended from the CLI showed a
grey unknown label with nothing to do but delete it.

BFF: POST .../sandboxes/{name}/suspend and /resume, through the SDK's
suspend and resume sub-client. A resume takes restartIfRestoreFails in an
optional body, as ResumeSandboxRequest.restart_if_restore_fails.

Frontend: the SUSPENDING and SUSPENDED phases, labelled as the CLI colours
them, and Suspend and Resume in the sandbox page's header and a list row's
actions.

Stop and Start follow what gateway 0.1.9 takes, as measured with the Docker
driver on 2026-11-20. Stop is offered from READY, COMPLETED, ERROR,
SUSPENDING and SUSPENDED: a sandbox in ERROR had no way on but a delete, and
a stop, then a start, runs it again. Start is offered from STOPPED only: the
gateway accepts one from COMPLETED too, and with the Docker driver that
start fails and leaves the sandbox in ERROR.

No compute driver upstream ships at 0.1.9 can suspend, so the compat test
asserts the refusal the Docker driver gives, and the page shows it. The
round trip is written for a driver that can and has never run.

Hard fact 1 in .claude/rules/openshell-api.md said there is no suspend. It
now says what 0.1.9 has, what was measured and what was only read.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Gage Krumbach <gkrumbac@redhat.com>
Comment thread frontend/src/utils/sandboxLifecycle.ts Resolved
Gkrumbach07 and others added 2 commits December 2, 2026 09:28
…ne that failed

Gateway 0.1.9 with the Docker driver answers the stop of a sandbox whose
image could not be pulled with 404 and has removed the sandbox. The page
said "Failed to stop sandbox: sandbox not found" and went on showing the
sandbox until the next poll.

A stop that fails now marks the workspace's sandboxes for re-reading, as
one that succeeds does, without waiting for the re-read. When the gateway
answers 404 the page says that the sandbox no longer exists and why that
can happen, as a warning. Any other refusal is shown in the gateway's
words, as before.

Stop stays offered for every ERROR: the gateway takes it there on purpose,
and it is the way to a start.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Gage Krumbach <gkrumbac@redhat.com>
The e2e job has failed on every run since 2026-11-30, on main too, without
a failing test: the first spec passes and Cypress then stops with
"* is not a valid URL" and "Could not find Cypress test run results".

The runner's Chrome went from 157 to 158 between the last green run and
the first red one. Chrome 158 refuses the Storage.clearDataForOrigin call
with origin "*" that Cypress 15.19.0 sends when it opens the next spec
(cypress-io/cypress#35195). 15.21.2 is the release of the 15 line with the
fix; nothing else moves but Cypress's own dependencies.

Reproduced on Chrome 158.0.8127.91: 15.19.0 stops at the second spec,
15.21.2 runs all six (47 tests).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Gage Krumbach <gkrumbac@redhat.com>

This branch has not been deployed

No deployments
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.

2 participants