From d65a74ed4f562c0569232ce52a7d7af2f0e979b2 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Tue, 4 Mar 2025 14:12:56 +0100 Subject: [PATCH] feat: add UI tweaks --- src/App.tsx | 6 +----- src/components/thread/index.tsx | 37 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2f5c3b5..f1b3264 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,11 +2,7 @@ import "./App.css"; import { Thread } from "@/components/thread"; function App() { - return ( -
- -
- ); + return ; } export default App; diff --git a/src/components/thread/index.tsx b/src/components/thread/index.tsx index 07743c3..f5a3d91 100644 --- a/src/components/thread/index.tsx +++ b/src/components/thread/index.tsx @@ -48,8 +48,8 @@ export function Thread() { const stream = useStreamContext(); const messages = stream.messages; const isLoading = stream.isLoading; - const prevMessageLength = useRef(0); + const prevMessageLength = useRef(0); useEffect(() => { if ( messages.length !== prevMessageLength.current && @@ -75,14 +75,14 @@ export function Thread() { const toolMessages = ensureToolCallsHaveResponses(stream.messages); stream.submit( { messages: [...toolMessages, newHumanMessage] }, - { streamMode: ["values"] } + { streamMode: ["values"] }, ); setInput(""); }; const handleRegenerate = ( - parentCheckpoint: Checkpoint | null | undefined + parentCheckpoint: Checkpoint | null | undefined, ) => { // Do this so the loading state is correct prevMessageLength.current = prevMessageLength.current - 1; @@ -95,15 +95,12 @@ export function Thread() { const chatStarted = isLoading || messages.length > 0; const renderMessages = messages.filter( - (m) => !m.id?.startsWith(DO_NOT_RENDER_ID_PREFIX) + (m) => !m.id?.startsWith(DO_NOT_RENDER_ID_PREFIX), ); return (
{!chatStarted && ( @@ -121,7 +118,7 @@ export function Thread() {
{renderMessages.map((message, index) => @@ -138,7 +135,7 @@ export function Thread() { isLoading={isLoading} handleRegenerate={handleRegenerate} /> - ) + ), )} {isLoading && !firstTokenReceived && }
@@ -146,29 +143,27 @@ export function Thread() {
setInput(e.target.value)} placeholder="Type your message..." - className="p-5 border-[0px] shadow-none ring-0 outline-none focus:outline-none focus:ring-0" + className="px-4 py-6 border-none bg-transparent shadow-none ring-0 outline-none focus:outline-none focus:ring-0" /> - +
+ +