File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
packages/jupyterlab-chat/src
python/jupyterlab-chat/jupyterlab_chat Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -162,13 +162,13 @@ export class LabChatModel extends ChatModel implements DocumentRegistry.IModel {
162
162
}
163
163
164
164
// Add the attachments to the message.
165
- if ( this . input . attachments . length ) {
166
- const attachmentIds = this . input . attachments . map ( attachment =>
167
- this . sharedModel . setAttachment ( attachment )
168
- ) ;
165
+ const attachmentIds = this . input . attachments ?. map ( attachment =>
166
+ this . sharedModel . setAttachment ( attachment )
167
+ ) ;
168
+ if ( attachmentIds ?. length ) {
169
169
msg . attachments = attachmentIds ;
170
- this . input . clearAttachments ( ) ;
171
170
}
171
+ this . input . clearAttachments ( ) ;
172
172
173
173
this . sharedModel . addMessage ( msg ) ;
174
174
}
@@ -204,9 +204,12 @@ export class LabChatModel extends ChatModel implements DocumentRegistry.IModel {
204
204
const attachmentIds = updatedMessage . attachments ?. map ( attachment =>
205
205
this . sharedModel . setAttachment ( attachment )
206
206
) ;
207
- if ( attachmentIds ) {
207
+ if ( attachmentIds ?. length ) {
208
208
message . attachments = attachmentIds ;
209
+ } else {
210
+ delete message . attachments ;
209
211
}
212
+
210
213
this . sharedModel . updateMessage ( index , message as IYmessage ) ;
211
214
}
212
215
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ class Message:
35
35
# 3.9 reaches EOL.
36
36
type : Literal ["msg" ] = "msg"
37
37
38
+ attachments : Optional [list [str ]] = None
39
+ """ The message attachments, a list of attachment ID """
40
+
38
41
raw_time : Optional [bool ] = None
39
42
"""
40
43
Whether the timestamp is raw (from client) or not (from server, unified)
You can’t perform that action at this time.
0 commit comments