fix: close delete resume and SSE replay races
This commit is contained in:
@@ -240,16 +240,16 @@ export function AppShell() {
|
||||
}
|
||||
|
||||
async function deleteSessions(targets: SessionSummary[]) {
|
||||
if (targets.some((session) => session.id === activeSessionIdRef.current)) {
|
||||
invalidateResumeIntent();
|
||||
}
|
||||
try {
|
||||
const results = await Promise.allSettled(targets.map((session) => deleteSession(session.id)));
|
||||
const deletedIds = new Set(
|
||||
targets.filter((_, index) => results[index].status === "fulfilled").map((session) => session.id),
|
||||
);
|
||||
const deletedActiveSession = deletedIds.has(activeSessionIdRef.current ?? "");
|
||||
const deletedResumeTarget = deletedIds.has(latestResumeIntentRef.current?.id ?? "");
|
||||
if (deletedActiveSession || deletedResumeTarget) invalidateResumeIntent();
|
||||
if (deletedIds.has(panelSession?.id ?? "")) setPanelSession(null);
|
||||
if (deletedIds.has(activeSessionId ?? "")) { resetSession(); selectActiveSession(null); }
|
||||
if (deletedActiveSession) { resetSession(); selectActiveSession(null); }
|
||||
setSelectedSessionIds((current) => new Set([...current].filter((id) => !deletedIds.has(id))));
|
||||
refresh();
|
||||
if (deletedIds.size !== targets.length) {
|
||||
|
||||
Reference in New Issue
Block a user