Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,6 @@ function _Chat() {

export function Chat() {
const chatStore = useChatStore();
const sessionIndex = chatStore.currentSessionIndex;
return <_Chat key={sessionIndex}></_Chat>;
const forceUpdateKey = chatStore.forceUpdateKey;
return <_Chat key={forceUpdateKey}></_Chat>;
}
7 changes: 7 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const DEFAULT_CHAT_STATE = {
sessions: [createEmptySession()],
currentSessionIndex: 0,
lastInput: "",
forceUpdateKey: Date.now(),
};

export const useChatStore = createPersistStore(
Expand Down Expand Up @@ -225,19 +226,22 @@ export const useChatStore = createPersistStore(
set((state) => ({
currentSessionIndex: 0,
sessions: [newSession, ...state.sessions],
forceUpdateKey: Date.now(),
}));
},

clearSessions() {
set(() => ({
sessions: [createEmptySession()],
currentSessionIndex: 0,
forceUpdateKey: Date.now(),
}));
},

selectSession(index: number) {
set({
currentSessionIndex: index,
forceUpdateKey: Date.now(),
});
},

Expand All @@ -262,6 +266,7 @@ export const useChatStore = createPersistStore(
return {
currentSessionIndex: newIndex,
sessions: newSessions,
forceUpdateKey: Date.now(),
};
});
},
Expand All @@ -286,6 +291,7 @@ export const useChatStore = createPersistStore(
set((state) => ({
currentSessionIndex: 0,
sessions: [session].concat(state.sessions),
forceUpdateKey: Date.now(),
}));
},

Expand Down Expand Up @@ -325,6 +331,7 @@ export const useChatStore = createPersistStore(
set(() => ({
currentSessionIndex: nextIndex,
sessions,
forceUpdateKey: Date.now(),
}));

showToast(
Expand Down