Skip to content

Commit 99f3ae4

Browse files
committed
cleanup on thread deletion
1 parent 2e486cb commit 99f3ae4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

frontend/app/components/ChatWindow.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function ChatWindow() {
215215
router.push(newUrl);
216216
};
217217

218-
const selectChat = useCallback(
218+
const selectThread = useCallback(
219219
async (id: string | null) => {
220220
if (currentThread) {
221221
stopStream?.(true);
@@ -231,6 +231,17 @@ export function ChatWindow() {
231231
[currentThread, stopStream, setMessages, createThread, insertUrlParam],
232232
);
233233

234+
const deleteThreadAndReset = async (id: string) => {
235+
await deleteThread(id);
236+
// reset
237+
router.push(
238+
window.location.protocol +
239+
"//" +
240+
window.location.host +
241+
window.location.pathname,
242+
);
243+
};
244+
234245
return (
235246
<>
236247
<div className="flex items-center rounded grow max-h-full">
@@ -243,8 +254,8 @@ export function ChatWindow() {
243254
>
244255
<ChatList
245256
threads={threads}
246-
enterChat={selectChat}
247-
deleteChat={deleteThread}
257+
enterChat={selectThread}
258+
deleteChat={deleteThreadAndReset}
248259
/>
249260
</Flex>
250261
<Flex

0 commit comments

Comments
 (0)