From bb50193cb9c0201dcc6181aafbc9170b7e7a1abd Mon Sep 17 00:00:00 2001 From: Black Circle Sentinel Date: Fri, 2 Jan 2026 19:06:16 -0500 Subject: [PATCH] fix(kanban): await plan updates before resolving merge (fixes #243) Root cause: updatePlans() was fire-and-forget, causing race condition where resolve() returned before files were written. UI refresh would then read old 'human_review' status instead of 'done'. Fix: Await updatePlans() with try/catch to ensure status persists before UI refresh. Non-fatal error handling preserves existing behavior. Fixes #243 Related: #586, #216 --- .../src/main/ipc-handlers/task/worktree-handlers.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts b/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts index a9edf89c..caf36cca 100644 --- a/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts +++ b/apps/frontend/src/main/ipc-handlers/task/worktree-handlers.ts @@ -1766,8 +1766,15 @@ export function registerWorktreeHandlers( } }; - // Run async updates without blocking the response - updatePlans().catch(err => debug('Background plan update failed:', err)); + // IMPORTANT: Wait for plan updates to complete before responding (fixes #243) + // Previously this was "fire and forget" which caused a race condition: + // resolve() would return before files were written, and UI refresh would read old status + try { + await updatePlans(); + } catch (err) { + debug('Plan update failed:', err); + // Non-fatal: UI will still update, but status may not persist across refresh + } const mainWindow = getMainWindow(); if (mainWindow) {