Skip to content

Commit

Permalink
fix: Fix message sender capitalization and update changelog and version
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Nov 24, 2024
1 parent dd52480 commit f5ddcf2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG.md

## v2.0.0-beta.25 (25-11-2024)

**Fixed:**
- Fixed an issue with z-index causing display issues in embedded chatbots
- Fixed and improved stream logic for messages

**Note:**
The message `sender` field now defaults to being fully capitalized (i.e. `bot` -> `BOT`). However, it is also no longer case sensitive so **no action is required**.

## v2.0.0-beta.24 (13-11-2024)

**Fixed:**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"files": [
"./dist"
],
"version": "2.0.0-beta.24",
"version": "2.0.0-beta.25",
"description": "A modern React library for creating flexible and extensible chatbots.",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/internal/useBotEffectsInternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const useBotEffectsInternal = () => {
const historyMessages = getHistoryMessages();
if (historyMessages.length > 0) {
// note: must always render this button even if autoload (chat history logic relies on system message)
const messageContent = createMessage(<ChatHistoryButton/>, "system");
const messageContent = createMessage(<ChatHistoryButton/>, "SYSTEM");
replaceMessages([messageContent]);
if (settings.chatHistory?.autoLoad) {
showChatHistory();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/internal/useMessagesInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export const useMessagesInternal = () => {

const lastMessage = updatedMessages[updatedMessages.length - 1];
// if message is sent by user or is bot typing or bot is embedded, return
if (!lastMessage || lastMessage.sender === "USER") {
if (!lastMessage || lastMessage.sender.toUpperCase() === "USER") {
shouldNotify = false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/services/ChatHistoryService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const loadChatHistory = (settings: Settings, styles: Styles, chatHistory: Messag
if (chatHistory != null) {
try {
setMessages((prevMessages) => {
const loaderMessage = createMessage(<LoadingSpinner/>, "system");
const loaderMessage = createMessage(<LoadingSpinner/>, "SYSTEM");
prevMessages.shift();
return [loaderMessage, ...prevMessages];
});
Expand All @@ -174,9 +174,9 @@ const loadChatHistory = (settings: Settings, styles: Styles, chatHistory: Messag
// if autoload, line break is invisible
let lineBreakMessage;
if (settings.chatHistory?.autoLoad) {
lineBreakMessage = createMessage(<></>, "system")
lineBreakMessage = createMessage(<></>, "SYSTEM")
} else {
lineBreakMessage = createMessage(<ChatHistoryLineBreak/>, "system")
lineBreakMessage = createMessage(<ChatHistoryLineBreak/>, "SYSTEM")
}
return [...parsedMessages, lineBreakMessage, ...prevMessages];
});
Expand Down

0 comments on commit f5ddcf2

Please sign in to comment.