Skip to content

refactor(client|workspace): remove unused client options#605

Merged
skevetter merged 2 commits intoskevetter:mainfrom
dubinsky:remove-some-noise
Mar 12, 2026
Merged

refactor(client|workspace): remove unused client options#605
skevetter merged 2 commits intoskevetter:mainfrom
dubinsky:remove-some-noise

Conversation

@dubinsky
Copy link

@dubinsky dubinsky commented Mar 10, 2026

Summary by CodeRabbit

  • Refactor

    • Simplified client APIs by removing per-call option parameters for create/start operations and standardizing status values as plain strings.
  • New Features

    • Added a unified "describe" surface to expose descriptive status when supported by the environment.
  • Behavioral

    • Troubleshoot output now emits workspace status as a plain string, altering the JSON shape consumers may receive.

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Client API signatures changed: Create and Start lost their options parameters; Status and ParseStatus now return plain strings. All client implementations, workspace/machine usage, and CLI callers were updated to the new signatures and string-based status handling.

Changes

Cohort / File(s) Summary
Client core & types
pkg/client/client.go
Removed option types and the typed Status; changed Create(ctx) and Start(ctx) signatures; Status/ParseStatus now use string; DescriptionNotFound constant restored/moved.
Machine implementation
pkg/client/clientimplementation/machine_client.go
Dropped options from Create/Start and updated Status to return string; adjusted internal returns and error handling to use ParseStatus.
Workspace implementation
pkg/client/clientimplementation/workspace_client.go, pkg/workspace/workspace.go
Delegates to new machineClient.Create(ctx)/Start(ctx) signatures; Status/getContainerStatus now return strings; added Describe(ctx) (string, error) and adjusted control flow to propagate string statuses.
Daemon / proxy implementations
pkg/client/clientimplementation/daemonclient/status.go, pkg/client/clientimplementation/proxy_client.go
Status implementations changed to return string and now return string values (via ParseStatus) instead of client.Status; error paths preserved.
CLI callers
cmd/machine/create.go, cmd/machine/start.go, cmd/troubleshoot.go
Removed imports of client option types; updated calls to Create(ctx) / Start(ctx); changed local WorkspaceStatus usage to string.
Other usages
Various files referencing client option types or client.Status
Minor call-site updates and error/return adaptations to accommodate removed option types and string-based Status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • skevetter
🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring objective: removing unused client options parameters (CreateOptions, StartOptions, ValidateOptions, InitOptions, ImportWorkspaceOptions) and the Status type from the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/client/clientimplementation/workspace_client.go (1)

559-588: ⚠️ Potential issue | 🟠 Major

Validate machine provider status before returning or using it.

The machineClient.Status() path returns the raw provider output without normalizing it through ParseStatus(), while getContainerStatus() correctly validates its output. This creates an inconsistency: StartWait() has a default case (line 896) that treats any unrecognized status value as success, so a typo or backend-specific string in the machine provider's status could incorrectly mark the workspace as ready.

Parse the machine status before the comparison and return:

		status, err := machineClient.Status(ctx, options)
		if err != nil {
			return client.StatusNotFound, err
		}
+		status, err = client.ParseStatus(status)
+		if err != nil {
+			return client.StatusNotFound, err
+		}
 
 		// try to check container status and if that fails check workspace folder
 		if status == client.StatusRunning && options.ContainerStatus {
 			return s.getContainerStatus(ctx)
 		}
 
 		return status, nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/clientimplementation/workspace_client.go` around lines 559 - 588,
The machine provider path returns raw status from machineClient.Status() without
normalizing it via ParseStatus(), risking unrecognized strings being treated as
success; after calling machineClient.Status(ctx, options) pass the returned
status through ParseStatus() (e.g. ParseStatus(status)) and use the parsed value
for comparisons and returns: if parsed == client.StatusRunning and
options.ContainerStatus then call s.getContainerStatus(ctx), otherwise return
the parsed status (and propagate any ParseStatus error if it returns one)
instead of the raw provider string so StartWait's default handling can't
misinterpret provider-specific/typoed values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/client/clientimplementation/workspace_client.go`:
- Around line 559-588: The machine provider path returns raw status from
machineClient.Status() without normalizing it via ParseStatus(), risking
unrecognized strings being treated as success; after calling
machineClient.Status(ctx, options) pass the returned status through
ParseStatus() (e.g. ParseStatus(status)) and use the parsed value for
comparisons and returns: if parsed == client.StatusRunning and
options.ContainerStatus then call s.getContainerStatus(ctx), otherwise return
the parsed status (and propagate any ParseStatus error if it returns one)
instead of the raw provider string so StartWait's default handling can't
misinterpret provider-specific/typoed values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c0db4e51-c074-45f3-a1fb-0bbc66abe455

📥 Commits

Reviewing files that changed from the base of the PR and between 1451fa1 and c32b3de.

📒 Files selected for processing (9)
  • cmd/machine/create.go
  • cmd/machine/start.go
  • cmd/troubleshoot.go
  • pkg/client/client.go
  • pkg/client/clientimplementation/daemonclient/status.go
  • pkg/client/clientimplementation/machine_client.go
  • pkg/client/clientimplementation/proxy_client.go
  • pkg/client/clientimplementation/workspace_client.go
  • pkg/workspace/workspace.go

@dubinsky dubinsky force-pushed the remove-some-noise branch from 748f292 to a6dda58 Compare March 10, 2026 06:02
@dubinsky dubinsky requested a review from skevetter March 10, 2026 06:47
@dubinsky dubinsky force-pushed the remove-some-noise branch from a6dda58 to 61d55fe Compare March 10, 2026 23:54
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/client/clientimplementation/daemonclient/status.go (1)

35-35: Normalize the daemon status before returning it.

StartWait in pkg/client/clientimplementation/workspace_client.go Lines 897-918 treats any non-canonical status as ready. Returning instance.Status.LastWorkspaceStatus raw here skips clientpkg.ParseStatus, so a casing or spelling drift from the platform would bypass the stopped/busy/not-found branches.

Suggested change
-	return string(instance.Status.LastWorkspaceStatus), nil
+	parsedStatus, err := clientpkg.ParseStatus(string(instance.Status.LastWorkspaceStatus))
+	if err != nil {
+		return clientpkg.StatusNotFound, fmt.Errorf("parse platform status: %w", err)
+	}
+
+	return parsedStatus, nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/clientimplementation/daemonclient/status.go` at line 35, The
function returning instance.Status.LastWorkspaceStatus should normalize the
status using clientpkg.ParseStatus before returning so non-canonical
casing/spelling doesn't bypass StartWait's checks; update the return in
status.go to call clientpkg.ParseStatus (or the appropriate ParseStatus function
used by StartWait), handle any parse error (returning a safe default or the
error) and then return the canonical string from the parsed status instead of
the raw instance.Status.LastWorkspaceStatus.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/client/clientimplementation/daemonclient/status.go`:
- Line 35: The function returning instance.Status.LastWorkspaceStatus should
normalize the status using clientpkg.ParseStatus before returning so
non-canonical casing/spelling doesn't bypass StartWait's checks; update the
return in status.go to call clientpkg.ParseStatus (or the appropriate
ParseStatus function used by StartWait), handle any parse error (returning a
safe default or the error) and then return the canonical string from the parsed
status instead of the raw instance.Status.LastWorkspaceStatus.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27a3255a-1a3e-4329-bd53-fbed58cd5c58

📥 Commits

Reviewing files that changed from the base of the PR and between 748f292 and 61d55fe.

📒 Files selected for processing (9)
  • cmd/machine/create.go
  • cmd/machine/start.go
  • cmd/troubleshoot.go
  • pkg/client/client.go
  • pkg/client/clientimplementation/daemonclient/status.go
  • pkg/client/clientimplementation/machine_client.go
  • pkg/client/clientimplementation/proxy_client.go
  • pkg/client/clientimplementation/workspace_client.go
  • pkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • cmd/troubleshoot.go
  • pkg/workspace/workspace.go
  • cmd/machine/create.go

@dubinsky
Copy link
Author

@skevetter some tests seem to be stuck...

@dubinsky dubinsky force-pushed the remove-some-noise branch 2 times, most recently from 974298a to 021e6f2 Compare March 11, 2026 01:44
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/client/client.go (1)

184-200: ⚠️ Potential issue | 🟠 Major

Return the unrecognized status value rather than StatusNotFound on parse failure.

The current implementation converts any unrecognized status to StatusNotFound with an error. This masks new backend states, making them indistinguishable from genuinely missing resources. When callers receive a parse error (in workspace_client.go and machine_client.go), they return StatusNotFound anyway, silencing the actual status value. Return the raw trimmed input in the default case to preserve information and allow proper diagnosis of unexpected statuses.

Suggested fix
 func ParseStatus(in string) (string, error) {
-	in = strings.ToUpper(strings.TrimSpace(in))
-	switch in {
+	raw := strings.TrimSpace(in)
+	switch strings.ToUpper(raw) {
 	case "RUNNING":
 		return StatusRunning, nil
 	case "BUSY":
 		return StatusBusy, nil
 	case "STOPPED":
 		return StatusStopped, nil
 	case "NOTFOUND":
 		return StatusNotFound, nil
 	default:
-		return StatusNotFound, fmt.Errorf(
+		return raw, fmt.Errorf(
 			"error parsing status: '%s' unrecognized status, needs to be one of: %s",
-			in,
+			raw,
 			[]string{StatusRunning, StatusBusy, StatusStopped, StatusNotFound},
 		)
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/client.go` around lines 184 - 200, The ParseStatus function
currently returns StatusNotFound on unrecognized inputs which hides unknown
backend states; update the default case in ParseStatus to return the raw trimmed
input value (the local variable "in") along with the error instead of
StatusNotFound so callers (e.g., workspace_client.go and machine_client.go) can
see the actual unrecognized status; keep the existing error message but replace
the returned status constant with the "in" variable.
🧹 Nitpick comments (1)
pkg/client/client.go (1)

25-27: Please call out these interface changes in the release notes.

pkg/client is exported, and changing Status, Create, and Start here is a compile-time break for downstream implementations and callers. If this surface is supported outside this repo, add a short migration note.

Also applies to: 47-54

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/client.go` around lines 25 - 27, The change made to the exported
pkg/client interface (notably the signatures for Status(ctx context.Context,
options StatusOptions), Create and Start) is a compile-time breaking change for
downstream implementers; update the release notes to explicitly call out these
interface changes, document the exact signature diffs (old vs new), provide a
short migration note showing how to adapt implementations/callers to the new
signatures, and ensure the same note covers the other altered methods referenced
around the same area (lines with the other changed Signatures referenced in the
diff, e.g., the block at 47-54) so downstream projects can upgrade smoothly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/client/client.go`:
- Around line 184-200: The ParseStatus function currently returns StatusNotFound
on unrecognized inputs which hides unknown backend states; update the default
case in ParseStatus to return the raw trimmed input value (the local variable
"in") along with the error instead of StatusNotFound so callers (e.g.,
workspace_client.go and machine_client.go) can see the actual unrecognized
status; keep the existing error message but replace the returned status constant
with the "in" variable.

---

Nitpick comments:
In `@pkg/client/client.go`:
- Around line 25-27: The change made to the exported pkg/client interface
(notably the signatures for Status(ctx context.Context, options StatusOptions),
Create and Start) is a compile-time breaking change for downstream implementers;
update the release notes to explicitly call out these interface changes,
document the exact signature diffs (old vs new), provide a short migration note
showing how to adapt implementations/callers to the new signatures, and ensure
the same note covers the other altered methods referenced around the same area
(lines with the other changed Signatures referenced in the diff, e.g., the block
at 47-54) so downstream projects can upgrade smoothly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f85d2f52-59b8-4827-9120-4330371a1afc

📥 Commits

Reviewing files that changed from the base of the PR and between 61d55fe and 974298a.

📒 Files selected for processing (9)
  • cmd/machine/create.go
  • cmd/machine/start.go
  • cmd/troubleshoot.go
  • pkg/client/client.go
  • pkg/client/clientimplementation/daemonclient/status.go
  • pkg/client/clientimplementation/machine_client.go
  • pkg/client/clientimplementation/proxy_client.go
  • pkg/client/clientimplementation/workspace_client.go
  • pkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/machine/start.go
  • pkg/workspace/workspace.go

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
pkg/client/clientimplementation/workspace_client.go (2)

603-609: ⚠️ Potential issue | 🟠 Major

Don't treat every os.Stat failure as StatusNotFound.

Line 604 currently maps permission and I/O errors to NotFound. In StartWait, that can send callers down the create path even though the workspace folder still exists, which turns a transient filesystem problem into the wrong lifecycle action.

Suggested fix
-	_, err = os.Stat(workspaceFolder)
-	if err == nil {
-		return client.StatusRunning, nil
-	}
-
-	return client.StatusNotFound, nil
+	if _, err := os.Stat(workspaceFolder); err == nil {
+		return client.StatusRunning, nil
+	} else if os.IsNotExist(err) {
+		return client.StatusNotFound, nil
+	} else {
+		return "", fmt.Errorf("stat workspace folder: %w", err)
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/clientimplementation/workspace_client.go` around lines 603 - 609,
The current os.Stat(workspaceFolder) treats all errors as StatusNotFound; change
the logic in the function that checks workspaceFolder (used by StartWait) to
only return client.StatusNotFound when os.IsNotExist(err) is true, return
client.StatusRunning when err == nil, and for any other error propagate the
underlying error (do not map permission or I/O errors to NotFound) so callers
like StartWait can handle transient filesystem errors correctly.

710-714: ⚠️ Potential issue | 🟡 Minor

Fix the mislabeled container-status debug fields.

Line 711 logs the merged buffer as stdout, and Line 712 logs the stdout buffer as stderr. When this path misbehaves, the debug record points at the wrong stream.

Suggested fix
 	s.log.WithFields(logrus.Fields{
-		"stdout": buf.String(),
-		"stderr": stdout.String(),
-		"parsed": parsed,
+		"stdout":         stdout.String(),
+		"combinedOutput": buf.String(),
+		"parsed":         parsed,
 	}).Debug("container status command output")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/clientimplementation/workspace_client.go` around lines 710 - 714,
The debug log in s.log.WithFields is labeling the wrong buffers: it currently
sets "stdout" to buf.String() and "stderr" to stdout.String(); swap these so
"stdout" maps to stdout.String() and "stderr" maps to buf.String() (retain
"parsed" and the Debug message). Update the call in the containing
function/method where s.log.WithFields is used (referencing variables buf,
stdout, parsed and the s.log.WithFields invocation) to correct the labels.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/client/clientimplementation/workspace_client.go`:
- Around line 603-609: The current os.Stat(workspaceFolder) treats all errors as
StatusNotFound; change the logic in the function that checks workspaceFolder
(used by StartWait) to only return client.StatusNotFound when os.IsNotExist(err)
is true, return client.StatusRunning when err == nil, and for any other error
propagate the underlying error (do not map permission or I/O errors to NotFound)
so callers like StartWait can handle transient filesystem errors correctly.
- Around line 710-714: The debug log in s.log.WithFields is labeling the wrong
buffers: it currently sets "stdout" to buf.String() and "stderr" to
stdout.String(); swap these so "stdout" maps to stdout.String() and "stderr"
maps to buf.String() (retain "parsed" and the Debug message). Update the call in
the containing function/method where s.log.WithFields is used (referencing
variables buf, stdout, parsed and the s.log.WithFields invocation) to correct
the labels.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66d5c06d-38c3-4e07-8ef8-d6d45a8c3476

📥 Commits

Reviewing files that changed from the base of the PR and between 974298a and 021e6f2.

📒 Files selected for processing (9)
  • cmd/machine/create.go
  • cmd/machine/start.go
  • cmd/troubleshoot.go
  • pkg/client/client.go
  • pkg/client/clientimplementation/daemonclient/status.go
  • pkg/client/clientimplementation/machine_client.go
  • pkg/client/clientimplementation/proxy_client.go
  • pkg/client/clientimplementation/workspace_client.go
  • pkg/workspace/workspace.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/client/clientimplementation/daemonclient/status.go
  • cmd/troubleshoot.go
  • cmd/machine/start.go

@skevetter
Copy link
Owner

@skevetter some tests seem to be stuck...

The test names were changed for #593. I will update them in a bit.

@dubinsky
Copy link
Author

@skevetter although ubuntu-latest was downgraded, CI is still somehow expecting results from those runs:

Build CLI Binary on ubuntu-latest
Build Desktop App for amd64 on ubuntu-latest

@skevetter
Copy link
Owner

@skevetter although ubuntu-latest was downgraded, CI is still somehow expecting results from those runs:


Build CLI Binary on ubuntu-latest

Build Desktop App for amd64 on ubuntu-latest

Yes. I need to update the repository branch settings for the new test names. After I update it, it will remove the old test names from the list.

@dubinsky dubinsky force-pushed the remove-some-noise branch 2 times, most recently from f28bf00 to ae99cf4 Compare March 11, 2026 23:16
@dubinsky
Copy link
Author

I need to update the repository branch settings for the new test names.

Thank you!

@dubinsky dubinsky force-pushed the remove-some-noise branch from cee9acf to f547c3e Compare March 12, 2026 04:57
Signed-off-by: Leonid Dubinsky <dub@podval.org>
Signed-off-by: Leonid Dubinsky <dub@podval.org>
@dubinsky dubinsky force-pushed the remove-some-noise branch from f547c3e to 759f13d Compare March 12, 2026 17:49
@skevetter skevetter changed the title chore(cli): remove some spurious types and parameters refactor(cmd/machine): remove unused options from machineclient Mar 12, 2026
@skevetter skevetter changed the title refactor(cmd/machine): remove unused options from machineclient refactor(client|workspace): remove unused client options Mar 12, 2026
@skevetter skevetter merged commit 766e86f into skevetter:main Mar 12, 2026
41 checks passed
@dubinsky dubinsky deleted the remove-some-noise branch March 12, 2026 22:42
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.

2 participants