"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
feat(frontend): clarify inputs, unify error feedback, guard mandate commit
wison1717-maker8e7e16313e2b
diff --git a/frontend/src/components/chat/MandateProposalCard.tsx b/frontend/src/components/chat/MandateProposalCard.tsxindex 160fbdafc..c83e69edd 100644--- a/frontend/src/components/chat/MandateProposalCard.tsx+++ b/frontend/src/components/chat/MandateProposalCard.tsx@@ -4,6 +4,7 @@ import { ShieldCheck, ShieldAlert, Wallet, OctagonX, SlidersHorizontal, Check, Ximport { toast } from "sonner";import { api, type MandateProfile, type MandateProposal } from "@/lib/api";import { AgentAvatar } from "./AgentAvatar";+import { ConfirmDialog } from "@/components/common/ConfirmDialog";interface Props {proposal: MandateProposal;@@ -130,6 +131,7 @@ function ProfileTile({type="text"value={adjustText}autoFocus+ aria-label={i18n.t("mandate.adjustInputLabel")}onChange={(e) => setAdjustText(e.target.value)}onKeyDown={(e) => {if (e.key === "Enter") {@@ -149,7 +151,7 @@ function ProfileTile({className="inline-flex items-center gap-1 rounded-lg border px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground"><X className="h-3 w-3" />- Cancel+ {i18n.t("mandate.cancel")}</button><buttontype="button"@@ -158,7 +160,7 @@ function ProfileTile({className="inline-flex items-center gap-1 rounded-lg bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground transition-opacity disabled:opacity-40"><Check className="h-3 w-3" />- Send adjustment+ {i18n.t("mandate.sendAdjustment")}</button></div></div>@@ -170,7 +172,7 @@ function ProfileTile({className="mt-3 inline-flex w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40">{busy ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : <ShieldCheck className="h-3.5 w-3.5" />}- {busy ? "Committing…" : `Commit “${profile.label}”`}+ {busy ? i18n.t("mandate.committing") : i18n.t("mandate.commit", { label: profile.label })}</button>)}</div>@@ -188,13 +190,14 @@ function ProfileTile({export const MandateProposalCard = memo(function MandateProposalCard({ proposal, committed, onAdjust }: Props) {const [busyOrdinal, setBusyOrdinal] = useState<number | null>(null);const [adjustingOrdinal, setAdjustingOrdinal] = useState<number | null>(null);+ const [pendingOrdinal, setPendingOrdinal] = useState<number | null>(null);const handleCommit = useCallback(async (ordinal: number) => {if (busyOrdinal != null) return;const broker = proposal.account?.broker?.trim().toLowerCase();if (!broker) {- toast.error("Cannot commit mandate: connector broker is missing. Ask the agent to regenerate the proposal.");+ toast.error(i18n.t("mandate.noBroker"));return;}setBusyOrdinal(ordinal);@@ -211,12 +214,14 @@ export const MandateProposalCard = memo(function MandateProposalCard({ proposal,// SSE event arrives; no optimistic state-write here.} catch (error) {setBusyOrdinal(null);- toast.error(error instanceof Error ? error.message : "Failed to commit mandate.");+ toast.error(error instanceof Error ? error.message : i18n.t("mandate.failedToCommit"));}},[busyOrdinal, proposal.account?.broker, proposal.proposal_id, proposal.session_id],);+ const pendingProfile = proposal.profiles.find((p) => p.ordinal === pendingOrdinal) ?? null;+// Collapsed state: a compact active-mandate badge (same visual family as the goal badge).if (committed) {const profile = proposal.profiles.find((p) => p.ordinal === committed.selected_ordinal);@@ -283,7 +288,7 @@ export const MandateProposalCard = memo(function MandateProposalCard({ proposal,busy={busyOrdinal === profile.ordinal}disabled={busyOrdinal != null}adjusting={adjustingOrdinal === profile.ordinal}- onCommit={() => handleCommit(profile.ordinal)}+ onCommit={() => setPendingOrdinal(profile.ordinal)}onAdjustToggle={() =>setAdjustingOrdinal((cur) => (cur === profile.ordinal ? null : profile.ordinal))}@@ -311,6 +316,44 @@ export const MandateProposalCard = memo(function MandateProposalCard({ proposal,)}</div></div>++ <ConfirmDialog+ open={pendingOrdinal != null}+ title={i18n.t("mandate.confirmTitle")}+ description={i18n.t("mandate.confirmDescription")}+ confirmLabel={i18n.t("mandate.confirmButton")}+ cancelLabel={i18n.t("mandate.cancel")}+ tone="destructive"+ onCancel={() => setPendingOrdinal(null)}+ onConfirm={() => {+ const ordinal = pendingOrdinal;+ setPendingOrdinal(null);+ if (ordinal != null) handleCommit(ordinal);+ }}+ >+ {pendingProfile && (+ <dl className="grid grid-cols-2 gap-x-3 gap-y-1.5 rounded-lg border bg-muted/20 p-2.5 text-[11px]">+ <div className="col-span-2">+ <dt className="text-muted-foreground">{i18n.t("mandate.universe")}</dt>+ <dd className="font-medium text-foreground">{formatUniverse(pendingProfile.universe)}</dd>+ </div>+ <div>+ <dt className="text-muted-foreground">{i18n.t("mandate.maxOrder")}</dt>+ <dd className="font-mono font-medium text-foreground">{formatUsd(pendingProfile.max_order_usd)}</dd>+ </div>+ <div>+ <dt className="text-muted-foreground">{i18n.t("mandate.dailyCap")}</dt>+ <dd className="font-mono font-medium text-foreground">+ {i18n.t("mandate.tradesPerDay", { count: pendingProfile.daily_trade_cap })}+ </dd>+ </div>+ <div>+ <dt className="text-muted-foreground">{i18n.t("mandate.leverage")}</dt>+ <dd className="font-medium text-foreground">{formatLeverage(pendingProfile.leverage)}</dd>+ </div>+ </dl>+ )}+ </ConfirmDialog></div>);});diff --git a/frontend/src/components/common/ConfirmDialog.tsx b/frontend/src/components/common/ConfirmDialog.tsxnew file mode 100644index 000000000..278baf735--- /dev/null+++ b/frontend/src/components/common/ConfirmDialog.tsx@@ -0,0 +1,91 @@+import { useEffect, useRef, type ReactNode } from "react";+import { createPortal } from "react-dom";++interface ConfirmDialogProps {+ open: boolean;+ title: string;+ description?: string;+ confirmLabel: string;+ cancelLabel: string;+ /** "destructive" for irreversible/high-risk actions (red confirm button); "primary" otherwise. */+ tone?: "primary" | "destructive";+ onConfirm: () => void;+ onCancel: () => void;+ /** Extra summary content rendered between the description and the action buttons. */+ children?: ReactNode;+}++/**+ * Minimal dependency-free confirmation modal. Used for actions that need a+ * second, explicit step before firing (e.g. committing a real trading mandate)+ * without pulling in a dialog library for a single use case.+ */+export function ConfirmDialog({+ open,+ title,+ description,+ confirmLabel,+ cancelLabel,+ tone = "primary",+ onConfirm,+ onCancel,+ children,+}: ConfirmDialogProps) {+ const confirmRef = useRef<HTMLButtonElement>(null);++ useEffect(() => {+ if (!open) return;+ confirmRef.current?.focus();+ const onKeyDown = (e: KeyboardEvent) => {+ if (e.key === "Escape") onCancel();+ };+ document.addEventListener("keydown", onKeyDown);+ return () => document.removeEventListener("keydown", onKeyDown);+ }, [open, onCancel]);++ if (!open) return null;++ return createPortal(+ <div+ className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"+ onClick={onCancel}+ >+ <div+ role="alertdialog"+ aria-modal="true"+ aria-labelledby="confirm-dialog-title"+ className="w-full max-w-sm rounded-2xl border bg-background p-4 shadow-lg"+ onClick={(e) => e.stopPropagation()}+ >+ <h2 id="confirm-dialog-title" className="text-sm font-semibold text-foreground">+ {title}+ </h2>+ {description && <p className="mt-1 text-xs leading-relaxed text-muted-foreground">{description}</p>}+ {children && <div className="mt-3">{children}</div>}+ <div className="mt-4 flex justify-end gap-2">+ <button+ type="button"+ onClick={onCancel}+ className="rounded-lg border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground"+ >+ {cancelLabel}+ </button>+ <button+ ref={confirmRef}+ type="button"+ onClick={onConfirm}+ className={[+ "rounded-lg px-3 py-1.5 text-xs font-medium transition-opacity hover:opacity-90",+ tone === "destructive"+ ? "bg-destructive text-destructive-foreground"+ : "bg-primary text-primary-foreground",+ ].join(" ")}+ >+ {confirmLabel}+ </button>+ </div>+ </div>+ </div>,+ document.body,+ );+}diff --git a/frontend/src/components/settings/QVerisSettings.tsx b/frontend/src/components/settings/QVerisSettings.tsxindex c31a0c5f1..9cdecc1dd 100644--- a/frontend/src/components/settings/QVerisSettings.tsx+++ b/frontend/src/components/settings/QVerisSettings.tsx@@ -170,7 +170,6 @@ export function QVerisSettings() {} catch (saveError) {const message = saveError instanceof Error ? saveError.message : t("qveris.testFailed");setError(message);- toast.error(t("qveris.testFailed"));} finally {setSaving(false);}diff --git a/frontend/src/i18n/locales/ar.json b/frontend/src/i18n/locales/ar.jsonindex 4c2b4d89f..937089eed 100644--- a/frontend/src/i18n/locales/ar.json+++ b/frontend/src/i18n/locales/ar.json@@ -362,6 +362,10 @@"cancelGoal": "إلغاء الهدف","describeGoal": "صف هدف البحث لإرفاقه بهذه الجلسة","placeholder": "مثال: أنشئ استراتيجية تقاطع MA مزدوجة لـ 000001.SZ، واختبرها عكسيًا لعام 2024",+ "send": "إرسال",+ "messageInputLabel": "رسالة إلى الوكيل",+ "inputHint": "Enter للإرسال · Shift+Enter لسطر جديد",+ "editGoalObjectiveLabel": "تعديل هدف البحث","exportChat": "تصدير المحادثة","stopGeneration": "إيقاف التوليد","runSwarmTeam": "تشغيل فريق السرب",@@ -460,6 +464,7 @@"compareCol": "المقارنة","delta": "الفرق","selectTwoRuns": "اختر تشغيلين لمقارنة مقاييسهما.",+ "loadError": "فشل تحميل بيانات التشغيل. يرجى المحاولة مرة أخرى.","totalReturn": "العائد الإجمالي","annualizedReturn": "العائد السنوي","sharpeRatio": "نسبة Sharpe",@@ -714,7 +719,11 @@"leverageValue": "{{value}}× رافعة","tradesPerDay": "{{count}} صفقة/يوم","adjustTitle": "تعديل هذا التفويض",- "adjustPlaceholder": "مثال: أبقِ هذا لكن ارفع الحد اليومي إلى 10"+ "adjustPlaceholder": "مثال: أبقِ هذا لكن ارفع الحد اليومي إلى 10",+ "adjustInputLabel": "محتوى طلب التعديل",+ "confirmTitle": "تأكيد الالتزام بالتفويض",+ "confirmDescription": "سيؤدي الالتزام إلى منح الوكيل صلاحية تداول فورية ضمن الحدود الموضحة أدناه.",+ "confirmButton": "تأكيد والالتزام"},"messageBubble": {"copied": "تم النسخ",@@ -746,7 +755,16 @@"featureStreaming": "بث في الوقت الفعلي","featureStreamingDesc": "راقب الوكيل وهو يفكّر، ويستدعي الأدوات، ويتكرّر","featureReplay": "إعادة تشغيل الاستراتيجية",- "featureReplayDesc": "محلّل يومية التداول + الحساب الظلّي — استخرج قواعدك، واختبرها عكسيًا، وأرجع فرق الأرباح والخسائر"+ "featureReplayDesc": "محلّل يومية التداول + الحساب الظلّي — استخرج قواعدك، واختبرها عكسيًا، وأرجع فرق الأرباح والخسائر",+ "howItWorksTitle": "كيف يعمل",+ "step1Title": "1. صف استراتيجيتك",+ "step1Desc": "أخبر الوكيل بما تريد اختباره بلغة طبيعية — دون الحاجة لكتابة أي كود.",+ "step2Title": "2. راقب البحث والاختبار العكسي",+ "step2Desc": "يخطط الوكيل، ويجلب بيانات السوق، وينفّذ الاختبار العكسي مباشرةً أمامك.",+ "step3Title": "3. راجع النتائج",+ "step3Desc": "اطّلع على مقاييس الأداء ومنحنى حقوق الملكية وشيفرة Pine Script القابلة للتصدير.",+ "step4Title": "4. انتقل للتداول الفعلي عندما تكون جاهزًا",+ "step4Desc": "يمكنك اختياريًا الموافقة على تفويض تداول بحدود واضحة — لن يُنفَّذ أي أمر دون تأكيدك."},"errorBoundary": {"somethingWrong": "حدث خطأ ما"diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.jsonindex 2bd71033e..bea20ef82 100644--- a/frontend/src/i18n/locales/en.json+++ b/frontend/src/i18n/locales/en.json@@ -367,6 +367,10 @@"cancelGoal": "Cancel goal","describeGoal": "Describe the research goal to attach to this session","placeholder": "e.g. Create a dual MA crossover strategy for 000001.SZ, backtest 2024",+ "send": "Send message",+ "messageInputLabel": "Message to the agent",+ "inputHint": "Enter to send · Shift+Enter for a new line",+ "editGoalObjectiveLabel": "Edit research goal objective","exportChat": "Export chat","stopGeneration": "Stop generation","runSwarmTeam": "Run swarm team",@@ -465,6 +469,7 @@"compareCol": "Compare","delta": "Delta","selectTwoRuns": "Select two runs to compare their metrics.",+ "loadError": "Failed to load run data. Please try again.","totalReturn": "Total Return","annualizedReturn": "Annualized Return","sharpeRatio": "Sharpe Ratio",@@ -719,7 +724,11 @@"leverageValue": "{{value}}× leverage","tradesPerDay": "{{count}} trades/day","adjustTitle": "Adjust this mandate",- "adjustPlaceholder": "e.g. keep this but raise the daily cap to 10"+ "adjustPlaceholder": "e.g. keep this but raise the daily cap to 10",+ "adjustInputLabel": "Adjustment request",+ "confirmTitle": "Confirm mandate commit",+ "confirmDescription": "This grants the agent trading authorization under the limits shown below and takes effect immediately.",+ "confirmButton": "Confirm & commit"},"messageBubble": {"copied": "Copied",@@ -751,7 +760,16 @@"featureStreaming": "Real-time Streaming","featureStreamingDesc": "Watch the agent think, call tools, and iterate","featureReplay": "Strategy Replay",- "featureReplayDesc": "Trade journal analyzer + Shadow Account — extract your rules, backtest them, attribute PnL delta"+ "featureReplayDesc": "Trade journal analyzer + Shadow Account — extract your rules, backtest them, attribute PnL delta",+ "howItWorksTitle": "How it works",+ "step1Title": "1. Describe your strategy",+ "step1Desc": "Tell the agent what you want to test, in plain language — no code required.",+ "step2Title": "2. Watch it research and backtest",+ "step2Desc": "The agent plans, pulls market data, and runs the backtest live, so you can follow every step.",+ "step3Title": "3. Review the results",+ "step3Desc": "See performance metrics, the equity curve, and exportable Pine Script for the strategy.",+ "step4Title": "4. Go live when you're ready",+ "step4Desc": "Optionally approve a trading mandate with explicit limits — nothing trades without your confirmation."},"errorBoundary": {"somethingWrong": "Something went wrong"diff --git a/frontend/src/i18n/locales/ja.json b/frontend/src/i18n/locales/ja.jsonindex 3d0852faa..167e71138 100644--- a/frontend/src/i18n/locales/ja.json+++ b/frontend/src/i18n/locales/ja.json@@ -362,6 +362,10 @@"cancelGoal": "目標をキャンセル","describeGoal": "このセッションに添付するリサーチ目標を記述してください","placeholder": "例: 000001.SZ のデュアル MA クロスオーバー戦略を作成し、2024 年をバックテストする",+ "send": "送信",+ "messageInputLabel": "エージェントへのメッセージ",+ "inputHint": "Enter で送信 · Shift+Enter で改行",+ "editGoalObjectiveLabel": "リサーチ目標を編集","exportChat": "チャットをエクスポート","stopGeneration": "生成を停止","runSwarmTeam": "Swarm チームを実行",@@ -460,6 +464,7 @@"compareCol": "比較対象","delta": "差分","selectTwoRuns": "比較する 2 つの実行を選択してください。",+ "loadError": "実行データの読み込みに失敗しました。もう一度お試しください。","totalReturn": "トータルリターン","annualizedReturn": "年率リターン","sharpeRatio": "Sharpe レシオ",@@ -714,7 +719,11 @@"leverageValue": "{{value}}× レバレッジ","tradesPerDay": "{{count}} トレード/日","adjustTitle": "このマンデートを調整",- "adjustPlaceholder": "例: そのままにして日次上限を 10 に引き上げる"+ "adjustPlaceholder": "例: そのままにして日次上限を 10 に引き上げる",+ "adjustInputLabel": "調整リクエスト内容",+ "confirmTitle": "マンデートのコミットを確認",+ "confirmDescription": "コミットすると、以下の上限でエージェントに取引権限が即座に付与されます。",+ "confirmButton": "確認してコミット"},"messageBubble": {"copied": "コピーしました",@@ -746,7 +755,16 @@"featureStreaming": "リアルタイムストリーミング","featureStreamingDesc": "エージェントの思考、ツール呼び出し、反復を観察","featureReplay": "戦略リプレイ",- "featureReplayDesc": "トレードジャーナル分析 + シャドウアカウント — ルールを抽出しバックテスト、損益差分を要因分解"+ "featureReplayDesc": "トレードジャーナル分析 + シャドウアカウント — ルールを抽出しバックテスト、損益差分を要因分解",+ "howItWorksTitle": "使い方",+ "step1Title": "1. 戦略を記述する",+ "step1Desc": "コード不要。自然言語でテストしたい内容をエージェントに伝えるだけ。",+ "step2Title": "2. リサーチとバックテストを見守る",+ "step2Desc": "エージェントが計画を立て、市場データを取得し、バックテストをリアルタイムで実行します。",+ "step3Title": "3. 結果を確認する",+ "step3Desc": "パフォーマンス指標、エクイティカーブ、エクスポート可能な Pine Script を確認できます。",+ "step4Title": "4. 準備ができたら本番へ",+ "step4Desc": "上限を明示したトレーディングマンデートを任意で承認 — 確認なしに注文が入ることはありません。"},"errorBoundary": {"somethingWrong": "問題が発生しました"diff --git a/frontend/src/i18n/locales/ko.json b/frontend/src/i18n/locales/ko.jsonindex 04052872f..538245607 100644--- a/frontend/src/i18n/locales/ko.json+++ b/frontend/src/i18n/locales/ko.json@@ -362,6 +362,10 @@"cancelGoal": "목표 취소","describeGoal": "이 세션에 첨부할 리서치 목표를 설명하세요","placeholder": "예: 000001.SZ에 대한 듀얼 MA 크로스오버 전략을 만들고 2024년 백테스트 수행",+ "send": "보내기",+ "messageInputLabel": "에이전트에게 보낼 메시지",+ "inputHint": "Enter로 전송 · Shift+Enter로 줄바꿈",+ "editGoalObjectiveLabel": "리서치 목표 편집","exportChat": "채팅 내보내기","stopGeneration": "생성 중지","runSwarmTeam": "Swarm 팀 실행",@@ -460,6 +464,7 @@"compareCol": "비교 대상","delta": "차이","selectTwoRuns": "비교할 두 실행을 선택하세요.",+ "loadError": "실행 데이터를 불러오지 못했습니다. 다시 시도해주세요.","totalReturn": "총 수익률","annualizedReturn": "연환산 수익률","sharpeRatio": "Sharpe 비율",@@ -714,7 +719,11 @@"leverageValue": "{{value}}× 레버리지","tradesPerDay": "일 {{count}}건 거래","adjustTitle": "이 mandate 조정",- "adjustPlaceholder": "예: 유지하되 일일 한도를 10으로 상향"+ "adjustPlaceholder": "예: 유지하되 일일 한도를 10으로 상향",+ "adjustInputLabel": "조정 요청 내용",+ "confirmTitle": "mandate 커밋 확인",+ "confirmDescription": "커밋하면 아래 한도로 에이전트에게 즉시 거래 권한이 부여됩니다.",+ "confirmButton": "확인 후 커밋"},"messageBubble": {"copied": "복사됨",@@ -746,7 +755,16 @@"featureStreaming": "실시간 스트리밍","featureStreamingDesc": "에이전트의 사고, 도구 호출, 반복 과정을 지켜보세요","featureReplay": "전략 리플레이",- "featureReplayDesc": "매매 일지 분석 + 섀도우 계좌 — 규칙 추출, 백테스트, PnL 차이 귀인 분석"+ "featureReplayDesc": "매매 일지 분석 + 섀도우 계좌 — 규칙 추출, 백테스트, PnL 차이 귀인 분석",+ "howItWorksTitle": "사용 방법",+ "step1Title": "1. 전략을 설명하세요",+ "step1Desc": "코드 없이 자연어로 테스트하고 싶은 내용을 에이전트에게 전달하세요.",+ "step2Title": "2. 리서치와 백테스트 과정을 지켜보세요",+ "step2Desc": "에이전트가 계획을 세우고 시장 데이터를 가져와 실시간으로 백테스트를 실행합니다.",+ "step3Title": "3. 결과를 확인하세요",+ "step3Desc": "성과 지표, 자산 곡선, 내보내기 가능한 Pine Script를 확인할 수 있습니다.",+ "step4Title": "4. 준비되면 실전으로",+ "step4Desc": "한도가 명시된 거래 mandate를 선택적으로 승인하세요 — 확인 없이는 어떤 주문도 실행되지 않습니다."},"errorBoundary": {"somethingWrong": "문제가 발생했습니다"diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.jsonindex 996c7b294..d0b78d773 100644--- a/frontend/src/i18n/locales/zh-CN.json+++ b/frontend/src/i18n/locales/zh-CN.json@@ -362,6 +362,10 @@"cancelGoal": "取消目标","describeGoal": "描述要附加到此会话的研究目标","placeholder": "例如:为 000001.SZ 创建双均线交叉策略,回测 2024 年",+ "send": "发送",+ "messageInputLabel": "发送给智能体的消息",+ "inputHint": "Enter 送出 · Shift+Enter 换行",+ "editGoalObjectiveLabel": "编辑研究目标内容","exportChat": "导出对话","stopGeneration": "停止生成","runSwarmTeam": "运行群体团队",@@ -460,6 +464,7 @@"compareCol": "对比","delta": "差值","selectTwoRuns": "选择两次运行以对比其指标。",+ "loadError": "加载运行数据失败,请重试。","totalReturn": "总收益率","annualizedReturn": "年化收益率","sharpeRatio": "夏普比率",@@ -714,7 +719,11 @@"leverageValue": "{{value}}× 杠杆","tradesPerDay": "{{count}} 笔/天","adjustTitle": "调整此 mandate",- "adjustPlaceholder": "例如:保持不变但将每日上限提高到 10"+ "adjustPlaceholder": "例如:保持不变但将每日上限提高到 10",+ "adjustInputLabel": "调整请求内容",+ "confirmTitle": "确认提交 mandate",+ "confirmDescription": "提交后将立即依据下方额度授权智能体进行真实交易。",+ "confirmButton": "确认并提交"},"messageBubble": {"copied": "已复制",@@ -746,7 +755,16 @@"featureStreaming": "实时流式输出","featureStreamingDesc": "观看智能体思考、调用工具和迭代的全过程","featureReplay": "策略回放",- "featureReplayDesc": "交易日志分析器 + 影子账户 —— 提取你的规则、回测验证、归因盈亏差异"+ "featureReplayDesc": "交易日志分析器 + 影子账户 —— 提取你的规则、回测验证、归因盈亏差异",+ "howItWorksTitle": "怎么使用",+ "step1Title": "1. 描述你的策略",+ "step1Desc": "用自然语言告诉智能体你想测试什么,不需要写代码。",+ "step2Title": "2. 观看研究与回测过程",+ "step2Desc": "智能体会规划、抓取市场数据并即时执行回测,每一步都能看到。",+ "step3Title": "3. 查看结果",+ "step3Desc": "查看绩效指标、净值曲线,以及可导出的 Pine Script 策略代码。",+ "step4Title": "4. 准备好了再上线",+ "step4Desc": "可选择授权明确额度的交易 mandate——未经你确认不会下任何真实订单。"},"errorBoundary": {"somethingWrong": "出了点问题"diff --git a/frontend/src/pages/Agent.tsx b/frontend/src/pages/Agent.tsxindex e41918c48..79f40af49 100644--- a/frontend/src/pages/Agent.tsx+++ b/frontend/src/pages/Agent.tsx@@ -1343,6 +1343,7 @@ export function Agent() {value={goalEditValue}onChange={(event) => setGoalEditValue(event.target.value)}rows={3}+ aria-label={t("agent.editGoalObjectiveLabel")}className="w-full rounded-lg border bg-background px-3 py-2 text-xs leading-relaxed text-foreground outline-none focus:ring-2 focus:ring-primary/30"/><div className="flex justify-end gap-2">@@ -1493,9 +1494,12 @@ export function Agent() {</div>)}{/* Persistent kill switch — distinct from the per-turn Stop button- above; disables all live order activity (SPEC Consent §4). */}+ above; disables all live order activity (SPEC Consent §4).+ Given a top border + extra top padding so this safety-critical+ control visually separates from the lighter decorative chips+ (swarm/goal/attachment) stacked above it. */}{liveActive && (- <div className="flex items-center gap-2">+ <div className="flex items-center gap-2 border-t border-border/60 pt-2">{liveIsHalted ? (<span className="inline-flex items-center gap-1.5 rounded-lg bg-destructive/10 px-2.5 py-1 text-xs font-medium text-destructive"><OctagonX className="h-3 w-3" />@@ -1634,6 +1638,7 @@ export function Agent() {? t("agent.describeGoal"): t("agent.placeholder")}+ aria-label={t("agent.messageInputLabel")}className="flex-1 px-4 py-2.5 rounded-xl border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-primary/40 transition-shadow resize-none max-h-32 overflow-y-auto"disabled={status === "streaming"}/>@@ -1661,11 +1666,14 @@ export function Agent() {type="submit"disabled={goalComposerActive ? !input.trim() : (!input.trim() && !attachment)}className="px-4 py-2.5 rounded-xl bg-primary text-primary-foreground text-sm font-medium disabled:opacity-40 hover:opacity-90 transition-opacity"+ title={t("agent.send")}+ aria-label={t("agent.send")}><Send className="h-4 w-4" /></button>)}</div>+ <p className="px-1 text-[11px] text-muted-foreground">{t("agent.inputHint")}</p></div></form></div>diff --git a/frontend/src/pages/Compare.tsx b/frontend/src/pages/Compare.tsxindex 413d6200a..8e1491f09 100644--- a/frontend/src/pages/Compare.tsx+++ b/frontend/src/pages/Compare.tsx@@ -1,5 +1,6 @@import i18n from '@/i18n';import { useEffect, useRef, useState } from "react";+import { toast } from "sonner";import { GitCompare, ArrowRight } from "lucide-react";import { cn } from "@/lib/utils";import { api, type RunListItem, type RunData, type EquityPoint } from "@/lib/api";@@ -213,7 +214,9 @@ export function Compare() {setRuns(Array.isArray(items) ? items : []);if (items.length >= 2) { setLeftId(items[1].run_id); setRightId(items[0].run_id); }else if (items.length === 1) { setLeftId(items[0].run_id); }- }).catch(() => {});+ }).catch((error) => {+ toast.error(error instanceof Error ? error.message : i18n.t("compare.loadError"));+ });}, []);useEffect(() => {@@ -222,7 +225,11 @@ export function Compare() {api.getRun(leftId).then((d: RunData) => {setLeftData(d.metrics || null);setLeftCurve(d.equity_curve || []);- }).catch(() => { setLeftData(null); setLeftCurve([]); })+ }).catch((error) => {+ setLeftData(null);+ setLeftCurve([]);+ toast.error(error instanceof Error ? error.message : i18n.t("compare.loadError"));+ }).finally(() => setLeftLoading(false));} else {setLeftData(null);@@ -236,7 +243,11 @@ export function Compare() {api.getRun(rightId).then((d: RunData) => {setRightData(d.metrics || null);setRightCurve(d.equity_curve || []);- }).catch(() => { setRightData(null); setRightCurve([]); })+ }).catch((error) => {+ setRightData(null);+ setRightCurve([]);+ toast.error(error instanceof Error ? error.message : i18n.t("compare.loadError"));+ }).finally(() => setRightLoading(false));} else {setRightData(null);diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsxindex 789bfb1f1..73d475c44 100644--- a/frontend/src/pages/Home.tsx+++ b/frontend/src/pages/Home.tsx@@ -1,5 +1,5 @@import { Link } from "react-router-dom";-import { ArrowRight, Bot, BarChart3, Zap, UserCircle2 } from "lucide-react";+import { ArrowRight, Bot, BarChart3, Zap, UserCircle2, MessageSquarePlus, SearchCode, LineChart, ShieldCheck } from "lucide-react";import { useTranslation } from "react-i18next";export function Home() {@@ -12,6 +12,13 @@ export function Home() {{ icon: UserCircle2, title: t("home.featureReplay"), desc: t("home.featureReplayDesc") },];+ const STEPS = [+ { icon: MessageSquarePlus, title: t("home.step1Title"), desc: t("home.step1Desc") },+ { icon: SearchCode, title: t("home.step2Title"), desc: t("home.step2Desc") },+ { icon: LineChart, title: t("home.step3Title"), desc: t("home.step3Desc") },+ { icon: ShieldCheck, title: t("home.step4Title"), desc: t("home.step4Desc") },+ ];+return (<div className="flex flex-col items-center justify-center min-h-screen p-8"><div className="max-w-2xl text-center space-y-6">@@ -25,7 +32,29 @@ export function Home() {</Link></div>- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mt-16 max-w-5xl w-full">+ <div className="mt-16 max-w-5xl w-full">+ <h2 className="text-center text-sm font-semibold uppercase tracking-wide text-muted-foreground">+ {t("home.howItWorksTitle")}+ </h2>+ <div className="mt-4 grid grid-cols-1 md:grid-cols-4 gap-4">+ {STEPS.map(({ icon: Icon, title, desc }, index) => (+ <div key={title} className="relative rounded-lg border bg-card p-4 space-y-2">+ <div className="flex items-center gap-2 min-w-0">+ <span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">+ <Icon className="h-3.5 w-3.5" />+ </span>+ <h3 className="min-w-0 text-sm font-semibold">{title}</h3>+ </div>+ <p className="text-xs text-muted-foreground leading-relaxed">{desc}</p>+ {index < STEPS.length - 1 && (+ <ArrowRight className="hidden md:block absolute top-1/2 -right-6 h-4 w-4 -translate-y-1/2 text-muted-foreground/40" />+ )}+ </div>+ ))}+ </div>+ </div>++ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mt-12 max-w-5xl w-full">{FEATURES.map(({ icon: Icon, title, desc }) => (<div key={title} className="border rounded-lg p-6 space-y-3"><Icon className="h-8 w-8 text-primary" />