From 6c493f98790d75c050fa49b7aec08d46ed2419cc Mon Sep 17 00:00:00 2001 From: Matcham89 Date: Thu, 5 Mar 2026 11:18:38 -0700 Subject: [PATCH] fix(ui): prevent duplicate ask_user card on session load When loading a session with a pending ask_user request, the confirmation appeared twice because two code paths both created an AskUserRequest card: 1. extractMessagesFromTasks() found the unresolved confirmation in task history and created a pending card. 2. extractApprovalMessagesFromTasks() found the same confirmation in task.status.message and created another pending card. Both were then concatenated into storedMessages, resulting in the duplicate "Questions for you" UI shown to the user. Fix: skip unresolved confirmations in extractMessagesFromTasks(). Pending confirmations are now exclusively owned by extractApprovalMessagesFromTasks() via task.status.message, while resolved ones continue to be rendered inline from history. Signed-off-by: Matcham89 --- ui/src/lib/messageHandlers.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/src/lib/messageHandlers.ts b/ui/src/lib/messageHandlers.ts index 5d910e95d..c057c157e 100644 --- a/ui/src/lib/messageHandlers.ts +++ b/ui/src/lib/messageHandlers.ts @@ -28,6 +28,13 @@ export function extractMessagesFromTasks(tasks: Task[]): Message[] { i ); + // Skip unresolved confirmations — extractApprovalMessagesFromTasks + // handles pending ones via task.status.message to avoid duplicates. + if (!decision) { + seenMessageIds.add(historyItem.messageId); + continue; + } + for (const confPart of confirmationParts) { const approvalMsg = buildApprovalMessage(confPart, task.contextId, task.id, decision); messages.push(approvalMsg);