fix: close delete resume and SSE replay races

This commit is contained in:
User
2026-07-15 02:08:11 +02:00
parent 4d36f4acf1
commit 0bcec1591b
5 changed files with 208 additions and 5 deletions
+4 -4
View File
@@ -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) {