From c915970b50096c3914cd9b9b84868303d274ed68 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 31 Oct 2025 13:52:52 +0100 Subject: [PATCH 1/2] fix: approval in edit mode not working if log printed --- packages/blink/src/react/use-dev-mode.ts | 38 +++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/blink/src/react/use-dev-mode.ts b/packages/blink/src/react/use-dev-mode.ts index 10127a3..df9ef9a 100644 --- a/packages/blink/src/react/use-dev-mode.ts +++ b/packages/blink/src/react/use-dev-mode.ts @@ -523,28 +523,30 @@ export default function useDevMode(options: UseDevModeOptions): UseDevMode { setAutoApprove(true); } - const messages = chat.messages; - if (messages.length === 0) { - return; - } - const lastMsg = messages[messages.length - 1]; - if (!lastMsg) { - return; - } - if (lastMsg.role !== "assistant") { - return; - } - if (!Array.isArray(lastMsg.parts)) { - return; - } - if (approvalHandledRef.current === lastMsg.id) { + const lastApprovalMessage = chat.messages.reverse().find((msg) => { + if (msg.role !== "assistant") { + return false; + } + if (!Array.isArray(msg.parts)) { + return false; + } + return msg.parts.some( + (part) => + "output" in part && + isToolApprovalOutput(part.output) && + part.output.outcome === "pending" + ); + }); + + if (!lastApprovalMessage) { return; } + // CRITICAL: all code before this point must be synchronous. // Otherwise, the approval may be handled multiple times. - approvalHandledRef.current = lastMsg.id; + approvalHandledRef.current = lastApprovalMessage.id; // Update all pending approval outputs - const updatedParts = lastMsg.parts.map((part: any) => { + const updatedParts = lastApprovalMessage.parts.map((part: any) => { if ( part.output && isToolApprovalOutput(part.output) && @@ -562,7 +564,7 @@ export default function useDevMode(options: UseDevModeOptions): UseDevMode { }); await chat.upsertMessage({ - ...lastMsg, + ...lastApprovalMessage, parts: updatedParts, }); From 9ae3738399c85f5e505e8b37deb5a75fe97ba7c2 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 31 Oct 2025 13:54:35 +0100 Subject: [PATCH 2/2] chore: version 1.1.27 --- packages/blink/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/blink/package.json b/packages/blink/package.json index 9454a3e..fa5aaa5 100644 --- a/packages/blink/package.json +++ b/packages/blink/package.json @@ -1,6 +1,6 @@ { "name": "blink", - "version": "1.1.26", + "version": "1.1.27", "description": "Blink is a tool for building and deploying AI agents.", "type": "module", "bin": {