fix: update provider store after loading providers in bootstrap (#25236)
This commit is contained in:
parent
563177c6ac
commit
a5aa72bd7d
4 changed files with 15 additions and 5 deletions
|
|
@ -204,6 +204,9 @@ function createGlobalSync() {
|
||||||
},
|
},
|
||||||
translate: language.t,
|
translate: language.t,
|
||||||
getSdk: sdkFor,
|
getSdk: sdkFor,
|
||||||
|
global: {
|
||||||
|
provider: globalStore.provider,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadSessions(directory: string) {
|
async function loadSessions(directory: string) {
|
||||||
|
|
|
||||||
|
|
@ -260,9 +260,6 @@ export async function bootstrapDirectory(input: {
|
||||||
const seededPath = input.global.path.directory === input.directory ? input.global.path : undefined
|
const seededPath = input.global.path.directory === input.directory ? input.global.path : undefined
|
||||||
if (seededProject) input.setStore("project", seededProject)
|
if (seededProject) input.setStore("project", seededProject)
|
||||||
if (seededPath) input.setStore("path", seededPath)
|
if (seededPath) input.setStore("path", seededPath)
|
||||||
if (input.store.provider.all.length === 0 && input.global.provider.all.length > 0) {
|
|
||||||
input.setStore("provider", input.global.provider)
|
|
||||||
}
|
|
||||||
if (Object.keys(input.store.config).length === 0 && Object.keys(input.global.config).length > 0) {
|
if (Object.keys(input.store.config).length === 0 && Object.keys(input.global.config).length > 0) {
|
||||||
input.setStore("config", reconcile(input.global.config, { merge: false }))
|
input.setStore("config", reconcile(input.global.config, { merge: false }))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ describe("createChildStoreManager", () => {
|
||||||
onDispose() {},
|
onDispose() {},
|
||||||
translate: (key) => key,
|
translate: (key) => key,
|
||||||
getSdk: () => null!,
|
getSdk: () => null!,
|
||||||
|
global: { provider: null! },
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.from({ length: 30 }, (_, index) => `/pinned-${index}`).forEach((directory) => {
|
Array.from({ length: 30 }, (_, index) => `/pinned-${index}`).forEach((directory) => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createRoot, getOwner, onCleanup, runWithOwner, type Owner } from "solid-js"
|
import { createRoot, getOwner, onCleanup, runWithOwner, type Owner } from "solid-js"
|
||||||
import { createStore, type SetStoreFunction, type Store } from "solid-js/store"
|
import { createStore, type SetStoreFunction, type Store } from "solid-js/store"
|
||||||
import { Persist, persisted } from "@/utils/persist"
|
import { Persist, persisted } from "@/utils/persist"
|
||||||
import type { OpencodeClient, VcsInfo } from "@opencode-ai/sdk/v2/client"
|
import type { OpencodeClient, ProviderListResponse, VcsInfo } from "@opencode-ai/sdk/v2/client"
|
||||||
import {
|
import {
|
||||||
DIR_IDLE_TTL_MS,
|
DIR_IDLE_TTL_MS,
|
||||||
MAX_DIR_STORES,
|
MAX_DIR_STORES,
|
||||||
|
|
@ -27,6 +27,9 @@ export function createChildStoreManager(input: {
|
||||||
onDispose: (directory: string) => void
|
onDispose: (directory: string) => void
|
||||||
translate: (key: string, vars?: Record<string, string | number>) => string
|
translate: (key: string, vars?: Record<string, string | number>) => string
|
||||||
getSdk: (directory: string) => OpencodeClient
|
getSdk: (directory: string) => OpencodeClient
|
||||||
|
global: {
|
||||||
|
provider: ProviderListResponse
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
const children: Record<string, [Store<State>, SetStoreFunction<State>]> = {}
|
const children: Record<string, [Store<State>, SetStoreFunction<State>]> = {}
|
||||||
const vcsCache = new Map<string, VcsCache>()
|
const vcsCache = new Map<string, VcsCache>()
|
||||||
|
|
@ -189,7 +192,13 @@ export function createChildStoreManager(input: {
|
||||||
get provider_ready() {
|
get provider_ready() {
|
||||||
return !providerQuery.isLoading
|
return !providerQuery.isLoading
|
||||||
},
|
},
|
||||||
provider: { all: [], connected: [], default: {} },
|
get provider() {
|
||||||
|
const EMPTY = { all: [], connected: [], default: {} }
|
||||||
|
if (providerQuery.isLoading) return EMPTY
|
||||||
|
if (providerQuery.data?.all.length === 0 && input.global.provider.all.length > 0)
|
||||||
|
return input.global.provider
|
||||||
|
return providerQuery.data ?? EMPTY
|
||||||
|
},
|
||||||
config: {},
|
config: {},
|
||||||
get path() {
|
get path() {
|
||||||
if (pathQuery.isLoading || !pathQuery.data)
|
if (pathQuery.isLoading || !pathQuery.data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue