From 693baebe92df0ee73b101d43ff52399c157d8114 Mon Sep 17 00:00:00 2001 From: Rajan Chavada Date: Fri, 29 May 2026 22:46:41 -0400 Subject: [PATCH] fix(reducer): preserve relationship IDs when backend sends null Use `??` operator for parent_id, link_type, and root_chat_id in applyRestoredThread to match the pattern used in the snapshot event handler (lines 1331-1333). Previously, valueOrExisting would allow null to overwrite existing relationship IDs, breaking parent/child chat relationships when the backend sent null for these fields. The ?? operator correctly treats null as "keep existing value" rather than "overwrite with null", consistent with how SSE snapshot events handle the same backend fields. --- refact-agent/gui/src/features/Chat/Thread/reducer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/refact-agent/gui/src/features/Chat/Thread/reducer.ts b/refact-agent/gui/src/features/Chat/Thread/reducer.ts index 0ecb5ad1f..a4af3238f 100644 --- a/refact-agent/gui/src/features/Chat/Thread/reducer.ts +++ b/refact-agent/gui/src/features/Chat/Thread/reducer.ts @@ -379,9 +379,9 @@ function applyRestoredThread( payload.last_user_message_id, existing.last_user_message_id, ), - parent_id: valueOrExisting(payload.parent_id, existing.parent_id), - link_type: valueOrExisting(payload.link_type, existing.link_type), - root_chat_id: valueOrExisting(payload.root_chat_id, existing.root_chat_id), + parent_id: payload.parent_id ?? existing.parent_id, + link_type: payload.link_type ?? existing.link_type, + root_chat_id: payload.root_chat_id ?? existing.root_chat_id, worktree: valueOrExisting(payload.worktree, existing.worktree), task_meta: valueOrExisting(payload.task_meta, existing.task_meta), is_task_chat: valueOrExisting(payload.is_task_chat, existing.is_task_chat),