From 66351bea6ce0495c5c299761810c540ffbd013e2 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Mon, 29 Dec 2025 12:32:22 +0200 Subject: [PATCH] fix: reset turn UI states on expansion preference change to ensure consistency --- packages/ui/src/components/chat/hooks/useTurnGrouping.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/ui/src/components/chat/hooks/useTurnGrouping.ts b/packages/ui/src/components/chat/hooks/useTurnGrouping.ts index 521c3e0f..17e21dd9 100644 --- a/packages/ui/src/components/chat/hooks/useTurnGrouping.ts +++ b/packages/ui/src/components/chat/hooks/useTurnGrouping.ts @@ -412,6 +412,12 @@ export const useTurnGrouping = (messages: ChatMessageEntry[]): UseTurnGroupingRe const toolCallExpansion = useUIStore((state) => state.toolCallExpansion); // Activity group is expanded for 'activity' and 'detailed', collapsed for 'collapsed' const defaultActivityExpanded = toolCallExpansion === 'activity' || toolCallExpansion === 'detailed'; + + // Reset turn UI states when the expansion preference changes + // This ensures the setting takes precedence over manual toggles + React.useEffect(() => { + setTurnUiStates(new Map()); + }, [toolCallExpansion]); const getOrCreateTurnState = React.useCallback( (turnId: string): TurnUiState => {