Add Ai::FileAttachments.allowed? to workflow_type and duo_chat_data
What does this MR do and why?
Updates the workflow_type file_attachments_allowed and duo_chat_data methods to return the new ::Ai::FileAttachments.allowed?
workflow_type should work the same as it does today for .com (only respect feature flag), on SM it should now return the new duo_workflow_file_attachments_enabled instance level setting added in !268881 (merged).
Currently, nothing consumes the value added to duo_chat_data, but the frontend will use this to apply the same logic to the icon display !269284 (merged).
The .com route will be fixed with !269571, but was removed from this MR to allow it to be merged before the API and UI changes are applied to the group settings, this was done as this MR is blocking several others.
References
Admin setting issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/633198
File upload epic: &20481
Database
A single new query was added to retrieve the instance settings, and the same request ::Ai::Setting.for_current_or_default_organization appears several times in the rest of the code base already
SELECT
"ai_settings"."id",
"ai_settings"."created_at",
"ai_settings"."updated_at",
"ai_settings"."amazon_q_oauth_application_id",
"ai_settings"."amazon_q_service_account_user_id",
"ai_settings"."amazon_q_ready",
"ai_settings"."amazon_q_role_arn",
"ai_settings"."duo_workflow_service_account_user_id",
"ai_settings"."duo_workflow_oauth_application_id",
"ai_settings"."duo_core_features_enabled",
"ai_settings"."foundational_agents_default_enabled",
"ai_settings"."minimum_access_level_execute",
"ai_settings"."minimum_access_level_manage",
"ai_settings"."minimum_access_level_enable_on_projects",
"ai_settings"."minimum_access_level_execute_async",
"ai_settings"."feature_settings",
"ai_settings"."include_recommended_allowed",
"ai_settings"."allow_all_unix_sockets",
"ai_settings"."enforce_on_local_clients",
"ai_settings"."allow_project_extension",
"ai_settings"."allowed_domains",
"ai_settings"."denied_domains",
"ai_settings"."organization_id",
"ai_settings"."require_sandbox"
FROM
"ai_settings"
WHERE
"ai_settings"."organization_id" = 1
LIMIT 1https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/85104/commands/192037
How to set up and validate locally
Workflow query
query {
duoWorkflowWorkflows(last: 1) {
nodes {
id
projectId
namespaceId
fileAttachmentsAllowed
}
}
}Browser console test:
const html = await (await fetch(location.href)).text();
const panel = new DOMParser().parseFromString(html, 'text/html').querySelector('#duo-chat-panel');
panel.dataset.fileAttachmentsAllowed- In SM
GITLAB_SIMULATE_SAAS: '0'ingdk.ymlgdk reconfigure; gdk restart
- In
gdk rails cenable the feature flagFeature.enable(:dap_web_chat_file_attachments)
- Start an agentic chat by sending any message
- Open graphql-explorer http://gdk.test:8080/-/graphql-explorer and the Workflow query (should return false)
- In the browser console run the Browser console test, it should return false
- In
gdk rails crunAi::Setting.for_organization(Organizations::Organization.default_organization).update!(duo_workflow_file_attachments_enabled: true)
- Run the GraphQL again, and it should return true
- Run the browser console test again, it should return true
- In SaaS
GITLAB_SIMULATE_SAAS: '1'ingdk.ymlgdk reconfigure; gdk restart
- run the query and the browser test again, it should return true
- In
gdk rails cdisable the flag and wait a minuteFeature.disable(:dap_web_chat_file_attachments)
- run the query and the browser test again, it should return false
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.