Skip to content

fix(core): explain a restricted OpenCode Console workspace - #58905

Open
Irish-Joseph wants to merge 1 commit into
anomalyco:devfrom
Irish-Joseph:fix-console-workspace-restricted
Open

Irish-Joseph wants to merge 1 commit into
anomalyco:devfrom
Irish-Joseph:fix-console-workspace-restricted

Conversation

@Irish-Joseph

@Irish-Joseph Irish-Joseph commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #58891

Type of change

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

What does this PR do?

When OpenCode Console restricts the workspace or account, it answers both the config fetch and inference with 403 {"_tag":"Forbidden"} / {"type":"permission_error","message":"Workspace access denied"}. The client had no branch for that body: the config 403 fell through to the generic "failed to load provider config" warning with no connection status, and the inference body was passed through raw, so the TUI/CLI showed the bare "Workspace access denied" that reads like a local permissions bug.

This extends the pattern #51847 set up for the SSO case:

403 config body SsoRequired       -> needs_auth, SSO url            (unchanged)
403 config body {"_tag":"Forbidden"} -> restricted, console url     (new; was: no status)
other 403 bodies (HTML, unknown)  -> no status, logged              (unchanged)
restricted + inference 403/401    -> body replaced with the restriction (new; was: raw body)

Connection.Status gains a restricted variant (client types regenerated). The TUI connection footer now says "Restricted →" for it, and clicking opens the console URL where the workspace can be checked.

How did you verify your code works?

  • New test in provider-opencode.test.ts with the issue's exact bodies: the connection status is { status: "restricted", message: "Your OpenCode Console workspace is restricted", url: "<server>/console" }, inference rejections are rewritten from the raw permission_error body to the restriction, and non-Console providers are untouched. Without the fix the test fails — the status is undefined.
  • Updated the "ignores 403 responses" test: non-JSON and unknown-_tag 403 bodies still leave the status unset.
  • Full core plugin + integration suites: 420 pass, 0 fail. Root typecheck passes everywhere except the pre-existing @opencode/app Windows symlink artifact (identical on untouched dev). sdk-docs 0 problems, ast-grep clean.

Screenshots / recordings

Not a UI change beyond the connection footer wording ("Restricted →" for the new status).

Checklist

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

Added by the opencode bot (AI-generated).

Related: #55995

Public API: adds the restricted value to Connection.Status.status in the schema, HTTP API and client types (additive; clients that only handle needs_auth see a new value)

Console answers config and inference requests with 403 Forbidden when
the workspace or account itself is restricted. The client passed the
raw "Workspace access denied" body through, which read like a local
permissions bug, and left the connection without a status.

Decode the 403 Forbidden body alongside the existing SsoRequired body,
report the connection as restricted with the console URL, and let the
inference explainer replace the raw body with the restriction. The TUI
connection footer now says "Restricted" instead of "Sign in
required" for this status.
@Irish-Joseph

Copy link
Copy Markdown
Contributor Author

The check, test and nix-eval suites are stuck at "action required" for this fork, so they haven't run. I ran the same steps locally and everything is green: root typecheck (all packages; the only failure is the pre-existing @opencode/app Windows symlink artifact, identical on untouched dev), sdk-docs (0 problems), ast-grep, and the core plugin + integration suites (420 tests, 0 failures). Would a maintainer be able to approve and run the workflows? Thanks.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The core change works. On the base, a Console config 403 {"_tag":"Forbidden"} leaves the connection status unset; with this PR it becomes restricted and the inference 401/403 is rewritten, while other providers are left alone. I checked this by running your new test in provider-opencode.test.ts against the base, where it fails, and against this branch, where the whole file passes. I didn't drive the TUI, so could you add before/after screenshots of the "Restricted →" footer?

Public API: Connection.Status.status goes from "needs_auth" to "needs_auth" | "restricted" in @opencode/schema, the HTTP API / OpenAPI and the generated client ConnectionStatus. It's additive, but clients that assume every status is needs_auth will now see a new value.

Concerns:

  • packages/protocol/openapi.json wasn't regenerated: bun run check:generated in packages/protocol fails on this branch (it passes on dev). The client types.ts looks hand-edited. Please run bun run generate in packages/protocol and then in packages/client (AGENTS.md says not to edit generated client files directly).
  • The message and recovery path say signing in again can't help, but the reporter's follow-up on #58891 says signing in again fixed it (see inline).

Related: #55995

orgId: Schema.String,
connectionId: Schema.String,
})
// Console's 403 when the workspace or account itself is restricted; re-authenticating cannot help.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment, the Connection.Status doc ("signing in again cannot help") and the TUI action (clicking a restricted connection opens /console instead of the reconnect flow) all assume signing in can't fix this. But in the follow-up on #58891, the reporter says the 403 was tied to the stored API-key credential, and opencode auth login opencode --method device fixed it right away while the old credential still got the 403. As it stands, users are sent to the console page but not told the one step that worked. Could the message (and restricted handling in dialog-integration.tsx) also suggest signing in again or replacing the credential, e.g. "…restricted. Sign in again with opencode auth login opencode or check it at "?

@opencode-agent opencode-agent Bot mentioned this pull request Oct 26, 2026

This branch has not been deployed

No deployments
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.

fix(core): explain a 403 "Workspace access denied" from OpenCode Console instead of showing it raw

1 participant