Repository navigation
Conversation
Saving an edited message kept the attachments removed in the edit input, and kept the previous text when the input was emptied. An empty list of attachments was dropped at each step: when building the updated message, when sending it over the websocket, when applying the server message and when converting it to a shared model message.
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #586
Problem
Removing an attachment while editing a message has no effect once the edit is saved:
xbutton and save.(edited)but the attachment is still there.The same happens with the text: when a message has an attachment, clearing the text in the edit input and saving keeps the previous text.
I noticed it while editing messages in a local JupyterLab.
The empty list of attachments is lost at each step of the update:
ChatMessageonly copiesattachments(andbody) from the edit input when they are truthy, andInputModel.sendomitsattachmentswhen the list is empty, so the updated message keeps the previous ones.WebSocketHandler.updateMessagedoes not send an emptyattachmentslist, and_applyMessageignores an empty list in the message sent back by the server.LabChatModel.toYMessagedrops an empty list, so the shared model message keeps its attachments (this is the path used withjupyter_collaboration).Solution
ChatMessage, the saved message takes the text and the attachments of the edit input as they are, an empty list when all the attachments were removed.WebSocketHandlerandLabChatModel.toYMessage, an emptyattachmentslist is kept instead of being dropped. A message updated withoutattachments(undefined) still keeps its attachments, so other callers ofupdateMessageare not affected. The server already handles an empty list in aneditmessage.flowchart TD A[Message sent with a file attached] --> B{Edit it, remove the file, save} B -->|Before| C[File still on the message] B -->|After| D[File removed from the message]Narrated recording, before then after (sound on):
evidence.mp4
Edge cases and unchanged behavior checked
Checked in the running app (JupyterLab 4.6.6 with the extension built from
mainatc112d54, then from this branch, withoutjupyter_collaboration) and shown in the recording:Checked by tests only:
jupyter_collaborationinstalled (shared model path): the new UI test, and the new unit test inmodel.spec.ts.attachmentskeeps its attachments, and nothing is sent for them (websocket-handler.spec.ts).Tests run
With the source change reverted and the tests kept, 3 of the 5 new unit tests fail (the other 2 cover the behavior that must not change).
The new UI test
Should remove the attachment when editing a messagealso passes withjupyter_collaboration>=5,<6installed.prettier --checkandeslintpass on the changed files, andjlpm build(TypeScript) passes.Not run: the full jest suites, the full UI test suite and the Python tests (no Python change).
AI tools (Claude Code) assisted with this change; the bug was reproduced and the fix verified manually in the running app.
🤖 Generated with Claude Code