From 588f08d1fc31687758fc86552d78b5a7a9f7713a Mon Sep 17 00:00:00 2001 From: Mark Chao Date: Fri, 5 Sep 2025 10:37:01 +0800 Subject: [PATCH] Show Duo Chat regardless of project/group presence --- app/views/layouts/_page.html.haml | 2 +- app/views/layouts/nav/_top_bar.html.haml | 2 +- ee/lib/gitlab/llm/tanuki_bot.rb | 4 ++-- ee/spec/lib/gitlab/llm/tanuki_bot_spec.rb | 21 ++++++------------- .../16_ai_powered/duo_chat/duo_chat_spec.rb | 2 -- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index 655153807fa900..993c834c7d61bb 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -10,7 +10,7 @@ - sidebar_data = super_sidebar_context(current_user, group: group, project: @project, panel: sidebar_panel, panel_type: nav).to_json %aside.js-super-sidebar.super-sidebar.super-sidebar-loading{ data: { root_path: root_path, sidebar: sidebar_data, force_desktop_expanded_sidebar: @force_desktop_expanded_sidebar.to_s, command_palette: command_palette_data(project: @project, current_ref: current_ref).to_json, is_saas: Gitlab.com?.to_s } } - = render_if_exists "layouts/tanuki_bot_chat" if context + = render_if_exists "layouts/tanuki_bot_chat" = render_if_exists "layouts/session_expire_modal" - if project_studio_enabled? diff --git a/app/views/layouts/nav/_top_bar.html.haml b/app/views/layouts/nav/_top_bar.html.haml index 927d112e53d3c9..562590ed54558b 100644 --- a/app/views/layouts/nav/_top_bar.html.haml +++ b/app/views/layouts/nav/_top_bar.html.haml @@ -1,4 +1,4 @@ -- duo_button_enabled = (partial_exists? "layouts/nav/ask_duo_button") && ::Gitlab::Llm::TanukiBot.show_breadcrumbs_entry_point?(user: current_user, container: @group || @project) +- duo_button_enabled = (partial_exists? "layouts/nav/ask_duo_button") && ::Gitlab::Llm::TanukiBot.show_breadcrumbs_entry_point?(user: current_user) %div{ class: ['top-bar-fixed container-fluid', paneled_view && 'gl-rounded-t-lg gl-sticky gl-top-0 gl-left-0 gl-mx-0 gl-w-full'], data: { testid: 'top-bar' } } .top-bar-container.gl-flex.gl-items-center.gl-gap-2{ class: ("gl-group top-bar-duo-button-present" if duo_button_enabled) } diff --git a/ee/lib/gitlab/llm/tanuki_bot.rb b/ee/lib/gitlab/llm/tanuki_bot.rb index 0870efb950d665..28121281d3c03c 100644 --- a/ee/lib/gitlab/llm/tanuki_bot.rb +++ b/ee/lib/gitlab/llm/tanuki_bot.rb @@ -25,8 +25,8 @@ def self.agentic_mode_available?(user:, project:, group:) end end - def self.show_breadcrumbs_entry_point?(user:, container: nil) - return false unless chat_enabled?(user) && container + def self.show_breadcrumbs_entry_point?(user:) + return false unless chat_enabled?(user) Gitlab::Llm::Chain::Utils::ChatAuthorizer.user(user: user).allowed? end diff --git a/ee/spec/lib/gitlab/llm/tanuki_bot_spec.rb b/ee/spec/lib/gitlab/llm/tanuki_bot_spec.rb index 30610edc2cec04..2e2ae8883406a0 100644 --- a/ee/spec/lib/gitlab/llm/tanuki_bot_spec.rb +++ b/ee/spec/lib/gitlab/llm/tanuki_bot_spec.rb @@ -158,7 +158,6 @@ describe '.show_breadcrumbs_entry_point' do let(:authorizer_response) { instance_double(Gitlab::Llm::Utils::Authorizer::Response, allowed?: allowed) } - let(:allowed) { true } before do allow(described_class).to receive(:chat_enabled?).with(user) @@ -167,26 +166,18 @@ .and_return(authorizer_response) end - where(:container, :ai_features_enabled_for_user, :allowed, :duo_chat_access) do + where(:ai_features_enabled_for_user, :allowed, :duo_chat_access) do [ - [:project, true, true, true], - [:project, true, false, false], - [:project, false, false, false], - [:project, false, true, false], - [:group, true, true, true], - [:group, true, false, false], - [:group, false, false, false], - [:group, false, true, false], - [nil, true, true, false], - [nil, true, false, false], - [nil, false, false, false], - [nil, false, true, false] + [true, true, true], + [true, false, false], + [false, true, false], + [false, false, false] ] end with_them do it 'shows button in correct cases' do - expect(described_class.show_breadcrumbs_entry_point?(user: user, container: container)).to be(duo_chat_access) + expect(described_class.show_breadcrumbs_entry_point?(user: user)).to be(duo_chat_access) end end end diff --git a/qa/qa/specs/features/ee/browser_ui/16_ai_powered/duo_chat/duo_chat_spec.rb b/qa/qa/specs/features/ee/browser_ui/16_ai_powered/duo_chat/duo_chat_spec.rb index 286645c74574fd..f2ce832c2c5e58 100644 --- a/qa/qa/specs/features/ee/browser_ui/16_ai_powered/duo_chat/duo_chat_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/16_ai_powered/duo_chat/duo_chat_spec.rb @@ -7,7 +7,6 @@ module QA let(:user) { Runtime::User::Store.test_user } let(:api_client) { Runtime::User::Store.default_api_client } let(:token) { api_client.personal_access_token } - let(:project) { create(:project, name: 'duo-chat-project', api_client: api_client) } shared_examples 'Duo Chat' do |testcase| it 'a valid response is returned', testcase: testcase do @@ -30,7 +29,6 @@ module QA before do Flow::Login.sign_in(as: user) - project.visit! end context "when asking 'hi'" do -- GitLab