From 3dcdad4c8a5cf62f83ca4f893fc7f0c4d3d086bc Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Sat, 16 May 2026 13:35:23 -0700 Subject: [PATCH] [AI Chat] Disable chromium Actor UI Task Button (#36499) * [AI Chat] Disable chromium Actor UI Task Button When an actor framework task is invoked, the button shows due to kGlicActorUiTaskIcon being true. Interacting with this button causes a crash. First we will disable the button entirely, via this PR. Then we will bring the functionality either in a custom Brave button and menu, or fix the upstream one. Tests Guards the kGlicActorUiTaskIcon=false override in chromium_src/chrome/ common/chrome_features.cc against regressions: while the agent profile window is executing a task, neither the toolbar nor the tab strip action container should construct the upstream GlicAndActorButtonsContainer (which has been the source of crashes). --- .../ai_chat_conversation_task_browsertest.cc | 56 +++++++++++++++++++ chromium_src/chrome/common/chrome_features.cc | 8 +++ 2 files changed, 64 insertions(+) diff --git a/browser/ai_chat/ai_chat_conversation_task_browsertest.cc b/browser/ai_chat/ai_chat_conversation_task_browsertest.cc index 8e0c82c9ddf..4029fe186ae 100644 --- a/browser/ai_chat/ai_chat_conversation_task_browsertest.cc +++ b/browser/ai_chat/ai_chat_conversation_task_browsertest.cc @@ -34,6 +34,11 @@ #include "chrome/browser/glic/actor/glic_actor_policy_checker.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_element_identifiers.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/interaction/browser_elements_views.h" +#include "chrome/browser/ui/views/tabs/tab_strip_action_container.h" +#include "chrome/browser/ui/views/toolbar/toolbar_view.h" #include "components/grit/brave_components_strings.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h" @@ -613,6 +618,57 @@ IN_PROC_BROWSER_TEST_F(AIChatConversationTaskBrowserTest, TaskUI) { complete_label)); } +// Verify that the upstream GlicAndActorButtonsContainer is not constructed in +// either the toolbar or the tab strip of a window that is executing a task. +// The container has been the source of crashes; Brave disables it by +// overriding the `kGlicActorUiTaskIcon` feature param to false (see +// chromium_src/chrome/common/chrome_features.cc). This test guards against +// regressions of that override. +IN_PROC_BROWSER_TEST_F(AIChatConversationTaskBrowserTest, + NoUpstreamGlicAndActorButtonsContainer) { + CreateConversationWithMockEngine(); + std::string uuid = conversation_handler_->get_conversation_uuid(); + NavigateToConversationUI(uuid); + + // Drive the conversation into a running task state via a tool use event. + { + auto generate_future = SetupMockGenerateAssistantResponse(); + conversation_handler_->SubmitHumanConversationEntry( + "Navigate to example.com", std::nullopt); + auto callbacks = generate_future->Take(); + GURL test_url = embedded_https_test_server().GetURL("/actor/link.html"); + callbacks.data_callback.Run(EngineConsumer::GenerationResultData( + mojom::ConversationEntryEvent::NewToolUseEvent( + CreateNavigateToolUseEvent("tool_id_1", test_url)), + std::nullopt)); + std::move(callbacks.completed_callback) + .Run(base::ok( + EngineConsumer::GenerationResultData(nullptr, std::nullopt))); + } + ASSERT_TRUE(base::test::RunUntil([this]() { + return GetConversationState()->tool_use_task_state == + mojom::TaskState::kRunning; + })); + + // The toolbar must not contain the upstream glic actor task icon. + BrowserView* agent_browser_view = + BrowserView::GetBrowserViewForBrowser(agent_browser_window_); + ASSERT_TRUE(agent_browser_view); + EXPECT_EQ(agent_browser_view->toolbar()->glic_actor_task_icon(), nullptr); + + // The tab strip's action container must not contain the upstream glic actor + // button container. The container itself may be absent depending on the + // window's tab strip configuration; if so, there is nothing to verify. + auto* tab_strip_action_container = + BrowserElementsViews::From(agent_browser_window_) + ->GetViewAs( + kTabStripActionContainerElementId); + if (tab_strip_action_container) { + EXPECT_EQ(tab_strip_action_container->glic_actor_button_container(), + nullptr); + } +} + #endif // BUILDFLAG(ENABLE_BRAVE_AI_CHAT_AGENT_PROFILE) } // namespace ai_chat diff --git a/chromium_src/chrome/common/chrome_features.cc b/chromium_src/chrome/common/chrome_features.cc index a9646700b0f..e99d18934e1 100644 --- a/chromium_src/chrome/common/chrome_features.cc +++ b/chromium_src/chrome/common/chrome_features.cc @@ -7,7 +7,9 @@ #include "base/feature_override.h" +#define kGlicActorUiTaskIcon kGlicActorUiTaskIcon_ChromiumImpl #include +#undef kGlicActorUiTaskIcon namespace features { @@ -23,4 +25,10 @@ OVERRIDE_FEATURE_DEFAULT_STATES({{ #endif }}); +// Disable this feature because we it includes google-specific branding and +// causes a crash when interacted with. Brave will make its own version, or +// fix the Chromium version and remove this feature override. +const base::FeatureParam kGlicActorUiTaskIcon{ + &kGlicActorUi, kGlicActorUiTaskIconName, false}; + } // namespace features