Skip to content

Commit d257bcf

Browse files
authored
fix(ui): prevent duplicate ask_user card on session load (#1446)
## Summary - When loading a session with a pending `ask_user` request, the \"Questions for you\" card was rendered twice - Two code paths both generated an `AskUserRequest` message for the same pending confirmation: 1. `extractMessagesFromTasks()` found it in task history (no decision yet → pending card) 2. `extractApprovalMessagesFromTasks()` found the same confirmation in `task.status.message` - Both were concatenated into `storedMessages`, causing the duplicate **Fix:** `extractMessagesFromTasks()` now skips unresolved confirmations (where no subsequent user decision exists in history). Pending confirmations are exclusively owned by `extractApprovalMessagesFromTasks()` via `task.status.message`; resolved ones continue to render inline from history as before. ## Test plan - [ ] Start a session with an agent that uses `ask_user` (e.g. an agent configured to ask before merging a PR) - [ ] Trigger the `ask_user` prompt, then reload/revisit the session - [ ] Change/Swap to another conversation - then return - [ ] Verify only one \"Questions for you\" card is shown (previously two appeared) - [ ] Verify that answering the question still works correctly - [ ] Verify resolved `ask_user` sessions show the answered card correctly (read-only) Signed-off-by: Matcham89 <cjmatcham@hotmail.co.uk>
1 parent 953648a commit d257bcf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ui/src/lib/messageHandlers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export function extractMessagesFromTasks(tasks: Task[]): Message[] {
2828
i
2929
);
3030

31+
// Skip unresolved confirmations — extractApprovalMessagesFromTasks
32+
// handles pending ones via task.status.message to avoid duplicates.
33+
if (!decision) {
34+
seenMessageIds.add(historyItem.messageId);
35+
continue;
36+
}
37+
3138
for (const confPart of confirmationParts) {
3239
const approvalMsg = buildApprovalMessage(confPart, task.contextId, task.id, decision);
3340
messages.push(approvalMsg);

0 commit comments

Comments
 (0)