+ {/* ── Header ── */}
+
+
+ {/* ── Messages / Welcome ── */}
+
+ {isEmpty ? (
+
{
+ setInput(p);
+ setTimeout(() => textareaRef.current?.focus(), 0);
+ }}
+ />
+ ) : (
+
+ {messages.map((m) => (
+
+ ))}
+ {sending && messages[messages.length - 1]?.pending && }
+
+ )}
+
+
+ {/* ── Input bar ── */}
+
+
+ {chatId && messages.length > 0 && (
+
+
+
+ )}
+
+
+ {/* ── History panel ── */}
+ {historyOpen && (
+
setHistoryOpen(false)}
+ onSelect={loadChat}
+ onNew={newChat}
+ />
+ )}
+
+
+
+ );
+}
+
+// ============================================================
+// 子组件
+// ============================================================
+
+function WelcomeView({
+ deviceName,
+ onPick,
+}: {
+ deviceName: string;
+ onPick: (prompt: string) => void;
+}) {
+ return (
+