From a1a2d22b5ba7501ea109953238ed9e6d1eeb1beb Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Sat, 8 Aug 2026 10:51:39 -0400 Subject: [PATCH] fix: only emit fork chip at actual divergence point Changed last_fork.clone() to last_fork.take() in render_tree_path for both assistant and user branches. This prevents fork_info from propagating to every downstream message, ensuring the chip appears only at the actual divergence point in the conversation tree. --- src/ai/insight_chat.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ai/insight_chat.rs b/src/ai/insight_chat.rs index 58cce7a..88badfd 100644 --- a/src/ai/insight_chat.rs +++ b/src/ai/insight_chat.rs @@ -2511,8 +2511,10 @@ fn render_tree_path( std::collections::VecDeque::new(); let mut node_ids: Vec = Vec::new(); let mut fork_info: Vec> = Vec::new(); - // Nearest divergence seen so far, carried forward across nodes (rendered or - // not) so every message at/after a fork shows the indicator. + // Nearest divergence seen so far, carried forward across non-rendered + // nodes (e.g. tool-dispatch) so the fork is attributed to the next + // rendered message. Cleared after the first rendered message consumes it, + // so the chip appears only at the actual divergence point. let mut last_fork: Option = None; for node in path { @@ -2571,9 +2573,9 @@ fn render_tree_path( tools, }); node_ids.push(node.id); - fork_info.push(last_fork.clone()); + fork_info.push(last_fork.take()); } - "user" => { + "user" => { let is_initial = user_turns_seen == 0; user_turns_seen += 1; pending_tools.clear(); @@ -2585,7 +2587,7 @@ fn render_tree_path( tools: Vec::new(), }); node_ids.push(node.id); - fork_info.push(last_fork.clone()); + fork_info.push(last_fork.take()); } _ => continue, }