Compare commits

...
Author SHA1 Message Date
neriousy 45dda0a109 fix(app): stage Build when hiding the agent picker
Stage the Build agent and its model for the next prompt in an existing session without changing the running server session. The normal submission path applies that selection when the next steered prompt is sent.
2026-10-04 19:16:43 +00:00
neriousy 58f233503e fix(app): honor hidden agent setting for cycling 2026-10-04 19:12:53 +00:00
4 changed files with 29 additions and 16 deletions

No files matched your search

@@ -1,12 +1,8 @@
import { expect, test } from "bun:test"
import { hasCustomAgent, resolveAgent } from "./agent"
test("hasCustomAgent detects only explicitly custom agents", () => {
expect(hasCustomAgent([{ native: true }, { native: false }])).toBe(true)
expect(hasCustomAgent([{ native: true }, {}])).toBe(false)
})
import { resolveAgent } from "./agent"
const agents = [{ name: "plan" }, { name: "build" }, { name: "custom" }]
const rows: { name: string; agents: { name: string }[]; requested?: string; expected: string }[] = [
{ name: "the requested available agent", agents, requested: "custom", expected: "custom" },
{ name: "build without a request", agents, requested: undefined, expected: "build" },
@@ -1,7 +1,3 @@
export function hasCustomAgent(items: Array<{ native?: boolean }>) {
return items.some((item) => item.native === false)
}
export function resolveAgent<T extends { name: string }>(items: T[], name?: string) {
return items.find((item) => item.name === name) ?? items.find((item) => item.name === "build") ?? items[0]
}
@@ -9,7 +9,7 @@ import { useSettings } from "@/settings/model"
import { useProviders } from "@/providers/catalog/providers"
import { Persist, persisted } from "@/runtime/persistence/storage"
import { Persistence } from "@/runtime/persistence/schema"
import { hasCustomAgent, resolveAgent } from "./agent"
import { resolveAgent } from "./agent"
import { cycleModelVariant, getConfiguredAgentVariant, resolveModelVariant } from "./variant"
import { useWorkspaceLocation } from "@/workspaces/location"
import { useData } from "@/runtime/server/current"
@@ -98,7 +98,7 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
),
)
const agentsVisible = createMemo(() => settings.visibility.customAgents() || hasCustomAgent(list()))
const agentsVisible = settings.visibility.customAgents
const connected = createMemo(() => new Set(providers.connected().map((item) => item.id)))
const [saved, setSaved, , savedReady] = persisted(
@@ -266,6 +266,11 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
},
}
createEffect(() => {
if (agentsVisible() || agent.current()?.name === "build") return
agent.set("build")
})
const current = createMemo(() => {
if (!configuredModel.ready()) return
@@ -183,12 +183,28 @@ function selection(local: ReturnType<typeof useLocal>) {
}
}
test("restores durable agents even when the agent selector is hidden", () => {
const f = fixture({ session: durable("b", "high", "plan") })
test("hiding agents selects Build for the next prompt without changing the server session", () => {
const f = fixture({
session: durable("b", "high", "plan"),
agents: [agent("build", key("a")), agent("plan", key("b")), { ...agent("custom"), native: false }],
})
const first = f.mount()
expect(selection(first.local)).toEqual({ agent: "plan", model: "b", variant: "high" })
f.set("visible", false)
const { local } = f.mount()
const { local } = first
expect(local.agent.visible()).toBe(false)
expect(selection(local)).toEqual({ agent: "plan", model: "b", variant: "high" })
expect(selection(local)).toEqual({ agent: "build", model: "a", variant: undefined })
expect(f.state.sessions.ses_a?.agent).toBe("plan")
first.dispose()
const second = f.mount()
expect(selection(second.local)).toEqual({ agent: "build", model: "a", variant: undefined })
f.set("route", "id", undefined)
expect(second.local.agent.current()?.name).toBe("build")
f.set("visible", true)
expect(second.local.agent.visible()).toBe(true)
f.set("route", "id", "ses_a")
expect(second.local.agent.current()?.name).toBe("build")
})
test("waits for initial configuration and reloads it after reconnecting", () => {