Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChatMessage & ChatFeed edit functionality #7559

Merged
merged 15 commits into from
Jan 13, 2025
Merged

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Dec 17, 2024

Closes #5761

Useful for editing & re-triggering downstream chat events if necessary

Introduces:

  • enter_pressed in ChatAreaInput because it's better than watching value change and parallels TextInput's enter_pressed
  1. show_edit_icon for the new edit icon that toggles the ChatMessage between original object & ChatAreaInput; only shows if message is from user
  2. edited for when an edit is submitted in ChatMessage
  3. Feed watches messages for any edited event; if so, call edit_callback with contents, index, instance
def echo_callback(content, index, instance):
    return content

def edit_callback(content, index, instance):
    instance.objects[index + 1].object = content

feed = ChatFeed(edit_callback=edit_callback, callback=echo_callback, callback_user="Echo Guy")
feed.send(pn.widgets.TextInput(value="Hello World!"))
feed.show()
edit.mp4

@ahuang11 ahuang11 added the type: feature A major new feature label Dec 17, 2024
@ahuang11 ahuang11 added this to the v1.6.0 milestone Dec 17, 2024
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 12 lines in your changes missing coverage. Please review.

Project coverage is 82.21%. Comparing base (6544d78) to head (d72c215).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
panel/tests/ui/chat/test_chat_interface_ui.py 60.00% 6 Missing ⚠️
panel/chat/message.py 90.00% 4 Missing ⚠️
panel/chat/feed.py 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7559      +/-   ##
==========================================
+ Coverage   82.19%   82.21%   +0.01%     
==========================================
  Files         340      340              
  Lines       51533    51632      +99     
==========================================
+ Hits        42359    42448      +89     
- Misses       9174     9184      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

panel/chat/interface.py Outdated Show resolved Hide resolved
@philippjfr
Copy link
Member

Needs rebasing.

panel/chat/feed.py Outdated Show resolved Hide resolved
panel/chat/message.py Outdated Show resolved Hide resolved
@ahuang11 ahuang11 requested a review from philippjfr January 10, 2025 19:33
@philippjfr philippjfr merged commit 2e71bae into main Jan 13, 2025
18 checks passed
@philippjfr philippjfr deleted the add_edit_message branch January 13, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A major new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit button for ChatMessage
2 participants