fix(webui): delete unpersisted pane sessions (#5624)
Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
1 parent
9ecdc4533f
commit
042f96f6ba
5 files changed
+108
-3
No files matched your search
@@ -257,11 +257,14 @@ export function useSessions(): {
|
||||
|
||||
const deleteChat = useCallback(
|
||||
async (key: string, options?: { deleteAutomations?: boolean }) => {
|
||||
const optimistic = optimisticKeysRef.current.has(key);
|
||||
const result = await apiDeleteSession(client, key, options);
|
||||
if (!result.deleted) return result;
|
||||
if (result.blocked_by_automations || (!result.deleted && !optimistic)) return result;
|
||||
optimisticKeysRef.current.delete(key);
|
||||
setSessions((prev) => prev.filter((s) => s.key !== key));
|
||||
return result;
|
||||
// The gateway may have restarted and forgotten an unpersisted chat's
|
||||
// draft scope, but removing that optimistic session is still a deletion.
|
||||
return result.deleted ? result : { ...result, deleted: true };
|
||||
},
|
||||
[client],
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user