diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index 89adfd2b0a..41d46f9efe 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -425,7 +425,6 @@ function App() { value: "agent.cycle", keybind: "agent_cycle", category: "Agent", - disabled: true, onSelect: () => { local.agent.move(1) }, @@ -435,7 +434,6 @@ function App() { value: "agent.cycle.reverse", keybind: "agent_cycle_reverse", category: "Agent", - disabled: true, onSelect: () => { local.agent.move(-1) }, diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index e94c34ba37..e86bdcea82 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -119,17 +119,25 @@ export function Session() { return messages().findLast((x) => x.role === "user") }) + // Track the last message ID we synced to, so we only sync when the message changes + // not when the user manually switches agents + let lastSyncedMessageId: string | undefined + createEffect(() => { const lastUser = lastUserMessage() - if (lastUser?.agent && lastUser.agent !== local.agent.current().name) { - local.agent.set(lastUser.agent) - // Also update the model if configured for this agent - const cfg = sync.data.config as any - const agentModel = cfg?.[`${lastUser.agent}_model`] - if (agentModel) { - const [providerID, modelID] = agentModel.split("/") - if (providerID && modelID) { - local.model.set({ providerID, modelID }, { recent: true }) + // Only sync when we see a NEW message, not on every agent change + if (lastUser?.id && lastUser.id !== lastSyncedMessageId && lastUser.agent) { + lastSyncedMessageId = lastUser.id + if (lastUser.agent !== local.agent.current().name) { + local.agent.set(lastUser.agent) + // Also update the model if configured for this agent + const cfg = sync.data.config as any + const agentModel = cfg?.[`${lastUser.agent}_model`] + if (agentModel) { + const [providerID, modelID] = agentModel.split("/") + if (providerID && modelID) { + local.model.set({ providerID, modelID }, { recent: true }) + } } } }