From b51a06d65b99818db807d130a54bc1bd28106316 Mon Sep 17 00:00:00 2001 From: Ignacio Cervino Date: Mon, 19 Jan 2026 01:03:47 -0300 Subject: [PATCH] fix: dedupe review started item --- .../threads/hooks/useThreadsReducer.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/features/threads/hooks/useThreadsReducer.ts b/src/features/threads/hooks/useThreadsReducer.ts index 69a9d5951..9e9fbb274 100644 --- a/src/features/threads/hooks/useThreadsReducer.ts +++ b/src/features/threads/hooks/useThreadsReducer.ts @@ -233,6 +233,20 @@ function mergeStreamingText(existing: string, delta: string) { return `${existing}${delta}`; } +function dropLatestLocalReviewStart(list: ConversationItem[]) { + for (let index = list.length - 1; index >= 0; index -= 1) { + const item = list[index]; + if ( + item.kind === "review" && + item.state === "started" && + item.id.startsWith("review-start-") + ) { + return [...list.slice(0, index), ...list.slice(index + 1)]; + } + } + return list; +} + export function threadReducer(state: ThreadState, action: ThreadAction): ThreadState { switch (action.type) { case "setActiveThreadId": @@ -573,8 +587,15 @@ export function threadReducer(state: ThreadState, action: ThreadAction): ThreadS }; } case "upsertItem": { - const list = state.itemsByThread[action.threadId] ?? []; + let list = state.itemsByThread[action.threadId] ?? []; const item = normalizeItem(action.item); + if ( + item.kind === "review" && + item.state === "started" && + !item.id.startsWith("review-start-") + ) { + list = dropLatestLocalReviewStart(list); + } return { ...state, itemsByThread: {