Skip to content

Commit 4cc0fa3

Browse files
committed
feat(app): add tab cycling for modes in the prompt input
1 parent fd77d31 commit 4cc0fa3

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { usePermission } from "@/context/permission"
5252
import { useLanguage } from "@/context/language"
5353
import { useGlobalSync } from "@/context/global-sync"
5454
import { usePlatform } from "@/context/platform"
55-
import { createOpencodeClient, type Message, type Part } from "@opencode-ai/sdk/v2/client"
55+
import { Agent, createOpencodeClient, type Message, type Part } from "@opencode-ai/sdk/v2/client"
5656
import { Binary } from "@opencode-ai/util/binary"
5757
import { showToast } from "@opencode-ai/ui/toast"
5858
import { base64Encode } from "@opencode-ai/util/encode"
@@ -980,6 +980,33 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
980980
abort()
981981
}
982982
}
983+
984+
if (event.key === "Tab") {
985+
const agentName = local.agent.current()?.name
986+
const agentNames = local.agent.list().map((agent) => agent.name)
987+
988+
if (!agentName || !agentNames.length || agentNames.length === 1) {
989+
return
990+
}
991+
992+
const agentNameIndex = agentNames.indexOf(agentName)
993+
994+
let nextAgentName: Agent["name"]
995+
996+
if (event.shiftKey) {
997+
nextAgentName = agentNames[agentNameIndex === 0 ? agentNames.length - 1 : agentNameIndex - 1]
998+
} else {
999+
nextAgentName = agentNames[agentNameIndex === agentNames.length - 1 ? 0 : agentNameIndex + 1]
1000+
}
1001+
1002+
if (!nextAgentName) {
1003+
return
1004+
}
1005+
1006+
event.preventDefault()
1007+
1008+
local.agent.set(nextAgentName)
1009+
}
9831010
}
9841011

9851012
const handleSubmit = async (event: Event) => {

0 commit comments

Comments
 (0)