Skip to content
Open
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
29 changes: 28 additions & 1 deletion packages/app/src/components/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { SessionContextUsage } from "@/components/session-context-usage"
import { usePermission } from "@/context/permission"
import { useGlobalSync } from "@/context/global-sync"
import { usePlatform } from "@/context/platform"
import { createOpencodeClient, type Message, type Part } from "@opencode-ai/sdk/v2/client"
import { Agent, createOpencodeClient, type Message, type Part } from "@opencode-ai/sdk/v2/client"
import { Binary } from "@opencode-ai/util/binary"
import { showToast } from "@opencode-ai/ui/toast"
import { base64Encode } from "@opencode-ai/util/encode"
Expand Down Expand Up @@ -959,6 +959,33 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
abort()
}
}

if (event.key === "Tab") {
const agentName = local.agent.current()?.name
const agentNames = local.agent.list().map((agent) => agent.name)

if (!agentName || !agentNames.length || agentNames.length === 1) {
return
}

const agentNameIndex = agentNames.indexOf(agentName)

let nextAgentName: Agent["name"]

if (event.shiftKey) {
nextAgentName = agentNames[agentNameIndex === 0 ? agentNames.length - 1 : agentNameIndex - 1]
} else {
nextAgentName = agentNames[agentNameIndex === agentNames.length - 1 ? 0 : agentNameIndex + 1]
}

if (!nextAgentName) {
return
}

event.preventDefault()

local.agent.set(nextAgentName)
}
}

const handleSubmit = async (event: Event) => {
Expand Down