Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ function App() {
value: "agent.cycle",
keybind: "agent_cycle",
category: "Agent",
disabled: true,
onSelect: () => {
local.agent.move(1)
},
Expand All @@ -435,7 +434,6 @@ function App() {
value: "agent.cycle.reverse",
keybind: "agent_cycle_reverse",
category: "Agent",
disabled: true,
onSelect: () => {
local.agent.move(-1)
},
Expand Down
26 changes: 17 additions & 9 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}
}
}
Expand Down
Loading