@@ -138,7 +138,11 @@ export default function Home() {
138138 const data = await res.json();
139139 threadId = data.thread.id;
140140 setCurrentThreadId(threadId);
141- setThreads((prev) => [data.thread, ...prev.slice(0, 9)]);
141+ setMessages([]);
142+ // Reload threads to ensure UI is in sync
143+ const threadsRes = await fetch("/api/threads");
144+ const threadsData = await threadsRes.json();
145+ setThreads(threadsData.threads || []);
142146 } catch (error) {
143147 console.error("Failed to create thread", error);
144148 return;
@@ -153,7 +157,8 @@ export default function Home() {
153157 createdAt: new Date(),
154158 };
155159 setMessages((prev) => [...prev, userMsg]);
156- const inputValue = input;
160+ const inputValue = input.trim();
161+ if (!inputValue) return;
157162 setInput("");
158163
159164 const res = await fetch("/api/chat", {