Skip to content

fix(workspaces): surface real error messages on failed workspace operations#29167

Open
jamesmurdza wants to merge 2 commits into
anomalyco:devfrom
jamesmurdza:fix/swallowed-workspace-errors
Open

fix(workspaces): surface real error messages on failed workspace operations#29167
jamesmurdza wants to merge 2 commits into
anomalyco:devfrom
jamesmurdza:fix/swallowed-workspace-errors

Conversation

@jamesmurdza
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #27284

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a workspace operation failed, the UI showed a generic message ("Creating workspace failed", "Failed to load workspace adapters", etc.) with no detail about the actual cause, so users had no idea why it failed.

There were two reasons the real error never reached the user:

  1. Server. The workspace.create handler mapped every failure to a generic BadRequest, and plugin throws arrive as Effect defects (EffectBridge runs plugins via Effect.promise), so they bypassed Effect.mapError and surfaced generically. Now it catches the cause, extracts the original message, and returns a typed ApiWorkspaceCreateError.

  2. Client (TUI). The create / warp / adapter-load flows used .catch(() => undefined) and detail-less toasts, discarding the error. Now they try/catch and show the real message via errorMessage() in a title + message toast. Warp keeps its existing VcsApplyError alert.

The server and client changes are complementary: the server makes the real message available in the response, and the client actually displays it. Success paths are unchanged.

How did you verify your code works?

Manually, in the TUI, against a build of this branch. I registered a workspace adapter whose create() throws a recognizable error, then triggered a workspace creation so the adapter throws.

  1. Create a plugin that registers a workspace adapter which always throws on create:
// fail-workspace-plugin.ts
export default async ({ experimental_workspace }) => {
  experimental_workspace.register("testfail", {
    name: "Test Fail",
    description: "Always throws on create",
    async configure(config) {
      return config
    },
    async create() {
      throw new Error("Daytona auth failed: invalid API key")
    },
    async remove() {},
    target(config) {
      return { type: "local", directory: config.directory ?? "" }
    },
  })
  return {}
}
  1. Point a project's opencode.json at it (absolute path):
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["file:///absolute/path/to/fail-workspace-plugin.ts"]
}
  1. Launch opencode in that project with workspaces enabled:
OPENCODE_EXPERIMENTAL_WORKSPACES=1 opencode
  1. In the TUI: ctrl+pWarp → under New workspace pick Test Fail. The adapter's create() throws.

Result:

  • Before this change: a generic "Creating workspace failed" toast with no detail (the plugin throw surfaced as a generic error server-side).
  • After: the toast shows the adapter's actual message ("Daytona auth failed: invalid API key") under a "Failed to create workspace" title — confirming the real error now travels server (ApiWorkspaceCreateError) → client (result.error) → toast.

Screenshots / recordings

SmoothCapture_2026-05-24_215539.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Plugin throws reach the create handler as Effect defects (EffectBridge
uses Effect.promise), so they bypassed Effect.mapError and surfaced as a
generic error. Catch the cause, extract the original message, and return
a typed ApiWorkspaceCreateError so the real reason reaches the client.

Signed-off-by: James Murdza <james@jamesmurdza.com>
…lures

Replace .catch(() => undefined) and detail-less toasts in the workspace
create, warp, and adapter-load flows with try/catch that surfaces the
real error via errorMessage(), shown as a title + message toast.

Signed-off-by: James Murdza <james@jamesmurdza.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Workspaces] Workspace creation, warp, and adapter loading errors are swallowed

1 participant