-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add generated caution text to the messages with corresponding k…
…eywords (#5298) * feat: add generated text to the messages with corresponding keywords * Changelog * Snapshots * Update multiline message snapshot * Update packages/component/src/Attachment/Text/TextContent.tsx Co-authored-by: William Wong <[email protected]> --------- Co-authored-by: William Wong <[email protected]>
- Loading branch information
Showing
65 changed files
with
103 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/ | |
- Moved from `[email protected]` to `@redux/[email protected]`, in PR [#5292](https://github.com/microsoft/BotFramework-WebChat/pull/5292), by [@compulim](https://github.com/compulim) | ||
- Enhanced the visual presentation of the Fluent theme copilot variant, in PR [#5293](https://github.com/microsoft/BotFramework-WebChat/pull/5293), by [@OEvgeny](https://github.com/OEvgeny) | ||
- Refactored spacing and layout for copilot variant in Fluent theme, improving visual consistency, in PR [#5296](https://github.com/microsoft/BotFramework-WebChat/pull/5296), by [@OEvgeny](https://github.com/OEvgeny) | ||
- Added a content generated badge to AI-generated messages, in PR [#5298](https://github.com/microsoft/BotFramework-WebChat/pull/5298), by [@OEvgeny](https://github.com/OEvgeny) | ||
|
||
### Fixed | ||
|
||
|
Binary file modified
BIN
+1 Byte
(100%)
...nter-on-an-empty-multiline-send-box-should-alert-about-empty-message-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+235 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+232 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+231 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+235 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+230 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-5-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+232 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-6-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+231 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-7-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+232 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-8-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+240 KB
...eme-applied-dark-theme-applied-side-by-side-left-fluent-right-fluent-9-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.3 KB
(100%)
...rk-theme-applied-side-by-side-left-transcript-right-pre-chat-message-5-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.3 KB
(98%)
...rk-theme-applied-side-by-side-left-transcript-right-pre-chat-message-6-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.9 KB
(100%)
...rk-theme-applied-side-by-side-left-transcript-right-pre-chat-message-7-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.87 KB
(100%)
...rk-theme-applied-side-by-side-left-transcript-right-pre-chat-message-8-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+201 KB
...rk-theme-applied-side-by-side-left-transcript-right-pre-chat-message-9-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+7.17 KB
(100%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-10-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.81 KB
(98%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-11-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.05 KB
(100%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-12-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.23 KB
(100%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-13-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+344 Bytes
(100%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-14-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.95 KB
(98%)
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-15-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+242 KB
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-16-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+249 KB
...ed-dark-theme-applied-side-by-side-left-transcript-right-transcript-17-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.06 KB
(100%)
...ied-dark-theme-applied-side-by-side-left-transcript-right-transcript-5-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.36 KB
(100%)
...ied-dark-theme-applied-side-by-side-left-transcript-right-transcript-6-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.38 KB
(99%)
...ied-dark-theme-applied-side-by-side-left-transcript-right-transcript-7-snap.png
Oops, something went wrong.
Binary file modified
BIN
-4.67 KB
(98%)
...ied-dark-theme-applied-side-by-side-left-transcript-right-transcript-8-snap.png
Oops, something went wrong.
Binary file modified
BIN
+7.47 KB
(100%)
...ied-dark-theme-applied-side-by-side-left-transcript-right-transcript-9-snap.png
Oops, something went wrong.
Binary file added
BIN
+262 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-1-snap.png
Oops, something went wrong.
Binary file added
BIN
+258 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-2-snap.png
Oops, something went wrong.
Binary file added
BIN
+257 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-3-snap.png
Oops, something went wrong.
Binary file added
BIN
+263 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-4-snap.png
Oops, something went wrong.
Binary file added
BIN
+257 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-5-snap.png
Oops, something went wrong.
Binary file added
BIN
+257 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-6-snap.png
Oops, something went wrong.
Binary file added
BIN
+258 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-7-snap.png
Oops, something went wrong.
Binary file added
BIN
+259 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-8-snap.png
Oops, something went wrong.
Binary file added
BIN
+276 KB
...e-wide-js-fluent-theme-applied-side-by-side-left-fluent-right-fluent-9-snap.png
Oops, something went wrong.
Binary file modified
BIN
+3.57 KB
(100%)
...nt-theme-applied-side-by-side-left-transcript-right-pre-chat-message-5-snap.png
Oops, something went wrong.
Binary file modified
BIN
-3.59 KB
(98%)
...nt-theme-applied-side-by-side-left-transcript-right-pre-chat-message-6-snap.png
Oops, something went wrong.
Binary file modified
BIN
+3.11 KB
(100%)
...nt-theme-applied-side-by-side-left-transcript-right-pre-chat-message-7-snap.png
Oops, something went wrong.
Binary file modified
BIN
+4.16 KB
(100%)
...nt-theme-applied-side-by-side-left-transcript-right-pre-chat-message-8-snap.png
Oops, something went wrong.
Binary file added
BIN
+225 KB
...nt-theme-applied-side-by-side-left-transcript-right-pre-chat-message-9-snap.png
Oops, something went wrong.
Binary file modified
BIN
+6.32 KB
(100%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-10-snap.png
Oops, something went wrong.
Binary file modified
BIN
-6.14 KB
(98%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-11-snap.png
Oops, something went wrong.
Binary file modified
BIN
+5.56 KB
(100%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-12-snap.png
Oops, something went wrong.
Binary file modified
BIN
+4.22 KB
(100%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-13-snap.png
Oops, something went wrong.
Binary file modified
BIN
+245 Bytes
(100%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-14-snap.png
Oops, something went wrong.
Binary file modified
BIN
-15.5 KB
(95%)
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-15-snap.png
Oops, something went wrong.
Binary file added
BIN
+270 KB
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-16-snap.png
Oops, something went wrong.
Binary file added
BIN
+289 KB
...-fluent-theme-applied-side-by-side-left-transcript-right-transcript-17-snap.png
Oops, something went wrong.
Binary file modified
BIN
+425 Bytes
(100%)
...s-fluent-theme-applied-side-by-side-left-transcript-right-transcript-5-snap.png
Oops, something went wrong.
Binary file modified
BIN
+1.72 KB
(100%)
...s-fluent-theme-applied-side-by-side-left-transcript-right-transcript-6-snap.png
Oops, something went wrong.
Binary file modified
BIN
-2.14 KB
(99%)
...s-fluent-theme-applied-side-by-side-left-transcript-right-transcript-7-snap.png
Oops, something went wrong.
Binary file modified
BIN
-12.7 KB
(96%)
...s-fluent-theme-applied-side-by-side-left-transcript-right-transcript-8-snap.png
Oops, something went wrong.
Binary file modified
BIN
+17.2 KB
(110%)
...s-fluent-theme-applied-side-by-side-left-transcript-right-transcript-9-snap.png
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
import React, { type FC, memo } from 'react'; | ||
import React, { memo, useMemo } from 'react'; | ||
import classNames from 'classnames'; | ||
import { hooks } from 'botframework-webchat-api'; | ||
import { type WebChatActivity } from 'botframework-webchat-core'; | ||
|
||
import isAIGeneratedActivity from './private/isAIGeneratedActivity'; | ||
import MarkdownTextContent from './private/MarkdownTextContent'; | ||
import PlainTextContent from './private/PlainTextContent'; | ||
import CustomPropertyNames from '../../Styles/CustomPropertyNames'; | ||
import useStyleToEmotionObject from '../../hooks/internal/useStyleToEmotionObject'; | ||
import useRenderMarkdownAsHTML from '../../hooks/useRenderMarkdownAsHTML'; | ||
|
||
import { type WebChatActivity } from 'botframework-webchat-core'; | ||
const { useLocalizer } = hooks; | ||
|
||
type Props = Readonly<{ | ||
activity: WebChatActivity; | ||
contentType?: string; | ||
text: string; | ||
}>; | ||
|
||
const TextContent: FC<Props> = memo(({ activity, contentType = 'text/plain', text }: Props) => { | ||
const generatedBadgeStyle = { | ||
'&.webchat__text-content__generated-badge': { | ||
color: `var(${CustomPropertyNames.ColorSubtle})`, | ||
fontSize: `var(${CustomPropertyNames.FontSizeSmall})` | ||
} | ||
}; | ||
|
||
const TextContent = memo(({ activity, contentType = 'text/plain', text }: Props) => { | ||
const supportMarkdown = !!useRenderMarkdownAsHTML('message activity'); | ||
const localize = useLocalizer(); | ||
const generatedBadgeClassName = useStyleToEmotionObject()(generatedBadgeStyle) + ''; | ||
|
||
const generatedBadge = useMemo( | ||
() => | ||
isAIGeneratedActivity(activity) && ( | ||
<div className={classNames('webchat__text-content__generated-badge', generatedBadgeClassName)}> | ||
{localize('ACTIVITY_CONTENT_CAUTION')} | ||
</div> | ||
), | ||
[activity, generatedBadgeClassName, localize] | ||
); | ||
|
||
return text ? ( | ||
contentType === 'text/markdown' && supportMarkdown ? ( | ||
<MarkdownTextContent activity={activity} markdown={text} /> | ||
<MarkdownTextContent activity={activity} markdown={text}> | ||
{generatedBadge} | ||
</MarkdownTextContent> | ||
) : ( | ||
<PlainTextContent text={text} /> | ||
<PlainTextContent text={text}>{generatedBadge}</PlainTextContent> | ||
) | ||
) : null; | ||
}); | ||
|
||
TextContent.defaultProps = { contentType: 'text/plain' }; | ||
TextContent.displayName = 'TextContent'; | ||
|
||
export default TextContent; |
This file contains 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
This file contains 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
5 changes: 5 additions & 0 deletions
5
packages/component/src/Attachment/Text/private/isAIGeneratedActivity.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { getOrgSchemaMessage, type WebChatActivity } from 'botframework-webchat-core'; | ||
|
||
export default function isAIGeneratedActivity(activity: undefined | WebChatActivity) { | ||
return !!(activity && getOrgSchemaMessage(activity?.entities || [])?.keywords?.includes('AIGeneratedContent')); | ||
} |
This file contains 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