Skip to content

Commit

Permalink
[history-embeddings] Removes redundant feature check
Browse files Browse the repository at this point in the history
The answers feature check in the history WebUI controller can be
safely removed, because #1 answers may be disabled for the profile
even if the answers feature itself is enabled. and chromium#2 when the
feature is disabled, the answer mojom fields fall back to default
values with the exception of the answer text which should be empty.

Bug: 381108241
Change-Id: I2c7bcd3bd38aab64263103cbea923ac1d25ad75a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6116038
Commit-Queue: Moe Ahmadi <[email protected]>
Reviewed-by: John Lee <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1400350}
  • Loading branch information
Moe Ahmadi authored and Chromium LUCI CQ committed Dec 26, 2024
1 parent 6b1edb4 commit 9109830
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,9 @@ void HistoryEmbeddingsHandler::PublishResultToPage(

auto mojom_search_result = history_embeddings::mojom::SearchResult::New();
mojom_search_result->query = native_search_result.query;

bool has_answer = false;
if (history_embeddings::IsHistoryEmbeddingsAnswersFeatureEnabled()) {
mojom_search_result->answer_status = AnswererAnswerStatusToMojoAnswerStatus(
native_search_result.answerer_result.status);
if (!native_search_result.AnswerText().empty()) {
has_answer = true;
mojom_search_result->answer = native_search_result.AnswerText();
}
}
mojom_search_result->answer_status = AnswererAnswerStatusToMojoAnswerStatus(
native_search_result.answerer_result.status);
mojom_search_result->answer = native_search_result.AnswerText();

for (size_t i = 0; i < native_search_result.scored_url_rows.size(); i++) {
const history_embeddings::ScoredUrlRow& scored_url_row =
Expand All @@ -147,7 +140,8 @@ void HistoryEmbeddingsHandler::PublishResultToPage(
base::UTF16ToUTF8(history_clusters::ComputeURLForDisplay(
scored_url_row.row.url(), history_embeddings::GetFeatureParameters()
.trim_after_host_in_results));
if (has_answer && i == native_search_result.AnswerIndex()) {
if (!native_search_result.AnswerText().empty() &&
i == native_search_result.AnswerIndex()) {
item->answer_data = history_embeddings::mojom::AnswerData::New();
item->answer_data->answer_text_directives.assign(
native_search_result.answerer_result.text_directives.begin(),
Expand Down

0 comments on commit 9109830

Please sign in to comment.