fix(cli): skip dry-run for workspace start/restart commands #20754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
prepWorkspaceBuild()function incli/create.gowas unconditionally executing dry-runs for all workspace actions. This caused unnecessary delays and "Planning workspace..." messages duringcoder startandcoder restartcommands when they should only happen duringcoder createandcoder update.Root Cause
The
prepWorkspaceBuild()function is shared code called by:WorkspaceCreateaction ✅ dry-run IS desiredWorkspaceUpdateaction ✅ dry-run IS desiredWorkspaceStartaction (orWorkspaceUpdateas fallback) ❌ dry-run NOT desired forWorkspaceStartWorkspaceRestartaction ❌ dry-run NOT desiredWorkspaceCreateaction ✅ dry-run IS desiredSolution
Wrapped the dry-run section (lines 580-627) in a conditional that only executes when
args.Action == WorkspaceCreate || args.Action == WorkspaceUpdate.This skips dry-run for
WorkspaceStartandWorkspaceRestartactions while preserving it for creation and explicit updates.Changes
if args.Action == WorkspaceCreate || args.Action == WorkspaceUpdate { ... }Impact
coder createWorkspaceCreatecoder updateWorkspaceUpdatecoder start(normal)WorkspaceStartcoder start(template changed)WorkspaceUpdatecoder restartWorkspaceRestartWorkspaceCreateTesting
✅ Code compiles successfully
✅ All relevant tests pass locally
✅ All CI checks pass
Behavior Changes
Before:
coder startwould see "Planning workspace..." and wait for unnecessary dry-run completioncoder restartwould experience unnecessary dry-run overheadAfter:
coder start(simple start) skips dry-run entirely (faster, more intuitive)coder start(with template update) still shows dry-run (correct - user needs to see what's changing)coder restartskips dry-run entirely (faster, more intuitive)coder createmaintains existing dry-run behavior (shows "Planning workspace..." and resource preview)coder updatemaintains existing dry-run behavior (shows "Planning workspace..." and resource preview)Verification
Manual testing should verify:
coder createstill shows "Planning workspace..." ✅coder updatestill shows "Planning workspace..." ✅coder start(simple start) does NOT show "Planning workspace..." ✅coder restartdoes NOT show "Planning workspace..." ✅