Skip to content

fix(devcontainer): persist source override across workspace restarts#744

Merged
skevetter merged 2 commits into
mainfrom
majestic-dog
Jul 25, 2026
Merged

fix(devcontainer): persist source override across workspace restarts#744
skevetter merged 2 commits into
mainfrom
majestic-dog

Conversation

@skevetter

@skevetter skevetter commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

When the container image devcontainer override is selected (e.g. --devcontainer image:<ref>), the workspace launches correctly the first time but fails to launch after a stop/restart with:

devcontainer up: parsing devcontainer.json: multiple devcontainer configurations found. Detected: [claude default]

Root cause

The override arrives as the transient CLI option DevContainerSource. On the first up, the agent takes the "ignore the project devcontainer, synthesize a config from just this image" branch. But DevContainerSource was never persisted to the workspace record (unlike DevContainerImage/DevContainerPath). On restart the desktop re-invokes up with only the workspace id and no --devcontainer flag, so the override is lost and the agent falls through to filesystem discovery, which errors on repos that contain multiple .devcontainer/<id>/ configs.

Fix

  • Add a persisted DevContainerSource field to the Workspace struct.
  • Thread it through ResolveParams and persist it in applyDevContainerOverrides.
  • Re-emit it in buildWorkspaceOptions (proxy/daemon paths).
  • Make getRawConfig fall back to the persisted Workspace.DevContainerSource when the CLI option is absent — this covers the local/docker machine-client path, which does not go through buildWorkspaceOptions but always receives the serialized Workspace. The CLI option still wins when present.

Persisting the source (rather than converting image:<ref> into the existing DevContainerImage field) preserves the "ignore the project devcontainer" semantics; DevContainerImage only overrides the image inside a discovered config and would still require discovery.

Added regression tests for the restart scenario, CLI-over-persisted precedence, and source persistence.

Summary by CodeRabbit

  • New Features

    • Dev container source overrides are now remembered across workspace restarts.
    • Command-line source selections take precedence over previously saved workspace settings.
    • Saved image-based sources can be reused without rediscovering project configuration.
  • Bug Fixes

    • Workspace configuration now consistently preserves and applies dev container source selections.

The container image devcontainer override (--devcontainer image:<ref>)
was passed only as a transient CLI option and never persisted to the
workspace record. On restart the flag was absent, so the agent fell back
to filesystem discovery and failed with "multiple devcontainer
configurations found" when the repo contained more than one config.

Persist DevContainerSource on the workspace and reuse it in getRawConfig
when the CLI option is absent, so restarts reproduce the first-launch
behavior.
@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 8ebfa8c
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a63f54af492580008cd2a4c

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 8ebfa8c
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a63f54af9e2240008f5a2b6

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e364f015-55fb-44bd-abc9-6f23e778955b

📥 Commits

Reviewing files that changed from the base of the PR and between 1ebaa4b and 8ebfa8c.

📒 Files selected for processing (7)
  • cmd/workspace/up/agent.go
  • cmd/workspace/up/up_client.go
  • pkg/devcontainer/config.go
  • pkg/devcontainer/config_test.go
  • pkg/provider/workspace.go
  • pkg/workspace/workspace.go
  • pkg/workspace/workspace_test.go

📝 Walkthrough

Walkthrough

Workspace devcontainer source overrides now propagate through workspace resolution, persist in workspace metadata, and apply during configuration loading with CLI values taking precedence over persisted values.

Changes

Devcontainer source override flow

Layer / File(s) Summary
Persist and propagate source overrides
pkg/provider/workspace.go, pkg/workspace/workspace.go, cmd/workspace/up/up_client.go, cmd/workspace/up/agent.go, pkg/workspace/workspace_test.go
Workspace metadata and resolution parameters carry DevContainerSource; changed overrides are persisted and passed through workspace startup.
Resolve configuration source precedence
pkg/devcontainer/config.go, pkg/devcontainer/config_test.go
Configuration loading prefers the CLI source, falls back to the persisted workspace source, and validates both behaviors for image sources.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant WorkspaceResolver
  participant WorkspaceConfig
  participant DevcontainerConfig
  CLI->>WorkspaceResolver: provide DevContainerSource
  WorkspaceResolver->>WorkspaceConfig: persist source override
  WorkspaceConfig-->>DevcontainerConfig: provide persisted source
  CLI->>DevcontainerConfig: provide optional CLI source
  DevcontainerConfig->>DevcontainerConfig: prefer CLI source, otherwise persisted source
Loading

Possibly related PRs

  • devsy-org/devsy#717: Both changes modify devcontainer source parsing and handling in pkg/devcontainer/config.go.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: persisting the devcontainer source override across workspace restarts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@skevetter
skevetter marked this pull request as ready for review July 25, 2026 00:01
@skevetter
skevetter merged commit 9f02601 into main Jul 25, 2026
109 of 111 checks passed
@skevetter
skevetter deleted the majestic-dog branch July 25, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant