Skip to content

Commit

Permalink
Merge pull request #1705 from solliancenet/jdh-delete-chat-session-fi…
Browse files Browse the repository at this point in the history
…x-081

(0.8.1) Fix issue with deleted sessions reappearing when immediately deleting another
  • Loading branch information
ciprianjichici authored Sep 10, 2024
2 parents dc09a0a + ced7d46 commit dfa19cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ui/UserPortal/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const useAppStore = defineStore('app', {
sessions: [] as Session[],
currentSession: null as Session | null,
renamedSessions: [] as Session[],
deletedSessions: [] as Session[],
currentMessages: [] as Message[],
isSidebarClosed: false as boolean,
agents: [] as ResourceProviderGetResult<Agent>[],
Expand Down Expand Up @@ -103,6 +104,14 @@ export const useAppStore = defineStore('app', {
existingSession.name = renamedSession.name;
}
});

// Handle inconsistencies in displaying the deleted session due to potential delays in the backend updating the session list.
this.deletedSessions.forEach((deletedSession: Session) => {
const existingSession = this.sessions.find((s: Session) => s.id === deletedSession.id);
if (existingSession) {
this.removeSession(deletedSession.id);
}
});
},

async addSession(properties: ChatSessionProperties) {
Expand Down Expand Up @@ -155,6 +164,9 @@ export const useAppStore = defineStore('app', {

this.removeSession(sessionToDelete!.id);

// Add the deleted session to the list of deleted sessions to handle inconsistencies in the backend updating the session list.
this.deletedSessions = [sessionToDelete, ...this.deletedSessions];

// Ensure there is at least always 1 session
if (this.sessions.length === 0) {
const newSession = await this.addSession(this.getDefaultChatSessionProperties());
Expand Down

0 comments on commit dfa19cf

Please sign in to comment.