Skip to content

Commit a6425b3

Browse files
authored
Merge pull request #6172 from ethereum/aichat-patch-001
Remix AI Chat UI Patch
2 parents 59f1bfc + 3f72cb5 commit a6425b3

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

libs/remix-ui/remix-ai-assistant/src/components/chat.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,26 @@ export interface ChatHistoryComponentProps {
2424

2525
const AiChatIntro = (props) => {
2626
return (
27-
<div className="assistant-landing d-flex flex-column align-items-center justify-content-center text-center px-1 h-100">
28-
<img src={assistantAvatar} alt="RemixAI logo" style={{ width: '120px' }} className="mb-3" />
27+
<div className="assistant-landing d-flex flex-column mx-1 align-items-center justify-content-center text-center h-100 w-100">
28+
<img src={assistantAvatar} alt="RemixAI logo" style={{ width: '120px' }} className="mb-3 container-img" />
2929
<h5 className="mb-2">RemixAI</h5>
3030
<p className="mb-4" style={{ fontSize: '0.9rem' }}>
3131
RemixAI provides you personalized guidance as you build. It can break down concepts,
3232
answer questions about blockchain technology and assist you with your smart contracts.
3333
</p>
3434
<div className="d-flex flex-column" style={{ fontSize: '0.9rem' }}>
35-
<div className="d-flex flex-row align-items-center"><p className="font-italic m-1">{`<prompt>: `}</p><span>ask your question</span></div>
36-
<div className="d-flex flex-row align-items-center"><p className="font-italic m-1">{`/w <prompt>: `}</p><span>modify your code</span></div>
37-
<div className="d-flex flex-row align-items-center"><p className="font-italic m-1">{`/c <prompt>: `}</p><span>continue fixing compilation</span></div>
38-
<div className="d-flex flex-row align-items-center"><p className="font-italic m-1 mb-2">{`/g <prompt>: `}</p><span>generate a new workspace</span></div>
35+
<div className="d-flex flex-row align-items-center">
36+
<span className="font-italic m-1">{`<prompt>: `}</span>
37+
<span>ask your question</span></div>
38+
<div className="d-flex flex-row align-items-center">
39+
<span className="font-italic m-1">{`/w <prompt>: `}</span>
40+
<span>modify your code</span></div>
41+
<div className="d-flex flex-row align-items-center">
42+
<span className="font-italic m-1">{`/c <prompt>: `}</span>
43+
<span>continue fixing compilation</span></div>
44+
<div className="d-flex flex-row align-items-center">
45+
<span className="font-italic m-1">{`/g <prompt>: `}</span>
46+
<span>generate a new workspace</span></div>
3947
</div>
4048
<div className="d-flex flex-column mt-3">
4149
{DEFAULT_SUGGESTIONS.map((s, index) => (

libs/remix-ui/remix-ai-assistant/src/components/prompt.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface PromptAreaProps {
3030
aiContextGroupList: groupListType[]
3131
aiAssistantGroupList: groupListType[]
3232
textareaRef?: React.RefObject<HTMLTextAreaElement>
33+
maximizePanel: () => Promise<void>
3334
}
3435

3536
const _paq = (window._paq = window._paq || [])
@@ -57,7 +58,8 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
5758
modelBtnRef,
5859
aiContextGroupList,
5960
aiAssistantGroupList,
60-
textareaRef
61+
textareaRef,
62+
maximizePanel
6163
}) => {
6264

6365
return (
@@ -78,7 +80,7 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
7880
)}
7981

8082
<div
81-
className="prompt-area d-flex flex-column gap-2 w-100 p-3 border border-text bg-light align-self-start"
83+
className="prompt-area d-flex flex-column mx-1 p-2 border border-text bg-light"
8284
>
8385
<div className="d-flex justify-content-between mb-3 border border-right-0 border-left-0 border-top-0 border-bottom pb-1">
8486
<button
@@ -120,6 +122,7 @@ export const PromptArea: React.FC<PromptAreaProps> = ({
120122
disabled={isStreaming}
121123
onFocus={() => {
122124
dispatchActivity('typing', input)
125+
maximizePanel()
123126
}}
124127
onChange={e => {
125128
dispatchActivity('typing', e.target.value)

libs/remix-ui/remix-ai-assistant/src/components/remix-ui-remix-ai-assistant.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
5252
const modelBtnRef = useRef(null)
5353
const contextBtnRef = useRef(null)
5454
const textareaRef = useRef<HTMLTextAreaElement>(null)
55+
const aiChatRef = useRef<HTMLDivElement>(null)
5556

5657
useOnClickOutside([modelBtnRef, contextBtnRef], () => setShowAssistantOptions(false))
5758
useOnClickOutside([modelBtnRef, contextBtnRef], () => setShowContextOptions(false))
@@ -468,9 +469,17 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
468469
}
469470
}, [messages])
470471

472+
const maximizePanel = async () => {
473+
await props.plugin.call('layout', 'maximisePinnedPanel')
474+
}
475+
471476
return (
472477
<div
473-
className="d-flex flex-column h-100 mx-3 "
478+
className="d-flex flex-column h-100 w-100"
479+
ref={aiChatRef}
480+
onBlur={async () => {
481+
await props.plugin.call('layout', 'resetPinnedPanel')
482+
}}
474483
>
475484
<section id="remix-ai-chat-history" className="h-83 d-flex flex-column align-items-center p-2 overflow-x-hidden" style={{ flex: 7, overflowY: 'scroll' }} ref={chatHistoryRef}>
476485
<div data-id="remix-ai-assistant-ready"></div>
@@ -488,12 +497,12 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
488497
historyRef={historyRef}
489498
/>
490499
</section>
491-
<section id="remix-ai-prompt-area" className=" mt-1" style={{ flex: 1 }}
500+
<section id="remix-ai-prompt-area" className="mt-1" style={{ flex: 1 }}
492501
>
493502
{showAssistantOptions && (
494503
<div
495-
className="pt-2 mb-2 z-3 bg-light border border-text"
496-
style={{ borderRadius: '8px', left: `${calcAndConvertToDvw(getBoundingRect(modelBtnRef).left)}dvw`, right: '0px', bottom: '75px', height: '235px', width: '300px', }}
504+
className="pt-2 mb-2 z-3 bg-light border border-text w-75"
505+
style={{ borderRadius: '8px' }}
497506
>
498507
<div className="text-uppercase ml-2 mb-2 small">AI Assistant Provider</div>
499508
<GroupListMenu
@@ -506,6 +515,7 @@ export const RemixUiRemixAiAssistant = React.forwardRef<
506515
)}
507516
<PromptArea
508517
input={input}
518+
maximizePanel={maximizePanel}
509519
setInput={setInput}
510520
isStreaming={isStreaming}
511521
handleSend={handleSend}

libs/remix-ui/remix-ai-assistant/src/css/remix-ai-assistant.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,12 @@
301301
.border-box-sizing {
302302
box-sizing: border-box;
303303
}
304+
305+
@media (max-width: 1280px) {
306+
@container container-img (inline-size < 150px) {
307+
.container-img {
308+
width: 80px;
309+
min-height: 80px;
310+
}
311+
}
312+
}

0 commit comments

Comments
 (0)