Repository navigation
fix(opencode-plugin): fetch the provider inventory once per change, not once per workspace - #6391
Conversation
…ot once per workspace OpenCode loads one plugin instance per workspace location. They already share one inventory change stream, but each change reached every location and each one fetched the full gateway inventory itself: the provider list plus one connect call per provider. A desktop with many locations sent the same inventory reads to Den many times over for a single change, and every Den deploy is a change for every desktop. Locations that ask at the same time now share one fetch per session and credential scope. A location only takes a fetch that started after it asked, so a change is never answered with inventory read before it. Aborting one location's request leaves the shared fetch running for the others, and a failed fetch is never reused. Like the inventory stream, only an immutable capability is global; credentials stay in a closure. Signed-off-by: Jalil <reachjalil@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
There was a problem hiding this comment.
Warden clearance. Complete security and confidentiality review of 336e2aa7c2e6a4aee7bfb165a2c0d07b50a24ed6 found no high or medium security findings and no confidentiality findings. Any new push dismisses this approval. Analysis run
Warden: approvedNo high or medium security findings and no confidentiality findings. Reviewed |
…y clock Comparing millisecond timestamps let a Location that asked after a denial join a fetch that started before it when both landed in the same millisecond, which the denial-fencing tests caught on Node 24. Each Location now takes a ticket from a strictly increasing counter when it decides to refresh and joins only a fetch started after that ticket. Finished fetches are no longer reused; only a fetch still in flight is shared, which is all one change fanning out to every Location needs. Signed-off-by: Jalil <reachjalil@gmail.com>
There was a problem hiding this comment.
Warden clearance. Complete security and confidentiality review of bcec488f1f0c9a01da51fe2353379b7237247e23 found no high or medium security findings and no confidentiality findings. Any new push dismisses this approval. Analysis run
What is this about?
Desktops reload their AI provider list once per change, instead of once per open workspace.
What problem does it solve?
After a Den deploy, every desktop reloads its providers. A desktop with several workspaces open sent the same reload once per workspace: the provider list plus one connect call per provider, each about 36 database queries. During a few back-to-back deploys this came to hundreds of connect calls a minute and about 40% of all Den queries.
What was the situation before?
OpenCode loads one plugin instance per workspace location. The locations already shared one inventory change stream, but each change reached every location and each fetched the full inventory itself.
How is this implemented?
packages/opencode-plugin/src/inventory-fetch.ts: one shared fetch per session and credential scope, held behind an immutableglobalThiscapability likeinventory-events.ts.plugin.tsanddesktop.tscall it instead offetchGatewayInventory.What else changed?
None.
Release note
None.
Evidence
packages/opencode-plugin/src/inventory-fetch.test.ts: five locations asking together went from five inventory fetches → one; a request made after a fetch started still gets its own.