From 069360e38784a65d2e12354d0d37dc474d3d8189 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2026 07:10:09 +0000 Subject: [PATCH] perf(storage): parallelize sequential file reads in onFileDrop Refactored the sequential `for...of` loop over `event.payload.paths` in `onFileDrop` to use `Promise.all` with `paths.map`, executing `invoke("read_text_file", ...)` concurrently. This resolves the performance bottleneck where reading multiple dropped files was artificially serialized. Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- src/storage.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/storage.ts b/src/storage.ts index 211180b..666a654 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -310,14 +310,16 @@ export async function onFileDrop(cb: (content: string) => void): Promise { const { getCurrentWebview } = await import("@tauri-apps/api/webview"); await getCurrentWebview().onDragDropEvent(async (event) => { if (event.payload.type !== "drop") return; - for (const path of event.payload.paths) { - try { - const content = await invoke("read_text_file", { path }); - cb(content); - } catch (e) { - logger.warn("file drop rejected", path, e); - } - } + await Promise.all( + event.payload.paths.map(async (path) => { + try { + const content = await invoke("read_text_file", { path }); + cb(content); + } catch (e) { + logger.warn("file drop rejected", path, e); + } + }) + ); }); return; }