Repository navigation
Conversation
OpenCode 2 replaced the per-project URL scheme and added authentication, which made the panel fail with "Cannot read properties of undefined (reading 'type')" (mtymek#74). - Server: pass OPENCODE_SERVER_PASSWORD and authenticate /api/* with HTTP Basic; probe /api/info instead of the removed /global/health. - URLs: open sessions at <server>/server/<base64url(server)>/session/<id> instead of <server>/<base64-directory>, which is no longer a route. - Embed: use an Electron <webview> and seed the server credential into the web app's localStorage (server pairings are client-side; the pairing-link cookie is SameSite=Lax and never sent from an iframe). - API: talk to the server through node:http; renderer fetch is CORS-blocked because OpenCode sends no allow-origin header for app://obsidian.md. - Client: /api/location, /api/session with location.directory and /api/session/<id>/synthetic for context injection. Closes mtymek#74
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Since OpenCode 2.0 the panel never comes up. Opening it shows:
Fixes #74.
Root cause
Three independent 2.x changes, all confirmed against opencode 2.2.5:
Route scheme. The web app's router (
_assets/current-*.js) only accepts/,/settings,/connect,/components,/new-sessionand/server/<serverKey>/session/<id>. Everything else throwsUnrecognised route!, which a Solid memo swallows intoundefined- and thenext line does
e.type, which is the reportedTypeError. The plugin stillbuilt
http://host:port/<base64(vault path)>, the 1.x scheme.<serverKey>is the base64url encoding of the server URL.Authentication.
servenow prints a password and every/api/*requestneeds HTTP Basic (
opencode:<password>). The old health check/global/healthdoes not exist anymore - it falls through to the SPA andanswers
200 text/html, so "server is running" was a false positive.Embedding. The web app keeps its server list (url + password) in
localStorage; without it the panel only shows "Connect to a server". Thatstorage is not reachable from an iframe (cross-origin to
app://obsidian.md),and the pairing-link cookie is
SameSite=Lax, so it is never sent from anembedded frame either - pairing does not help.
Additionally,
fetchfrom the renderer is CORS-blocked against the server: thepreflight is answered for loopback HTTP origins but carries no
access-control-allow-originforapp://obsidian.md.Changes
src/lib/serverUrl.ts- base64url server key, session URL, Basic auth header.src/lib/http.ts-node:httpclient, so plugin API calls are not subject tothe renderer's CORS restrictions.
src/ui/embed.ts- webview detection + script that seeds the servercredential into the web app's
localStorage(one reload, no loop).OpenCodeView- embeds the app in an Electron<webview>(Obsidian's mainwindow has
webviewTag: true), seeds the credential ondom-ready, falls backto the old
<iframe>with an explanatory note if the webview does not becomeready.
ServerManager-OPENCODE_SERVER_PASSWORDhanded to the server, health viaGET /api/infowith auth, URL without the project path segment. A server leftover from a previous session keeps working because the password is derived from
host + port.
OpenCodeClient-/api/location,POST /api/sessionwithlocation.directory,POST /api/session/<id>/syntheticfor context injection(v1's hidden-message-part update no longer exists).
Testing
bun run build(tsc + esbuild) clean,bun test: 25 pass, 3 skipped(Windows-only), 0 fail.
tests/serverUrl.test.tsis new; theServerManagertests now start a real 2.2.5 server and authenticate against/api/info.the vault renders,
@-mention completion only lists files of that vault, and amessage round-trips to the model. Before/after screenshots available on
request.
Compatibility
No behaviour change for existing users: the plugin still starts its own
opencode serveper vault on the configured port. It just speaks the 2.xprotocol now. A follow-up PR will propose attaching to the shared service that
2.x is designed around; that one changes defaults and is out of scope here.