diff --git a/ee/config/feature_flags/gitlab_com_derisk/ci_editor_tool_removed.yml b/ee/config/feature_flags/gitlab_com_derisk/ci_editor_tool_removed.yml new file mode 100644 index 0000000000000000000000000000000000000000..2f5302e62026dff0a327644faab79529959e83dd --- /dev/null +++ b/ee/config/feature_flags/gitlab_com_derisk/ci_editor_tool_removed.yml @@ -0,0 +1,9 @@ +--- +name: ci_editor_tool_removed +feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/495684 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/171017 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501273 +milestone: '17.6' +group: group::duo chat +type: gitlab_com_derisk +default_enabled: false diff --git a/ee/lib/gitlab/llm/completions/chat.rb b/ee/lib/gitlab/llm/completions/chat.rb index e44051623ed0bd6c45e584a5ed208835e3a5b3aa..e5e396be18ca2f59ae001da30fb0c8528633f906 100644 --- a/ee/lib/gitlab/llm/completions/chat.rb +++ b/ee/lib/gitlab/llm/completions/chat.rb @@ -178,6 +178,10 @@ def push_feature_flags Gitlab::AiGateway.push_feature_flag(:ai_commit_reader_for_chat, user) Gitlab::AiGateway.push_feature_flag(:expanded_ai_logging, user) Gitlab::AiGateway.push_feature_flag(:ai_build_reader_for_chat, user) + + return unless Feature.enabled?(:ci_editor_tool_removed, user) + + Gitlab::AiGateway.push_feature_flag(:ci_editor_tool_removed, user) end end end diff --git a/ee/spec/lib/gitlab/llm/completions/chat_spec.rb b/ee/spec/lib/gitlab/llm/completions/chat_spec.rb index 241fa782013063a3c05130322e5137e189b4a826..06d84ec2948dfd591666f4d5427d4f4b1af89443 100644 --- a/ee/spec/lib/gitlab/llm/completions/chat_spec.rb +++ b/ee/spec/lib/gitlab/llm/completions/chat_spec.rb @@ -218,6 +218,10 @@ stub_saas_features(duo_chat_categorize_question: true) stub_feature_flags(ai_commit_reader_for_chat: false) stub_feature_flags(ai_build_reader_for_chat: false) + # This flag is used only on AI Gateway and we need to stub it to + # prevent Rubocop from marking this flag as unused + # and raising an error + stub_feature_flags(ci_editor_tool_removed: false) end context 'when resource is an issue' do @@ -338,6 +342,25 @@ end end + context 'with ci editor toll disabled' do + before do + stub_feature_flags(ci_editor_tool_removed: true) + allow(ai_request).to receive(:request) + allow(::Gitlab::AiGateway).to receive(:push_feature_flag) + end + + it 'pushes feature flag to AI Gateway' do + allow_next_instance_of(::Gitlab::Duo::Chat::ReactExecutor) do |instance| + allow(instance).to receive(:execute).and_return(answer) + end + + expect(::Gitlab::AiGateway).to receive(:push_feature_flag) + .with(:ci_editor_tool_removed, user).and_return(:ci_editor_tool_removed) + + subject + end + end + context 'when message is a slash command' do shared_examples_for 'slash command execution' do let(:executor) { instance_double(Gitlab::Llm::Chain::Tools::ExplainCode::Executor) }