Skip to content

feat(app): sign in to OpenCode Go and Console through the browser - #50267

Merged
Hona merged 9 commits into
anomalyco:v2from
Hona:console-onboarding
Sep 22, 2026
Merged

Hona merged 9 commits into
anomalyco:v2from
Hona:console-onboarding

Conversation

@Hona

@Hona Hona commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Desktop onboarding for OpenCode Go / OpenCode Console. Picking either provider now goes straight to the Console sign-in in the browser; the API key path is a small link at the bottom.

flowchart LR
  A[Pick OpenCode Go / OpenCode] --> B[Opening your browser…]
  B --> C[Browser: Console → pick workspace → Authorize]
  B --> D[Desktop: waiting + code to verify]
  C --> E[Connected]
  D --> E
  E --> F[Models of the connection shown in picker]
  D -. small link .-> H[API key / service account]
Loading

Before → after

Before After
OpenCode Go opencode-go integration only has a key method → API key form, no Console option Uses the opencode Console device sign-in (consoleIntegration("opencode-go") → "opencode")
OpenCode title flashes Connect opencode-go / Connect Anomaly / OpenCode → method list → empty text input + Continue (hidden server field rendered) → code view Connect OpenCode → Opening your browser… → waiting view. Two states, no method list, no empty field
Browser user clicks "this link" platform.openExternal(url) as soon as the attempt starts (same as opencode auth login), plus an Open browser button
Device code shown as the main instruction shown to verify against the Console page ("Confirm this code matches the code shown in your app"); the field is present from the first frame (placeholder until the code arrives) so nothing moves
API key equal option in the method list small muted link: "Connect with an API key or service account instead"
Leaving the dialog server attempt left open integration.oauth.cancel on cleanup / method switch
After connecting new models hidden unless newest-per-family every model of providers linked to the integration is set to show. Console sign-in returns Go models inside the opencode provider, so Go models are included
Screen behind the dialog blanks while the integration loads stable
Dialog while the attempt starts spinner-only "Opening your browser…" then a different layout one layout; only the status line changes ("Opening your browser…" → "Waiting for authorization…")
Settings → Providers after Console sign-in Default / OpenCode Go tagged Config with no Disconnect; Default / OpenCode tagged API key both follow provider.integrationID (opencode) → tagged Account, Disconnect on both; Connection.CredentialInfo gains method: "key" | "oauth" (schema + core + regenerated client)
Connect picker OpenCode with the Zen "Z" glyph OpenCode Console with the OpenCode mark (integration.name in core, provider-icons/sprite.svg)
/connect TUI only (Console setup steps say "Run /connect") desktop composer command provider.connect, slash connect

Controller (packages/app/src/providers/connect/controller.ts)

// One "busy" state until something useful can be shown: loading, auto-select pending, or connect in flight
busy: () =>
  integration.loading ||
  (store.methodIndex === undefined && !store.auto && autoIndex() !== undefined) ||
  store.state === "pending"

// Hidden form fields answer themselves; only visible fields open the form
const visible = (selected.form ?? []).some((field) => field.type === "external" || !field.hidden)
const merged = { ...hiddenDefaults(selected), ...answer }

The integration is loaded through a guarded store rather than createResource. useDialog captures getOwner() at the call site (packages/ui/src/context/dialog.tsx:173), so the dialog lives under the opener's <Suspense> (shell.tsx:116); reading a pending resource there (latest → read() → SuspenseContext.increment()) blanked the whole route behind the dialog.

The dialog passes autoSelect for Console providers so the oauth method starts without a menu; other providers keep the method list. Client ID becomes opencode-desktop for the Console URL on desktop, so the Console page reads "Authorize OpenCode Desktop".

Screenshots: I could not capture the review-pane tab (not visible), so none attached yet. Flow verified against the live server in the web app: two dialog states, browser tab opened to console/login?next=/console/device?user_code=…, API key link → key → back returns to sign-in.

OpenCode Go and OpenCode (Zen) now start the Console device sign-in as soon as
they are picked, open the browser automatically, and keep the API key path
behind an Advanced toggle. The dialog holds one stable state until the
authorization URL is ready, hidden form fields no longer render as empty
inputs, abandoned attempts are cancelled, and models unlocked by the new
connection are shown in the picker. Adds a /connect command matching the TUI
and the Console setup steps.
Console sign-in returns Go models inside the opencode provider, so checking
for an opencode-go provider always failed and produced a misleading toast.
Load the integration through a guarded store instead of createResource: the
dialog runs under the opener's Suspense boundary, so a pending resource read
blanked the whole route while the integration loaded. Also show the API key
switch directly instead of behind an Advanced toggle.
@Hona
Hona force-pushed the console-onboarding branch from f2f79a7 to 2b9c4bb Compare September 21, 2026 21:35
The Console sign-in is shared, but a Go service-account key must still be
stored where it was before so the zen/go/v1 provider keeps working.
Console-managed providers such as opencode-go connect through the opencode
integration, so the connected list now follows integrationID instead of the
provider id (it showed Go as Config with no Disconnect). Credential
connections carry their method so an OAuth grant is tagged Account rather
than API key.
@Hona
Hona marked this pull request as ready for review September 22, 2026 09:10
@Hona
Hona requested a review from Brendonovich as a code owner September 22, 2026 09:10
Copilot AI lite review requested due to automatic review settings September 22, 2026 09:10

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The connect dialog's busy state read the controller's initial pending state,
so providers with several methods never left the spinner. Start idle, hide
the Console API key link until the integration has loaded, pass the
workspace directory to /connect directly, and regenerate the OpenAPI
documents for the new credential method field.
@Hona
Hona merged commit fbacf6a into anomalyco:v2 Sep 22, 2026
8 checks passed
Hona added a commit that referenced this pull request Sep 24, 2026
Resolve against browser sign-in for OpenCode Go and Console (#50267): route opencode and opencode-go through the Console device flow on every platform, keep Desktop-only return-window and client ID handling, and restore v2 behavior for other integrations. Remove the Desktop onboarding Playwright suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants