fix(app): improve agent selection logic passing in configured models and variants correctly (#16072)

This commit is contained in:
OpeOginni
2026-03-05 13:26:20 +01:00
committed by GitHub
parent 161734fb95
commit a60e715fc6
2 changed files with 24 additions and 11 deletions

View File

@@ -35,6 +35,8 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
const agent = (() => { const agent = (() => {
const list = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden)) const list = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden))
const models = useModels()
const [store, setStore] = createStore<{ const [store, setStore] = createStore<{
current?: string current?: string
}>({ }>({
@@ -53,11 +55,17 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
setStore("current", undefined) setStore("current", undefined)
return return
} }
if (name && available.some((x) => x.name === name)) { const match = name ? available.find((x) => x.name === name) : undefined
setStore("current", name) const value = match ?? available[0]
return if (!value) return
} setStore("current", value.name)
setStore("current", available[0].name) if (!value.model) return
setModel({
providerID: value.model.providerID,
modelID: value.model.modelID,
})
if (value.variant)
models.variant.set({ providerID: value.model.providerID, modelID: value.model.modelID }, value.variant)
}, },
move(direction: 1 | -1) { move(direction: 1 | -1) {
const available = list() const available = list()
@@ -71,11 +79,13 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
const value = available[next] const value = available[next]
if (!value) return if (!value) return
setStore("current", value.name) setStore("current", value.name)
if (value.model) if (!value.model) return
setModel({ setModel({
providerID: value.model.providerID, providerID: value.model.providerID,
modelID: value.model.modelID, modelID: value.model.modelID,
}) })
if (value.variant)
models.variant.set({ providerID: value.model.providerID, modelID: value.model.modelID }, value.variant)
}, },
} }
})() })()

View File

@@ -416,7 +416,10 @@ export default function Page() {
() => { () => {
const msg = lastUserMessage() const msg = lastUserMessage()
if (!msg) return if (!msg) return
if (msg.agent) local.agent.set(msg.agent) if (msg.agent) {
local.agent.set(msg.agent)
if (local.agent.current()?.model) return
}
if (msg.model) local.model.set(msg.model) if (msg.model) local.model.set(msg.model)
}, },
), ),