/** * @file web/src/components/recommend/RecommendView.jsx * @description Smart Recommend modal for Web M3 parity: 3-question wizard, * 10-second analysis phase, then Top 3 results from the shared scoring engine. * * @functions RecommendView → full-screen recommendation wizard * @exports RecommendView */ import { useMemo, useState } from 'react' import { IconArrowLeft, IconSparkles, IconX } from '@tabler/icons-react' import { TASK_TYPES, PRIORITY_TYPES, CONTEXT_BUDGETS } from '../../../../src/core/utils.js' import LaunchButton from '../launch/LaunchButton.jsx' import { useRecommend } from '../../hooks/useRecommend.js' import styles from './RecommendView.module.css' import { useI18n } from '../../i18n.jsx' const QUESTIONS = [ { key: 'taskType', titleKey: 'recommend.questionTask', options: TASK_TYPES }, { key: 'priority', titleKey: 'recommend.questionPriority', options: PRIORITY_TYPES }, { key: 'contextBudget', titleKey: 'recommend.questionContext', options: CONTEXT_BUDGETS }, ] export default function RecommendView({ onClose, onLaunch, onPinAndLaunch, toolMode, onToast }) { const { t } = useI18n() const [step, setStep] = useState(0) const [answers, setAnswers] = useState({ taskType: null, priority: null, contextBudget: null }) const { recommend, loading, progress, results, error, reset } = useRecommend({ onToast }) const question = QUESTIONS[step] const complete = results.length > 0 const summary = useMemo(() => QUESTIONS .map((q) => q.options[answers[q.key]] ? t(`recommend.${q.key}.${answers[q.key]}`) : null) .filter(Boolean) .join(' · '), [answers]) async function choose(value) { const nextAnswers = { ...answers, [question.key]: value } setAnswers(nextAnswers) if (step < QUESTIONS.length - 1) { setStep(step + 1) return } await recommend(nextAnswers) } function back() { if (complete || loading) { reset() setStep(0) setAnswers({ taskType: null, priority: null, contextBudget: null }) return } setStep((value) => Math.max(0, value - 1)) } return (
event.stopPropagation()}>

{t('recommend.title')}

{t('recommend.findBest')}

{summary &&

{summary}

}
{!loading && !complete && (
{t('recommend.questionProgress', { step: step + 1, total: QUESTIONS.length })}

{t(question.titleKey)}

{Object.entries(question.options).map(([key, option]) => ( ))}
)} {loading && (

{t('recommend.analyzing')}

{t('recommend.analysisHint')}

{progress}%

)} {complete && (

{t('recommend.topThree')}

{results.map((item, index) => (
{['🥇', '🥈', '🥉'][index]}
{item.result.label} {item.result.origin} · {item.result.tier} · {item.result.ctx}

{item.reason}

{item.score}
onPinAndLaunch?.(item.result)} />
))}
)} {error &&

{error}

}
) }