Skip to content

Commit 9f12d4e

Browse files
committed
Show which mode is current in slash menu
1 parent 21a45f5 commit 9f12d4e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

cli/src/chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ export const Chat = ({
410410
slashCommands: SLASH_COMMANDS,
411411
localAgents,
412412
fileTree,
413+
currentAgentMode: agentMode,
413414
})
414415

415416
useEffect(() => {

cli/src/hooks/use-suggestion-engine.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { logger } from '../utils/logger'
1414
import type { SuggestionItem } from '../components/suggestion-menu'
1515
import type { SlashCommand } from '../data/slash-commands'
1616
import type { Prettify } from '../types/utils'
17+
import type { AgentMode } from '../utils/constants'
1718
import type { LocalAgentInfo } from '../utils/local-agent-registry'
1819
import type { FileTreeNode } from '@codebuff/common/util/file'
1920

@@ -542,6 +543,7 @@ interface SuggestionEngineOptions {
542543
localAgents: LocalAgentInfo[]
543544
fileTree: FileTreeNode[]
544545
disableAgentSuggestions?: boolean
546+
currentAgentMode?: AgentMode
545547
}
546548

547549
export const useSuggestionEngine = ({
@@ -551,6 +553,7 @@ export const useSuggestionEngine = ({
551553
localAgents,
552554
fileTree,
553555
disableAgentSuggestions = false,
556+
currentAgentMode,
554557
}: SuggestionEngineOptions): SuggestionEngineResult => {
555558
const deferredInput = useDeferredValue(inputValue)
556559
const slashCacheRef = useRef<Map<string, MatchedSlashCommand[]>>(
@@ -675,14 +678,23 @@ export const useSuggestionEngine = ({
675678
}, [mentionContext, filePaths])
676679

677680
const slashSuggestionItems = useMemo<SuggestionItem[]>(() => {
678-
return slashMatches.map((command) => ({
679-
id: command.id,
680-
label: command.label,
681-
labelHighlightIndices: command.labelHighlightIndices,
682-
description: command.description,
683-
descriptionHighlightIndices: command.descriptionHighlightIndices,
684-
}))
685-
}, [slashMatches])
681+
return slashMatches.map((command) => {
682+
// Check if this is a mode command and if it's the current mode
683+
const modeMatch = command.id.match(/^mode:(default|max|plan)$/i)
684+
const isCurrentMode =
685+
modeMatch && currentAgentMode?.toLowerCase() === modeMatch[1]
686+
687+
return {
688+
id: command.id,
689+
label: command.label,
690+
labelHighlightIndices: command.labelHighlightIndices,
691+
description: isCurrentMode
692+
? `${command.description} (current)`
693+
: command.description,
694+
descriptionHighlightIndices: command.descriptionHighlightIndices,
695+
}
696+
})
697+
}, [slashMatches, currentAgentMode])
686698

687699
const agentSuggestionItems = useMemo<SuggestionItem[]>(() => {
688700
return agentMatches.map((agent) => ({

0 commit comments

Comments
 (0)