From 66e2830efbf0d8e47b514bcb2d7dd211af4d7f41 Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Tue, 12 Nov 2024 15:46:52 +1300 Subject: [PATCH] Changes for PR --- .../core/browser/conversation_handler.cc | 2 +- .../browser/conversation_handler_unittest.cc | 8 ++++--- .../components/suggested_question/index.tsx | 22 +++++++++---------- .../suggested_question/style.module.scss | 10 ++++----- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/components/ai_chat/core/browser/conversation_handler.cc b/components/ai_chat/core/browser/conversation_handler.cc index 8b4847392e89..e2c9bfbb15d3 100644 --- a/components/ai_chat/core/browser/conversation_handler.cc +++ b/components/ai_chat/core/browser/conversation_handler.cc @@ -1069,7 +1069,7 @@ void ConversationHandler::MaybeSeedOrClearSuggestions() { suggestions_.clear(); } - if (is_page_associated && suggestions_.empty() && + if (suggestions_.empty() && suggestion_generation_status_ != mojom::SuggestionGenerationStatus::IsGenerating && suggestion_generation_status_ != diff --git a/components/ai_chat/core/browser/conversation_handler_unittest.cc b/components/ai_chat/core/browser/conversation_handler_unittest.cc index 04fdc9e85fd9..361d86910479 100644 --- a/components/ai_chat/core/browser/conversation_handler_unittest.cc +++ b/components/ai_chat/core/browser/conversation_handler_unittest.cc @@ -17,6 +17,7 @@ #include "base/functional/overloaded.h" #include "base/memory/scoped_refptr.h" #include "base/ranges/algorithm.h" +#include "base/run_loop.h" #include "base/scoped_observation.h" #include "base/task/sequenced_task_runner.h" #include "base/task/thread_pool.h" @@ -1313,14 +1314,15 @@ TEST_F(ConversationHandlerUnitTest_NoAssociatedContent, MockEngineConsumer* engine = static_cast( conversation_handler_->GetEngineForTesting()); + base::RunLoop loop; // The prompt should be submitted to the engine, not the title. EXPECT_CALL(*engine, GenerateAssistantResponse(false, StrEq(""), _, "do the thing!", - StrEq(""), _, _)); + StrEq(""), _, _)) + .WillOnce(testing::InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); - testing::Sequence s; conversation_handler_->SubmitHumanConversationEntry("the thing"); - task_environment_.RunUntilIdle(); + loop.Run(); testing::Mock::VerifyAndClearExpectations(engine); // Suggestion should be removed diff --git a/components/ai_chat/resources/page/components/suggested_question/index.tsx b/components/ai_chat/resources/page/components/suggested_question/index.tsx index 97f7de40d32d..52bc4ac651c8 100644 --- a/components/ai_chat/resources/page/components/suggested_question/index.tsx +++ b/components/ai_chat/resources/page/components/suggested_question/index.tsx @@ -9,16 +9,16 @@ import { useConversation } from "../../state/conversation_context"; import styles from './style.module.scss' export default function SuggestedQuestion({ question }: { question: string }) { - const context = useConversation() - const handleQuestionSubmit = (question: string) => { - context.conversationHandler?.submitHumanConversationEntry(question) - } + const context = useConversation() + const handleQuestionSubmit = (question: string) => { + context.conversationHandler?.submitHumanConversationEntry(question) + } - return + return } diff --git a/components/ai_chat/resources/page/components/suggested_question/style.module.scss b/components/ai_chat/resources/page/components/suggested_question/style.module.scss index c905e6a322b2..8efcb1c4d233 100644 --- a/components/ai_chat/resources/page/components/suggested_question/style.module.scss +++ b/components/ai_chat/resources/page/components/suggested_question/style.module.scss @@ -4,8 +4,8 @@ // You can obtain one at https://mozilla.org/MPL/2.0/. .buttonText { - display: flex; - align-items: flex-start; - text-align: left; - font: var(--leo-font-default-regular); - } + display: flex; + align-items: flex-start; + text-align: left; + font: var(--leo-font-default-regular); +}