mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(shortcuts): add favorite model cycle shortcut (Ctrl+R)
This commit is contained in:
1 parent
994a8b82e8
commit
e89b782fef
7 files changed
+71
-5
No files matched your search
@@ -34,9 +34,10 @@ import { useSessionPermissionMode } from '@/hooks/useSessionPermissionMode'
|
||||
import { detectMentionTrigger, parsePromptToInput, getFilename, getDirectory, type MentionItem } from '@/lib/promptParser'
|
||||
import { matchText, rankByMatch, type MatchRange } from '@/lib/fuzzyMatch'
|
||||
import { getNextPrimaryAgentId } from '@/lib/primaryAgents'
|
||||
import { getNextFavoriteModel } from '@/lib/favoriteModels'
|
||||
import { randomId } from '@/lib/utils'
|
||||
import { showToast } from '@/lib/toast'
|
||||
import { findModelInfo } from '@opencode-manager/shared/opencode'
|
||||
import { findModelInfo, isSameModelSelection } from '@opencode-manager/shared/opencode'
|
||||
import { isOpenSessionGoal } from '@opencode-manager/shared/schemas'
|
||||
import { useProviders } from '@/hooks/useProviders'
|
||||
|
||||
@@ -112,6 +113,7 @@ export interface PromptInputHandle {
|
||||
openModelPicker: () => void
|
||||
cycleAgent: () => void
|
||||
cycleVariant: () => void
|
||||
cycleFavoriteModel: () => void
|
||||
}
|
||||
|
||||
interface PromptInputProps {
|
||||
@@ -1229,7 +1231,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
[sessionID, sessionAgent.sessionAgentId, sessionAgent.modelRef],
|
||||
)
|
||||
|
||||
const { model, modelString, modelRef, setActiveAgent, isModelReady } = useModelSelection(directory, modelSelectionSession)
|
||||
const { model, modelString, modelRef, favoriteModels, setModel, setActiveAgent, isModelReady } = useModelSelection(directory, modelSelectionSession)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveAgent({
|
||||
@@ -1266,6 +1268,18 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
cycleVariant()
|
||||
}, [hasVariants, cycleVariant])
|
||||
|
||||
const handleCycleFavoriteModel = useCallback(() => {
|
||||
const next = getNextFavoriteModel(favoriteModels, model)
|
||||
if (!next) {
|
||||
showToast.info('No favorite models')
|
||||
return
|
||||
}
|
||||
if (model && isSameModelSelection(model, next)) {
|
||||
return
|
||||
}
|
||||
setModel(next)
|
||||
}, [favoriteModels, model, setModel])
|
||||
|
||||
const handleCycleAgent = useCallback(() => {
|
||||
const next = getNextPrimaryAgentId(agents, currentMode)
|
||||
if (!next) {
|
||||
@@ -1290,7 +1304,8 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
},
|
||||
cycleAgent: handleCycleAgent,
|
||||
cycleVariant: handleCycleVariant,
|
||||
}), [resetPrompt, openFilePicker, handleCycleAgent, handleCycleVariant])
|
||||
cycleFavoriteModel: handleCycleFavoriteModel,
|
||||
}), [resetPrompt, openFilePicker, handleCycleAgent, handleCycleVariant, handleCycleFavoriteModel])
|
||||
|
||||
const commandActionsWithPrompt = useMemo<CommandActions>(
|
||||
() => ({
|
||||
|
||||
@@ -7,7 +7,7 @@ import { formatEventModifiers, formatShortcutEvent, isModifierOnlyEvent, normali
|
||||
import { applyTuiKeybindImport, parseTuiKeybindConfig } from '@/lib/tuiKeybindImport'
|
||||
import { showToast } from '@/lib/toast'
|
||||
|
||||
const CONVERSATION_ACTIONS = ['submit', 'abort', 'clearPrompt', 'toggleMode', 'undo', 'redo', 'compact', 'fork', 'timeline', 'exportSession', 'selectModel', 'variantCycle', 'halfPageUp', 'halfPageDown']
|
||||
const CONVERSATION_ACTIONS = ['submit', 'abort', 'clearPrompt', 'toggleMode', 'undo', 'redo', 'compact', 'fork', 'timeline', 'exportSession', 'selectModel', 'variantCycle', 'favoriteCycle', 'halfPageUp', 'halfPageDown']
|
||||
const NAVIGATION_ACTIONS = ['settings', 'sessions', 'newSession', 'closeSession', 'toggleSidebar', 'toggleTerminal', 'toggleSourceControl']
|
||||
|
||||
const formatShortcutLabel = (action: string): string => {
|
||||
|
||||
Reference in new issue
Block a user