From 1056722f8c1727d6d9e19c887fd9a742f811c7bb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 10:50:45 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20[Performance]=20Eliminate=20concurr?= =?UTF-8?q?ent=20IPC=20map-promise-all=20in=20hostBridge=20cell=20batch=20?= =?UTF-8?q?updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored the `updateCellBatch` in `src/hostBridge.ts` to replace the parallel `Promise.all` fallback with a sequential execution loop. Retained the capability check for backward compatibility with older extensions that do not support batching, but pre-processed updates to ensure `tryGeneratePatch` JSON payload optimizations are still executed. --- src/hostBridge.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/hostBridge.ts b/src/hostBridge.ts index d65b64c..a8813ce 100644 --- a/src/hostBridge.ts +++ b/src/hostBridge.ts @@ -382,23 +382,36 @@ export class HostBridge implements ToastService { throw new Error("Document is read-only"); } + // Ensure all updates try to generate patches for efficiency + const processedUpdates = updates.map(update => { + if (update.operation !== 'json_patch') { + const patch = this.tryGeneratePatch(update.value, update.originalValue); + if (patch) { + return { + ...update, + operation: 'json_patch' as const, + value: patch + }; + } + } + return update; + }); + if ('updateCellBatch' in dbOps) { - await dbOps.updateCellBatch(table, updates); + await dbOps.updateCellBatch(table, processedUpdates); } else { - // Fallback: execute updates in parallel - await Promise.all(updates.map(async update => { + // Fallback: execute updates sequentially to avoid IPC overload and N+1 concurrency + for (const update of processedUpdates) { let patch: string | undefined; let val = update.value; if (update.operation === 'json_patch') { patch = update.value as string; - val = null; // Value is ignored when patch is provided - } else { - patch = this.tryGeneratePatch(update.value, update.originalValue); + val = null; } await dbOps.updateCell(table, update.rowId, update.column, val, patch); - })); + } } // Fire batch edit event