[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).
This commit is contained in:
@@ -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<TabStripActionContainer>(
|
||||
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
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
#include "base/feature_override.h"
|
||||
|
||||
#define kGlicActorUiTaskIcon kGlicActorUiTaskIcon_ChromiumImpl
|
||||
#include <chrome/common/chrome_features.cc>
|
||||
#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<bool> kGlicActorUiTaskIcon{
|
||||
&kGlicActorUi, kGlicActorUiTaskIconName, false};
|
||||
|
||||
} // namespace features
|
||||
|
||||
Reference in New Issue
Block a user