Repository navigation
refactor(core): share oauth loopback server and provider attribution table - #67216
Conversation
There was a problem hiding this comment.
I found no problems with this refactor. I compared each removed attribution plugin with its row in the new table: matching, header precedence (Zenmux fills headers in, NVIDIA keeps only the user's billing header, the rest overwrite), the LLM Gateway active/configured checks and OpenRouter's hidden aliases are all unchanged. The five login servers keep their host, port rules, taken-port message and connection closing. A small script against listenLoopback confirmed the custom taken-port message, the raw error without one, the ephemeral fallback, the server being closed once the login ends, and the PKCE lengths. The MCP and provider suites give the same results as on dev: 234 pass and the same 12 environment-related failures (port 8080 is already in use on this machine, plus one unrelated process-kill test). typecheck:tsc is clean.
The public API is unchanged: only internal @opencode/core modules move, and the plugin ids and registration order stay the same.
Provider sign-in callback servers and attribution headers each live in one place now.
Five browser logins built their own copy of the same loopback HTTP server; six provider plugins repeated the same header transform. Nothing changes for users.
❌ Before
node:httpserver, listened on their own port, turnedEADDRINUSEinto their own message, closed the server when the login ended, and — except DigitalOcean — hashed their own PKCE challenge.✅ After
oauth/loopback.tsowns the listener, the preferred/fallback port rules, the taken-port message, PKCE, and the callback answer page.provider/attribution.tsdescribes each provider as a table row (match,headers,userWins, plus the LLM Gateway and OpenRouter extras) and builds the same six plugins, with the same ids and registration slots.📊 Numbers (against
origin/dev)packages/core/srcpackages/core/testNo tests were added: the existing suites pin the moved behavior, and their only change is the import path of the six provider plugins.
👀 Read:
loopback.ts— its port fallback (preferred → port from an earlier registration → ephemeral, with fallback only for the middle case), and the finalizer registered before listening so cancelling betweenlistenandlisteningstill releases the port. Then theuserWinsmerge inattribution.ts. Those are the places a provider could drift. Azure keeps its own refresh loop on purpose:ProviderRefresh.startapplies state only after a load finishes and takes a single reload, so it cannot drop the previous resource's deployments and reload providers before discovery runs, which the Azure tests observe. The rest is routine.Found in a structural cleanup pass · no user reports · line counts from
git diff --numstat origin/dev...HEADChecks run
bun run test test/mcpinpackages/core: 146 passbun run test test/plugin/provider-digitalocean.test.ts: 6 fail on this machine, exactly as atorigin/dev(Bun bindslocalhostto::1whilefetchresolves it to127.0.0.1); all 13 pass when the test listener is pointed at127.0.0.1bun typecheckandbun run typecheck:tscinpackages/core: cleanbun run checkfrom the repo root: 37/37 tasksprettier --checkon every changed file: clean