Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

merge: resolve conflicts with dev for PR #362

Bingxi Zhao (Frank)5662c1cfde8a
diff --cc web/app/(workspace)/agents/[botId]/chat/page.tsx
index 0bb928cdf,02c1c71f0..2328441f1
--- a/web/app/(workspace)/agents/[botId]/chat/page.tsx
+++ b/web/app/(workspace)/agents/[botId]/chat/page.tsx
@@@ -5,8 -5,8 +5,9 @@@ import { useParams, useRouter } from "n
import { useTranslation } from "react-i18next";
import { ArrowLeft, Bot, Loader2, Send } from "lucide-react";
import { apiUrl, wsUrl } from "@/lib/api";
+ import { firstParam } from "@/lib/route-params";
import AssistantResponse from "@/components/common/AssistantResponse";
+import { SimpleComposerInput } from "@/components/chat/home/SimpleComposerInput";
interface BotInfo {
bot_id: string;
@@@ -101,23 -109,28 +109,23 @@@ export default function BotChatPage()
};
}, [botId, scrollToBottom]);
- const send = useCallback(() => {
- if (!botId) return;
- const text = input.trim();
- if (!text || streaming || !wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) return;
+ const handleSend = useCallback((content: string) => {
- if (streaming || !wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) return;
++ if (!botId || streaming || !wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) return;
- setMessages((msgs) => [...msgs, { role: "user", content: text }]);
- setInput("");
+ setMessages((msgs) => [...msgs, { role: "user", content }]);
setStreaming(true);
setThinking([]);
- wsRef.current.send(JSON.stringify({ content: text }));
+ wsRef.current.send(JSON.stringify({ content }));
scrollToBottom();
- }, [streaming, scrollToBottom]);
- }, [botId, input, streaming, scrollToBottom]);
++ }, [botId, streaming, scrollToBottom]);
- const handleKeyDown = useCallback(
- (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
- if (e.key === "Enter" && !e.shiftKey) {
- e.preventDefault();
- send();
- }
- },
- [send],
- );
+ const handleManualSend = useCallback(() => {
+ const content = inputRef.current?.value.trim();
+ if (content) {
+ handleSend(content);
+ if (inputRef.current) inputRef.current.value = "";
+ }
+ }, [handleSend]);
return (
<div className="flex h-full flex-col">