Skip to content

Commit f199550

Browse files
committed
chore: 3
1 parent 9887f11 commit f199550

File tree

4 files changed

+14
-55
lines changed

4 files changed

+14
-55
lines changed

packages/paste-website/src/component-examples/AIChatLogExamples.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const MessageWithLoadingAndStop = () => {
101101
return (
102102
<AIChatLog>
103103
<AIChatMessage variant="bot">
104-
<AIChatMessageAuthor aria-label="AI said" bot>
104+
<AIChatMessageAuthor aria-label="AI said">
105105
Good Bot
106106
</AIChatMessageAuthor>
107107
<AIChatMessageBody>
@@ -120,7 +120,7 @@ const MessageWithLoading = () => {
120120
return (
121121
<AIChatLog>
122122
<AIChatMessage variant="bot">
123-
<AIChatMessageAuthor aria-label="AI said" bot>
123+
<AIChatMessageAuthor aria-label="AI said">
124124
Good Bot
125125
</AIChatMessageAuthor>
126126
<AIChatMessageBody>

packages/paste-website/src/components/assistant/AssistantCanvas.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type AssistantCanvasProps = {
1818

1919
export const AssistantCanvas: React.FC<AssistantCanvasProps> = ({ selectedThreadID }) => {
2020
const [mounted, setMounted] = React.useState(false);
21-
const [logWidth, setLogWidth] = React.useState(0);
2221
const messages = useAssistantMessagesStore(useShallow((state) => state.messages));
2322
const setMessages = useAssistantMessagesStore(useShallow((state) => state.setMessages));
2423
const activeRun = useAssistantRunStore(useShallow((state) => state.activeRun));
@@ -49,8 +48,6 @@ export const AssistantCanvas: React.FC<AssistantCanvasProps> = ({ selectedThread
4948

5049
React.useEffect(() => {
5150
setMounted(true);
52-
// whats the width of the log? You'll need it to render the skeleton loader
53-
setLogWidth(loggerRef.current?.offsetWidth ?? 0);
5451
}, []);
5552

5653
// scroll to bottom of chat log when new messages are added
@@ -106,7 +103,7 @@ export const AssistantCanvas: React.FC<AssistantCanvasProps> = ({ selectedThread
106103
}
107104
return <UserMessage key={threadMessage.id} threadMessage={threadMessage} />;
108105
})}
109-
{(isCreatingAResponse || activeRun != null) && <LoadingMessage maxWidth={logWidth} />}
106+
{(isCreatingAResponse || activeRun != null) && <LoadingMessage />}
110107
</AIChatLog>
111108
</Box>
112109
</Box>

packages/paste-website/src/components/assistant/AssistantMessage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import { AssistantMarkdown } from "./AssistantMarkdown";
88
export const AssistantMessage: React.FC<{ threadMessage: ThreadMessage }> = ({ threadMessage }) => {
99
return (
1010
<AIChatMessage variant="bot">
11-
<AIChatMessageAuthor
12-
aria-label={`said by paste assistant at ${formatTimestamp(threadMessage.created_at)}`}
13-
avatarSrc="../../assets/Logo"
14-
>
11+
<AIChatMessageAuthor aria-label={`said by paste assistant at ${formatTimestamp(threadMessage.created_at)}`}>
1512
PasteBot
1613
</AIChatMessageAuthor>
1714
<AIChatMessageBody>
Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,20 @@
1-
/* eslint-disable camelcase */
2-
import { Box } from "@twilio-paste/box";
3-
import { ChatBubble, ChatMessage, ChatMessageMeta, ChatMessageMetaItem } from "@twilio-paste/chat-log";
4-
import { SkeletonLoader } from "@twilio-paste/skeleton-loader";
5-
import { useUID } from "@twilio-paste/uid-library";
1+
import { AIChatMessage, AIChatMessageAuthor, AIChatMessageBody, AIChatMessageLoading } from "@twilio-paste/ai-chat-log";
62
import * as React from "react";
73

8-
import { Logo } from "../../assets/Logo";
9-
import { useAssistantRunStore } from "../../stores/assistantRunStore";
104
import { formatTimestamp } from "../../utils/formatTimestamp";
115

12-
const getRandomNumber = (max: number): number => {
13-
return Math.floor(Math.random() * max);
14-
};
15-
16-
const STATUS_MAP = {
17-
queued: "Queued...",
18-
in_progress: "Researching...",
19-
requires_action: "Researching...",
20-
cancelling: "Concelling...",
21-
cancelled: "Cancelled.",
22-
failed: "Failed.",
23-
completed: "Finished.",
24-
expired: "Expired.",
25-
};
26-
27-
export const LoadingMessage: React.FC<{ maxWidth: number }> = ({ maxWidth }) => {
28-
const activeRun = useAssistantRunStore((state) => state.activeRun);
29-
6+
export const LoadingMessage: React.FC = () => {
307
const newDateTime = new Date();
318
const timestamp = Math.floor(newDateTime.getTime() / 1000);
329

33-
const randomWidths = React.useMemo(() => {
34-
return Array.from({ length: 3 }, () => getRandomNumber(maxWidth));
35-
}, [maxWidth]);
36-
3710
return (
38-
<ChatMessage variant="inbound">
39-
<ChatBubble>
40-
<Box display="grid" rowGap="space30">
41-
{randomWidths.map((width) => (
42-
<SkeletonLoader key={useUID()} height="20px" width={`${width}px`} />
43-
))}
44-
</Box>
45-
</ChatBubble>
46-
<ChatMessageMeta aria-label={`said by the assistant at ${formatTimestamp(timestamp)}`}>
47-
<ChatMessageMetaItem>
48-
<Logo size={20} />
49-
PasteBot ・ {activeRun?.status ? STATUS_MAP[activeRun?.status] : "Thinking..."}
50-
</ChatMessageMetaItem>
51-
</ChatMessageMeta>
52-
</ChatMessage>
11+
<AIChatMessage variant="bot">
12+
<AIChatMessageAuthor aria-label={`said by paste assistant at ${formatTimestamp(timestamp)}`}>
13+
PasteBot
14+
</AIChatMessageAuthor>
15+
<AIChatMessageBody>
16+
<AIChatMessageLoading />
17+
</AIChatMessageBody>
18+
</AIChatMessage>
5319
);
5420
};
55-
/* eslint-enable camelcase */

0 commit comments

Comments
 (0)