Skip to content

fix: refresh stale directory provider state#443

Merged
hsteude merged 2 commits into
mainfrom
fix/provider-directory-cache
May 28, 2026
Merged

fix: refresh stale directory provider state#443
hsteude merged 2 commits into
mainfrom
fix/provider-directory-cache

Conversation

@hsteude

@hsteude hsteude commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detect when a directory-scoped OpenCode instance has stale connected provider state
  • compare directory provider state against global provider auth state
  • dispose and refetch the directory instance once when it is missing globally connected providers

Diagnosis

In the Kubeflow OpenCode notebook, /provider without x-opencode-directory returned connected providers [openai, opencode], but /provider with x-opencode-directory for /home/jovyan/kubeflow-examples returned only [opencode]. The model picker uses the directory-scoped SDK client, so it only showed OpenCode/Open Zen models until the directory instance was manually disposed.

Verification

  • bun run typecheck
  • bun test tests/provider-auth.test.ts tests/model-variant.test.ts
  • bun run build

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +247 to +251
const globalRes = await globalClient.provider.list()
const globalData = globalRes.data as ProviderListData | undefined
const stale = (globalData?.connected ?? []).some((id) => !data.connected.includes(id))
if (stale) {
await client.instance.dispose()
Comment on lines +245 to +253
if (directory) {
try {
const globalRes = await globalClient.provider.list()
const globalData = globalRes.data as ProviderListData | undefined
const stale = (globalData?.connected ?? []).some((id) => !data.connected.includes(id))
if (stale) {
await client.instance.dispose()
const refreshed = await client.provider.list()
const refreshedData = refreshed.data as ProviderListData | undefined
Comment on lines +246 to +257
try {
const globalRes = await globalClient.provider.list()
const globalData = globalRes.data as ProviderListData | undefined
const stale = (globalData?.connected ?? []).some((id) => !data.connected.includes(id))
if (stale) {
await client.instance.dispose()
const refreshed = await client.provider.list()
const refreshedData = refreshed.data as ProviderListData | undefined
if (refreshedData) return normalizeProviderData(refreshedData)
}
} catch (e) {
console.warn("Failed to refresh stale directory provider state:", e)
@hsteude hsteude merged commit d252201 into main May 28, 2026
1 check passed
@hsteude hsteude deleted the fix/provider-directory-cache branch May 28, 2026 20:32
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