Skip to content

Commit

Permalink
add brave-ai-chat-sidebar-page-context flag
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed Dec 19, 2024
1 parent 90918ed commit 2a17b1e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@
"Enables opening Leo AI Chat from Brave Search", \
kOsDesktop | kOsAndroid, \
FEATURE_VALUE_TYPE(ai_chat::features::kOpenAIChatFromBraveSearch), \
}, \
{ \
"brave-ai-chat-sidebar-page-context", \
"Brave AI Chat Page Context", \
"Use page context to improve AI chat responses in the sidebar", \
kOsWin | kOsMac | kOsLinux | kOsAndroid, \
FEATURE_VALUE_TYPE(ai_chat::features::kSidebarUsePageContext), \
})

#if BUILDFLAG(ENABLE_AI_REWRITER)
Expand Down
4 changes: 2 additions & 2 deletions components/ai_chat/core/browser/conversation_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void ConversationHandler::SetArchiveContent(std::string text_content,
is_video);
associated_content_delegate_ = archive_content->GetWeakPtr();
archive_content_ = std::move(archive_content);
should_send_page_contents_ = true;
should_send_page_contents_ = features::IsSidebarUsePageContextEnabled();
}

void ConversationHandler::SetAssociatedContentDelegate(
Expand Down Expand Up @@ -465,7 +465,7 @@ void ConversationHandler::SetAssociatedContentDelegate(
// This class should only be provided with a delegate when
// it is allowed to use it (e.g. not internal WebUI content).
// The user can toggle this via the UI.
should_send_page_contents_ = true;
should_send_page_contents_ = features::IsSidebarUsePageContextEnabled();

MaybeSeedOrClearSuggestions();
MaybeFetchOrClearContentStagedConversation();
Expand Down
8 changes: 8 additions & 0 deletions components/ai_chat/core/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ bool IsOpenAIChatFromBraveSearchEnabled() {
return base::FeatureList::IsEnabled(features::kOpenAIChatFromBraveSearch);
}

BASE_FEATURE(kSidebarUsePageContext,
"SidebarUsePageContext",
base::FEATURE_ENABLED_BY_DEFAULT);

bool IsSidebarUsePageContextEnabled() {
return base::FeatureList::IsEnabled(features::kSidebarUsePageContext);
}

} // namespace ai_chat::features
6 changes: 5 additions & 1 deletion components/ai_chat/core/common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ COMPONENT_EXPORT(AI_CHAT_COMMON)
BASE_DECLARE_FEATURE(kOpenAIChatFromBraveSearch);
COMPONENT_EXPORT(AI_CHAT_COMMON) bool IsOpenAIChatFromBraveSearchEnabled();

COMPONENT_EXPORT(AI_CHAT_COMMON)
BASE_DECLARE_FEATURE(kSidebarUsePageContext);
COMPONENT_EXPORT(AI_CHAT_COMMON) bool IsSidebarUsePageContextEnabled();

} // namespace ai_chat::features

#endif // BRAVE_COMPONENTS_AI_CHAT_CORE_COMMON_FEATURES_H_
#endif // BRAVE_COMPONENTS_AI_CHAT_CORE_COMMON_FEATURES_H_

0 comments on commit 2a17b1e

Please sign in to comment.