From 6313441a55c9ebec0e892d439aa64278fa655510 Mon Sep 17 00:00:00 2001 From: Sampson Date: Tue, 10 Dec 2024 19:05:46 -0600 Subject: [PATCH] add CHECK guardrail and a cleaner conditional --- components/ai_chat/renderer/page_text_distilling.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/ai_chat/renderer/page_text_distilling.cc b/components/ai_chat/renderer/page_text_distilling.cc index 2916e2d4dad5..705195e8dc9b 100644 --- a/components/ai_chat/renderer/page_text_distilling.cc +++ b/components/ai_chat/renderer/page_text_distilling.cc @@ -231,7 +231,7 @@ void DistillPageTextViaSiteScript( std::string_view script_content, int32_t world_id, base::OnceCallback&)> callback) { - CHECK(ai_chat::features::IsCustomSiteDistillerScriptsEnabled()); + CHECK(ai_chat::features::IsCustomSiteDistillerScriptsEnabled()); // TODO (jonathansampson): Wrap scripts at build/transpile-time instead std::string script = absl::StrFormat( R"((()=> { @@ -248,10 +248,9 @@ void DistillPageTextViaSiteScript( std::optional value, base::TimeTicks start_time) { if (value && value->is_string() && !value->GetString().empty()) { std::move(callback).Run(value->GetString()); - return; + } else { + std::move(callback).Run({}); } - - std::move(callback).Run({}); }; // Execute the combined script as a single source