@uipath/apollo-react 6.29.0 → 6.30.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.
Files changed (77) hide show
  1. package/dist/canvas/components/index.cjs +55 -48
  2. package/dist/canvas/components/index.d.ts +1 -0
  3. package/dist/canvas/components/index.d.ts.map +1 -1
  4. package/dist/canvas/components/index.js +1 -0
  5. package/dist/canvas/icons/FileSparklesCornerIcon.cjs +80 -0
  6. package/dist/canvas/icons/FileSparklesCornerIcon.d.ts +6 -0
  7. package/dist/canvas/icons/FileSparklesCornerIcon.d.ts.map +1 -0
  8. package/dist/canvas/icons/FileSparklesCornerIcon.js +46 -0
  9. package/dist/canvas/icons/index.cjs +4 -0
  10. package/dist/canvas/icons/index.d.ts +1 -0
  11. package/dist/canvas/icons/index.d.ts.map +1 -1
  12. package/dist/canvas/icons/index.js +2 -1
  13. package/dist/canvas/locales/de.cjs +1 -1
  14. package/dist/canvas/locales/de.d.ts.map +1 -1
  15. package/dist/canvas/locales/de.js +1 -1
  16. package/dist/canvas/locales/es-MX.cjs +1 -1
  17. package/dist/canvas/locales/es-MX.d.ts.map +1 -1
  18. package/dist/canvas/locales/es-MX.js +1 -1
  19. package/dist/canvas/locales/es.cjs +1 -1
  20. package/dist/canvas/locales/es.d.ts.map +1 -1
  21. package/dist/canvas/locales/es.js +1 -1
  22. package/dist/canvas/locales/fr.cjs +1 -1
  23. package/dist/canvas/locales/fr.d.ts.map +1 -1
  24. package/dist/canvas/locales/fr.js +1 -1
  25. package/dist/canvas/locales/ja.cjs +1 -1
  26. package/dist/canvas/locales/ja.d.ts.map +1 -1
  27. package/dist/canvas/locales/ja.js +1 -1
  28. package/dist/canvas/locales/ko.cjs +1 -1
  29. package/dist/canvas/locales/ko.d.ts.map +1 -1
  30. package/dist/canvas/locales/ko.js +1 -1
  31. package/dist/canvas/locales/pt-BR.cjs +1 -1
  32. package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
  33. package/dist/canvas/locales/pt-BR.js +1 -1
  34. package/dist/canvas/locales/pt.cjs +1 -1
  35. package/dist/canvas/locales/pt.d.ts.map +1 -1
  36. package/dist/canvas/locales/pt.js +1 -1
  37. package/dist/canvas/locales/ro.cjs +1 -1
  38. package/dist/canvas/locales/ro.d.ts.map +1 -1
  39. package/dist/canvas/locales/ro.js +1 -1
  40. package/dist/canvas/locales/tr.cjs +1 -1
  41. package/dist/canvas/locales/tr.d.ts.map +1 -1
  42. package/dist/canvas/locales/tr.js +1 -1
  43. package/dist/canvas/locales/zh-CN.cjs +1 -1
  44. package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
  45. package/dist/canvas/locales/zh-CN.js +1 -1
  46. package/dist/canvas/locales/zh-TW.cjs +1 -1
  47. package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
  48. package/dist/canvas/locales/zh-TW.js +1 -1
  49. package/dist/canvas/types/execution.d.ts.map +1 -1
  50. package/dist/canvas/utils/adornment-resolver.cjs +1 -18
  51. package/dist/canvas/utils/adornment-resolver.d.ts.map +1 -1
  52. package/dist/canvas/utils/adornment-resolver.js +1 -18
  53. package/dist/canvas/utils/icon-registry.cjs +5 -0
  54. package/dist/canvas/utils/icon-registry.d.ts.map +1 -1
  55. package/dist/canvas/utils/icon-registry.js +6 -1
  56. package/dist/material/components/ap-chat/components/history/chat-history-item.cjs +174 -46
  57. package/dist/material/components/ap-chat/components/history/chat-history-item.d.ts.map +1 -1
  58. package/dist/material/components/ap-chat/components/history/chat-history-item.js +174 -46
  59. package/dist/material/components/ap-chat/locales/en.cjs +1 -1
  60. package/dist/material/components/ap-chat/locales/en.d.ts.map +1 -1
  61. package/dist/material/components/ap-chat/locales/en.js +1 -1
  62. package/dist/material/components/ap-chat/service/ChatModel.cjs +2 -0
  63. package/dist/material/components/ap-chat/service/ChatModel.d.ts +8 -1
  64. package/dist/material/components/ap-chat/service/ChatModel.d.ts.map +1 -1
  65. package/dist/material/components/ap-chat/service/ChatModel.js +2 -0
  66. package/dist/material/components/ap-chat/service/ChatService.cjs +9 -1
  67. package/dist/material/components/ap-chat/service/ChatService.d.ts +1 -0
  68. package/dist/material/components/ap-chat/service/ChatService.d.ts.map +1 -1
  69. package/dist/material/components/ap-chat/service/ChatService.js +9 -1
  70. package/dist/material/components/ap-chat/service/LocalHistory.cjs +22 -0
  71. package/dist/material/components/ap-chat/service/LocalHistory.d.ts +1 -0
  72. package/dist/material/components/ap-chat/service/LocalHistory.d.ts.map +1 -1
  73. package/dist/material/components/ap-chat/service/LocalHistory.js +22 -0
  74. package/dist/material/stories/chat-story-support.cjs +20 -3
  75. package/dist/material/stories/chat-story-support.d.ts.map +1 -1
  76. package/dist/material/stories/chat-story-support.js +20 -3
  77. package/package.json +2 -2
@@ -48,7 +48,7 @@ const chat_state_provider_cjs_namespaceObject = require("../../providers/chat-st
48
48
  const loading_provider_cjs_namespaceObject = require("../../providers/loading-provider.cjs");
49
49
  const external_service_index_cjs_namespaceObject = require("../../service/index.cjs");
50
50
  const action_button_cjs_namespaceObject = require("../common/action-button.cjs");
51
- const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive, showRemoveIcon })=>({
51
+ const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive, showActionButtons })=>({
52
52
  width: `calc(100% - 2 * ${apollo_core_default().Spacing.SpacingBase})`,
53
53
  padding: `0 calc(${apollo_core_default().Padding.PadL} + ${apollo_core_default().Spacing.SpacingBase})`,
54
54
  display: 'flex',
@@ -66,11 +66,14 @@ const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive, showR
66
66
  backgroundColor: 'var(--color-background-selected)',
67
67
  borderLeft: "4px solid var(--color-selection-indicator)"
68
68
  },
69
- '& .delete-button-wrapper': {
70
- opacity: showRemoveIcon ? 1 : 0,
69
+ '& .action-buttons-wrapper': {
70
+ opacity: showActionButtons ? 1 : 0,
71
71
  position: 'relative',
72
72
  left: apollo_core_default().Spacing.SpacingXs,
73
- marginRight: apollo_core_default().Spacing.SpacingBase
73
+ marginRight: apollo_core_default().Spacing.SpacingBase,
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ gap: apollo_core_default().Spacing.SpacingXs
74
77
  }
75
78
  }));
76
79
  const GroupTitle = (0, material_namespaceObject.styled)('div')(()=>({
@@ -82,20 +85,47 @@ const GroupTitle = (0, material_namespaceObject.styled)('div')(()=>({
82
85
  whiteSpace: 'nowrap'
83
86
  }
84
87
  }));
88
+ const RenameInput = (0, material_namespaceObject.styled)('input')(()=>({
89
+ width: '100%',
90
+ padding: 0,
91
+ margin: 0,
92
+ border: 'none',
93
+ background: 'transparent',
94
+ color: 'var(--color-foreground)',
95
+ fontFamily: 'inherit',
96
+ fontSize: 'inherit',
97
+ lineHeight: 'inherit',
98
+ outline: 'none',
99
+ '&:focus-visible': {
100
+ outline: "1px solid var(--color-focus-indicator)",
101
+ outlineOffset: '2px',
102
+ borderRadius: apollo_core_default().Border.BorderRadiusS
103
+ }
104
+ }));
85
105
  const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
86
106
  const { _ } = (0, react_namespaceObject.useLingui)();
87
107
  const chatService = (0, chat_service_provider_cjs_namespaceObject.useChatService)();
88
- const { spacing } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
108
+ const { spacing, disabledFeatures } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
109
+ const renameEnabled = !disabledFeatures.renameChat;
89
110
  const [isActive, setIsActive] = external_react_default().useState(chatService.activeConversationId === item.id);
90
111
  const { setWaitingResponse } = (0, loading_provider_cjs_namespaceObject.useLoading)();
91
- const [isRemoveIconVisible, setIsRemoveIconVisible] = external_react_default().useState(false);
112
+ const [isActionButtonsVisible, setIsActionButtonsVisible] = external_react_default().useState(false);
92
113
  const [isFocused, setIsFocused] = external_react_default().useState(false);
114
+ const [isEditing, setIsEditing] = external_react_default().useState(false);
115
+ const [draftName, setDraftName] = external_react_default().useState(item.name);
93
116
  const itemRef = external_react_default().useRef(null);
117
+ const inputRef = external_react_default().useRef(null);
94
118
  const lastMousePosition = external_react_default().useRef({
95
119
  x: 0,
96
120
  y: 0
97
121
  });
98
- const focusButtonRef = external_react_default().useRef(null);
122
+ const isCommittingRef = external_react_default().useRef(false);
123
+ external_react_default().useEffect(()=>{
124
+ if (!isEditing) setDraftName(item.name);
125
+ }, [
126
+ item.name,
127
+ isEditing
128
+ ]);
99
129
  external_react_default().useEffect(()=>{
100
130
  const handleMouseMove = (e)=>{
101
131
  if (isFocused) return;
@@ -106,7 +136,7 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
106
136
  if (itemRef.current) {
107
137
  const rect = itemRef.current.getBoundingClientRect();
108
138
  const isInside = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
109
- setIsRemoveIconVisible(isInside);
139
+ setIsActionButtonsVisible(isInside);
110
140
  }
111
141
  };
112
142
  document.addEventListener('mousemove', handleMouseMove);
@@ -138,6 +168,54 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
138
168
  isActive,
139
169
  setWaitingResponse
140
170
  ]);
171
+ external_react_default().useEffect(()=>{
172
+ if (isEditing) {
173
+ inputRef.current?.focus();
174
+ inputRef.current?.select();
175
+ }
176
+ }, [
177
+ isEditing
178
+ ]);
179
+ const enterEditMode = external_react_default().useCallback(()=>{
180
+ if (!isHistoryOpen) return;
181
+ isCommittingRef.current = false;
182
+ setDraftName(item.name);
183
+ setIsEditing(true);
184
+ }, [
185
+ isHistoryOpen,
186
+ item.name
187
+ ]);
188
+ const cancelRename = external_react_default().useCallback(()=>{
189
+ isCommittingRef.current = false;
190
+ setDraftName(item.name);
191
+ setIsEditing(false);
192
+ }, [
193
+ item.name
194
+ ]);
195
+ const commitRename = external_react_default().useCallback(()=>{
196
+ if (isCommittingRef.current) return;
197
+ const trimmed = draftName.trim();
198
+ if ('' === trimmed || trimmed === item.name) return void cancelRename();
199
+ if (!chatService) return void setIsEditing(false);
200
+ isCommittingRef.current = true;
201
+ chatService.getPreHook(external_service_index_cjs_namespaceObject.AutopilotChatPreHookAction.RenameConversation)({
202
+ conversationId: item.id,
203
+ name: trimmed
204
+ }).then((proceed)=>{
205
+ if (!proceed) return void cancelRename();
206
+ chatService.renameConversation(item.id, trimmed);
207
+ setIsEditing(false);
208
+ isCommittingRef.current = false;
209
+ }).catch(()=>{
210
+ cancelRename();
211
+ });
212
+ }, [
213
+ draftName,
214
+ item.id,
215
+ item.name,
216
+ chatService,
217
+ cancelRename
218
+ ]);
141
219
  const handleDelete = external_react_default().useCallback((ev, itemId)=>{
142
220
  ev.stopPropagation();
143
221
  setIsFocused(false);
@@ -151,65 +229,115 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
151
229
  }, [
152
230
  chatService
153
231
  ]);
232
+ const handleRename = external_react_default().useCallback((ev)=>{
233
+ ev.stopPropagation();
234
+ setIsFocused(false);
235
+ enterEditMode();
236
+ }, [
237
+ enterEditMode
238
+ ]);
154
239
  const handleItemClick = external_react_default().useCallback((itemId)=>{
155
- if (isActive) return;
240
+ if (isEditing || isActive) return;
156
241
  chatService.openConversation(itemId);
157
242
  chatService.toggleHistory(false);
158
243
  }, [
159
244
  chatService,
160
- isActive
161
- ]);
162
- external_react_default().useEffect(()=>{
163
- if (isFocused) focusButtonRef.current?.focus();
164
- }, [
165
- isFocused
245
+ isActive,
246
+ isEditing
166
247
  ]);
248
+ const renameLabel = _({
249
+ id: 'autopilot-chat.history.rename'
250
+ });
251
+ const renameInputLabel = _({
252
+ id: 'autopilot-chat.history.rename-input'
253
+ });
254
+ const deleteLabel = _({
255
+ id: 'autopilot-chat.history.delete'
256
+ });
257
+ const showActionButtons = !isEditing && (isFocused || isActionButtonsVisible);
258
+ const tooltipVisible = showActionButtons && isHistoryOpen;
167
259
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(GroupItem, {
168
- showRemoveIcon: isFocused || isRemoveIconVisible,
260
+ showActionButtons: showActionButtons,
169
261
  ref: itemRef,
170
- tabIndex: isHistoryOpen ? 0 : -1,
262
+ tabIndex: isHistoryOpen && !isEditing ? 0 : -1,
171
263
  isActive: isActive,
172
264
  onClick: ()=>handleItemClick(item.id),
173
265
  onKeyDown: (ev)=>{
266
+ if (isEditing) return;
174
267
  if ('Enter' === ev.key || ' ' === ev.key) handleItemClick(item.id);
175
268
  },
176
- "aria-label": item.name,
177
- role: "button",
178
- "aria-pressed": isActive,
269
+ "aria-label": isEditing ? void 0 : item.name,
270
+ role: isEditing ? void 0 : 'button',
271
+ "aria-pressed": isEditing ? void 0 : isActive,
179
272
  children: [
180
273
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GroupTitle, {
181
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTypography, {
274
+ children: isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RenameInput, {
275
+ ref: inputRef,
276
+ value: draftName,
277
+ "aria-label": renameInputLabel,
278
+ "data-testid": "autopilot-chat-history-rename-input",
279
+ onChange: (ev)=>setDraftName(ev.target.value),
280
+ onClick: (ev)=>ev.stopPropagation(),
281
+ onBlur: commitRename,
282
+ onKeyDown: (ev)=>{
283
+ if ('Enter' === ev.key) {
284
+ ev.preventDefault();
285
+ ev.stopPropagation();
286
+ commitRename();
287
+ } else if ('Escape' === ev.key) {
288
+ ev.preventDefault();
289
+ ev.stopPropagation();
290
+ cancelRename();
291
+ } else ev.stopPropagation();
292
+ }
293
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTypography, {
182
294
  variant: spacing.primaryFontToken,
183
295
  color: 'var(--color-foreground)',
184
296
  children: item.name
185
297
  })
186
298
  }),
187
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
188
- className: "delete-button-wrapper",
189
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(action_button_cjs_namespaceObject.AutopilotChatActionButton, {
190
- disabled: !isHistoryOpen,
191
- ref: focusButtonRef,
192
- onClick: (ev)=>handleDelete(ev, item.id),
193
- onFocus: ()=>{
194
- setIsFocused(true);
195
- },
196
- onBlur: ()=>{
197
- setIsFocused(false);
198
- },
199
- onKeyDown: (ev)=>{
200
- if ('Escape' !== ev.key) ev.stopPropagation();
201
- if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
202
- },
203
- iconName: "delete",
204
- iconSize: "16px",
205
- tooltip: (isRemoveIconVisible || isFocused) && isHistoryOpen ? _({
206
- id: 'autopilot-chat.history.delete'
207
- }) : '',
208
- "data-testid": "autopilot-chat-history-delete",
209
- ariaLabel: _({
210
- id: 'autopilot-chat.history.delete'
299
+ !isEditing && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
300
+ className: "action-buttons-wrapper",
301
+ children: [
302
+ renameEnabled && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(action_button_cjs_namespaceObject.AutopilotChatActionButton, {
303
+ disabled: !isHistoryOpen,
304
+ onClick: (ev)=>handleRename(ev),
305
+ onFocus: ()=>{
306
+ setIsFocused(true);
307
+ },
308
+ onBlur: ()=>{
309
+ setIsFocused(false);
310
+ },
311
+ onKeyDown: (ev)=>{
312
+ if ('Escape' !== ev.key) ev.stopPropagation();
313
+ if ('Enter' === ev.key || ' ' === ev.key) handleRename(ev);
314
+ },
315
+ iconName: "edit",
316
+ iconSize: "16px",
317
+ tooltip: tooltipVisible ? renameLabel : '',
318
+ "data-testid": "autopilot-chat-history-rename",
319
+ ariaLabel: renameLabel
320
+ }),
321
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(action_button_cjs_namespaceObject.AutopilotChatActionButton, {
322
+ disabled: !isHistoryOpen,
323
+ onClick: (ev)=>handleDelete(ev, item.id),
324
+ onFocus: ()=>{
325
+ setIsFocused(true);
326
+ },
327
+ onBlur: ()=>{
328
+ setIsFocused(false);
329
+ },
330
+ onKeyDown: (ev)=>{
331
+ if ('Escape' !== ev.key) ev.stopPropagation();
332
+ if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
333
+ },
334
+ iconName: "delete",
335
+ iconSize: "16px",
336
+ tooltip: tooltipVisible ? deleteLabel : '',
337
+ "data-testid": "autopilot-chat-history-delete",
338
+ ariaLabel: deleteLabel
211
339
  })
212
- })
340
+ ]
213
341
  })
214
342
  ]
215
343
  }, item.id);
@@ -1 +1 @@
1
- {"version":3,"file":"chat-history-item.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/history/chat-history-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAyCvB,UAAU,6BAA6B;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;CACxB;AAgMD,eAAO,MAAM,wBAAwB,2DAAgD,CAAC"}
1
+ {"version":3,"file":"chat-history-item.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/history/chat-history-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AA+DvB,UAAU,6BAA6B;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;CACxB;AA0UD,eAAO,MAAM,wBAAwB,2DAAgD,CAAC"}
@@ -9,7 +9,7 @@ import { useChatState } from "../../providers/chat-state-provider.js";
9
9
  import { useLoading } from "../../providers/loading-provider.js";
10
10
  import { AutopilotChatEvent, AutopilotChatPreHookAction } from "../../service/index.js";
11
11
  import { AutopilotChatActionButton } from "../common/action-button.js";
12
- const GroupItem = styled('div')(({ isActive, showRemoveIcon })=>({
12
+ const GroupItem = styled('div')(({ isActive, showActionButtons })=>({
13
13
  width: `calc(100% - 2 * ${apollo_core.Spacing.SpacingBase})`,
14
14
  padding: `0 calc(${apollo_core.Padding.PadL} + ${apollo_core.Spacing.SpacingBase})`,
15
15
  display: 'flex',
@@ -27,11 +27,14 @@ const GroupItem = styled('div')(({ isActive, showRemoveIcon })=>({
27
27
  backgroundColor: 'var(--color-background-selected)',
28
28
  borderLeft: "4px solid var(--color-selection-indicator)"
29
29
  },
30
- '& .delete-button-wrapper': {
31
- opacity: showRemoveIcon ? 1 : 0,
30
+ '& .action-buttons-wrapper': {
31
+ opacity: showActionButtons ? 1 : 0,
32
32
  position: 'relative',
33
33
  left: apollo_core.Spacing.SpacingXs,
34
- marginRight: apollo_core.Spacing.SpacingBase
34
+ marginRight: apollo_core.Spacing.SpacingBase,
35
+ display: 'flex',
36
+ alignItems: 'center',
37
+ gap: apollo_core.Spacing.SpacingXs
35
38
  }
36
39
  }));
37
40
  const GroupTitle = styled('div')(()=>({
@@ -43,20 +46,47 @@ const GroupTitle = styled('div')(()=>({
43
46
  whiteSpace: 'nowrap'
44
47
  }
45
48
  }));
49
+ const RenameInput = styled('input')(()=>({
50
+ width: '100%',
51
+ padding: 0,
52
+ margin: 0,
53
+ border: 'none',
54
+ background: 'transparent',
55
+ color: 'var(--color-foreground)',
56
+ fontFamily: 'inherit',
57
+ fontSize: 'inherit',
58
+ lineHeight: 'inherit',
59
+ outline: 'none',
60
+ '&:focus-visible': {
61
+ outline: "1px solid var(--color-focus-indicator)",
62
+ outlineOffset: '2px',
63
+ borderRadius: apollo_core.Border.BorderRadiusS
64
+ }
65
+ }));
46
66
  const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
47
67
  const { _ } = useLingui();
48
68
  const chatService = useChatService();
49
- const { spacing } = useChatState();
69
+ const { spacing, disabledFeatures } = useChatState();
70
+ const renameEnabled = !disabledFeatures.renameChat;
50
71
  const [isActive, setIsActive] = react.useState(chatService.activeConversationId === item.id);
51
72
  const { setWaitingResponse } = useLoading();
52
- const [isRemoveIconVisible, setIsRemoveIconVisible] = react.useState(false);
73
+ const [isActionButtonsVisible, setIsActionButtonsVisible] = react.useState(false);
53
74
  const [isFocused, setIsFocused] = react.useState(false);
75
+ const [isEditing, setIsEditing] = react.useState(false);
76
+ const [draftName, setDraftName] = react.useState(item.name);
54
77
  const itemRef = react.useRef(null);
78
+ const inputRef = react.useRef(null);
55
79
  const lastMousePosition = react.useRef({
56
80
  x: 0,
57
81
  y: 0
58
82
  });
59
- const focusButtonRef = react.useRef(null);
83
+ const isCommittingRef = react.useRef(false);
84
+ react.useEffect(()=>{
85
+ if (!isEditing) setDraftName(item.name);
86
+ }, [
87
+ item.name,
88
+ isEditing
89
+ ]);
60
90
  react.useEffect(()=>{
61
91
  const handleMouseMove = (e)=>{
62
92
  if (isFocused) return;
@@ -67,7 +97,7 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
67
97
  if (itemRef.current) {
68
98
  const rect = itemRef.current.getBoundingClientRect();
69
99
  const isInside = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
70
- setIsRemoveIconVisible(isInside);
100
+ setIsActionButtonsVisible(isInside);
71
101
  }
72
102
  };
73
103
  document.addEventListener('mousemove', handleMouseMove);
@@ -99,6 +129,54 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
99
129
  isActive,
100
130
  setWaitingResponse
101
131
  ]);
132
+ react.useEffect(()=>{
133
+ if (isEditing) {
134
+ inputRef.current?.focus();
135
+ inputRef.current?.select();
136
+ }
137
+ }, [
138
+ isEditing
139
+ ]);
140
+ const enterEditMode = react.useCallback(()=>{
141
+ if (!isHistoryOpen) return;
142
+ isCommittingRef.current = false;
143
+ setDraftName(item.name);
144
+ setIsEditing(true);
145
+ }, [
146
+ isHistoryOpen,
147
+ item.name
148
+ ]);
149
+ const cancelRename = react.useCallback(()=>{
150
+ isCommittingRef.current = false;
151
+ setDraftName(item.name);
152
+ setIsEditing(false);
153
+ }, [
154
+ item.name
155
+ ]);
156
+ const commitRename = react.useCallback(()=>{
157
+ if (isCommittingRef.current) return;
158
+ const trimmed = draftName.trim();
159
+ if ('' === trimmed || trimmed === item.name) return void cancelRename();
160
+ if (!chatService) return void setIsEditing(false);
161
+ isCommittingRef.current = true;
162
+ chatService.getPreHook(AutopilotChatPreHookAction.RenameConversation)({
163
+ conversationId: item.id,
164
+ name: trimmed
165
+ }).then((proceed)=>{
166
+ if (!proceed) return void cancelRename();
167
+ chatService.renameConversation(item.id, trimmed);
168
+ setIsEditing(false);
169
+ isCommittingRef.current = false;
170
+ }).catch(()=>{
171
+ cancelRename();
172
+ });
173
+ }, [
174
+ draftName,
175
+ item.id,
176
+ item.name,
177
+ chatService,
178
+ cancelRename
179
+ ]);
102
180
  const handleDelete = react.useCallback((ev, itemId)=>{
103
181
  ev.stopPropagation();
104
182
  setIsFocused(false);
@@ -112,65 +190,115 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
112
190
  }, [
113
191
  chatService
114
192
  ]);
193
+ const handleRename = react.useCallback((ev)=>{
194
+ ev.stopPropagation();
195
+ setIsFocused(false);
196
+ enterEditMode();
197
+ }, [
198
+ enterEditMode
199
+ ]);
115
200
  const handleItemClick = react.useCallback((itemId)=>{
116
- if (isActive) return;
201
+ if (isEditing || isActive) return;
117
202
  chatService.openConversation(itemId);
118
203
  chatService.toggleHistory(false);
119
204
  }, [
120
205
  chatService,
121
- isActive
122
- ]);
123
- react.useEffect(()=>{
124
- if (isFocused) focusButtonRef.current?.focus();
125
- }, [
126
- isFocused
206
+ isActive,
207
+ isEditing
127
208
  ]);
209
+ const renameLabel = _({
210
+ id: 'autopilot-chat.history.rename'
211
+ });
212
+ const renameInputLabel = _({
213
+ id: 'autopilot-chat.history.rename-input'
214
+ });
215
+ const deleteLabel = _({
216
+ id: 'autopilot-chat.history.delete'
217
+ });
218
+ const showActionButtons = !isEditing && (isFocused || isActionButtonsVisible);
219
+ const tooltipVisible = showActionButtons && isHistoryOpen;
128
220
  return /*#__PURE__*/ jsxs(GroupItem, {
129
- showRemoveIcon: isFocused || isRemoveIconVisible,
221
+ showActionButtons: showActionButtons,
130
222
  ref: itemRef,
131
- tabIndex: isHistoryOpen ? 0 : -1,
223
+ tabIndex: isHistoryOpen && !isEditing ? 0 : -1,
132
224
  isActive: isActive,
133
225
  onClick: ()=>handleItemClick(item.id),
134
226
  onKeyDown: (ev)=>{
227
+ if (isEditing) return;
135
228
  if ('Enter' === ev.key || ' ' === ev.key) handleItemClick(item.id);
136
229
  },
137
- "aria-label": item.name,
138
- role: "button",
139
- "aria-pressed": isActive,
230
+ "aria-label": isEditing ? void 0 : item.name,
231
+ role: isEditing ? void 0 : 'button',
232
+ "aria-pressed": isEditing ? void 0 : isActive,
140
233
  children: [
141
234
  /*#__PURE__*/ jsx(GroupTitle, {
142
- children: /*#__PURE__*/ jsx(ApTypography, {
235
+ children: isEditing ? /*#__PURE__*/ jsx(RenameInput, {
236
+ ref: inputRef,
237
+ value: draftName,
238
+ "aria-label": renameInputLabel,
239
+ "data-testid": "autopilot-chat-history-rename-input",
240
+ onChange: (ev)=>setDraftName(ev.target.value),
241
+ onClick: (ev)=>ev.stopPropagation(),
242
+ onBlur: commitRename,
243
+ onKeyDown: (ev)=>{
244
+ if ('Enter' === ev.key) {
245
+ ev.preventDefault();
246
+ ev.stopPropagation();
247
+ commitRename();
248
+ } else if ('Escape' === ev.key) {
249
+ ev.preventDefault();
250
+ ev.stopPropagation();
251
+ cancelRename();
252
+ } else ev.stopPropagation();
253
+ }
254
+ }) : /*#__PURE__*/ jsx(ApTypography, {
143
255
  variant: spacing.primaryFontToken,
144
256
  color: 'var(--color-foreground)',
145
257
  children: item.name
146
258
  })
147
259
  }),
148
- /*#__PURE__*/ jsx("div", {
149
- className: "delete-button-wrapper",
150
- children: /*#__PURE__*/ jsx(AutopilotChatActionButton, {
151
- disabled: !isHistoryOpen,
152
- ref: focusButtonRef,
153
- onClick: (ev)=>handleDelete(ev, item.id),
154
- onFocus: ()=>{
155
- setIsFocused(true);
156
- },
157
- onBlur: ()=>{
158
- setIsFocused(false);
159
- },
160
- onKeyDown: (ev)=>{
161
- if ('Escape' !== ev.key) ev.stopPropagation();
162
- if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
163
- },
164
- iconName: "delete",
165
- iconSize: "16px",
166
- tooltip: (isRemoveIconVisible || isFocused) && isHistoryOpen ? _({
167
- id: 'autopilot-chat.history.delete'
168
- }) : '',
169
- "data-testid": "autopilot-chat-history-delete",
170
- ariaLabel: _({
171
- id: 'autopilot-chat.history.delete'
260
+ !isEditing && /*#__PURE__*/ jsxs("div", {
261
+ className: "action-buttons-wrapper",
262
+ children: [
263
+ renameEnabled && /*#__PURE__*/ jsx(AutopilotChatActionButton, {
264
+ disabled: !isHistoryOpen,
265
+ onClick: (ev)=>handleRename(ev),
266
+ onFocus: ()=>{
267
+ setIsFocused(true);
268
+ },
269
+ onBlur: ()=>{
270
+ setIsFocused(false);
271
+ },
272
+ onKeyDown: (ev)=>{
273
+ if ('Escape' !== ev.key) ev.stopPropagation();
274
+ if ('Enter' === ev.key || ' ' === ev.key) handleRename(ev);
275
+ },
276
+ iconName: "edit",
277
+ iconSize: "16px",
278
+ tooltip: tooltipVisible ? renameLabel : '',
279
+ "data-testid": "autopilot-chat-history-rename",
280
+ ariaLabel: renameLabel
281
+ }),
282
+ /*#__PURE__*/ jsx(AutopilotChatActionButton, {
283
+ disabled: !isHistoryOpen,
284
+ onClick: (ev)=>handleDelete(ev, item.id),
285
+ onFocus: ()=>{
286
+ setIsFocused(true);
287
+ },
288
+ onBlur: ()=>{
289
+ setIsFocused(false);
290
+ },
291
+ onKeyDown: (ev)=>{
292
+ if ('Escape' !== ev.key) ev.stopPropagation();
293
+ if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
294
+ },
295
+ iconName: "delete",
296
+ iconSize: "16px",
297
+ tooltip: tooltipVisible ? deleteLabel : '',
298
+ "data-testid": "autopilot-chat-history-delete",
299
+ ariaLabel: deleteLabel
172
300
  })
173
- })
301
+ ]
174
302
  })
175
303
  ]
176
304
  }, item.id);
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  messages: ()=>messages
28
28
  });
29
- const messages = JSON.parse('{"autopilot-chat.common.attachments.remove-file":["Remove"],"autopilot-chat.common.attachments.remove-file-name":["Remove ",["name"]],"autopilot-chat.common.mode-selector":["Mode selector"],"autopilot-chat.common.model-selector":["Model selector"],"autopilot-chat.dropzone.allowed-file-types":["Allowed file types: ",["fileTypes"]],"autopilot-chat.dropzone.overlay-max-count":["Maximum files allowed: ",["maxCount"]],"autopilot-chat.dropzone.overlay-max-size":["Maximum file size: ",["maxSize"],"MB"],"autopilot-chat.dropzone.overlay-title":["Drop your files here to add them to your prompt"],"autopilot-chat.error.file-invalid-type":["Unsupported file: ",["fileName"]],"autopilot-chat.error.file-too-large":["File too large: ",["fileName"]," ",["fileSize"],"MB/",["maxSize"],"MB"],"autopilot-chat.error.multiple-files":["Only one file can be attached per message"],"autopilot-chat.error.too-many-files":["Too many files. ",["maxCount"]," files are allowed per message"],"autopilot-chat.header.actions.close":["Close chat"],"autopilot-chat.header.actions.collapse":["Collapse"],"autopilot-chat.header.actions.custom-actions":["More actions"],"autopilot-chat.header.actions.expand":["Expand"],"autopilot-chat.header.actions.history":["Chat history"],"autopilot-chat.header.actions.new-chat":["New chat"],"autopilot-chat.header.actions.settings":["Settings"],"autopilot-chat.header.preview":["Preview"],"autopilot-chat.header.title":["Autopilot"],"autopilot-chat.history.delete":["Delete"],"autopilot-chat.history.empty":["There are no conversations yet."],"autopilot-chat.history.group.last-30-days":["Previous 30 days"],"autopilot-chat.history.group.last-week":["Last week"],"autopilot-chat.history.group.months-ago":[["count"]," months ago"],"autopilot-chat.history.group.today":["Today"],"autopilot-chat.history.group.yesterday":["Yesterday"],"autopilot-chat.history.no-results":["No results found."],"autopilot-chat.history.search-placeholder":["Search"],"autopilot-chat.input.actions.attach-file":["Attach file(s)"],"autopilot-chat.input.actions.attachments.allowed-types":["Allowed file types: ",["fileTypes"]],"autopilot-chat.input.actions.attachments.max-count":["Maximum files allowed: ",["maxCount"]],"autopilot-chat.input.actions.attachments.max-size":["Maximum file size: ",["maxSize"],"MB"],"autopilot-chat.input.actions.dictate":["Dictate"],"autopilot-chat.input.actions.error.file-too-large":["File too large: ",["fileName"]," ",["fileSize"],"MB/",["maxSize"],"MB"],"autopilot-chat.input.actions.send":["Send"],"autopilot-chat.input.actions.stop":["Stop"],"autopilot-chat.input.actions.voice-interaction":["Voice interaction"],"autopilot-chat.input.agent-mode-selection-label":["Agent mode selection"],"autopilot-chat.input.footer":["Autopilot can make mistakes. Please double check the responses."],"autopilot-chat.input.model-selection-label":["Model selection"],"autopilot-chat.input.placeholder":["What would you like me to do?"],"autopilot-chat.input.resource-chip.remove":["Remove"],"autopilot-chat.input.resource-chip.remove-name":["Remove ",["label"]],"autopilot-chat.message.actions.bad":["Needs improvement"],"autopilot-chat.message.actions.copy":["Copy"],"autopilot-chat.message.actions.good":["Love this"],"autopilot-chat.message.actions.label":["Message actions"],"autopilot-chat.message.actions.more":["More actions"],"autopilot-chat.message.citation-aria-label":["Citation ",["id"],": ",["title"]],"autopilot-chat.message.close":["Close chat"],"autopilot-chat.message.code-block-code":["Code"],"autopilot-chat.message.code-block-copy":["Copy"],"autopilot-chat.message.code-block-language":["Text"],"autopilot-chat.message.code-block-preview":["Preview"],"autopilot-chat.message.expand":["Expand"],"autopilot-chat.message.footnote-label":["Sources"],"autopilot-chat.message.generating-response":["Generating..."],"autopilot-chat.message.page-number":["Page ",["page_number"]],"autopilot-chat.message.scroll-to-bottom":["Scroll to bottom"],"autopilot-chat.message.show-less":["Show less"],"autopilot-chat.message.show-more":["Show more"],"autopilot-chat.message.sources":["Sources"],"autopilot-chat.message.suggestions-title":["Suggestions"],"autopilot-chat.resource-picker.back":["Go back"],"autopilot-chat.resource-picker.empty":["No resources available"],"autopilot-chat.resource-picker.error":["Failed to load resources"],"autopilot-chat.resource-picker.label":["Resource picker"],"autopilot-chat.resource-picker.load-more-error":["Failed to load more"],"autopilot-chat.resource-picker.no-results":["No matching resources"],"autopilot-chat.resource-picker.retry":["Retry"],"autopilot-chat.resource-picker.search-error":["Search failed"],"autopilot-chat.resource-trigger.label":["Add resource reference"],"autopilot-chat.resource-trigger.tooltip":["Add resource"],"autopilot-chat.settings.heading-description":["heading level 2"],"autopilot-chat.settings.hide":["Hide settings"],"autopilot-chat.settings.title":["Chat settings"],"autopilot-chat.tree.no-description":["No description"],"autopilot-chat.tree.no-items":["No items"],"autopilot-chat.tree.unknown":["Unknown"]}');
29
+ const messages = JSON.parse('{"autopilot-chat.common.attachments.remove-file":["Remove"],"autopilot-chat.common.attachments.remove-file-name":["Remove ",["name"]],"autopilot-chat.common.mode-selector":["Mode selector"],"autopilot-chat.common.model-selector":["Model selector"],"autopilot-chat.dropzone.allowed-file-types":["Allowed file types: ",["fileTypes"]],"autopilot-chat.dropzone.overlay-max-count":["Maximum files allowed: ",["maxCount"]],"autopilot-chat.dropzone.overlay-max-size":["Maximum file size: ",["maxSize"],"MB"],"autopilot-chat.dropzone.overlay-title":["Drop your files here to add them to your prompt"],"autopilot-chat.error.file-invalid-type":["Unsupported file: ",["fileName"]],"autopilot-chat.error.file-too-large":["File too large: ",["fileName"]," ",["fileSize"],"MB/",["maxSize"],"MB"],"autopilot-chat.error.multiple-files":["Only one file can be attached per message"],"autopilot-chat.error.too-many-files":["Too many files. ",["maxCount"]," files are allowed per message"],"autopilot-chat.header.actions.close":["Close chat"],"autopilot-chat.header.actions.collapse":["Collapse"],"autopilot-chat.header.actions.custom-actions":["More actions"],"autopilot-chat.header.actions.expand":["Expand"],"autopilot-chat.header.actions.history":["Chat history"],"autopilot-chat.header.actions.new-chat":["New chat"],"autopilot-chat.header.actions.settings":["Settings"],"autopilot-chat.header.preview":["Preview"],"autopilot-chat.header.title":["Autopilot"],"autopilot-chat.history.delete":["Delete"],"autopilot-chat.history.empty":["There are no conversations yet."],"autopilot-chat.history.group.last-30-days":["Previous 30 days"],"autopilot-chat.history.group.last-week":["Last week"],"autopilot-chat.history.group.months-ago":[["count"]," months ago"],"autopilot-chat.history.group.today":["Today"],"autopilot-chat.history.group.yesterday":["Yesterday"],"autopilot-chat.history.no-results":["No results found."],"autopilot-chat.history.rename":["Rename chat"],"autopilot-chat.history.rename-input":["Chat name"],"autopilot-chat.history.search-placeholder":["Search"],"autopilot-chat.input.actions.attach-file":["Attach file(s)"],"autopilot-chat.input.actions.attachments.allowed-types":["Allowed file types: ",["fileTypes"]],"autopilot-chat.input.actions.attachments.max-count":["Maximum files allowed: ",["maxCount"]],"autopilot-chat.input.actions.attachments.max-size":["Maximum file size: ",["maxSize"],"MB"],"autopilot-chat.input.actions.dictate":["Dictate"],"autopilot-chat.input.actions.error.file-too-large":["File too large: ",["fileName"]," ",["fileSize"],"MB/",["maxSize"],"MB"],"autopilot-chat.input.actions.send":["Send"],"autopilot-chat.input.actions.stop":["Stop"],"autopilot-chat.input.actions.voice-interaction":["Voice interaction"],"autopilot-chat.input.agent-mode-selection-label":["Agent mode selection"],"autopilot-chat.input.footer":["Autopilot can make mistakes. Please double check the responses."],"autopilot-chat.input.model-selection-label":["Model selection"],"autopilot-chat.input.placeholder":["What would you like me to do?"],"autopilot-chat.input.resource-chip.remove":["Remove"],"autopilot-chat.input.resource-chip.remove-name":["Remove ",["label"]],"autopilot-chat.message.actions.bad":["Needs improvement"],"autopilot-chat.message.actions.copy":["Copy"],"autopilot-chat.message.actions.good":["Love this"],"autopilot-chat.message.actions.label":["Message actions"],"autopilot-chat.message.actions.more":["More actions"],"autopilot-chat.message.citation-aria-label":["Citation ",["id"],": ",["title"]],"autopilot-chat.message.close":["Close chat"],"autopilot-chat.message.code-block-code":["Code"],"autopilot-chat.message.code-block-copy":["Copy"],"autopilot-chat.message.code-block-language":["Text"],"autopilot-chat.message.code-block-preview":["Preview"],"autopilot-chat.message.expand":["Expand"],"autopilot-chat.message.footnote-label":["Sources"],"autopilot-chat.message.generating-response":["Generating..."],"autopilot-chat.message.page-number":["Page ",["page_number"]],"autopilot-chat.message.scroll-to-bottom":["Scroll to bottom"],"autopilot-chat.message.show-less":["Show less"],"autopilot-chat.message.show-more":["Show more"],"autopilot-chat.message.sources":["Sources"],"autopilot-chat.message.suggestions-title":["Suggestions"],"autopilot-chat.resource-picker.back":["Go back"],"autopilot-chat.resource-picker.empty":["No resources available"],"autopilot-chat.resource-picker.error":["Failed to load resources"],"autopilot-chat.resource-picker.label":["Resource picker"],"autopilot-chat.resource-picker.load-more-error":["Failed to load more"],"autopilot-chat.resource-picker.no-results":["No matching resources"],"autopilot-chat.resource-picker.retry":["Retry"],"autopilot-chat.resource-picker.search-error":["Search failed"],"autopilot-chat.resource-trigger.label":["Add resource reference"],"autopilot-chat.resource-trigger.tooltip":["Add resource"],"autopilot-chat.settings.heading-description":["heading level 2"],"autopilot-chat.settings.hide":["Hide settings"],"autopilot-chat.settings.title":["Chat settings"],"autopilot-chat.tree.no-description":["No description"],"autopilot-chat.tree.no-items":["No items"],"autopilot-chat.tree.unknown":["Unknown"]}');
30
30
  exports.messages = __webpack_exports__.messages;
31
31
  for(var __rspack_i in __webpack_exports__)if (-1 === [
32
32
  "messages"
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../../src/material/components/ap-chat/locales/en.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,EAA+3K,QAAQ,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../../src/material/components/ap-chat/locales/en.ts"],"names":[],"mappings":"AAAkB,OAAO,KAAI,EAAC,QAAQ,EAAC,MAAI,cAAc,CAAC;AAAA,eAAO,MAAM,QAAQ,EAA2+K,QAAQ,CAAC"}