diff --git a/templates/types/streaming/fastapi/app/api/routers/messaging.py b/templates/types/streaming/fastapi/app/api/routers/messaging.py
index ae5cc19357c1b933db6faea766e872e04204d05c..d13595df5731faa96a3f50fd3df48f23f7469367 100644
--- a/templates/types/streaming/fastapi/app/api/routers/messaging.py
+++ b/templates/types/streaming/fastapi/app/api/routers/messaging.py
@@ -79,14 +79,8 @@ class EventCallbackHandler(BaseCallbackHandler):
         """No-op."""
 
     async def async_event_gen(self) -> AsyncGenerator[CallbackEvent, None]:
-        while True:
-            if not self._aqueue.empty() or not self.is_done:
-                try:
-                    event = await asyncio.wait_for(self._aqueue.get(), timeout=0.1)
-                except asyncio.TimeoutError:
-                    if self.is_done:
-                        break
-                    continue
-                yield event
-            else:
-                break
+        while not self._aqueue.empty() or not self.is_done:
+            try:
+                yield await asyncio.wait_for(self._aqueue.get(), timeout=0.1)
+            except asyncio.TimeoutError:
+                pass
diff --git a/templates/types/streaming/nextjs/app/components/ui/chat/chat-events.tsx b/templates/types/streaming/nextjs/app/components/ui/chat/chat-events.tsx
index 96d36fefa69e33038214fcdd07d703417d83f1c7..eb921a981cb6fa013cb26387d44071e569cd2dad 100644
--- a/templates/types/streaming/nextjs/app/components/ui/chat/chat-events.tsx
+++ b/templates/types/streaming/nextjs/app/components/ui/chat/chat-events.tsx
@@ -1,5 +1,5 @@
 import { ChevronDown, ChevronRight, Loader2 } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useState } from "react";
 import { Button } from "../button";
 import {
   Collapsible,
@@ -15,24 +15,11 @@ export function ChatEvents({
   data: EventData[];
   isLoading: boolean;
 }) {
-  const [isOpen, setIsOpen] = useState(true);
+  const [isOpen, setIsOpen] = useState(false);
 
-  useEffect(() => {
-    // Collapse the events when finished streaming
-    if (!isLoading) {
-      setIsOpen(false);
-    }
-  }, [isLoading]);
+  const buttonLabel = isOpen ? "Hide events" : "Show events";
 
-  const buttonLabel = isLoading
-    ? "In progress"
-    : isOpen
-      ? "Hide events"
-      : "Show events";
-
-  const EventIcon = isLoading ? (
-    <Loader2 className="h-4 w-4 animate-spin" />
-  ) : isOpen ? (
+  const EventIcon = isOpen ? (
     <ChevronDown className="h-4 w-4" />
   ) : (
     <ChevronRight className="h-4 w-4" />
@@ -43,6 +30,7 @@ export function ChatEvents({
       <Collapsible open={isOpen} onOpenChange={setIsOpen}>
         <CollapsibleTrigger asChild>
           <Button variant="secondary" className="space-x-2">
+            {isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : null}
             <span>{buttonLabel}</span>
             {EventIcon}
           </Button>