Skip to content

Commit cd910c3

Browse files
committed
Include custom modes in mode switching keyboard shortcut
1 parent 6ff8838 commit cd910c3

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

.changeset/honest-queens-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Include custom modes in mode switching keyboard shortcut

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import TaskHeader from "./TaskHeader"
2828
import AutoApproveMenu from "./AutoApproveMenu"
2929
import { AudioType } from "../../../../src/shared/WebviewMessage"
3030
import { validateCommand } from "../../utils/command-validation"
31-
import { modes } from "../../../../src/shared/modes"
31+
import { getAllModes } from "../../../../src/shared/modes"
3232

3333
interface ChatViewProps {
3434
isHidden: boolean
@@ -60,6 +60,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
6060
setMode,
6161
autoApprovalEnabled,
6262
alwaysAllowModeSwitch,
63+
customModes,
6364
} = useExtensionState()
6465

6566
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
@@ -967,12 +968,13 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
967968
isWriteToolAction,
968969
])
969970

970-
// Add this new function to handle mode switching
971+
// Function to handle mode switching
971972
const switchToNextMode = useCallback(() => {
972-
const currentModeIndex = modes.findIndex((m) => m.slug === mode)
973-
const nextModeIndex = (currentModeIndex + 1) % modes.length
974-
setMode(modes[nextModeIndex].slug)
975-
}, [mode, setMode])
973+
const allModes = getAllModes(customModes)
974+
const currentModeIndex = allModes.findIndex((m) => m.slug === mode)
975+
const nextModeIndex = (currentModeIndex + 1) % allModes.length
976+
setMode(allModes[nextModeIndex].slug)
977+
}, [mode, setMode, customModes])
976978

977979
// Add keyboard event handler
978980
const handleKeyDown = useCallback(

0 commit comments

Comments
 (0)