Include custom modes in mode switching keyboard shortcut

This commit is contained in:
Matt Rubens 2025-03-01 23:53:30 -05:00
parent 6ff88383a2
commit cd910c3435
2 changed files with 13 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Include custom modes in mode switching keyboard shortcut

View file

@ -28,7 +28,7 @@ import TaskHeader from "./TaskHeader"
import AutoApproveMenu from "./AutoApproveMenu"
import { AudioType } from "../../../../src/shared/WebviewMessage"
import { validateCommand } from "../../utils/command-validation"
import { modes } from "../../../../src/shared/modes"
import { getAllModes } from "../../../../src/shared/modes"
interface ChatViewProps {
isHidden: boolean
@ -60,6 +60,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
setMode,
autoApprovalEnabled,
alwaysAllowModeSwitch,
customModes,
} = useExtensionState()
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
@ -967,12 +968,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
isWriteToolAction,
])
// Add this new function to handle mode switching
// Function to handle mode switching
const switchToNextMode = useCallback(() => {
const currentModeIndex = modes.findIndex((m) => m.slug === mode)
const nextModeIndex = (currentModeIndex + 1) % modes.length
setMode(modes[nextModeIndex].slug)
}, [mode, setMode])
const allModes = getAllModes(customModes)
const currentModeIndex = allModes.findIndex((m) => m.slug === mode)
const nextModeIndex = (currentModeIndex + 1) % allModes.length
setMode(allModes[nextModeIndex].slug)
}, [mode, setMode, customModes])
// Add keyboard event handler
const handleKeyDown = useCallback(