Commit a8f6d85
Add message deletion functionality to AI Assistant (supabase#37698)
* add delete chat message functionality
* Implement message editing functionality in AIAssistant
* add functionality to delete messages in AI Assistant chat in assistant state
* remove duplicated `text-xs` class
* add a 'group' class for improved styling and refining action button visibility on hover
* Refine action button visibility in AIAssistantPanel to show only for user messages on hover, improving user experience.
* remove `"` from the message to edit
* Enhance editing message display in AIAssistantPanel by updating styling for improved visibility and user experience.
* Refactor AIAssistantPanel state management by simplifying original message content initialization and clarifying comments for better code readability.
* clean up action button rendering in AIAssistantPanel message component
* adjust the chat message layout (space)
* simplify the editing mode message
* show the edit button even when user is already in the edit mode
* Update AssistantChatForm styling for editing mode, positioning the editing message above the input field without changing the layout
* use `ButtonTooltip` for edit button to show tooltip
* simplify the condiiton to show the edit buton
* add the delete action button
* Refactor action button rendering in AIAssistantPanel to improve clarity and maintainability. Ensure buttons are only shown for user messages on hover, and simplify the conditional rendering logic.
* Remove commented-out code for cleaner implementation.
* improve unused onDeleteAfter prop and consolidating delete logic into a single `deleteMessageFromHere` function for improved clarity
* abort streaming when a user deletes a message
* delete unnecessary `originalMessageContent` state variable
* delete `confirmEdit` and move its logic into `sendMessageToAssistant`
* add `strokeWidth={1.5}` to `Pencil` icon
* add `opacity-50` to any messages that are after the message being edited, and it cancels the edit when those messages are clicked
* add a pulse animation to the user’s message being edited
* add more space between mesages and `AssistantChatForm`
* add framer-motion animation to `Editing message` element
* update strokeWidth of Trash2 icon in Message component for better visibility
* refactor Message component to make onDelete prop required
* add `DeleteMessageConfirmModal` for message deletion confirmation in Message component
* refactor message deletion logic in AIAssistant component to streamline editing process
* cancel editing when a user clicks the edit button again or the edit button in subsequent messages
* Add success toast notification for message deletion
* add Pencil icon to AIAssistantPanel component and fixed duplicated tailwind class
* Update AIAssistantPanel to use the Pencil icon
* Refactor AIAssistant to set editing message content from text parts
* Remove unused `reload` prop from AIAssistant component
* `setIsSticky(false)` when a user deletes all the messages or clear the chat to remove the `ArrowDown` icon scroll down button
* refactor: remove deleteMessagesBefore function from AiAssistantState
* refactor: simplify AssistantChatForm layout by removing unnecessary `z-index`
* enable the input field when a user wants to edit the message while the response is streaming
* Smol fixes
* remove conosle log
* Add state for resubmitting in AI Assistant panel
* Remove classes that hide the focus styles + fix focusing when editing message to ensure cursor is at the end of the text
---------
Co-authored-by: Joshen Lim <[email protected]>1 parent aea43f6 commit a8f6d85
File tree
5 files changed
+168
-36
lines changed- apps/studio/components/ui/AIAssistantPanel
5 files changed
+168
-36
lines changedLines changed: 59 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| |||
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
| 125 | + | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| |||
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
252 | 272 | | |
253 | 273 | | |
254 | 274 | | |
| |||
266 | 286 | | |
267 | 287 | | |
268 | 288 | | |
269 | | - | |
270 | | - | |
271 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
272 | 299 | | |
273 | 300 | | |
274 | 301 | | |
| |||
292 | 319 | | |
293 | 320 | | |
294 | 321 | | |
| 322 | + | |
295 | 323 | | |
296 | 324 | | |
297 | 325 | | |
298 | 326 | | |
299 | 327 | | |
300 | 328 | | |
301 | 329 | | |
302 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
303 | 339 | | |
304 | 340 | | |
305 | 341 | | |
| |||
308 | 344 | | |
309 | 345 | | |
310 | 346 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
317 | 350 | | |
318 | 351 | | |
319 | 352 | | |
| |||
355 | 388 | | |
356 | 389 | | |
357 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
358 | 399 | | |
359 | 400 | | |
360 | 401 | | |
| |||
381 | 422 | | |
382 | 423 | | |
383 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
384 | 429 | | |
385 | 430 | | |
386 | 431 | | |
| |||
699 | 744 | | |
700 | 745 | | |
701 | 746 | | |
702 | | - | |
| 747 | + | |
| 748 | + | |
703 | 749 | | |
704 | 750 | | |
705 | 751 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | | - | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
110 | 114 | | |
111 | | - | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| 78 | + | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| |||
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
240 | | - | |
241 | | - | |
| 245 | + | |
| 246 | + | |
242 | 247 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
259 | 278 | | |
260 | 279 | | |
261 | 280 | | |
262 | 281 | | |
263 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
264 | 293 | | |
265 | 294 | | |
266 | 295 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
0 commit comments