diff --git a/.changeset/collapsible-reasoning-heading.md b/.changeset/collapsible-reasoning-heading.md new file mode 100644 index 000000000..4135d9f09 --- /dev/null +++ b/.changeset/collapsible-reasoning-heading.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Assistant: the "Explored briefly" activity heading no longer appears when there's nothing to show. It now renders only when the answer is preceded by a real preamble or one or more tool calls, so a simple answer with an empty reasoning step no longer surfaces an empty collapsible. diff --git a/packages/gitbook/src/components/AI/useAIChat.tsx b/packages/gitbook/src/components/AI/useAIChat.tsx index 9ca8bb5a8..94a1b4a9d 100644 --- a/packages/gitbook/src/components/AI/useAIChat.tsx +++ b/packages/gitbook/src/components/AI/useAIChat.tsx @@ -863,12 +863,22 @@ function updateAIChatMessageActivity( return { ...activity, currentPhase: event.phase, - hasCommentary: - activity.hasCommentary || event.phase === AIMessageStepPhase.Commentary, hasFinalAnswer: activity.hasFinalAnswer || event.phase === AIMessageStepPhase.FinalAnswer, }; } + case 'response_document': { + // A commentary phase can start without ever producing anything visible. Only a + // commentary step that emits document content is a real preamble worth collapsing + // behind the activity heading, so flag it here rather than on phase start. + return { + ...activity, + hasCommentary: + activity.hasCommentary || + (activity.currentPhase === AIMessageStepPhase.Commentary && + event.blocks.length > 0), + }; + } case 'response_tool_call': { return { ...activity,