mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Fixed modelStore scope issue in TypeScript
Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
f22edc15ba
commit
125f8a93d2
1 changed files with 18 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue