Fixed modelStore scope issue in TypeScript

Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2025-11-13 18:04:52 +00:00
parent f22edc15ba
commit 125f8a93d2

View file

@ -30,24 +30,6 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
}
}
// Automatically update model when agent changes, but only if user hasn't selected a model
createEffect(() => {
const value = agent.current()
if (value.model && !modelStore.model[value.name]) {
if (isModelValid(value.model))
model.set({
providerID: value.model.providerID,
modelID: value.model.modelID,
})
else
toast.show({
variant: "warning",
message: `Agent ${value.name}'s configured model ${value.model.providerID}/${value.model.modelID} is not valid`,
duration: 3000,
})
}
})
const agent = iife(() => {
const agents = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent"))
const [agentStore, setAgentStore] = createStore<{
@ -118,6 +100,24 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
recent: [],
})
// Automatically update model when agent changes, but only if user hasn't selected a model
createEffect(() => {
const value = agent.current()
if (value.model && !modelStore.model[value.name]) {
if (isModelValid(value.model))
model.set({
providerID: value.model.providerID,
modelID: value.model.modelID,
})
else
toast.show({
variant: "warning",
message: `Agent ${value.name}'s configured model ${value.model.providerID}/${value.model.modelID} is not valid`,
duration: 3000,
})
}
})
const file = Bun.file(path.join(Global.Path.state, "model.json"))
file