From 4756a3852dbfd7af495a19ba18a31af3e2fc847e Mon Sep 17 00:00:00 2001 From: Serg Date: Wed, 11 Sep 2024 09:47:16 -0400 Subject: [PATCH] Fixes browser tests --- browser/ui/webui/ai_chat/ai_chat_ui.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/browser/ui/webui/ai_chat/ai_chat_ui.cc b/browser/ui/webui/ai_chat/ai_chat_ui.cc index 28ed4663db38..a87d728cf9a2 100644 --- a/browser/ui/webui/ai_chat/ai_chat_ui.cc +++ b/browser/ui/webui/ai_chat/ai_chat_ui.cc @@ -94,11 +94,16 @@ AIChatUI::AIChatUI(content::WebUI* web_ui) #endif untrusted_source->AddBoolean("isMobile", kIsMobile); - ai_chat::AIChatTabHelper* active_chat_tab_helper = - ai_chat::AIChatTabHelper::FromWebContents(GetChatWebContents()); - untrusted_source->AddBoolean( - "hasInitialHistory", - active_chat_tab_helper->GetVisibleConversationHistory().size() != 0); + content::WebContents* chat_web_contents = GetChatWebContents(); + size_t visible_conversation_history_size = 0; + if (chat_web_contents) { + ai_chat::AIChatTabHelper* active_chat_tab_helper = + ai_chat::AIChatTabHelper::FromWebContents(chat_web_contents); + visible_conversation_history_size = + active_chat_tab_helper->GetVisibleConversationHistory().size(); + } + untrusted_source->AddBoolean("hasInitialHistory", + visible_conversation_history_size != 0); untrusted_source->AddBoolean( "hasUserDismissedPremiumPrompt",