[eric] perf: mass-delete parallel-detaches browsers too (removeBrowserCardsCleanly); flat latency, same crash-safe ordering

This commit is contained in:
ciregenz
2026-07-29 00:53:52 -07:00
parent 103a3af31a
commit b1f0f5b74e
2 changed files with 16 additions and 2 deletions
+14
View File
@@ -38,3 +38,17 @@ export async function removeBrowserCardCleanly(
forgetBrowser(browserId);
dispatch(removeBrowserCard(browserId));
}
// Batch remove: detach every browser's CDP in PARALLEL (order-independent, the only invariant is
// all debuggers gone before any unmount), THEN remove them. Serial detach cost ~72ms/browser, so a
// 20-card multi-select delete lagged over a second; this keeps the crash-safe ordering but flat.
export async function removeBrowserCardsCleanly(
browserIds: string[],
dispatch: Dispatch,
): Promise<void> {
await Promise.allSettled(browserIds.map((id) => detachBrowserCdp(id)));
for (const id of browserIds) {
forgetBrowser(id);
dispatch(removeBrowserCard(id));
}
}