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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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.24%. Comparing base (ad154df) to head (eabaf0e).
Report is 2 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   71.90%   82.24%   +10.33%     
===========================================
  Files         338      339        +1     
  Lines       51441    51575      +134     
===========================================
+ Hits        36990    42418     +5428     
+ Misses      14451     9157     -5294     

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

panel/chat/interface.py Outdated Show resolved Hide resolved
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
1 participant