@gitlab/duo-ui 15.15.0 → 15.15.1

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.
@@ -26,6 +26,10 @@ const metadataProperties = {
26
26
  icon: 'project',
27
27
  label: projectLabel
28
28
  },
29
+ projectName: {
30
+ icon: 'project',
31
+ label: projectLabel
32
+ },
29
33
  projectPath: {
30
34
  icon: 'project',
31
35
  label: projectLabel
@@ -163,9 +167,17 @@ var script = {
163
167
  },
164
168
  metadataProperties() {
165
169
  const toolParams = this.toolParams || {};
170
+ const projectProperties = ['projectFullPath', 'projectPath', 'projectName', 'projectId'];
171
+ const preferredProjectProperty = projectProperties.find(p => toolParams[p]);
166
172
  return Object.entries(metadataProperties).filter(_ref => {
167
173
  let [property] = _ref;
168
- return toolParams[property];
174
+ if (!toolParams[property]) return false;
175
+
176
+ // Show only the highest-priority project property to avoid redundant badges
177
+ if (projectProperties.includes(property)) {
178
+ return property === preferredProjectProperty;
179
+ }
180
+ return true;
169
181
  }).map(_ref2 => {
170
182
  let [property, styles] = _ref2;
171
183
  return {
@@ -26,13 +26,23 @@ var script = {
26
26
  var _this$toolParams;
27
27
  return (_this$toolParams = this.toolParams) === null || _this$toolParams === void 0 ? void 0 : _this$toolParams.branch;
28
28
  },
29
+ repository() {
30
+ var _this$toolParams2, _this$toolParams3, _this$toolParams4, _this$toolParams5, _this$toolParams6;
31
+ return ((_this$toolParams2 = this.toolParams) === null || _this$toolParams2 === void 0 ? void 0 : _this$toolParams2.projectName) || ((_this$toolParams3 = this.toolParams) === null || _this$toolParams3 === void 0 ? void 0 : _this$toolParams3.projectPath) || ((_this$toolParams4 = this.toolParams) === null || _this$toolParams4 === void 0 ? void 0 : _this$toolParams4.projectFullPath) || ((_this$toolParams5 = this.toolParams) === null || _this$toolParams5 === void 0 ? void 0 : _this$toolParams5.url) || ((_this$toolParams6 = this.toolParams) === null || _this$toolParams6 === void 0 ? void 0 : _this$toolParams6.projectId);
32
+ },
33
+ summaryMessage() {
34
+ if (this.branch && this.repository) return this.$options.i18n.COMMIT_SUMMARY_MESSAGE;
35
+ if (this.branch) return this.$options.i18n.COMMIT_SUMMARY_MESSAGE_NO_REPO;
36
+ if (this.repository) return this.$options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE;
37
+ return this.$options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE_NO_REPO;
38
+ },
29
39
  commitMessage() {
30
- var _this$toolParams2;
31
- return (_this$toolParams2 = this.toolParams) === null || _this$toolParams2 === void 0 ? void 0 : _this$toolParams2.commitMessage;
40
+ var _this$toolParams7;
41
+ return (_this$toolParams7 = this.toolParams) === null || _this$toolParams7 === void 0 ? void 0 : _this$toolParams7.commitMessage;
32
42
  },
33
43
  actions() {
34
- var _this$toolParams3;
35
- return ((_this$toolParams3 = this.toolParams) === null || _this$toolParams3 === void 0 ? void 0 : _this$toolParams3.actions) || [];
44
+ var _this$toolParams8;
45
+ return ((_this$toolParams8 = this.toolParams) === null || _this$toolParams8 === void 0 ? void 0 : _this$toolParams8.actions) || [];
36
46
  },
37
47
  actionsCount() {
38
48
  return this.actions.length;
@@ -109,8 +119,10 @@ var script = {
109
119
  }
110
120
  },
111
121
  i18n: {
112
- COMMIT_SUMMARY_MESSAGE: translate('CreateCommitToolParams.commitSummaryMessage', 'Create a commit in the branch %{branch}.'),
113
- COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE: translate('CreateCommitToolParams.commitSummaryAutoBranchMessage', 'Create a commit in a new auto-created branch.'),
122
+ COMMIT_SUMMARY_MESSAGE: translate('CreateCommitToolParams.commitSummaryMessage', 'Commit and push to branch %{branch} in repository %{repository}.'),
123
+ COMMIT_SUMMARY_MESSAGE_NO_REPO: translate('CreateCommitToolParams.commitSummaryMessageNoRepo', 'Commit and push to branch %{branch}.'),
124
+ COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE: translate('CreateCommitToolParams.commitSummaryAutoBranchMessage', 'Commit and push to a new branch in repository %{repository}.'),
125
+ COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE_NO_REPO: translate('CreateCommitToolParams.commitSummaryAutoBranchMessageNoRepo', 'Commit and push to a new branch.'),
114
126
  READ_COMMIT_MESSAGE: translate('CreateCommitToolParams.readCommitMessage', 'Read commit message'),
115
127
  CREATE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.createFileActionLabel', 'Create file %{filePath}'),
116
128
  UPDATE_FILE_ACTION_LABEL: translate('CreateCommitToolParams.updateFileActionLabel', 'Update file %{filePath}'),
@@ -127,9 +139,7 @@ var script = {
127
139
  const __vue_script__ = script;
128
140
 
129
141
  /* template */
130
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('base-tool-params',{attrs:{"tool-params":_vm.toolParams}},[_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.branch
131
- ? _vm.$options.i18n.COMMIT_SUMMARY_MESSAGE
132
- : _vm.$options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE},scopedSlots:_vm._u([(_vm.branch)?{key:"branch",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.branch))])]},proxy:true}:null],null,true)}),_vm._v("\n "+_vm._s(_vm.actionsCountMessage)+"\n ")],1),_vm._v(" "),_c('gl-accordion',{staticClass:"-gl-ml-2",attrs:{"header-level":3}},[(_vm.commitMessage)?_c('gl-accordion-item',{staticClass:"gl-mb-3",attrs:{"title":_vm.$options.i18n.READ_COMMIT_MESSAGE}},[_c('pre-block',{attrs:{"languages":['markdown']}},[_vm._v(_vm._s(_vm.commitMessage))])],1):_vm._e(),_vm._v(" "),(_vm.actionsCount)?_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,staticClass:"gl-mb-3",attrs:{"title":_vm.getActionTitle(action)}},[_c('pre-block',{attrs:{"languages":[_vm.getActionFileExtension(action), 'diff']}},[_vm._v(_vm._s(_vm.getActionContent(action)))])],1)}),1)],1):_vm._e()],1)],1)};
142
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('base-tool-params',{attrs:{"tool-params":_vm.toolParams}},[_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.summaryMessage},scopedSlots:_vm._u([(_vm.branch)?{key:"branch",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.branch))])]},proxy:true}:null,(_vm.repository)?{key:"repository",fn:function(){return [_c('code',[_vm._v(_vm._s(_vm.repository))])]},proxy:true}:null],null,true)}),_vm._v("\n "+_vm._s(_vm.actionsCountMessage)+"\n ")],1),_vm._v(" "),_c('gl-accordion',{staticClass:"-gl-ml-2",attrs:{"header-level":3}},[(_vm.commitMessage)?_c('gl-accordion-item',{staticClass:"gl-mb-3",attrs:{"title":_vm.$options.i18n.READ_COMMIT_MESSAGE}},[_c('pre-block',{attrs:{"languages":['markdown']}},[_vm._v(_vm._s(_vm.commitMessage))])],1):_vm._e(),_vm._v(" "),(_vm.actionsCount)?_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,staticClass:"gl-mb-3",attrs:{"title":_vm.getActionTitle(action)}},[_c('pre-block',{attrs:{"languages":[_vm.getActionFileExtension(action), 'diff']}},[_vm._v(_vm._s(_vm.getActionContent(action)))])],1)}),1)],1):_vm._e()],1)],1)};
133
143
  var __vue_staticRenderFns__ = [];
134
144
 
135
145
  /* style */
@@ -41,6 +41,9 @@ const TOOL_PARAMS_VIEW_COMPONENTS = {
41
41
  [APPROVAL_TOOL_NAMES.runCommand]: 'RunCommandToolParams',
42
42
  [APPROVAL_TOOL_NAMES.runGitCommand]: 'RunCommandToolParams'
43
43
  };
44
+ const TOOL_DISPLAY_TITLES = {
45
+ [APPROVAL_TOOL_NAMES.createCommit]: translate('MessageToolApproval.createCommitTitle', 'Commit and push to repository')
46
+ };
44
47
  var script = {
45
48
  name: 'MessageToolApproval',
46
49
  components: {
@@ -136,6 +139,11 @@ var script = {
136
139
  return this.$options.i18n.MULTI_TOOL_TITLE.replace('%{count}', this.messages.length);
137
140
  }
138
141
 
142
+ // Use explicit display title when available
143
+ if (TOOL_DISPLAY_TITLES[this.toolName]) {
144
+ return TOOL_DISPLAY_TITLES[this.toolName];
145
+ }
146
+
139
147
  // Single tool: show specific tool message
140
148
  return capitalize(startCase(this.toolName));
141
149
  },
@@ -351,6 +351,7 @@ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT = {
351
351
  name: 'create_commit',
352
352
  args: {
353
353
  project_id: 35104827,
354
+ project_name: 'duo-ui',
354
355
  branch: 'feat/add-web-ide-duo-chat-package',
355
356
  start_branch: 'main',
356
357
  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',
@@ -385,6 +386,7 @@ const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT_OLD_NEW_CONTENT = {
385
386
  name: 'create_commit',
386
387
  args: {
387
388
  project_id: 35104827,
389
+ project_name: 'duo-ui',
388
390
  branch: 'feat/add-web-ide-duo-chat-package',
389
391
  start_branch: 'main',
390
392
  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',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/duo-ui",
3
- "version": "15.15.0",
3
+ "version": "15.15.1",
4
4
  "description": "Duo UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -27,6 +27,7 @@ const metadataProperties = {
27
27
  icon: 'project',
28
28
  label: projectLabel,
29
29
  },
30
+ projectName: { icon: 'project', label: projectLabel },
30
31
  projectPath: { icon: 'project', label: projectLabel },
31
32
  projectFullPath: { icon: 'project', label: projectLabel },
32
33
  groupId: { icon: 'group', label: groupLabel },
@@ -100,9 +101,20 @@ export default {
100
101
  },
101
102
  metadataProperties() {
102
103
  const toolParams = this.toolParams || {};
104
+ const projectProperties = ['projectFullPath', 'projectPath', 'projectName', 'projectId'];
105
+ const preferredProjectProperty = projectProperties.find((p) => toolParams[p]);
103
106
 
104
107
  return Object.entries(metadataProperties)
105
- .filter(([property]) => toolParams[property])
108
+ .filter(([property]) => {
109
+ if (!toolParams[property]) return false;
110
+
111
+ // Show only the highest-priority project property to avoid redundant badges
112
+ if (projectProperties.includes(property)) {
113
+ return property === preferredProjectProperty;
114
+ }
115
+
116
+ return true;
117
+ })
106
118
  .map(([property, styles]) => ({
107
119
  key: property,
108
120
  value: toolParams[property],
@@ -26,6 +26,21 @@ export default {
26
26
  branch() {
27
27
  return this.toolParams?.branch;
28
28
  },
29
+ repository() {
30
+ return (
31
+ this.toolParams?.projectName ||
32
+ this.toolParams?.projectPath ||
33
+ this.toolParams?.projectFullPath ||
34
+ this.toolParams?.url ||
35
+ this.toolParams?.projectId
36
+ );
37
+ },
38
+ summaryMessage() {
39
+ if (this.branch && this.repository) return this.$options.i18n.COMMIT_SUMMARY_MESSAGE;
40
+ if (this.branch) return this.$options.i18n.COMMIT_SUMMARY_MESSAGE_NO_REPO;
41
+ if (this.repository) return this.$options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE;
42
+ return this.$options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE_NO_REPO;
43
+ },
29
44
  commitMessage() {
30
45
  return this.toolParams?.commitMessage;
31
46
  },
@@ -107,11 +122,19 @@ export default {
107
122
  i18n: {
108
123
  COMMIT_SUMMARY_MESSAGE: translate(
109
124
  'CreateCommitToolParams.commitSummaryMessage',
110
- 'Create a commit in the branch %{branch}.'
125
+ 'Commit and push to branch %{branch} in repository %{repository}.'
126
+ ),
127
+ COMMIT_SUMMARY_MESSAGE_NO_REPO: translate(
128
+ 'CreateCommitToolParams.commitSummaryMessageNoRepo',
129
+ 'Commit and push to branch %{branch}.'
111
130
  ),
112
131
  COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE: translate(
113
132
  'CreateCommitToolParams.commitSummaryAutoBranchMessage',
114
- 'Create a commit in a new auto-created branch.'
133
+ 'Commit and push to a new branch in repository %{repository}.'
134
+ ),
135
+ COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE_NO_REPO: translate(
136
+ 'CreateCommitToolParams.commitSummaryAutoBranchMessageNoRepo',
137
+ 'Commit and push to a new branch.'
115
138
  ),
116
139
  READ_COMMIT_MESSAGE: translate(
117
140
  'CreateCommitToolParams.readCommitMessage',
@@ -152,16 +175,13 @@ export default {
152
175
  <template>
153
176
  <base-tool-params :tool-params="toolParams">
154
177
  <div>
155
- <gl-sprintf
156
- :message="
157
- branch
158
- ? $options.i18n.COMMIT_SUMMARY_MESSAGE
159
- : $options.i18n.COMMIT_SUMMARY_AUTO_BRANCH_MESSAGE
160
- "
161
- >
178
+ <gl-sprintf :message="summaryMessage">
162
179
  <template v-if="branch" #branch>
163
180
  <code>{{ branch }}</code>
164
181
  </template>
182
+ <template v-if="repository" #repository>
183
+ <code>{{ repository }}</code>
184
+ </template>
165
185
  </gl-sprintf>
166
186
  {{ actionsCountMessage }}
167
187
  </div>
@@ -68,6 +68,13 @@ const TOOL_PARAMS_VIEW_COMPONENTS = {
68
68
  [APPROVAL_TOOL_NAMES.runGitCommand]: 'RunCommandToolParams',
69
69
  };
70
70
 
71
+ const TOOL_DISPLAY_TITLES = {
72
+ [APPROVAL_TOOL_NAMES.createCommit]: translate(
73
+ 'MessageToolApproval.createCommitTitle',
74
+ 'Commit and push to repository'
75
+ ),
76
+ };
77
+
71
78
  export default {
72
79
  name: 'MessageToolApproval',
73
80
  components: {
@@ -164,6 +171,11 @@ export default {
164
171
  return this.$options.i18n.MULTI_TOOL_TITLE.replace('%{count}', this.messages.length);
165
172
  }
166
173
 
174
+ // Use explicit display title when available
175
+ if (TOOL_DISPLAY_TITLES[this.toolName]) {
176
+ return TOOL_DISPLAY_TITLES[this.toolName];
177
+ }
178
+
167
179
  // Single tool: show specific tool message
168
180
  return capitalize(startCase(this.toolName));
169
181
  },
@@ -393,6 +393,7 @@ export const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT = {
393
393
  name: 'create_commit',
394
394
  args: {
395
395
  project_id: 35104827,
396
+ project_name: 'duo-ui',
396
397
  branch: 'feat/add-web-ide-duo-chat-package',
397
398
  start_branch: 'main',
398
399
  commit_message:
@@ -437,6 +438,7 @@ export const MOCK_REQUEST_MESSAGE_WITH_TOOL_APPROVAL_CREATE_COMMIT_OLD_NEW_CONTE
437
438
  name: 'create_commit',
438
439
  args: {
439
440
  project_id: 35104827,
441
+ project_name: 'duo-ui',
440
442
  branch: 'feat/add-web-ide-duo-chat-package',
441
443
  start_branch: 'main',
442
444
  commit_message:
package/translations.js CHANGED
@@ -76,8 +76,11 @@ export default {
76
76
  'CreateCommitToolParams.actionsCountMessage': null,
77
77
  'CreateCommitToolParams.chmodFileActionLabel': 'Change permissions for file %{filePath}',
78
78
  'CreateCommitToolParams.commitSummaryAutoBranchMessage':
79
- 'Create a commit in a new auto-created branch.',
80
- 'CreateCommitToolParams.commitSummaryMessage': 'Create a commit in the branch %{branch}.',
79
+ 'Commit and push to a new branch in repository %{repository}.',
80
+ 'CreateCommitToolParams.commitSummaryAutoBranchMessageNoRepo': 'Commit and push to a new branch.',
81
+ 'CreateCommitToolParams.commitSummaryMessage':
82
+ 'Commit and push to branch %{branch} in repository %{repository}.',
83
+ 'CreateCommitToolParams.commitSummaryMessageNoRepo': 'Commit and push to branch %{branch}.',
81
84
  'CreateCommitToolParams.createFileActionLabel': 'Create file %{filePath}',
82
85
  'CreateCommitToolParams.deleteFileActionLabel': 'Delete file %{filePath}',
83
86
  'CreateCommitToolParams.expandFileChanges': 'Expand file changes',
@@ -167,6 +170,7 @@ export default {
167
170
  'MessageToolApproval.cancelText': 'Cancel',
168
171
  'MessageToolApproval.collapseButtonCollapsed': 'Display tool details',
169
172
  'MessageToolApproval.collapseButtonExpanded': 'Hide tool details',
173
+ 'MessageToolApproval.createCommitTitle': 'Commit and push to repository',
170
174
  'MessageToolApproval.denialReasonLabel': 'Rejection reason',
171
175
  'MessageToolApproval.denialReasonPlaceholder':
172
176
  "Tell Duo why you're rejecting this tool execution...",