From 93b2199c563b9b53f059d1e5c8a79ca6b8770256 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 6 Apr 2026 08:35:02 +0700 Subject: [PATCH] fix: emit workspace update after shortstat cache warm Add onComplete callback to warmCheckoutShortstatInBackground so session can push a workspace_update once diff stats resolve. --- packages/server/src/utils/checkout-git.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/server/src/utils/checkout-git.ts b/packages/server/src/utils/checkout-git.ts index 5a0a8b620..659084a66 100644 --- a/packages/server/src/utils/checkout-git.ts +++ b/packages/server/src/utils/checkout-git.ts @@ -1345,15 +1345,23 @@ export function getCachedCheckoutShortstat(cwd: string): CheckoutShortstat | nul return shortstatCache.get(getShortstatCacheKey(cwd)); } -export function warmCheckoutShortstatInBackground(cwd: string, context?: CheckoutContext): void { +export function warmCheckoutShortstatInBackground( + cwd: string, + context?: CheckoutContext, + onComplete?: () => void, +): void { const cacheKey = getShortstatCacheKey(cwd); if (shortstatCache.get(cacheKey) !== undefined || shortstatInFlight.has(cacheKey)) { return; } - void getOrLoadCheckoutShortstat(cwd, context).catch(() => { - // Non-critical: keep listing path resilient even if git commands fail. - }); + void getOrLoadCheckoutShortstat(cwd, context) + .then(() => { + onComplete?.(); + }) + .catch(() => { + // Non-critical: keep listing path resilient even if git commands fail. + }); } export async function getCheckoutDiff(