From b1089b6331af5b3952c9606023c1736ce8951e55 Mon Sep 17 00:00:00 2001 From: rafia-10 Date: Sat, 21 Feb 2026 18:36:51 +0300 Subject: [PATCH] refactor: enforce hook middleware as single execution path and unify postHook tracing with failure logging --- .../assistant-message/presentAssistantMessage.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index a173f887e7..be42c5c607 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -76,7 +76,7 @@ async function runWithHooks( // ===== BRIDGE END ===== // pre-hook can access cline and block - await preWriteHook(cline, block) + await preWriteHook(filePath, intentId) // Keep helpers in scope so handlers still compile const askApproval = async ( @@ -111,9 +111,10 @@ async function runWithHooks( try { await handler.handle(cline, block, { askApproval, handleError, pushToolResult }) - await postWriteHook(cline, block, { success: true }) + + postWriteHook(filePath, intentId, sessionId, contributorModel, "SUCCESS") } catch (err) { - await postWriteHook(cline, block, { success: false, error: err }) + postWriteHook(filePath, intentId, sessionId, contributorModel, "FAILED", err) throw err } } @@ -755,12 +756,7 @@ export async function presentAssistantMessage(cline: Task) { switch (block.name) { case "write_to_file": - await checkpointSaveAndMark(cline) - await writeToFileTool.handle(cline, block as ToolUse<"write_to_file">, { - askApproval, - handleError, - pushToolResult, - }) + await runWithHooks(cline, block as ToolUse<"write_to_file">, writeToFileTool, { checkpoint: true }) break case "update_todo_list": await updateTodoListTool.handle(cline, block as ToolUse<"update_todo_list">, {