Skip to content

Commit a01c123

Browse files
authored
Merge branch 'master' into solgpt_chat
2 parents 15dd500 + 0239e06 commit a01c123

File tree

7 files changed

+118
-117
lines changed

7 files changed

+118
-117
lines changed

apps/remix-ide/src/app/components/vertical-icons.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ export class VerticalIcons extends Plugin {
7373
Object.keys(this.icons).map((o) => {
7474
this.icons[o].active = false
7575
})
76-
this.icons[name].active = true
76+
77+
if (this.icons[name]) {
78+
this.icons[name].active = true
79+
}
7780
this.renderComponent()
7881
})
7982
}

apps/remix-ide/src/app/plugins/solcoderAI.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export class SolCoder extends Plugin {
8181
let result
8282
try {
8383
const main_prompt = this._build_solgpt_promt(prompt)
84-
console.log(main_prompt.length)
8584
result = await(
8685
await fetch(this.api_url, {
8786
method: 'POST',
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"remixUiTabs.tooltipText1": "Run script (CTRL + SHIFT + S)",
33
"remixUiTabs.tooltipText2": "Compile CTRL + S",
4-
"remixUiTabs.tooltipText3": "Select .sol or .yul file to compile or a .ts or .js file and run it",
5-
"remixUiTabs.tooltipText4": "Select .sol file to use AI tools [BETA]",
4+
"remixUiTabs.tooltipText3": "Select .sol or .yul file to compile OR a .ts or .js file to run",
5+
"remixUiTabs.tooltipText4": "To explain a contract, choose a .sol file",
66
"remixUiTabs.tooltipText5": "Explain the contract(s) in current file [BETA]",
77
"remixUiTabs.tooltipText6": "Enable Remix AI Copilot [BETA]",
88
"remixUiTabs.tooltipText7": "Disable Remix AI Copilot [BETA]",
9-
"remixUiTabs.tooltipText8": "Remix AI Tools Documentation [BETA]",
9+
"remixUiTabs.tooltipText8": "Remix AI Tools Documentation",
10+
"remixUiTabs.tooltipTextDisabledCopilot": "To use Remix AI Copilot, choose a .sol file",
1011
"remixUiTabs.zoomOut": "Zoom out",
1112
"remixUiTabs.zoomIn": "Zoom in"
1213
}

apps/remix-ide/src/app/tabs/settings-tab.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const _paq = (window._paq = window._paq || [])
1515
const profile = {
1616
name: 'settings',
1717
displayName: 'Settings',
18-
methods: ['get', 'updateCopilotChoice'],
18+
methods: ['get', 'updateCopilotChoice', 'getCopilotSetting'],
1919
events: [],
2020
icon: 'assets/img/settings.webp',
2121
description: 'Remix-IDE settings',
@@ -52,7 +52,7 @@ module.exports = class SettingsTab extends ViewPlugin {
5252
this.element = document.createElement('div')
5353
this.element.setAttribute('id', 'settingsTab')
5454
this.useMatomoAnalytics = null
55-
this.useCopilot = false
55+
this.useCopilot = this.get('settings/copilot/suggest/activate')
5656
}
5757

5858
setDispatch(dispatch: React.Dispatch<any>) {
@@ -102,6 +102,10 @@ module.exports = class SettingsTab extends ViewPlugin {
102102
})
103103
}
104104

105+
getCopilotSetting(){
106+
return this.useCopilot
107+
}
108+
105109
updateMatomoAnalyticsChoice(isChecked) {
106110
this.config.set('settings/matomo-analytics', isChecked)
107111
this.useMatomoAnalytics = isChecked

libs/remix-ui/run-tab/src/lib/components/environment.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export function EnvironmentUI(props: EnvironmentProps) {
1515
const currentProvider = props.providers.providerList.find((exEnv) => exEnv.name === props.selectedEnv)
1616
const bridges = {
1717
'L2 - Optimism': 'https://app.optimism.io/bridge/deposit',
18-
'L2 - Arbitrum One': 'https://bridge.arbitrum.io/'
18+
'L2 - Arbitrum': 'https://bridge.arbitrum.io/'
1919
}
2020

21-
const isL2 = (providerDisplayName: string) => providerDisplayName === 'Optimism Provider' || providerDisplayName === 'Arbitrum One Provider'
21+
const isL2 = (providerDisplayName: string) => providerDisplayName === 'L2 - Optimism' || providerDisplayName === 'L2 - Arbitrum'
2222
return (
2323
<div className="udapp_crow">
2424
<label id="selectExEnv" className="udapp_settingsLabel">
@@ -38,16 +38,16 @@ export function EnvironmentUI(props: EnvironmentProps) {
3838
<div className="udapp_environment">
3939
<Dropdown id="selectExEnvOptions" data-id="settingsSelectEnvOptions" className="udapp_selectExEnvOptions">
4040
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control" icon={null}>
41-
{isL2(currentProvider && currentProvider.displayName) && 'L2 - '}
41+
{isL2(currentProvider && currentProvider.displayName)}
4242
{currentProvider && currentProvider.displayName}
43-
{currentProvider && bridges[currentProvider.name] && (
43+
{currentProvider && bridges[currentProvider.displayName] && (
4444
<CustomTooltip placement={'right'} tooltipClasses="text-nowrap" tooltipId="info-recorder" tooltipText={<FormattedMessage id="udapp.tooltipText3" />}>
4545
<i
4646
style={{ fontSize: 'medium' }}
4747
className={'ml-2 fa fa-rocket-launch'}
4848
aria-hidden="true"
4949
onClick={() => {
50-
window.open(bridges[currentProvider.name], '_blank')
50+
window.open(bridges[currentProvider.displayName], '_blank')
5151
}}
5252
></i>
5353
</CustomTooltip>
@@ -63,7 +63,7 @@ export function EnvironmentUI(props: EnvironmentProps) {
6363
data-id={`dropdown-item-${name}`}
6464
>
6565
<span className="">
66-
{isL2(displayName) && 'L2 - '}
66+
{isL2(displayName)}
6767
{displayName}
6868
</span>
6969
</Dropdown.Item>

libs/remix-ui/settings/src/lib/remix-ui-settings.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ViewPlugin } from '@remixproject/engine-web'
22
import React, {useState, useRef, useReducer, useEffect, useCallback} from 'react' // eslint-disable-line
3+
import { CustomTooltip } from '@remix-ui/helper'
4+
const _paq = (window._paq = window._paq || [])
35

46
import { AppModal, AlertModal, ModalTypes } from '@remix-ui/app'
57
import { labels, textDark, textSecondary } from './constants'
@@ -56,7 +58,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
5658
const [ipfsProtocol, setipfsProtocol] = useState('')
5759
const [ipfsProjectId, setipfsProjectId] = useState('')
5860
const [ipfsProjectSecret, setipfsProjectSecret] = useState('')
59-
const copilotDownload = useRef(null)
6061

6162
const intl = useIntl()
6263
const initValue = () => {
@@ -143,7 +144,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
143144
}
144145

145146
const startCopilot = async () => {
146-
copilotActivate(props.config, true, dispatch)
147+
copilotActivate(props.config, props.useCopilot, dispatch)
147148
props.plugin.call('terminal', 'log', { type: 'typewriterlog', value: `Solidity copilot activated!` })
148149
}
149150

@@ -450,9 +451,23 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
450451
const copilotSettings = () => (
451452
<div className="border-top">
452453
<div className="card-body pt-3 pb-2">
453-
<h6 className="card-title">
454+
<h6 className="card-title d-inline">
454455
<FormattedMessage id="settings.copilot" />
455456
</h6>
457+
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-aiDocumentation" tooltipText={<FormattedMessage id="remixUiTabs.tooltipText8" />}>
458+
<span
459+
data-id="remix_ai_docs"
460+
id="remix_ai_docs"
461+
className="btn pl-2 pr-0 py-0 d-inline ai-docs"
462+
role='link'
463+
onClick={()=>{
464+
window.open("https://remix-ide.readthedocs.io/en/latest/ai.html")
465+
_paq.push(['trackEvent', 'ai', 'solcoder', 'documentation'])
466+
}}
467+
>
468+
<i aria-hidden="true" className="fas fa-book"></i>
469+
</span>
470+
</CustomTooltip>
456471

457472
<div className="pt-2 mb-0">
458473
<div className="text-secondary mb-0 h6">

libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

Lines changed: 80 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React, {useState, useRef, useEffect, useReducer} from 'react' // eslint-d
55
import { FormattedMessage } from 'react-intl'
66
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
77
import './remix-ui-tabs.css'
8+
import { values } from 'lodash'
89
const _paq = (window._paq = window._paq || [])
910

1011
/* eslint-disable-next-line */
@@ -64,7 +65,6 @@ export const TabsUI = (props: TabsUIProps) => {
6465
const tabsRef = useRef({})
6566
const tabsElement = useRef(null)
6667
const [ai_switch, setAI_switch] = useState<boolean>(false)
67-
6868
const tabs = useRef(props.tabs)
6969
tabs.current = props.tabs // we do this to pass the tabs list to the onReady callbacks
7070

@@ -77,6 +77,14 @@ export const TabsUI = (props: TabsUIProps) => {
7777
}
7878
}, [tabsState.selectedIndex])
7979

80+
const getAI = async() => {
81+
try {
82+
return await props.plugin.call('settings', 'getCopilotSetting')
83+
} catch (e){
84+
return false
85+
}
86+
}
87+
8088
const getFileDecorationClasses = (tab: any) => {
8189
const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => {
8290
if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true
@@ -92,7 +100,6 @@ export const TabsUI = (props: TabsUIProps) => {
92100
const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass
93101
const classNameTab = 'nav-item nav-link d-flex justify-content-center align-items-center px-2 py-1 tab' + (index === currentIndexRef.current ? ' active' : '')
94102
const invert = props.themeQuality === 'dark' ? 'invert(1)' : 'invert(0)'
95-
96103
return (
97104
<CustomTooltip tooltipId="tabsActive" tooltipText={tab.tooltip} placement="bottom-start">
98105
<div
@@ -133,6 +140,7 @@ export const TabsUI = (props: TabsUIProps) => {
133140
}
134141

135142
const setFileDecorations = (fileStates: fileDecoration[]) => {
143+
getAI().then(value => setAI_switch(value)).catch(error => console.log(error))
136144
dispatch({ type: 'SET_FILE_DECORATIONS', payload: fileStates })
137145
}
138146

@@ -185,7 +193,7 @@ export const TabsUI = (props: TabsUIProps) => {
185193
>
186194
<button
187195
data-id="play-editor"
188-
className="btn text-success py-0"
196+
className="btn text-success pr-0 py-0 d-flex"
189197
disabled={!(tabsState.currentExt === 'js' || tabsState.currentExt === 'ts' || tabsState.currentExt === 'sol' || tabsState.currentExt === 'circom' || tabsState.currentExt === 'vy')}
190198
onClick={async () => {
191199
const path = active().substr(active().indexOf('/') + 1, active().length)
@@ -205,111 +213,82 @@ export const TabsUI = (props: TabsUIProps) => {
205213
}
206214
}}
207215
>
208-
<i className="fad fa-play"></i>
209-
</button>
210-
</CustomTooltip>
211-
<CustomTooltip
212-
placement="bottom"
213-
tooltipId="overlay-tooltip-explaination"
214-
tooltipText={
215-
<span>
216-
{tabsState.currentExt === 'sol'? (
217-
<FormattedMessage id="remixUiTabs.tooltipText5" />
218-
) : (
219-
<FormattedMessage id="remixUiTabs.tooltipText4" />
220-
)}
221-
</span>
222-
}
223-
>
224-
<button
225-
data-id="explain-editor"
226-
id='explain_btn'
227-
className='btn py-0 text-ai px-0 d-flex'
228-
disabled={!(tabsState.currentExt === 'sol') || explaining}
229-
onClick={async () => {
230-
const path = active().substr(active().indexOf('/') + 1, active().length)
231-
const content = await props.plugin.call('fileManager', 'readFile', path)
232-
if (tabsState.currentExt === 'sol') {
233-
setExplaining(true)
234-
await props.plugin.call('solcoder', 'code_explaining', content)
235-
setExplaining(false)
236-
_paq.push(['trackEvent', 'ai', 'solcoder', 'explain_file'])
237-
}
238-
}}
239-
>
240-
<i className={`fa-solid fa-user-robot ${explaining ? 'loadingExplanation' : ''}`}></i>
241-
<span
242-
className="position-relative text-ai text-sm pl-1"
243-
style={{ fontSize: "x-small", alignSelf: "end" }}
244-
>
245-
AI
246-
</span>
216+
<i className="fas fa-play"></i>
247217
</button>
248218
</CustomTooltip>
249-
<CustomTooltip
250-
placement="bottom"
251-
tooltipId="overlay-tooltip-copilot"
252-
tooltipText={
253-
<span>
254-
{ tabsState.currentExt === 'sol'? (
255-
!ai_switch ? (
256-
<FormattedMessage id="remixUiTabs.tooltipText6" />
257-
) : (<FormattedMessage id="remixUiTabs.tooltipText7" />)
258-
) : (
259-
<FormattedMessage id="remixUiTabs.tooltipText4" />
260-
)}
261-
</span>
262-
}
263-
>
264-
<button
265-
data-id="remix_ai_switch"
266-
id='remix_ai_switch'
267-
className="btn ai-switch text-ai pl-2 pr-0 py-0 d-flex"
268-
disabled={!(tabsState.currentExt === 'sol' )}
269-
onClick={async () => {
270-
await props.plugin.call('settings', 'updateCopilotChoice', !ai_switch)
271-
setAI_switch(!ai_switch)
272-
ai_switch ? _paq.push(['trackEvent', 'ai', 'solcoder', 'copilot_enabled']) : _paq.push(['trackEvent', 'ai', 'solcoder', 'copilot_disabled'])
273-
}}
219+
220+
<div className= "d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
221+
<CustomTooltip
222+
placement="bottom"
223+
tooltipId="overlay-tooltip-explaination"
224+
tooltipText={
225+
<span>
226+
{tabsState.currentExt === 'sol'? (
227+
<FormattedMessage id="remixUiTabs.tooltipText5" />
228+
) : (
229+
<FormattedMessage id="remixUiTabs.tooltipText4" />
230+
)}
231+
</span>
232+
}
274233
>
275-
<i
276-
className={ai_switch ? "fa-solid fa-toggle-on" : "fa-solid fa-toggle-off"}
277-
></i>
278-
<span
279-
className="position-relative text-ai text-sm pl-1"
280-
style={{ fontSize: "x-small", alignSelf: "end" }}
234+
<button
235+
data-id="explain-editor"
236+
id='explain_btn'
237+
className='btn text-ai pl-2 pr-0 py-0 d-flex'
238+
disabled={!(tabsState.currentExt === 'sol') || explaining}
239+
onClick={async () => {
240+
const path = active().substr(active().indexOf('/') + 1, active().length)
241+
const content = await props.plugin.call('fileManager', 'readFile', path)
242+
if (tabsState.currentExt === 'sol') {
243+
setExplaining(true)
244+
await props.plugin.call('solcoder', 'code_explaining', content)
245+
setExplaining(false)
246+
_paq.push(['trackEvent', 'ai', 'solcoder', 'explain_file'])
247+
}
248+
}}
281249
>
282-
AI
283-
</span>
284-
</button>
285-
</CustomTooltip>
286-
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-aiDocumentation" tooltipText={<FormattedMessage id="remixUiTabs.tooltipText8" />}>
287-
<span
288-
data-id="remix_ai_docs"
289-
id="remix_ai_docs"
290-
className="btn pl-2 pr-0 py-0 d-flex ai-docs"
291-
role='link'
292-
onClick={()=>{
293-
window.open("https://remix-ide.readthedocs.io/en/latest/ai.html")
294-
_paq.push(['trackEvent', 'ai', 'solcoder', 'documentation'])
295-
}}
250+
<i className={`fas fa-user-robot ${explaining ? 'loadingExplanation' : ''}`}></i>
251+
</button>
252+
</CustomTooltip>
253+
<CustomTooltip
254+
placement="bottom"
255+
tooltipId="overlay-tooltip-copilot"
256+
tooltipText={
257+
<span>
258+
{ tabsState.currentExt === 'sol'? (
259+
!ai_switch ? (
260+
<FormattedMessage id="remixUiTabs.tooltipText6" />
261+
) : (<FormattedMessage id="remixUiTabs.tooltipText7" />)
262+
) : (
263+
<FormattedMessage id="remixUiTabs.tooltipTextDisabledCopilot" />
264+
)}
265+
</span>
266+
}
296267
>
297-
<i className="fa-solid fa-book text-ai"></i>
298-
<span
299-
className="position-relative text-ai text-sm pl-1"
300-
style={{ fontSize: "x-small", alignSelf: "end" }}
268+
<button
269+
data-id="remix_ai_switch"
270+
id='remix_ai_switch'
271+
className="btn ai-switch text-ai pl-2 pr-0 py-0 d-flex"
272+
disabled={!(tabsState.currentExt === 'sol' )}
273+
onClick={async () => {
274+
await props.plugin.call('settings', 'updateCopilotChoice', !ai_switch)
275+
setAI_switch(!ai_switch)
276+
ai_switch ? _paq.push(['trackEvent', 'ai', 'solcoder', 'copilot_enabled']) : _paq.push(['trackEvent', 'ai', 'solcoder', 'copilot_disabled'])
277+
}}
301278
>
302-
AI
303-
</span>
304-
</span>
305-
</CustomTooltip>
279+
<i className={ai_switch ? "fas fa-toggle-on fa-lg" : "fas fa-toggle-off fa-lg"}></i>
280+
</button>
281+
</CustomTooltip>
282+
</div>
306283

307-
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-zoom-out" tooltipText={<FormattedMessage id="remixUiTabs.zoomOut" />}>
308-
<span data-id="tabProxyZoomOut" className="btn btn-sm px-2 fas fa-search-minus text-dark" onClick={() => props.onZoomOut()}></span>
309-
</CustomTooltip>
310-
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-run-zoom-in" tooltipText={<FormattedMessage id="remixUiTabs.zoomIn" />}>
311-
<span data-id="tabProxyZoomIn" className="btn btn-sm px-2 fas fa-search-plus text-dark" onClick={() => props.onZoomIn()}></span>
312-
</CustomTooltip>
284+
<div className= "d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
285+
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-zoom-out" tooltipText={<FormattedMessage id="remixUiTabs.zoomOut" />}>
286+
<span data-id="tabProxyZoomOut" className="btn fas fa-search-minus text-dark pl-2 pr-0 py-0 d-flex" onClick={() => props.onZoomOut()}></span>
287+
</CustomTooltip>
288+
<CustomTooltip placement="bottom" tooltipId="overlay-tooltip-run-zoom-in" tooltipText={<FormattedMessage id="remixUiTabs.zoomIn" />}>
289+
<span data-id="tabProxyZoomIn" className="btn fas fa-search-plus text-dark pl-2 pr-0 py-0 d-flex" onClick={() => props.onZoomIn()}></span>
290+
</CustomTooltip>
291+
</div>
313292
</div>
314293
<Tabs
315294
className="tab-scroll"

0 commit comments

Comments
 (0)