mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: extract agent flavor utility functions into shared module
This commit is contained in:
@@ -20,6 +20,7 @@ import { useActiveSuggestions } from '@/hooks/useActiveSuggestions'
|
||||
import { applySuggestion } from '@/utils/applySuggestion'
|
||||
import { usePlatform } from '@/hooks/usePlatform'
|
||||
import { usePWAInstall } from '@/hooks/usePWAInstall'
|
||||
import { isCodexFamilyFlavor } from '@/lib/agentFlavorUtils'
|
||||
import { markSkillUsed } from '@/lib/recent-skills'
|
||||
import { FloatingOverlay } from '@/components/ChatInput/FloatingOverlay'
|
||||
import { Autocomplete } from '@/components/ChatInput/Autocomplete'
|
||||
@@ -312,7 +313,7 @@ export function HappyComposer(props: {
|
||||
|
||||
useEffect(() => {
|
||||
const handleGlobalKeyDown = (e: globalThis.KeyboardEvent) => {
|
||||
if (e.key === 'm' && (e.metaKey || e.ctrlKey) && onModelModeChange && agentFlavor !== 'codex' && agentFlavor !== 'gemini' && agentFlavor !== 'opencode') {
|
||||
if (e.key === 'm' && (e.metaKey || e.ctrlKey) && onModelModeChange && !isCodexFamilyFlavor(agentFlavor)) {
|
||||
e.preventDefault()
|
||||
const currentIndex = MODEL_MODES.indexOf(modelMode as typeof MODEL_MODES[number])
|
||||
const nextIndex = (currentIndex + 1) % MODEL_MODES.length
|
||||
@@ -386,7 +387,7 @@ export function HappyComposer(props: {
|
||||
}, [onModelModeChange, controlsDisabled, haptic])
|
||||
|
||||
const showPermissionSettings = Boolean(onPermissionModeChange && permissionModeOptions.length > 0)
|
||||
const showModelSettings = Boolean(onModelModeChange && agentFlavor !== 'codex' && agentFlavor !== 'gemini' && agentFlavor !== 'opencode')
|
||||
const showModelSettings = Boolean(onModelModeChange && !isCodexFamilyFlavor(agentFlavor))
|
||||
const showSettingsButton = Boolean(showPermissionSettings || showModelSettings)
|
||||
const showAbortButton = true
|
||||
const voiceEnabled = Boolean(onVoiceToggle)
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { SessionMetadataSummary } from '@/types/api'
|
||||
import type { ChatToolCall, ToolPermission } from '@/chat/types'
|
||||
import { usePlatform } from '@/hooks/usePlatform'
|
||||
import { Spinner } from '@/components/Spinner'
|
||||
import { isCodexFamilyFlavor } from '@/lib/agentFlavorUtils'
|
||||
import { getInputStringAny } from '@/lib/toolInputUtils'
|
||||
import { useTranslation } from '@/lib/use-translation'
|
||||
|
||||
@@ -22,9 +23,7 @@ function isToolAllowedForSession(toolName: string, toolInput: unknown, allowedTo
|
||||
}
|
||||
|
||||
function isCodexSession(metadata: SessionMetadataSummary | null, toolName: string): boolean {
|
||||
return metadata?.flavor === 'codex'
|
||||
|| metadata?.flavor === 'gemini'
|
||||
|| metadata?.flavor === 'opencode'
|
||||
return isCodexFamilyFlavor(metadata?.flavor)
|
||||
|| toolName.startsWith('Codex')
|
||||
|| toolName.startsWith('Gemini')
|
||||
|| toolName.startsWith('OpenCode')
|
||||
|
||||
Reference in New Issue
Block a user