import React from 'react'; import Box from '@mui/material/Box'; import Menu from '@mui/material/Menu'; import MenuItem from '@mui/material/MenuItem'; import Typography from '@mui/material/Typography'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined'; import { ClaudeTokens } from '@/shared/styles/claudeTokens'; type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'auto'; interface Props { c: ClaudeTokens; model: string; allModelFlat: Array; thinkingLevel: ThinkingLevel; onThinkingLevelChange?: (level: ThinkingLevel) => void; thinkingAnchor: HTMLElement | null; setThinkingAnchor: (el: HTMLElement | null) => void; menuPaperProps: { sx: any }; } export const ThinkingLevelControl: React.FC = ({ c, model, allModelFlat, thinkingLevel, onThinkingLevelChange, thinkingAnchor, setThinkingAnchor, menuPaperProps, }) => { const currentModel = allModelFlat.find((m: any) => m.value === model) as any; if (!currentModel?.reasoning || !onThinkingLevelChange) return null; const levels: Array<{ value: ThinkingLevel; label: string; desc: string }> = [ { value: 'auto', label: 'Auto', desc: 'Model decides (recommended)' }, { value: 'off', label: 'Off', desc: 'No thinking (fastest)' }, { value: 'low', label: 'Low', desc: 'Minimal thinking' }, { value: 'medium', label: 'Medium', desc: 'Balanced' }, { value: 'high', label: 'High', desc: 'Extensive thinking (slowest)' }, ]; const current = levels.find((l) => l.value === thinkingLevel) || levels[0]; return ( <> setThinkingAnchor(e.currentTarget)} sx={{ display: 'inline-flex', alignItems: 'center', gap: 0.25, px: 0.75, py: 0.25, borderRadius: '6px', cursor: 'pointer', userSelect: 'none', color: c.text.muted, '&:hover': { bgcolor: 'rgba(0,0,0,0.04)' }, transition: 'background 0.15s', }} > {current.label} setThinkingAnchor(null)} anchorOrigin={{ vertical: 'top', horizontal: 'left' }} transformOrigin={{ vertical: 'bottom', horizontal: 'left' }} slotProps={{ paper: menuPaperProps }} autoFocus MenuListProps={{ autoFocusItem: true }} > Thinking Level {/* Gemini 3 preview rejects "thought signature" on tool-call turns when thinking is on; warn search users. */} {(() => { const isGemini3 = typeof model === 'string' && (model.includes('gemini-3') || (allModelFlat.find((m: any) => m.value === model)?.label || '').toLowerCase().includes('gemini 3')); if (!isGemini3 || thinkingLevel === 'off') return null; return ( Web search breaks on Gemini 3 preview while thinking is on. Set to Off if you need search. ); })()} {levels.map((lvl) => ( { onThinkingLevelChange(lvl.value); setThinkingAnchor(null); }} sx={{ py: 0.6 }} > {lvl.label} {lvl.desc} ))} ); };