Skip to content

Commit befeb54

Browse files
committed
fix (chat): new chat page (WIP)
1 parent 592f0e7 commit befeb54

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/client/app/home/page.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@ export default function HomePage() {
1818
const [isStreaming, setIsStreaming] = useState(false)
1919
const messagesEndRef = useRef(null)
2020

21+
// Existing useEffect for params and pathname
2122
useEffect(() => {
2223
const urlChatId =
2324
params.chatId ||
2425
(Array.isArray(params.slug) ? params.slug[0] : null)
25-
26-
// If there's no chatId AND we're on the /chat route => reset everything
2726
if (!urlChatId && pathname === "/chat") {
2827
setMessages([])
2928
setChatId(null)
3029
return
3130
}
32-
3331
setChatId(urlChatId)
3432
}, [params, pathname])
3533

36-
37-
34+
// Existing useEffect for fetching history
3835
useEffect(() => {
3936
const fetchHistory = async () => {
4037
if (!chatId) {
@@ -60,6 +57,22 @@ export default function HomePage() {
6057
fetchHistory()
6158
}, [chatId])
6259

60+
// New useEffect for route change
61+
useEffect(() => {
62+
const handleRouteChange = (url) => {
63+
if (url === "/chat") {
64+
setMessages([])
65+
setChatId(null)
66+
}
67+
}
68+
69+
router.events.on("routeChangeComplete", handleRouteChange)
70+
71+
return () => {
72+
router.events.off("routeChangeComplete", handleRouteChange)
73+
}
74+
}, [router])
75+
6376
const scrollToBottom = useCallback(() => {
6477
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
6578
}, [])
@@ -72,7 +85,6 @@ export default function HomePage() {
7285
router.push("/chat") // navigate to base chat page
7386
}
7487

75-
7688
const handleSend = async (e) => {
7789
e.preventDefault()
7890
if (!input.trim() || isStreaming) return

src/server/celerybeat-schedule-shm

0 Bytes
Binary file not shown.

src/server/celerybeat-schedule-wal

64.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)