fix: respect duoFeaturesEnabled setting for Duo Chat actions
Description
This sends a resource_id
for the following AI Actions:
- Sending a slash command, via the dropdown menu or otherwise.
-
/generate
,/refactor
,/explain
.
-
- Writing in the chat directly.
- Clearing the chat.
This inclusion of this field ensures that Duo features respect project settings - the backend will automatically reject the action if the current project has Duo disabled.
The resourceId
is set to the GqlId property of the current project, if one exists. If not, it is set to null
.
See #1360 (closed) for more info.
TODOs:
- [n/a] dig into how the platform is synced - aka will
project.gqlId
always be up-to-date in the platform manager. -
validate error handling behavior. -
Update the code to always send resourceId
when it exists. -
Add more tests - gitlab_chat_api.ts
andget_platform_manager_for_chat.ts
Related Issues
issue: #1360 (closed)
How has this been tested?
- Create a personal project (e.g.
https://gitlab.com/tristan.read/mock-token-server
) - Check out the project locally.
- Open graphql explorer: https://gitlab.com/-/graphql-explorer
- Disable AI features with the a mutation, e.g:
mutation toggle_duo {
projectSettingsUpdate(input:{
fullPath: "tristan.read/mock-token-server",
duoFeaturesEnabled: true
})
{
errors
projectSettings {
duoFeaturesEnabled
}
}
}
- Run the test extension host using the changes in this branch.
- Open the repo you created above in the test extension host.
- Select some code and try a Duo action, such as "Explain selected code" .
Expected Behavior: The action should fail with an error.
Optional extra: Test with a non-project workspace (aka not a git repository) and confirm AI actions work there.
Screenshots (if appropriate)
before | after |
---|---|
ai_features_enabled | ai_features_disabled |
What CHANGELOG entry will this MR create?
-
fix:
Bug fix fixes - a user-facing issue in production - included in changelog -
feature:
New feature - a user-facing change which adds functionality - included in changelog -
BREAKING CHANGE:
(fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog -
None - other non-user-facing changes
Edited by Tristan Read