message_list_tooltips: Add "View bot card" tooltips for bots.

This change aids in differentiating between a normal user and a bot
account, furthur eliminating any confusion between them (a step forward,
considering how good LLM bots have become in impersonating a real user).

Fixes #25958.

Co-authored-by: 1010nishant <nishantjangid6377@gmail.com>
This commit is contained in:
Sayam Samal 2024-02-26 04:30:38 +05:30 committed by Tim Abbott
parent 30aa0a19fe
commit 069680a7d1
4 changed files with 14 additions and 2 deletions

View File

@ -283,6 +283,14 @@ export function initialize() {
message_list_tooltip(".view_user_card_tooltip", {
delay: LONG_HOVER_DELAY,
onShow(instance) {
const is_bot = $(instance.reference).data("is-bot");
if (is_bot) {
instance.setContent(parse_html($("#view-bot-card-tooltip-template").html()));
} else {
instance.setContent(parse_html($("#view-user-card-tooltip-template").html()));
}
},
onHidden(instance) {
instance.destroy();
},

View File

@ -1,4 +1,4 @@
<div class="u-{{msg/sender_id}} message-avatar sender_info_hover view_user_card_tooltip no-select" aria-hidden="true" data-tooltip-template-id="view-user-card-tooltip-template">
<div class="u-{{msg/sender_id}} message-avatar sender_info_hover view_user_card_tooltip no-select" aria-hidden="true" data-is-bot="{{sender_is_bot}}">
<div class="inline_profile_picture {{#sender_is_guest}} guest-avatar{{/sender_is_guest}}">
<img src="{{small_avatar_url}}" alt="" class="no-drag"/>
</div>

View File

@ -4,7 +4,7 @@
<span class="message_sender">
{{#if include_sender}}
<span class="sender_info_hover sender_name" role="button" tabindex="0">
<span class="view_user_card_tooltip sender_name_text" data-tooltip-template-id="view-user-card-tooltip-template">
<span class="view_user_card_tooltip sender_name_text" data-is-bot="{{sender_is_bot}}">
{{> user_full_name name=msg/sender_full_name should_add_guest_user_indicator=should_add_guest_indicator_for_sender}}
</span>
{{#unless status_message}}

View File

@ -2,6 +2,10 @@
{{t 'View user card' }}
{{tooltip_hotkey_hints "U"}}
</template>
<template id="view-bot-card-tooltip-template">
{{t 'View bot card' }}
{{tooltip_hotkey_hints "U"}}
</template>
<template id="compose_draft_tooltip_template">
{{t 'Drafts' }}
{{tooltip_hotkey_hints "D"}}