From d82423dd86218fc1a4745388221cbda9614cbce6 Mon Sep 17 00:00:00 2001 From: Buseong Kim Date: Sun, 11 Jan 2026 22:12:10 +0900 Subject: [PATCH] fix(tui): guard default agent selection --- packages/opencode/src/cli/cmd/tui/context/local.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/cli/cmd/tui/context/local.tsx b/packages/opencode/src/cli/cmd/tui/context/local.tsx index 63f1d9743bf..909718fb14e 100644 --- a/packages/opencode/src/cli/cmd/tui/context/local.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/local.tsx @@ -38,9 +38,15 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ const [agentStore, setAgentStore] = createStore<{ current: string }>({ - current: agents()[0].name, + current: "", }) const { theme } = useTheme() + + createEffect(() => { + const list = agents() + if (list.length === 0) return + if (!list.some((x) => x.name === agentStore.current)) setAgentStore("current", list[0].name) + }) const colors = createMemo(() => [ theme.secondary, theme.accent,