@@ -3,6 +3,8 @@ import remarkGfm from "remark-gfm"
3
3
import copy from "copy-to-clipboard"
4
4
import { ChatMessage , assistantAvatar } from "../lib/types"
5
5
import React from 'react'
6
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
7
+ import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'
6
8
7
9
const DEFAULT_SUGGESTIONS = [
8
10
'Explain what a modifier is' ,
@@ -19,6 +21,29 @@ export interface ChatHistoryComponentProps {
19
21
historyRef : React . RefObject < HTMLDivElement >
20
22
}
21
23
24
+ const AiChatIntro = ( props ) => {
25
+ return (
26
+ < div className = "assistant-landing d-flex flex-column align-items-center justify-content-center text-center px-3 h-100" >
27
+ < img src = { assistantAvatar } alt = "RemixAI logo" style = { { width : '120px' } } className = "mb-3" />
28
+ < h5 className = "mb-2" > RemixAI</ h5 >
29
+ < p className = "mb-4" style = { { fontSize : '1.1rem' } } >
30
+ RemixAI provides you personalized guidance as you build. It can break down concepts,
31
+ answer questions about blockchain technology and assist you with your smart contracts.
32
+ </ p >
33
+ { DEFAULT_SUGGESTIONS . map ( ( s , index ) => (
34
+ < button
35
+ key = { s }
36
+ data-id = { `remix-ai-assistant-starter-${ index } ` }
37
+ className = "btn btn-secondary mb-2 w-100 text-left"
38
+ onClick = { ( ) => props . sendPrompt ( s ) }
39
+ >
40
+ < i className = "fa-kit fa-remixai mr-2" > </ i > { s }
41
+ </ button >
42
+ ) ) }
43
+ </ div >
44
+ )
45
+ }
46
+
22
47
export const ChatHistoryComponent : React . FC < ChatHistoryComponentProps > = ( {
23
48
messages,
24
49
isStreaming,
@@ -29,34 +54,17 @@ export const ChatHistoryComponent: React.FC<ChatHistoryComponentProps> = ({
29
54
return (
30
55
< div
31
56
ref = { historyRef }
32
- className = "d-flex flex-column flex-grow-1 overflow-y-auto"
57
+ className = "d-flex flex-column overflow-y-auto border-box-sizing preserve-wrap w-100 "
33
58
>
34
59
{ messages . length === 0 ? (
35
- < div className = "assistant-landing d-flex flex-column align-items-center justify-content-center text-center px-3 h-100" >
36
- < img src = { assistantAvatar } alt = "RemixAI logo" style = { { width : '120px' } } className = "mb-3" />
37
- < h5 className = "mb-2" > RemixAI</ h5 >
38
- < p className = "mb-4" style = { { fontSize : '1.1rem' } } >
39
- RemixAI provides you personalized guidance as you build. It can break down concepts,
40
- answer questions about blockchain technology and assist you with your smart contracts.
41
- </ p >
42
- { DEFAULT_SUGGESTIONS . map ( ( s , index ) => (
43
- < button
44
- key = { s }
45
- data-id = { `remix-ai-assistant-starter-${ index } ` }
46
- className = "btn btn-secondary mb-2 w-100 text-left"
47
- onClick = { ( ) => sendPrompt ( s ) }
48
- >
49
- < i className = "fa-kit fa-remixai mr-2" > </ i > { s }
50
- </ button >
51
- ) ) }
52
- </ div >
60
+ < AiChatIntro sendPrompt = { sendPrompt } />
53
61
) : (
54
62
messages . map ( msg => {
55
63
const bubbleClass =
56
64
msg . role === 'user' ? 'bubble-user bg-light' : 'bubble-assistant bg-light'
57
65
58
66
return (
59
- < div key = { msg . id } className = "chat-row d-flex mb-2" >
67
+ < div key = { msg . id } className = "chat-row d-flex mb-2 w-100 " >
60
68
{ /* Avatar for assistant */ }
61
69
{ msg . role === 'assistant' && (
62
70
< img
@@ -67,7 +75,7 @@ export const ChatHistoryComponent: React.FC<ChatHistoryComponentProps> = ({
67
75
) }
68
76
69
77
{ /* Bubble */ }
70
- < div data-id = "ai-response-chat-bubble-section" className = "flex-grow-1 w-25 mr-1" >
78
+ < div data-id = "ai-response-chat-bubble-section" className = "overflow-y-scroll w-100 mr-1" >
71
79
< div className = { `chat-bubble p-2 rounded ${ bubbleClass } ` } >
72
80
{ msg . role === 'user' && (
73
81
< small className = "text-uppercase fw-bold text-secondary d-block mb-1" >
@@ -154,7 +162,7 @@ export const ChatHistoryComponent: React.FC<ChatHistoryComponentProps> = ({
154
162
</ div >
155
163
</ div >
156
164
)
157
- } )
165
+ } ) //end of messages render
158
166
) }
159
167
{ isStreaming && (
160
168
< div className = "text-center my-2" >
0 commit comments