@gitlab/ui 82.1.0 → 83.0.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [83.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v82.1.0...v83.0.0) (2024-06-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **DuoChat:** add propmpt abort functionality ([3792308](https://gitlab.com/gitlab-org/gitlab-ui/commit/3792308a7c086e9e3588a0793be10d41473f473f))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **DuoChat:** This commit adds an abort button to the
|
|
12
|
+
DuoChat textarea, it also introduces the
|
|
13
|
+
chat-abort event that can be caught
|
|
14
|
+
by the client.
|
|
15
|
+
|
|
1
16
|
# [82.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v82.0.1...v82.1.0) (2024-06-20)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -27,6 +27,7 @@ const i18n = {
|
|
|
27
27
|
CHAT_PROMPT_PLACEHOLDER_DEFAULT: 'GitLab Duo Chat',
|
|
28
28
|
CHAT_PROMPT_PLACEHOLDER_WITH_COMMANDS: 'Type "/" for slash commands',
|
|
29
29
|
CHAT_SUBMIT_LABEL: 'Send chat message.',
|
|
30
|
+
CHAT_CANCEL_LABEL: 'Cancel',
|
|
30
31
|
CHAT_LEGAL_DISCLAIMER: "May provide inappropriate responses not representative of GitLab's views. Do not input personal data.",
|
|
31
32
|
CHAT_DEFAULT_PREDEFINED_PROMPTS: ['How do I change my password in GitLab?', 'How do I fork a project?', 'How do I clone a repository?', 'How do I create a template?']
|
|
32
33
|
};
|
|
@@ -179,7 +180,8 @@ var script = {
|
|
|
179
180
|
isHidden: false,
|
|
180
181
|
prompt: '',
|
|
181
182
|
scrolledToBottom: true,
|
|
182
|
-
activeCommandIndex: 0
|
|
183
|
+
activeCommandIndex: 0,
|
|
184
|
+
displaySubmitButton: true
|
|
183
185
|
};
|
|
184
186
|
},
|
|
185
187
|
computed: {
|
|
@@ -202,7 +204,8 @@ var script = {
|
|
|
202
204
|
}, [[]]);
|
|
203
205
|
},
|
|
204
206
|
lastMessage() {
|
|
205
|
-
|
|
207
|
+
var _this$messages2;
|
|
208
|
+
return (_this$messages2 = this.messages) === null || _this$messages2 === void 0 ? void 0 : _this$messages2[this.messages.length - 1];
|
|
206
209
|
},
|
|
207
210
|
resetDisabled() {
|
|
208
211
|
var _this$lastMessage;
|
|
@@ -211,9 +214,6 @@ var script = {
|
|
|
211
214
|
}
|
|
212
215
|
return ((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : _this$lastMessage.content) === CHAT_RESET_MESSAGE;
|
|
213
216
|
},
|
|
214
|
-
submitDisabled() {
|
|
215
|
-
return this.isLoading || this.isStreaming;
|
|
216
|
-
},
|
|
217
217
|
isStreaming() {
|
|
218
218
|
var _this$lastMessage2, _this$lastMessage2$ch, _this$lastMessage3, _this$lastMessage4;
|
|
219
219
|
return Boolean(((_this$lastMessage2 = this.lastMessage) === null || _this$lastMessage2 === void 0 ? void 0 : (_this$lastMessage2$ch = _this$lastMessage2.chunks) === null || _this$lastMessage2$ch === void 0 ? void 0 : _this$lastMessage2$ch.length) > 0 && !((_this$lastMessage3 = this.lastMessage) !== null && _this$lastMessage3 !== void 0 && _this$lastMessage3.content) || typeof ((_this$lastMessage4 = this.lastMessage) === null || _this$lastMessage4 === void 0 ? void 0 : _this$lastMessage4.chunkId) === 'number');
|
|
@@ -237,9 +237,17 @@ var script = {
|
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
239
|
watch: {
|
|
240
|
-
isLoading() {
|
|
240
|
+
isLoading(newVal) {
|
|
241
|
+
if (!newVal && !this.isStreaming) {
|
|
242
|
+
this.displaySubmitButton = true; // Re-enable submit button when loading stops
|
|
243
|
+
}
|
|
241
244
|
this.isHidden = false;
|
|
242
245
|
this.scrollToBottom();
|
|
246
|
+
},
|
|
247
|
+
isStreaming(newVal) {
|
|
248
|
+
if (!newVal && !this.isLoading) {
|
|
249
|
+
this.displaySubmitButton = true; // Re-enable submit button when streaming stops
|
|
250
|
+
}
|
|
243
251
|
}
|
|
244
252
|
},
|
|
245
253
|
created() {
|
|
@@ -256,8 +264,17 @@ var script = {
|
|
|
256
264
|
*/
|
|
257
265
|
this.$emit('chat-hidden');
|
|
258
266
|
},
|
|
267
|
+
cancelPrompt() {
|
|
268
|
+
/**
|
|
269
|
+
* Emitted when user clicks the stop button in the textarea
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
this.displaySubmitButton = true;
|
|
273
|
+
this.$emit('chat-cancel');
|
|
274
|
+
this.setPromptAndFocus();
|
|
275
|
+
},
|
|
259
276
|
sendChatPrompt() {
|
|
260
|
-
if (this.
|
|
277
|
+
if (!this.displaySubmitButton) {
|
|
261
278
|
return;
|
|
262
279
|
}
|
|
263
280
|
if (this.prompt) {
|
|
@@ -270,6 +287,7 @@ var script = {
|
|
|
270
287
|
* @param {String} prompt The user prompt to send.
|
|
271
288
|
*/
|
|
272
289
|
this.$emit('send-chat-prompt', this.prompt.trim());
|
|
290
|
+
this.displaySubmitButton = false;
|
|
273
291
|
this.setPromptAndFocus();
|
|
274
292
|
}
|
|
275
293
|
},
|
|
@@ -364,7 +382,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
364
382
|
{
|
|
365
383
|
'gl-h-full': !_vm.hasMessages,
|
|
366
384
|
'force-scroll-bar': _vm.hasMessages,
|
|
367
|
-
} ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"show-delimiter":index > 0},on:{"track-feedback":_vm.onTrackFeedback}})}),_vm._v(" "),(!_vm.hasMessages && !_vm.isLoading)?[_c('gl-empty-state',{key:"empty-state",staticClass:"gl-flex-grow gl-justify-content-center",attrs:{"svg-path":_vm.$options.emptySvg,"svg-height":145,"title":_vm.emptyStateTitle,"description":_vm.emptyStateDescription}}),_vm._v(" "),_c('gl-duo-chat-predefined-prompts',{key:"predefined-prompts",attrs:{"prompts":_vm.predefinedPrompts},on:{"click":_vm.sendPredefinedPrompt}})]:_vm._e(),_vm._v(" "),(_vm.isLoading)?_c('gl-duo-chat-loader',{key:"loader",attrs:{"tool-name":_vm.toolName}}):_vm._e(),_vm._v(" "),_c('div',{key:"anchor",ref:"anchor",staticClass:"scroll-anchor"})],2)],1),_vm._v(" "),(_vm.isChatAvailable)?_c('footer',{staticClass:"duo-chat-drawer-footer duo-chat-drawer-footer-sticky gl-p-5 gl-border-t gl-bg-gray-10",class:{ 'duo-chat-drawer-body-scrim-on-footer': !_vm.scrolledToBottom },attrs:{"data-testid":"chat-footer"}},[_c('gl-form',{attrs:{"data-testid":"chat-prompt-form"},on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.sendChatPrompt.apply(null, arguments)}}},[_c('gl-form-input-group',{scopedSlots:_vm._u([{key:"append",fn:function(){return [_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"paper-airplane","category":"primary","variant":"confirm","type":"submit","data-testid":"chat-prompt-submit-button","aria-label":_vm.$options.i18n.CHAT_SUBMIT_LABEL,"
|
|
385
|
+
} ],attrs:{"tag":"section","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"show-delimiter":index > 0},on:{"track-feedback":_vm.onTrackFeedback}})}),_vm._v(" "),(!_vm.hasMessages && !_vm.isLoading)?[_c('gl-empty-state',{key:"empty-state",staticClass:"gl-flex-grow gl-justify-content-center",attrs:{"svg-path":_vm.$options.emptySvg,"svg-height":145,"title":_vm.emptyStateTitle,"description":_vm.emptyStateDescription}}),_vm._v(" "),_c('gl-duo-chat-predefined-prompts',{key:"predefined-prompts",attrs:{"prompts":_vm.predefinedPrompts},on:{"click":_vm.sendPredefinedPrompt}})]:_vm._e(),_vm._v(" "),(_vm.isLoading)?_c('gl-duo-chat-loader',{key:"loader",attrs:{"tool-name":_vm.toolName}}):_vm._e(),_vm._v(" "),_c('div',{key:"anchor",ref:"anchor",staticClass:"scroll-anchor"})],2)],1),_vm._v(" "),(_vm.isChatAvailable)?_c('footer',{staticClass:"duo-chat-drawer-footer duo-chat-drawer-footer-sticky gl-p-5 gl-border-t gl-bg-gray-10",class:{ 'duo-chat-drawer-body-scrim-on-footer': !_vm.scrolledToBottom },attrs:{"data-testid":"chat-footer"}},[_c('gl-form',{attrs:{"data-testid":"chat-prompt-form"},on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.sendChatPrompt.apply(null, arguments)}}},[_c('gl-form-input-group',{scopedSlots:_vm._u([{key:"append",fn:function(){return [(_vm.displaySubmitButton)?_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"paper-airplane","category":"primary","variant":"confirm","type":"submit","data-testid":"chat-prompt-submit-button","aria-label":_vm.$options.i18n.CHAT_SUBMIT_LABEL}}):_c('gl-button',{staticClass:"!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"stop","category":"primary","variant":"default","data-testid":"chat-prompt-cancel-button","aria-label":_vm.$options.i18n.CHAT_CANCEL_LABEL},on:{"click":_vm.cancelPrompt}})]},proxy:true}],null,false,2711323372)},[_c('div',{staticClass:"duo-chat-input gl-flex-grow-1 gl-vertical-align-top gl-max-w-full gl-min-h-8 gl-inset-border-1-gray-400 gl-rounded-base gl-bg-white",attrs:{"data-value":_vm.prompt}},[(_vm.shouldShowSlashCommands)?_c('gl-card',{ref:"commands",staticClass:"slash-commands !gl-absolute gl-translate-y-n100 gl-list-style-none gl-pl-0 gl-w-full gl-shadow-md",attrs:{"body-class":"gl-p-2!"}},_vm._l((_vm.filteredSlashCommands),function(command,index){return _c('gl-dropdown-item',{key:command.name,class:{ 'active-command': index === _vm.activeCommandIndex },on:{"click":function($event){return _vm.selectSlashCommand(index)}},nativeOn:{"mouseenter":function($event){_vm.activeCommandIndex = index;}}},[_c('span',{staticClass:"gl-display-flex gl-justify-content-space-between"},[_c('span',{staticClass:"gl-display-block"},[_vm._v(_vm._s(command.name))]),_vm._v(" "),_c('small',{staticClass:"gl-text-gray-500 gl-font-style-italic gl-text-right gl-pl-3"},[_vm._v(_vm._s(command.description))])])])}),1):_vm._e(),_vm._v(" "),_c('gl-form-textarea',{ref:"prompt",staticClass:"gl-absolute gl-h-full! gl-py-4! gl-bg-transparent! gl-rounded-top-right-none gl-rounded-bottom-right-none gl-shadow-none!",class:{ 'gl-text-truncate': !_vm.prompt },attrs:{"data-testid":"chat-prompt-input","placeholder":_vm.inputPlaceholder,"autofocus":""},nativeOn:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }$event.preventDefault();},"keyup":function($event){return _vm.onInputKeyup.apply(null, arguments)}},model:{value:(_vm.prompt),callback:function ($$v) {_vm.prompt=$$v;},expression:"prompt"}})],1)]),_vm._v(" "),_c('gl-form-text',{staticClass:"gl-text-gray-400 gl-line-height-20 gl-mt-3",attrs:{"data-testid":"chat-legal-disclaimer"}},[_vm._v(_vm._s(_vm.$options.i18n.CHAT_LEGAL_DISCLAIMER))])],1)],1):_vm._e()]):_vm._e()};
|
|
368
386
|
var __vue_staticRenderFns__ = [];
|
|
369
387
|
|
|
370
388
|
/* style */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "83.0.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
"test:integration:server": "NODE_ENV=test start-test storybook:run http-get://${STORYBOOK_HOST:-localhost}:9001/iframe.html",
|
|
50
50
|
"test:unit": "NODE_ENV=test jest",
|
|
51
51
|
"test:unit:watch": "yarn test:unit --watch",
|
|
52
|
+
"test:unit:coverage": "yarn test:unit --coverage",
|
|
52
53
|
"test:unit:debug": "NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
|
|
53
54
|
"test:unit-vue3": "VUE_VERSION=3 NODE_ENV=test jest",
|
|
54
55
|
"test:unit-vue3:watch": "VUE_VERSION=3 yarn test:unit --watch",
|
|
56
|
+
"test:unit-vue3:coverage": "VUE_VERSION=3 yarn test:unit --coverage",
|
|
55
57
|
"test:unit-vue3:debug": "VUE_VERSION=3 NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
|
|
56
58
|
"test:visual": "./bin/run-visual-tests.sh 'test-storybook --browsers firefox --verbose --url http://localhost:9001'",
|
|
57
59
|
"test:visual:update": "./bin/run-visual-tests.sh 'test-storybook -u --browsers firefox --verbose --url http://localhost:9001'",
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
"@gitlab/eslint-plugin": "19.5.0",
|
|
109
111
|
"@gitlab/fonts": "^1.3.0",
|
|
110
112
|
"@gitlab/stylelint-config": "6.1.0",
|
|
111
|
-
"@gitlab/svgs": "3.
|
|
113
|
+
"@gitlab/svgs": "3.103.0",
|
|
112
114
|
"@jest/test-sequencer": "^29.7.0",
|
|
113
115
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
114
116
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
@@ -27,6 +27,7 @@ export const i18n = {
|
|
|
27
27
|
CHAT_PROMPT_PLACEHOLDER_DEFAULT: 'GitLab Duo Chat',
|
|
28
28
|
CHAT_PROMPT_PLACEHOLDER_WITH_COMMANDS: 'Type "/" for slash commands',
|
|
29
29
|
CHAT_SUBMIT_LABEL: 'Send chat message.',
|
|
30
|
+
CHAT_CANCEL_LABEL: 'Cancel',
|
|
30
31
|
CHAT_LEGAL_DISCLAIMER:
|
|
31
32
|
"May provide inappropriate responses not representative of GitLab's views. Do not input personal data.",
|
|
32
33
|
CHAT_DEFAULT_PREDEFINED_PROMPTS: [
|
|
@@ -188,6 +189,7 @@ export default {
|
|
|
188
189
|
prompt: '',
|
|
189
190
|
scrolledToBottom: true,
|
|
190
191
|
activeCommandIndex: 0,
|
|
192
|
+
displaySubmitButton: true,
|
|
191
193
|
};
|
|
192
194
|
},
|
|
193
195
|
computed: {
|
|
@@ -213,7 +215,7 @@ export default {
|
|
|
213
215
|
);
|
|
214
216
|
},
|
|
215
217
|
lastMessage() {
|
|
216
|
-
return this.messages[this.messages.length - 1];
|
|
218
|
+
return this.messages?.[this.messages.length - 1];
|
|
217
219
|
},
|
|
218
220
|
resetDisabled() {
|
|
219
221
|
if (this.isLoading || !this.hasMessages) {
|
|
@@ -221,9 +223,6 @@ export default {
|
|
|
221
223
|
}
|
|
222
224
|
return this.lastMessage?.content === CHAT_RESET_MESSAGE;
|
|
223
225
|
},
|
|
224
|
-
submitDisabled() {
|
|
225
|
-
return this.isLoading || this.isStreaming;
|
|
226
|
-
},
|
|
227
226
|
isStreaming() {
|
|
228
227
|
return Boolean(
|
|
229
228
|
(this.lastMessage?.chunks?.length > 0 && !this.lastMessage?.content) ||
|
|
@@ -256,10 +255,18 @@ export default {
|
|
|
256
255
|
},
|
|
257
256
|
},
|
|
258
257
|
watch: {
|
|
259
|
-
isLoading() {
|
|
258
|
+
isLoading(newVal) {
|
|
259
|
+
if (!newVal && !this.isStreaming) {
|
|
260
|
+
this.displaySubmitButton = true; // Re-enable submit button when loading stops
|
|
261
|
+
}
|
|
260
262
|
this.isHidden = false;
|
|
261
263
|
this.scrollToBottom();
|
|
262
264
|
},
|
|
265
|
+
isStreaming(newVal) {
|
|
266
|
+
if (!newVal && !this.isLoading) {
|
|
267
|
+
this.displaySubmitButton = true; // Re-enable submit button when streaming stops
|
|
268
|
+
}
|
|
269
|
+
},
|
|
263
270
|
},
|
|
264
271
|
created() {
|
|
265
272
|
this.handleScrollingTrottled = throttle(this.handleScrolling, 200); // Assume a 200ms throttle for example
|
|
@@ -275,8 +282,17 @@ export default {
|
|
|
275
282
|
*/
|
|
276
283
|
this.$emit('chat-hidden');
|
|
277
284
|
},
|
|
285
|
+
cancelPrompt() {
|
|
286
|
+
/**
|
|
287
|
+
* Emitted when user clicks the stop button in the textarea
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
this.displaySubmitButton = true;
|
|
291
|
+
this.$emit('chat-cancel');
|
|
292
|
+
this.setPromptAndFocus();
|
|
293
|
+
},
|
|
278
294
|
sendChatPrompt() {
|
|
279
|
-
if (this.
|
|
295
|
+
if (!this.displaySubmitButton) {
|
|
280
296
|
return;
|
|
281
297
|
}
|
|
282
298
|
if (this.prompt) {
|
|
@@ -289,6 +305,7 @@ export default {
|
|
|
289
305
|
* @param {String} prompt The user prompt to send.
|
|
290
306
|
*/
|
|
291
307
|
this.$emit('send-chat-prompt', this.prompt.trim());
|
|
308
|
+
this.displaySubmitButton = false;
|
|
292
309
|
this.setPromptAndFocus();
|
|
293
310
|
}
|
|
294
311
|
},
|
|
@@ -517,6 +534,7 @@ export default {
|
|
|
517
534
|
</div>
|
|
518
535
|
<template #append>
|
|
519
536
|
<gl-button
|
|
537
|
+
v-if="displaySubmitButton"
|
|
520
538
|
icon="paper-airplane"
|
|
521
539
|
category="primary"
|
|
522
540
|
variant="confirm"
|
|
@@ -524,7 +542,16 @@ export default {
|
|
|
524
542
|
type="submit"
|
|
525
543
|
data-testid="chat-prompt-submit-button"
|
|
526
544
|
:aria-label="$options.i18n.CHAT_SUBMIT_LABEL"
|
|
527
|
-
|
|
545
|
+
/>
|
|
546
|
+
<gl-button
|
|
547
|
+
v-else
|
|
548
|
+
icon="stop"
|
|
549
|
+
category="primary"
|
|
550
|
+
variant="default"
|
|
551
|
+
class="!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!"
|
|
552
|
+
data-testid="chat-prompt-cancel-button"
|
|
553
|
+
:aria-label="$options.i18n.CHAT_CANCEL_LABEL"
|
|
554
|
+
@click="cancelPrompt"
|
|
528
555
|
/>
|
|
529
556
|
</template>
|
|
530
557
|
</gl-form-input-group>
|