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>
This commit is contained in:
google-labs-jules[bot] 2026-09-04 07:10:09 +00:00
parent 37cfd2144b
commit 069360e387

View file

@ -310,14 +310,16 @@ export async function onFileDrop(cb: (content: string) => void): Promise<void> {
const { getCurrentWebview } = await import("@tauri-apps/api/webview"); const { getCurrentWebview } = await import("@tauri-apps/api/webview");
await getCurrentWebview().onDragDropEvent(async (event) => { await getCurrentWebview().onDragDropEvent(async (event) => {
if (event.payload.type !== "drop") return; if (event.payload.type !== "drop") return;
for (const path of event.payload.paths) { await Promise.all(
try { event.payload.paths.map(async (path) => {
const content = await invoke<string>("read_text_file", { path }); try {
cb(content); const content = await invoke<string>("read_text_file", { path });
} catch (e) { cb(content);
logger.warn("file drop rejected", path, e); } catch (e) {
} logger.warn("file drop rejected", path, e);
} }
})
);
}); });
return; return;
} }