Remove agent cycling and enhance model selector display
- Remove Tab/Shift+Tab shortcuts for cycling agents - Remove Next/Previous Agent commands from command palette - Remove handleCycleAgent and handleCycleAgentReverse functions - Remove Tab keyboard hint from agent selector UI - Enhance model selector to show provider/modelId below model name - Widen model selector button to accommodate additional text
This commit is contained in:
70
src/App.tsx
70
src/App.tsx
@@ -371,26 +371,6 @@ const App: Component = () => {
|
||||
},
|
||||
})
|
||||
|
||||
commandRegistry.register({
|
||||
id: "next-agent",
|
||||
label: "Next Agent",
|
||||
description: "Cycle to next agent",
|
||||
category: "Agent & Model",
|
||||
keywords: ["agent", "switch", "cycle"],
|
||||
shortcut: { key: "Tab" },
|
||||
action: handleCycleAgent,
|
||||
})
|
||||
|
||||
commandRegistry.register({
|
||||
id: "prev-agent",
|
||||
label: "Previous Agent",
|
||||
description: "Cycle to previous agent",
|
||||
category: "Agent & Model",
|
||||
keywords: ["agent", "switch", "cycle"],
|
||||
shortcut: { key: "Tab", shift: true },
|
||||
action: handleCycleAgentReverse,
|
||||
})
|
||||
|
||||
commandRegistry.register({
|
||||
id: "open-model-selector",
|
||||
label: "Open Model Selector",
|
||||
@@ -503,54 +483,6 @@ const App: Component = () => {
|
||||
commandRegistry.execute(commandId)
|
||||
}
|
||||
|
||||
function handleCycleAgent() {
|
||||
const instance = activeInstance()
|
||||
const sessionId = activeSessionIdForInstance()
|
||||
if (!instance || !sessionId || sessionId === "logs") return
|
||||
|
||||
const sessions = getSessions(instance.id)
|
||||
const session = sessions.find((s) => s.id === sessionId)
|
||||
if (!session) return
|
||||
|
||||
const instanceAgents = agents().get(instance.id) || []
|
||||
const availableAgents =
|
||||
session.parentId === null ? instanceAgents.filter((a) => a.mode !== "subagent") : instanceAgents
|
||||
|
||||
if (availableAgents.length === 0) return
|
||||
|
||||
const currentIndex = availableAgents.findIndex((a) => a.name === session.agent)
|
||||
const nextIndex = (currentIndex + 1) % availableAgents.length
|
||||
const nextAgent = availableAgents[nextIndex]
|
||||
|
||||
if (nextAgent) {
|
||||
updateSessionAgent(instance.id, sessionId, nextAgent.name).catch(console.error)
|
||||
}
|
||||
}
|
||||
|
||||
function handleCycleAgentReverse() {
|
||||
const instance = activeInstance()
|
||||
const sessionId = activeSessionIdForInstance()
|
||||
if (!instance || !sessionId || sessionId === "logs") return
|
||||
|
||||
const sessions = getSessions(instance.id)
|
||||
const session = sessions.find((s) => s.id === sessionId)
|
||||
if (!session) return
|
||||
|
||||
const instanceAgents = agents().get(instance.id) || []
|
||||
const availableAgents =
|
||||
session.parentId === null ? instanceAgents.filter((a) => a.mode !== "subagent") : instanceAgents
|
||||
|
||||
if (availableAgents.length === 0) return
|
||||
|
||||
const currentIndex = availableAgents.findIndex((a) => a.name === session.agent)
|
||||
const prevIndex = currentIndex <= 0 ? availableAgents.length - 1 : currentIndex - 1
|
||||
const prevAgent = availableAgents[prevIndex]
|
||||
|
||||
if (prevAgent) {
|
||||
updateSessionAgent(instance.id, sessionId, prevAgent.name).catch(console.error)
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
initMarkdown(false).catch(console.error)
|
||||
|
||||
@@ -576,8 +508,6 @@ const App: Component = () => {
|
||||
},
|
||||
)
|
||||
registerAgentShortcuts(
|
||||
handleCycleAgent,
|
||||
handleCycleAgentReverse,
|
||||
() => {
|
||||
const modelInput = document.querySelector("[data-model-selector]") as HTMLInputElement
|
||||
if (modelInput) {
|
||||
|
||||
@@ -102,16 +102,9 @@ export default function AgentSelector(props: AgentSelectorProps) {
|
||||
</Select.Content>
|
||||
</Select.Portal>
|
||||
</Select>
|
||||
<div class="flex items-center gap-1">
|
||||
<Show when={availableAgents().length > 1}>
|
||||
<span class="text-xs text-gray-400">
|
||||
<Kbd>Tab</Kbd>
|
||||
</span>
|
||||
</Show>
|
||||
<span class="text-xs text-gray-400">
|
||||
<Kbd shortcut="cmd+shift+a" />
|
||||
</span>
|
||||
</div>
|
||||
<span class="text-xs text-gray-400">
|
||||
<Kbd shortcut="cmd+shift+a" />
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -101,10 +101,17 @@ export default function ModelSelector(props: ModelSelectorProps) {
|
||||
<Combobox.Input class="sr-only" data-model-selector />
|
||||
<Combobox.Trigger
|
||||
ref={triggerRef}
|
||||
class="inline-flex items-center justify-between gap-2 px-2 py-1 bg-white border border-gray-300 rounded hover:bg-gray-50 outline-none focus:ring-2 focus:ring-blue-500 text-xs min-w-[140px]"
|
||||
class="inline-flex items-center justify-between gap-2 px-2 py-1 bg-white border border-gray-300 rounded hover:bg-gray-50 outline-none focus:ring-2 focus:ring-blue-500 text-xs min-w-[180px]"
|
||||
>
|
||||
<span class="text-gray-700">Model: {currentModelValue()?.name ?? "None"}</span>
|
||||
<Combobox.Icon>
|
||||
<div class="flex flex-col items-start min-w-0">
|
||||
<span class="text-gray-700 font-medium">Model: {currentModelValue()?.name ?? "None"}</span>
|
||||
{currentModelValue() && (
|
||||
<span class="text-gray-500 text-[10px]">
|
||||
{currentModelValue()!.providerId}/{currentModelValue()!.id}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Combobox.Icon class="flex-shrink-0">
|
||||
<ChevronDown class="w-3 h-3 text-gray-500" />
|
||||
</Combobox.Icon>
|
||||
</Combobox.Trigger>
|
||||
|
||||
@@ -1,39 +1,8 @@
|
||||
import { keyboardRegistry } from "../keyboard-registry"
|
||||
|
||||
export function registerAgentShortcuts(
|
||||
cycleAgent: () => void,
|
||||
cycleAgentReverse: () => void,
|
||||
focusModelSelector: () => void,
|
||||
openAgentSelector: () => void,
|
||||
) {
|
||||
export function registerAgentShortcuts(focusModelSelector: () => void, openAgentSelector: () => void) {
|
||||
const isMac = () => navigator.platform.toLowerCase().includes("mac")
|
||||
|
||||
keyboardRegistry.register({
|
||||
id: "agent-next",
|
||||
key: "Tab",
|
||||
modifiers: {},
|
||||
handler: cycleAgent,
|
||||
description: "next agent",
|
||||
context: "global",
|
||||
condition: () => {
|
||||
const active = document.activeElement
|
||||
return !(active?.tagName === "TEXTAREA" || active?.tagName === "INPUT" || active?.hasAttribute("contenteditable"))
|
||||
},
|
||||
})
|
||||
|
||||
keyboardRegistry.register({
|
||||
id: "agent-prev",
|
||||
key: "Tab",
|
||||
modifiers: { shift: true },
|
||||
handler: cycleAgentReverse,
|
||||
description: "previous agent",
|
||||
context: "global",
|
||||
condition: () => {
|
||||
const active = document.activeElement
|
||||
return !(active?.tagName === "TEXTAREA" || active?.tagName === "INPUT" || active?.hasAttribute("contenteditable"))
|
||||
},
|
||||
})
|
||||
|
||||
keyboardRegistry.register({
|
||||
id: "focus-model",
|
||||
key: "M",
|
||||
|
||||
Reference in New Issue
Block a user