@gitlab/duo-ui 10.20.0 → 10.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/chat/components/duo_chat_message_tool_approval/components/create_commit_tool_params.js +148 -0
  3. package/dist/components/chat/components/duo_chat_message_tool_approval/components/create_issue_tool_params.js +88 -0
  4. package/dist/components/chat/components/duo_chat_message_tool_approval/components/create_merge_request_tool_params.js +83 -0
  5. package/dist/components/chat/components/duo_chat_message_tool_approval/components/pre_block.js +38 -0
  6. package/dist/components/chat/components/duo_chat_message_tool_approval/components/run_command_tool_params.js +62 -0
  7. package/dist/components/chat/components/duo_chat_message_tool_approval/message_tool_approval.js +46 -8
  8. package/dist/components/chat/mock_data.js +85 -1
  9. package/dist/tailwind.css +1 -1
  10. package/dist/tailwind.css.map +1 -1
  11. package/dist/utils/object.js +9 -0
  12. package/package.json +4 -4
  13. package/src/components/chat/components/duo_chat_message_tool_approval/components/create_commit_tool_params.vue +155 -0
  14. package/src/components/chat/components/duo_chat_message_tool_approval/components/create_issue_tool_params.vue +80 -0
  15. package/src/components/chat/components/duo_chat_message_tool_approval/components/create_merge_request_tool_params.vue +74 -0
  16. package/src/components/chat/components/duo_chat_message_tool_approval/components/pre_block.vue +5 -0
  17. package/src/components/chat/components/duo_chat_message_tool_approval/components/run_command_tool_params.vue +30 -0
  18. package/src/components/chat/components/duo_chat_message_tool_approval/message_tool_approval.vue +143 -88
  19. package/src/components/chat/mock_data.js +99 -0
  20. package/src/utils/object.js +4 -0
  21. package/translations.js +24 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [10.21.0](https://gitlab.com/gitlab-org/duo-ui/compare/v10.20.0...v10.21.0) (2025-09-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * Improve tool approval dialog UI ([d337427](https://gitlab.com/gitlab-org/duo-ui/commit/d33742757bb358add571ed9b2ae39c5c796b31d5))
7
+
1
8
  # [10.20.0](https://gitlab.com/gitlab-org/duo-ui/compare/v10.19.0...v10.20.0) (2025-09-05)
2
9
 
3
10
 
@@ -0,0 +1,148 @@
1
+ import { GlSprintf, GlAccordion, GlAccordionItem } from '@gitlab/ui';
2
+ import { sprintf, translatePlural, translate } from '../../../../../utils/i18n';
3
+ import PreBlock from './pre_block';
4
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
+
6
+ var script = {
7
+ name: 'CreateCommitToolParams',
8
+ components: {
9
+ GlSprintf,
10
+ GlAccordion,
11
+ GlAccordionItem,
12
+ PreBlock
13
+ },
14
+ props: {
15
+ projectId: {
16
+ type: [String, Number],
17
+ required: true
18
+ },
19
+ projectPath: {
20
+ type: String,
21
+ required: false,
22
+ default: ''
23
+ },
24
+ branch: {
25
+ type: String,
26
+ required: true
27
+ },
28
+ startBranch: {
29
+ type: String,
30
+ required: false,
31
+ default: ''
32
+ },
33
+ commitMessage: {
34
+ type: String,
35
+ required: true
36
+ },
37
+ actions: {
38
+ type: Array,
39
+ required: true
40
+ }
41
+ },
42
+ computed: {
43
+ actionsCount() {
44
+ return this.actions.length;
45
+ },
46
+ actionsCountMessage() {
47
+ return sprintf(translatePlural('CreateCommitToolParams.actionsCountMessage', 'The commit contains %{count} file change.', 'The commit contains %{count} file changes.')(this.actionsCount), {
48
+ count: this.actionsCount
49
+ });
50
+ }
51
+ },
52
+ methods: {
53
+ getActionTitle(_ref) {
54
+ let {
55
+ action,
56
+ file_path: filePath,
57
+ previous_path: previousPath
58
+ } = _ref;
59
+ switch (action) {
60
+ case 'create':
61
+ return sprintf(this.$options.i18n.CREATE_FILE_ACTION_LABEL, {
62
+ filePath
63
+ });
64
+ case 'update':
65
+ return sprintf(this.$options.i18n.UPDATE_FILE_ACTION_LABEL, {
66
+ filePath
67
+ });
68
+ case 'delete':
69
+ return sprintf(this.$options.i18n.DELETE_FILE_ACTION_LABEL, {
70
+ filePath
71
+ });
72
+ case 'move':
73
+ return sprintf(this.$options.i18n.MOVE_FILE_ACTION_LABEL, {
74
+ filePath: previousPath
75
+ });
76
+ case 'chmod':
77
+ return sprintf(this.$options.i18n.CHMOD_FILE_ACTION_LABEL, {
78
+ filePath
79
+ });
80
+ default:
81
+ return sprintf(this.$options.i18n.UNKNOWN_FILE_ACTION_LABEL, {
82
+ filePath
83
+ });
84
+ }
85
+ },
86
+ getActionContent(_ref2) {
87
+ let {
88
+ action,
89
+ content,
90
+ encoding
91
+ } = _ref2;
92
+ if (!['create', 'update'].includes(action)) {
93
+ return this.$options.i18n.ACTION_WITH_NO_CONTENT;
94
+ }
95
+ return (!encoding || encoding === 'text') && content ? content : '';
96
+ }
97
+ },
98
+ i18n: {
99
+ COMMIT_SUMMARY_MESSAGE: translate('CreateCommitToolParams.commitSummaryMessage', 'Create a commit in the branch %{branch} and project %{project}.'),
100
+ READ_COMMIT_MESSAGE: translate('CreateCommitToolParams.readCommitMessage', 'Read commit message'),
101
+ CREATE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.createFileActionLabel', 'Create file %{filePath}'),
102
+ UPDATE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.updateFileActionLabel', 'Update file %{filePath}'),
103
+ DELETE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.deleteFileActionLabel', 'Delete file %{filePath}'),
104
+ MOVE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.moveFileActionLabel', 'Move file %{filePath}'),
105
+ CHMOD_FILE_ACTION_LABEL: translate('CreateCommitToolParams.chmodFileActionLabel', 'Change permissions for file %{filePath}'),
106
+ UNKNOWN_FILE_ACTION_LABEL: translate('CreateCommitToolParams.unknownFileActionLabel', 'Modify file %{filePath}'),
107
+ ACTION_WITH_NO_CONTENT: translate('CreateCommitToolParams.actionWithNoContent', 'This action does not have any content.'),
108
+ EXPAND_CHANGES: translate('CreateCommitToolParams.expandFileChanges', 'Expand file changes')
109
+ }
110
+ };
111
+
112
+ /* script */
113
+ const __vue_script__ = script;
114
+
115
+ /* template */
116
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col"},[_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.$options.i18n.COMMIT_SUMMARY_MESSAGE},scopedSlots:_vm._u([{key:"project",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.projectPath || _vm.projectId))])]},proxy:true},{key:"branch",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.branch))])]},proxy:true}])}),_vm._v("\n "+_vm._s(_vm.actionsCountMessage)+"\n ")],1),_vm._v(" "),_c('gl-accordion',{staticClass:"-gl-ml-2 gl-mt-3",attrs:{"header-level":3}},[_c('gl-accordion-item',{attrs:{"title":_vm.$options.i18n.READ_COMMIT_MESSAGE}},[_c('pre-block',[_vm._v(_vm._s(_vm.commitMessage))])],1),_vm._v(" "),_c('gl-accordion-item',{attrs:{"title":_vm.$options.i18n.EXPAND_CHANGES}},[_c('gl-accordion',{attrs:{"header-level":4}},_vm._l((_vm.actions),function(action,index){return _c('gl-accordion-item',{key:index,attrs:{"title":_vm.getActionTitle(action)}},[_c('pre-block',[_vm._v(_vm._s(_vm.getActionContent(action)))])],1)}),1)],1)],1)],1)};
117
+ var __vue_staticRenderFns__ = [];
118
+
119
+ /* style */
120
+ const __vue_inject_styles__ = undefined;
121
+ /* scoped */
122
+ const __vue_scope_id__ = undefined;
123
+ /* module identifier */
124
+ const __vue_module_identifier__ = undefined;
125
+ /* functional template */
126
+ const __vue_is_functional_template__ = false;
127
+ /* style inject */
128
+
129
+ /* style inject SSR */
130
+
131
+ /* style inject shadow dom */
132
+
133
+
134
+
135
+ const __vue_component__ = __vue_normalize__(
136
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
137
+ __vue_inject_styles__,
138
+ __vue_script__,
139
+ __vue_scope_id__,
140
+ __vue_is_functional_template__,
141
+ __vue_module_identifier__,
142
+ false,
143
+ undefined,
144
+ undefined,
145
+ undefined
146
+ );
147
+
148
+ export default __vue_component__;
@@ -0,0 +1,88 @@
1
+ import { GlSprintf, GlAccordion, GlAccordionItem } from '@gitlab/ui';
2
+ import { translate } from '../../../../../utils/i18n';
3
+ import PreBlock from './pre_block';
4
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
+
6
+ var script = {
7
+ name: 'CreateIssueToolParams',
8
+ components: {
9
+ GlSprintf,
10
+ GlAccordion,
11
+ GlAccordionItem,
12
+ PreBlock
13
+ },
14
+ props: {
15
+ projectId: {
16
+ type: [String, Number],
17
+ required: true
18
+ },
19
+ projectPath: {
20
+ type: String,
21
+ required: false,
22
+ default: ''
23
+ },
24
+ title: {
25
+ type: String,
26
+ required: true
27
+ },
28
+ description: {
29
+ type: String,
30
+ required: true
31
+ },
32
+ labels: {
33
+ type: String,
34
+ required: false,
35
+ default: ''
36
+ }
37
+ },
38
+ computed: {
39
+ issueMessage() {
40
+ const baseMessage = this.$options.i18n.ISSUE_SUMMARY_MESSAGE_BASE;
41
+ const labelsMessage = this.$options.i18n.ISSUE_SUMMARY_MESSAGE_WITH_LABELS;
42
+ return this.labels ? `${baseMessage} ${labelsMessage}` : baseMessage;
43
+ }
44
+ },
45
+ i18n: {
46
+ ISSUE_SUMMARY_MESSAGE_BASE: translate('CreateIssueToolParams.ISSUE_SUMMARY_MESSAGE_BASE', 'Open an issue with title "%{title}" in project %{project}.'),
47
+ ISSUE_SUMMARY_MESSAGE_WITH_LABELS: translate('CreateIssueToolParams.ISSUE_SUMMARY_MESSAGE_WITH_LABELS', 'Assign the labels %{labels}.'),
48
+ ACCORDION_TITLE: translate('CreateIssueToolParams.ACCORDION_TITLE', 'Read description')
49
+ }
50
+ };
51
+
52
+ /* script */
53
+ const __vue_script__ = script;
54
+
55
+ /* template */
56
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col"},[_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.issueMessage},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('em',[_vm._v(_vm._s(_vm.title))])]},proxy:true},{key:"project",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.projectPath || _vm.projectId))])]},proxy:true},{key:"labels",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.labels))])]},proxy:true}])})],1),_vm._v(" "),_c('gl-accordion',{staticClass:"-gl-ml-2 gl-mt-3",attrs:{"header-level":3}},[_c('gl-accordion-item',{attrs:{"title":_vm.$options.i18n.ACCORDION_TITLE}},[_c('pre-block',[_vm._v(_vm._s(_vm.description))])],1)],1)],1)};
57
+ var __vue_staticRenderFns__ = [];
58
+
59
+ /* style */
60
+ const __vue_inject_styles__ = undefined;
61
+ /* scoped */
62
+ const __vue_scope_id__ = undefined;
63
+ /* module identifier */
64
+ const __vue_module_identifier__ = undefined;
65
+ /* functional template */
66
+ const __vue_is_functional_template__ = false;
67
+ /* style inject */
68
+
69
+ /* style inject SSR */
70
+
71
+ /* style inject shadow dom */
72
+
73
+
74
+
75
+ const __vue_component__ = __vue_normalize__(
76
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
77
+ __vue_inject_styles__,
78
+ __vue_script__,
79
+ __vue_scope_id__,
80
+ __vue_is_functional_template__,
81
+ __vue_module_identifier__,
82
+ false,
83
+ undefined,
84
+ undefined,
85
+ undefined
86
+ );
87
+
88
+ export default __vue_component__;
@@ -0,0 +1,83 @@
1
+ import { GlSprintf, GlAccordion, GlAccordionItem } from '@gitlab/ui';
2
+ import { translate } from '../../../../../utils/i18n';
3
+ import PreBlock from './pre_block';
4
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
+
6
+ var script = {
7
+ name: 'CreateMergeRequestToolParams',
8
+ components: {
9
+ GlSprintf,
10
+ GlAccordion,
11
+ GlAccordionItem,
12
+ PreBlock
13
+ },
14
+ props: {
15
+ projectId: {
16
+ type: [String, Number],
17
+ required: true
18
+ },
19
+ projectPath: {
20
+ type: String,
21
+ required: false,
22
+ default: ''
23
+ },
24
+ title: {
25
+ type: String,
26
+ required: true
27
+ },
28
+ sourceBranch: {
29
+ type: String,
30
+ required: true
31
+ },
32
+ targetBranch: {
33
+ type: String,
34
+ required: true
35
+ },
36
+ description: {
37
+ type: String,
38
+ required: true
39
+ }
40
+ },
41
+ i18n: {
42
+ MERGE_REQUEST_SUMMARY_MESSAGE: translate('CreateMergeRequestToolParams.MERGE_REQUEST_SUMMARY_MESSAGE', 'Open a merge request with title "%{title}" in project %{project} from branch %{sourceBranch} to branch %{targetBranch}.'),
43
+ ACCORDION_TITLE: translate('CreateMergeRequestToolParams.ACCORDION_TITLE', 'Read description')
44
+ }
45
+ };
46
+
47
+ /* script */
48
+ const __vue_script__ = script;
49
+
50
+ /* template */
51
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col"},[_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.$options.i18n.MERGE_REQUEST_SUMMARY_MESSAGE},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('em',[_vm._v(_vm._s(_vm.title))])]},proxy:true},{key:"project",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.projectPath || _vm.projectId))])]},proxy:true},{key:"sourceBranch",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.sourceBranch))])]},proxy:true},{key:"targetBranch",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.targetBranch))])]},proxy:true}])})],1),_vm._v(" "),_c('gl-accordion',{staticClass:"-gl-ml-2 gl-mt-3",attrs:{"header-level":3}},[_c('gl-accordion-item',{attrs:{"title":_vm.$options.i18n.ACCORDION_TITLE}},[_c('pre-block',[_vm._v(_vm._s(_vm.description))])],1)],1)],1)};
52
+ var __vue_staticRenderFns__ = [];
53
+
54
+ /* style */
55
+ const __vue_inject_styles__ = undefined;
56
+ /* scoped */
57
+ const __vue_scope_id__ = undefined;
58
+ /* module identifier */
59
+ const __vue_module_identifier__ = undefined;
60
+ /* functional template */
61
+ const __vue_is_functional_template__ = false;
62
+ /* style inject */
63
+
64
+ /* style inject SSR */
65
+
66
+ /* style inject shadow dom */
67
+
68
+
69
+
70
+ const __vue_component__ = __vue_normalize__(
71
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
72
+ __vue_inject_styles__,
73
+ __vue_script__,
74
+ __vue_scope_id__,
75
+ __vue_is_functional_template__,
76
+ __vue_module_identifier__,
77
+ false,
78
+ undefined,
79
+ undefined,
80
+ undefined
81
+ );
82
+
83
+ export default __vue_component__;
@@ -0,0 +1,38 @@
1
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
+
3
+ /* script */
4
+
5
+ /* template */
6
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('pre',{staticClass:"gl-border gl-grid gl-text-pretty gl-rounded-lg gl-border-strong gl-bg-strong gl-p-5 gl-font-monospace"},[_c('code',[_vm._t("default")],2)])};
7
+ var __vue_staticRenderFns__ = [];
8
+
9
+ /* style */
10
+ const __vue_inject_styles__ = undefined;
11
+ /* scoped */
12
+ const __vue_scope_id__ = undefined;
13
+ /* module identifier */
14
+ const __vue_module_identifier__ = undefined;
15
+ /* functional template */
16
+ const __vue_is_functional_template__ = false;
17
+ /* style inject */
18
+
19
+ /* style inject SSR */
20
+
21
+ /* style inject shadow dom */
22
+
23
+
24
+
25
+ const __vue_component__ = __vue_normalize__(
26
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
27
+ __vue_inject_styles__,
28
+ {},
29
+ __vue_scope_id__,
30
+ __vue_is_functional_template__,
31
+ __vue_module_identifier__,
32
+ false,
33
+ undefined,
34
+ undefined,
35
+ undefined
36
+ );
37
+
38
+ export default __vue_component__;
@@ -0,0 +1,62 @@
1
+ import { GlIcon } from '@gitlab/ui';
2
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
+
4
+ var script = {
5
+ name: 'RunCommandToolParams',
6
+ components: {
7
+ GlIcon
8
+ },
9
+ props: {
10
+ program: {
11
+ type: String,
12
+ required: true
13
+ },
14
+ args: {
15
+ type: String,
16
+ required: true
17
+ }
18
+ },
19
+ computed: {
20
+ formattedCommand() {
21
+ return `${this.program} ${this.args}`;
22
+ }
23
+ }
24
+ };
25
+
26
+ /* script */
27
+ const __vue_script__ = script;
28
+
29
+ /* template */
30
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-items-center gl-gap-3"},[_c('gl-icon',{attrs:{"name":"terminal"}}),_vm._v(" "),_c('code',[_vm._v(_vm._s(_vm.formattedCommand))])],1)};
31
+ var __vue_staticRenderFns__ = [];
32
+
33
+ /* style */
34
+ const __vue_inject_styles__ = undefined;
35
+ /* scoped */
36
+ const __vue_scope_id__ = undefined;
37
+ /* module identifier */
38
+ const __vue_module_identifier__ = undefined;
39
+ /* functional template */
40
+ const __vue_is_functional_template__ = false;
41
+ /* style inject */
42
+
43
+ /* style inject SSR */
44
+
45
+ /* style inject shadow dom */
46
+
47
+
48
+
49
+ const __vue_component__ = __vue_normalize__(
50
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
51
+ __vue_inject_styles__,
52
+ __vue_script__,
53
+ __vue_scope_id__,
54
+ __vue_is_functional_template__,
55
+ __vue_module_identifier__,
56
+ false,
57
+ undefined,
58
+ undefined,
59
+ undefined
60
+ );
61
+
62
+ export default __vue_component__;
@@ -1,14 +1,24 @@
1
- import { GlButton, GlIcon, GlFormTextarea, GlFormGroup } from '@gitlab/ui';
1
+ import { GlButton, GlCard, GlFormTextarea, GlFormGroup, GlBadge } from '@gitlab/ui';
2
2
  import { translate } from '../../../../utils/i18n';
3
+ import { convertKeysToCamelCase } from '../../../../utils/object';
4
+ import CreateCommitToolParams from './components/create_commit_tool_params';
5
+ import CreateIssueToolParams from './components/create_issue_tool_params';
6
+ import CreateMergeRequestToolParams from './components/create_merge_request_tool_params';
7
+ import RunCommandToolParams from './components/run_command_tool_params';
3
8
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
4
9
 
10
+ const APPROVAL_TOOL_NAMES = {
11
+ createCommit: 'create_commit',
12
+ createIssue: 'create_issue',
13
+ createMergeRequest: 'create_merge_request',
14
+ runCommand: 'run_command'
15
+ };
5
16
  const PROCESSING_STATE = {
6
17
  APPROVING: 'approving',
7
18
  DENYING: 'denying',
8
19
  NONE: null
9
20
  };
10
21
  const i18n = {
11
- TOOL_APPROVAL_TITLE: translate('MessageToolApproval.toolApprovalTitle', 'Duo would like to execute a tool. Do you want to proceed?'),
12
22
  TOOL_APPROVAL_DESCRIPTION: translate('MessageToolApproval.toolApprovalDescription', 'GitLab Duo Agentic Chat wants to execute a tool. Do you want to proceed?'),
13
23
  TOOL_LABEL: translate('MessageToolApproval.toolLabel', 'Tool:'),
14
24
  TOOL_UNKNOWN: translate('MessageToolApproval.toolUnknown', 'Unknown'),
@@ -20,15 +30,33 @@ const i18n = {
20
30
  REQUEST_TEXT: translate('MessageToolApproval.parametersText', 'Request'),
21
31
  DENIAL_REASON_LABEL: translate('MessageToolApproval.denialReasonLabel', 'Rejection reason'),
22
32
  DENIAL_REASON_PLACEHOLDER: translate('MessageToolApproval.denialReasonPlaceholder', "Tell Duo why you're rejecting this tool execution..."),
23
- CANCEL_TEXT: translate('MessageToolApproval.cancelText', 'Cancel')
33
+ CANCEL_TEXT: translate('MessageToolApproval.cancelText', 'Cancel'),
34
+ TOOL_APPROVAL_TITLES: {
35
+ [APPROVAL_TOOL_NAMES.createCommit]: translate('MessageToolApproval.createCommit', 'Duo wants to push a commit.'),
36
+ [APPROVAL_TOOL_NAMES.createIssue]: translate('MessageToolApproval.createIssue', 'Duo wants to open an issue.'),
37
+ [APPROVAL_TOOL_NAMES.createMergeRequest]: translate('MessageToolApproval.createMergeRequest', 'Duo wants to create a merge request.'),
38
+ [APPROVAL_TOOL_NAMES.runCommand]: translate('MessageToolApproval.runCommand', 'Duo wants to run a command.')
39
+ },
40
+ TOOL_STATUS: translate('MessageToolApproval.toolStatus', 'Pending')
41
+ };
42
+ const TOOL_PARAMS_VIEW_COMPONENTS = {
43
+ [APPROVAL_TOOL_NAMES.createCommit]: 'CreateCommitToolParams',
44
+ [APPROVAL_TOOL_NAMES.createIssue]: 'CreateIssueToolParams',
45
+ [APPROVAL_TOOL_NAMES.createMergeRequest]: 'CreateMergeRequestToolParams',
46
+ [APPROVAL_TOOL_NAMES.runCommand]: 'RunCommandToolParams'
24
47
  };
25
48
  var script = {
26
49
  name: 'MessageToolApproval',
27
50
  components: {
28
51
  GlButton,
29
- GlIcon,
52
+ GlCard,
30
53
  GlFormTextarea,
31
- GlFormGroup
54
+ GlFormGroup,
55
+ GlBadge,
56
+ CreateCommitToolParams,
57
+ CreateIssueToolParams,
58
+ CreateMergeRequestToolParams,
59
+ RunCommandToolParams
32
60
  },
33
61
  props: {
34
62
  message: {
@@ -57,9 +85,15 @@ var script = {
57
85
  var _this$message2, _this$message2$tool_i;
58
86
  return ((_this$message2 = this.message) === null || _this$message2 === void 0 ? void 0 : (_this$message2$tool_i = _this$message2.tool_info) === null || _this$message2$tool_i === void 0 ? void 0 : _this$message2$tool_i.args) || {};
59
87
  },
88
+ camelCaseToolParameters() {
89
+ return convertKeysToCamelCase(this.toolParameters);
90
+ },
60
91
  hasToolParameters() {
61
92
  return Object.keys(this.toolParameters).length > 0;
62
93
  },
94
+ toolApprovalTitle() {
95
+ return i18n.TOOL_APPROVAL_TITLES[this.toolName];
96
+ },
63
97
  isApproving() {
64
98
  return this.isProcessing && this.localProcessingState === PROCESSING_STATE.APPROVING;
65
99
  },
@@ -74,6 +108,9 @@ var script = {
74
108
  },
75
109
  denyButtonText() {
76
110
  return this.isDenying ? this.$options.i18n.DENYING_TEXT : this.$options.i18n.DENY_TEXT;
111
+ },
112
+ toolParamsViewComponent() {
113
+ return TOOL_PARAMS_VIEW_COMPONENTS[this.toolName];
77
114
  }
78
115
  },
79
116
  watch: {
@@ -111,14 +148,15 @@ var script = {
111
148
  this.denialReason = '';
112
149
  }
113
150
  },
114
- i18n
151
+ i18n,
152
+ APPROVAL_TOOL_NAMES
115
153
  };
116
154
 
117
155
  /* script */
118
156
  const __vue_script__ = script;
119
157
 
120
158
  /* template */
121
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"md gl-border gl-rounded-bl-none gl-border-1 gl-border-solid gl-border-transparent gl-bg-subtle gl-p-4 gl-leading-20 gl-text-default gl-break-anywhere"},[_c('p',{staticClass:"gl-mb-3 gl-text-gray-700"},[_vm._v("\n "+_vm._s(_vm.$options.i18n.TOOL_APPROVAL_TITLE)+"\n ")]),_vm._v(" "),_c('div',{staticClass:"gl-mb-3 gl-flex gl-items-center gl-gap-2"},[_c('gl-icon',{staticClass:"gl-text-gray-500",attrs:{"name":"work-item-maintenance"}}),_vm._v(" "),_c('strong',[_vm._v(_vm._s(_vm.toolName))])],1),_vm._v(" "),_c('div',{staticClass:"gl-border gl-mb-4 gl-rounded-base gl-border-gray-200 gl-bg-gray-50 gl-p-3"},[_c('p',{staticClass:"gl-mb-1 gl-text-sm gl-text-gray-500"},[_vm._v("\n "+_vm._s(_vm.$options.i18n.REQUEST_TEXT)+"\n ")]),_vm._v(" "),(_vm.hasToolParameters)?_c('code',{staticClass:"gl-whitespace-pre-wrap gl-text-sm gl-text-default gl-font-monospace",attrs:{"data-testid":"tool-parameters"}},[_vm._v(_vm._s(JSON.stringify(_vm.toolParameters, null, 2)))]):_c('span',{staticClass:"gl-text-sm gl-text-gray-500",attrs:{"data-testid":"no-parameters-message"}},[_vm._v("\n "+_vm._s(_vm.$options.i18n.NO_PARAMETERS_TEXT)+"\n ")])]),_vm._v(" "),(!_vm.showDenialReason)?_c('div',{staticClass:"gl-flex gl-justify-between"},[_c('gl-button',{attrs:{"variant":"danger","size":"small","icon":"cancel","data-testid":"deny-tool-inline","disabled":_vm.buttonsDisabled,"loading":_vm.isDenying},on:{"click":_vm.handleDeny}},[_vm._v("\n "+_vm._s(_vm.denyButtonText)+"\n ")]),_vm._v(" "),_c('gl-button',{attrs:{"variant":"confirm","size":"small","icon":"play","data-testid":"approve-tool-inline","disabled":_vm.buttonsDisabled,"loading":_vm.isApproving},on:{"click":_vm.handleApprove}},[_vm._v("\n "+_vm._s(_vm.approveButtonText)+"\n ")])],1):_c('div',{staticClass:"gl-mt-3"},[_c('gl-form-group',{staticClass:"gl-mb-3",attrs:{"label":_vm.$options.i18n.DENIAL_REASON_LABEL,"label-for":"inline-rejection-reason","optional":true}},[_c('gl-form-textarea',{attrs:{"id":"inline-rejection-reason","placeholder":_vm.$options.i18n.DENIAL_REASON_PLACEHOLDER,"rows":2,"no-resize":true,"submit-on-enter":false,"disabled":_vm.buttonsDisabled,"data-testid":"denial-reason-textarea","autofocus":""},on:{"submit":_vm.submitDenial},model:{value:(_vm.denialReason),callback:function ($$v) {_vm.denialReason=$$v;},expression:"denialReason"}})],1),_vm._v(" "),_c('div',{staticClass:"gl-flex gl-gap-3"},[_c('gl-button',{attrs:{"size":"small","data-testid":"cancel-denial","disabled":_vm.buttonsDisabled},on:{"click":_vm.cancelDenial}},[_vm._v("\n "+_vm._s(_vm.$options.i18n.CANCEL_TEXT)+"\n ")]),_vm._v(" "),_c('gl-button',{attrs:{"variant":"danger","size":"small","icon":"cancel","data-testid":"submit-denial","disabled":_vm.buttonsDisabled,"loading":_vm.isDenying},on:{"click":_vm.submitDenial}},[_vm._v("\n "+_vm._s(_vm.denyButtonText)+"\n ")])],1)],1)])};
159
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-card',{scopedSlots:_vm._u([{key:"header",fn:function(){return [_c('div',{staticClass:"gl-flex gl-items-center gl-justify-between"},[_c('span',[_vm._v("\n "+_vm._s(_vm.toolApprovalTitle)+"\n ")]),_vm._v(" "),_c('gl-badge',[_vm._v("\n "+_vm._s(_vm.$options.i18n.TOOL_STATUS)+"\n ")])],1)]},proxy:true},{key:"footer",fn:function(){return [(!_vm.showDenialReason)?_c('div',{staticClass:"gl-flex gl-gap-2"},[_c('gl-button',{attrs:{"variant":"confirm","size":"small","data-testid":"approve-tool-inline","disabled":_vm.buttonsDisabled,"loading":_vm.isApproving},on:{"click":_vm.handleApprove}},[_vm._v("\n "+_vm._s(_vm.approveButtonText)+"\n ")]),_vm._v(" "),_c('gl-button',{attrs:{"size":"small","data-testid":"deny-tool-inline","disabled":_vm.buttonsDisabled,"loading":_vm.isDenying},on:{"click":_vm.handleDeny}},[_vm._v("\n "+_vm._s(_vm.denyButtonText)+"\n ")])],1):_c('div',[_c('gl-form-group',{staticClass:"gl-mb-3",attrs:{"label":_vm.$options.i18n.DENIAL_REASON_LABEL,"label-for":"inline-rejection-reason","optional":true}},[_c('gl-form-textarea',{attrs:{"id":"inline-rejection-reason","placeholder":_vm.$options.i18n.DENIAL_REASON_PLACEHOLDER,"rows":2,"no-resize":true,"submit-on-enter":false,"disabled":_vm.buttonsDisabled,"data-testid":"denial-reason-textarea","autofocus":""},on:{"submit":_vm.submitDenial},model:{value:(_vm.denialReason),callback:function ($$v) {_vm.denialReason=$$v;},expression:"denialReason"}})],1),_vm._v(" "),_c('div',{staticClass:"gl-flex gl-gap-3"},[_c('gl-button',{attrs:{"size":"small","data-testid":"submit-denial","variant":"confirm","disabled":_vm.buttonsDisabled,"loading":_vm.isDenying},on:{"click":_vm.submitDenial}},[_vm._v("\n "+_vm._s(_vm.denyButtonText)+"\n ")]),_vm._v(" "),_c('gl-button',{attrs:{"size":"small","data-testid":"cancel-denial","disabled":_vm.buttonsDisabled},on:{"click":_vm.cancelDenial}},[_vm._v("\n "+_vm._s(_vm.$options.i18n.CANCEL_TEXT)+"\n ")])],1)],1)]},proxy:true}])},[_vm._v(" "),(_vm.toolParamsViewComponent)?_c(_vm.toolParamsViewComponent,_vm._b({tag:"component",staticClass:"gl-leading-20"},'component',_vm.camelCaseToolParameters,false)):_c('div',{staticClass:"md gl-border gl-rounded-bl-none gl-border-1 gl-border-solid gl-border-transparent gl-bg-subtle gl-p-4 gl-leading-20 gl-text-default gl-break-anywhere"},[_c('div',{staticClass:"gl-border gl-mb-4 gl-rounded-base gl-border-gray-200 gl-bg-gray-50 gl-p-3"},[_c('p',{staticClass:"gl-mb-1 gl-text-sm gl-text-gray-500"},[_vm._v("\n "+_vm._s(_vm.$options.i18n.REQUEST_TEXT)+"\n ")]),_vm._v(" "),(_vm.hasToolParameters)?_c('code',{staticClass:"gl-whitespace-pre-wrap gl-text-sm gl-text-default gl-font-monospace",attrs:{"data-testid":"tool-parameters"}},[_vm._v(_vm._s(JSON.stringify(_vm.toolParameters, null, 2)))]):_c('span',{staticClass:"gl-text-sm gl-text-gray-500",attrs:{"data-testid":"no-parameters-message"}},[_vm._v("\n "+_vm._s(_vm.$options.i18n.NO_PARAMETERS_TEXT)+"\n ")])])])],1)};
122
160
  var __vue_staticRenderFns__ = [];
123
161
 
124
162
  /* style */
@@ -151,4 +189,4 @@ var __vue_staticRenderFns__ = [];
151
189
  );
152
190
 
153
191
  export default __vue_component__;
154
- export { PROCESSING_STATE, i18n };
192
+ export { APPROVAL_TOOL_NAMES, PROCESSING_STATE, i18n };
@@ -146,6 +146,90 @@ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_PARAMS = {
146
146
  status: 'success',
147
147
  role: 'request'
148
148
  };
149
+ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_MERGE_REQUEST = {
150
+ id: '125',
151
+ content: 'Tool create_merge_request requires approval. Please confirm if you want to proceed.',
152
+ message_type: MESSAGE_MODEL_ROLES.request,
153
+ tool_info: {
154
+ name: 'create_merge_request',
155
+ args: {
156
+ project_id: 123,
157
+ source_branch: 'rename-all-spec-files',
158
+ target_branch: 'main',
159
+ title: 'Rename all the *.spec.ts files to *.test.ts',
160
+ description: '## What does this MR do?\n\nThis MR updates the `group` field in the `web_ide_language_server` beta feature flag configuration from `group::remote development` to `group:: editor extensions`.\n\n## Related issues\n\nThis change aligns the feature flag with the correct group ownership.\n\n## Changes made\n\n- Updated `config/feature_flags/beta/web_ide_language_server.yml`\n- Changed group field from `group::remote development` to `group:: editor extensions`\n\n## Checklist\n\n- [x] Feature flag configuration updated\n- [x] Group field correctly set to `group:: editor extensions`'
161
+ }
162
+ },
163
+ timestamp: '2025-06-25T19:22:21.290791+00:00',
164
+ status: 'success',
165
+ role: 'request'
166
+ };
167
+ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_RUN_COMMAND = {
168
+ id: '125',
169
+ content: 'Tool run_command requires approval. Please confirm if you want to proceed.',
170
+ message_type: MESSAGE_MODEL_ROLES.request,
171
+ tool_info: {
172
+ name: 'run_command',
173
+ args: {
174
+ program: 'ls',
175
+ args: '-a | grep package.json'
176
+ }
177
+ },
178
+ timestamp: '2025-06-25T19:22:21.290791+00:00',
179
+ status: 'success',
180
+ role: 'request'
181
+ };
182
+ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_ISSUE = {
183
+ id: '125',
184
+ content: 'Tool run_command requires approval. Please confirm if you want to proceed.',
185
+ message_type: MESSAGE_MODEL_ROLES.request,
186
+ tool_info: {
187
+ name: 'create_issue',
188
+ args: {
189
+ project_id: 123,
190
+ title: 'CSP bug in VSCode Fork prevents loading external web views in Web IDE',
191
+ description: "## Problem\n\nThe VSCode Fork implementation has a Content Security Policy (CSP) bug that prevents external web views from loading properly in the Web IDE.\n\n## Impact\n\n- External web views fail to load within the Web IDE environment\n- This affects functionality that relies on embedding external content\n- Users may experience broken or non-functional web view components\n\n## Expected Behavior\n\nExternal web views should load successfully within the Web IDE when permitted by security policies.\n\n## Current Behavior\n\nExternal web views are blocked due to CSP restrictions in the VSCode Fork implementation.\n\n## Technical Details\n\nThis appears to be related to how the VSCode Fork handles Content Security Policy headers, which may be overly restrictive for the Web IDE's use case with external web views.\n\n## Next Steps\n\n- [ ] Investigate the specific CSP directives causing the issue\n- [ ] Determine which external domains/resources need to be allowlisted\n- [ ] Implement appropriate CSP modifications in the VSCode Fork\n- [ ] Test the fix with various external web view scenarios\n- [ ] Ensure security implications are properly evaluated",
192
+ labels: 'bug,web-ide,vscode-fork,csp,security'
193
+ }
194
+ },
195
+ timestamp: '2025-06-25T19:22:21.290791+00:00',
196
+ status: 'success',
197
+ role: 'request'
198
+ };
199
+ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT = {
200
+ id: '125',
201
+ content: 'Tool create_commit requires approval. Please confirm if you want to proceed.',
202
+ message_type: MESSAGE_MODEL_ROLES.request,
203
+ tool_info: {
204
+ name: 'create_commit',
205
+ args: {
206
+ project_id: 35104827,
207
+ branch: 'feat/add-web-ide-duo-chat-package',
208
+ start_branch: 'main',
209
+ commit_message: 'feat: add web-ide-duo-chat package with TypeScript setup\n\n- Create new package @gitlab/web-ide-duo-chat\n- Set up TypeScript configuration following project patterns\n- Add src directory with index.ts entry point\n- Configure package.json with workspace dependencies\n- Add package reference to root tsconfig.json',
210
+ actions: [{
211
+ action: 'create',
212
+ file_path: 'packages/web-ide-duo-chat/package.json',
213
+ content: '{\n "name": "@gitlab/web-ide-duo-chat",\n "version": "0.0.1",\n "main": "./src/index.ts",\n "license": "MIT",\n "packageManager": "yarn@3.2.0",\n "devDependencies": {\n "@gitlab/utils-test": "workspace:*"\n },\n "dependencies": {\n "@gitlab/logger": "workspace:*",\n "@gitlab/web-ide-types": "workspace:*"\n },\n "publishConfig": {\n "main": "./lib/index.js"\n }\n}\n'
214
+ }, {
215
+ action: 'create',
216
+ file_path: 'packages/web-ide-duo-chat/src/types.ts',
217
+ content: "/**\n * Represents a chat message in the Duo Chat interface\n */\nexport interface ChatMessage {\n /**\n * Unique identifier for the message\n */\n id: string;\n /**\n * The content of the message\n */\n content: string;\n /**\n * Who sent the message\n */\n sender: 'user' | 'assistant';\n /**\n * Timestamp when the message was created\n */\n timestamp: Date;\n /**\n * Optional metadata for the message\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Represents a chat conversation\n */\nexport interface ChatConversation {\n /**\n * Unique identifier for the conversation\n */\n id: string;\n /**\n * Title of the conversation\n */\n title: string;\n /**\n * Messages in the conversation\n */\n messages: ChatMessage[];\n /**\n * When the conversation was created\n */\n createdAt: Date;\n /**\n * When the conversation was last updated\n */\n updatedAt: Date;\n}\n\n/**\n * Event types for Duo Chat\n */\nexport type DuoChatEvent = \n | { type: 'message-sent'; payload: ChatMessage }\n | { type: 'message-received'; payload: ChatMessage }\n | { type: 'conversation-started'; payload: ChatConversation }\n | { type: 'conversation-ended'; payload: { conversationId: string } }\n | { type: 'error'; payload: { error: Error; context?: string } };\n\n/**\n * Callback function for handling Duo Chat events\n */\nexport type DuoChatEventHandler = (event: DuoChatEvent) => void;\n\n/**\n * Interface for Duo Chat service providers\n */\nexport interface DuoChatProvider {\n /**\n * Send a message and get a response\n */\n sendMessage(message: string, conversationId?: string): Promise<ChatMessage>;\n /**\n * Start a new conversation\n */\n startConversation(title?: string): Promise<ChatConversation>;\n /**\n * Get conversation history\n */\n getConversation(conversationId: string): Promise<ChatConversation | null>;\n /**\n * List all conversations\n */\n listConversations(): Promise<ChatConversation[]>;\n}\n"
218
+ }, {
219
+ action: 'update',
220
+ file_path: 'tsconfig.json',
221
+ content: '{\n "extends": "./tsconfig.base.json",\n "references": [\n { "path": "./packages/example" },\n { "path": "./packages/gitlab-api-client" },\n { "path": "./packages/gitlab-api-client-factory" },\n { "path": "./packages/logger" },\n { "path": "./packages/oauth-client" },\n { "path": "./packages/utils-crypto" },\n { "path": "./packages/utils-escape" },\n { "path": "./packages/utils-test" },\n { "path": "./packages/utils-path" },\n { "path": "./packages/vscode-bootstrap" },\n { "path": "./packages/vscode-mediator-commands" },\n { "path": "./packages/web-ide" },\n { "path": "./packages/web-ide-duo-chat" },\n { "path": "./packages/web-ide-fs" },\n { "path": "./packages/web-ide-types" },\n { "path": "./packages/web-ide-interop" },\n { "path": "./packages/vscode-extension-web-ide" },\n { "path": "./packages/cross-origin-channel" },\n { "path": "./packages/cloudflare" }\n ],\n "files": []\n}\n'
222
+ }, {
223
+ action: 'move',
224
+ file_path: 'yarn.lock',
225
+ previous_path: 'yarn.lock.bkp'
226
+ }]
227
+ }
228
+ },
229
+ timestamp: '2025-06-25T19:22:21.290791+00:00',
230
+ status: 'success',
231
+ role: 'assistant'
232
+ };
149
233
  const MOCK_WORKFLOW_END_MESSAGE = {
150
234
  id: '123',
151
235
  content: "Search for 'duo.*chat.*message' in directory",
@@ -458,4 +542,4 @@ const AGENTIC_THREADLIST = [{
458
542
  }
459
543
  }];
460
544
 
461
- export { AGENTIC_THREADLIST, INCLUDE_SLASH_COMMAND, MOCK_AGENT_MESSAGE, MOCK_REQUEST_MESSAGE, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_PARAMS, MOCK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE_FOR_STREAMING, MOCK_TOOL_MESSAGE, MOCK_TOOL_MESSAGE_WITH_LINK, MOCK_USER_PROMPT_MESSAGE, MOCK_WORKFLOW_END_MESSAGE, SLASH_COMMANDS, THREADLIST, generateMockResponseChunks, generateSeparateChunks, renderGFM, renderMarkdown };
545
+ export { AGENTIC_THREADLIST, INCLUDE_SLASH_COMMAND, MOCK_AGENT_MESSAGE, MOCK_REQUEST_MESSAGE, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_ISSUE, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_MERGE_REQUEST, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_PARAMS, MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_RUN_COMMAND, MOCK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE_FOR_STREAMING, MOCK_TOOL_MESSAGE, MOCK_TOOL_MESSAGE_WITH_LINK, MOCK_USER_PROMPT_MESSAGE, MOCK_WORKFLOW_END_MESSAGE, SLASH_COMMANDS, THREADLIST, generateMockResponseChunks, generateSeparateChunks, renderGFM, renderMarkdown };