Skip to content

fix(ui): preserve preset-based creates when preset image digests change #117

@onutc

Description

@onutc

Context

A production Claude Code workspace (claude-code-wild-daisy) got stuck in Provisioning because it was created with the Claude Code image but without the Claude Code preset env. The live Spritz resource had no spec.env and no spritz.sh/preset-id=claude-code, so the Claude Code ACP health endpoint returned 503 due to missing ANTHROPIC_API_KEY.

This appears to come from the UI create flow, not the runtime itself.

Likely root cause

The create form currently treats a preset as "still selected" only when the image field exactly matches the preset image.

Relevant code:

  • ui/src/create-form-state.ts
  • ui/src/preset-panel.ts
  • ui/src/create-form-request.ts

That is brittle for digest-pinned preset images. If a preset image changes across deploys, previously persisted form state can silently fall out of preset mode even when the user still intends to create from that preset.

When that happens, submit falls back to sending raw spec.image instead of presetId, which drops preset-derived env like ANTHROPIC_API_KEY.

Repro

  1. Open the Spritz UI and select a preset like Claude Code.
  2. Persist the form state in local storage.
  3. Deploy a new Spritz version where that preset points to a new image digest.
  4. Reopen the UI with the persisted state.
  5. Submit the form without explicitly reselecting the preset.

Observed

  • The request can be submitted with spec.image instead of presetId.
  • The created workspace does not inherit preset env.
  • For Claude Code, the workspace stays stuck in Provisioning because the ACP health check fails without ANTHROPIC_API_KEY.

Expected

Preset selection should be anchored to a stable preset identity, not exact image equality.

Acceptance criteria

  • Persist a stable preset identifier in create-form state.
  • Restore preset selection by stable preset identity, not exact image equality.
  • Use presetId on submit whenever the form is still in preset mode.
  • Only fall back to raw spec.image when the user explicitly switches to custom or intentionally edits away from the preset.
  • Add regression tests covering persisted preset state across preset image digest changes.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions