diff --git a/apps/remix-ide/src/app/tabs/settings-tab.tsx b/apps/remix-ide/src/app/tabs/settings-tab.tsx index b32477aa17..49571922eb 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.tsx +++ b/apps/remix-ide/src/app/tabs/settings-tab.tsx @@ -15,7 +15,7 @@ const _paq = (window._paq = window._paq || []) const profile = { name: 'settings', displayName: 'Settings', - methods: ['get', 'updateCopilotChoice'], + methods: ['get', 'updateCopilotChoice', 'getCopilotSetting'], events: [], icon: 'assets/img/settings.webp', description: 'Remix-IDE settings', @@ -52,7 +52,7 @@ module.exports = class SettingsTab extends ViewPlugin { this.element = document.createElement('div') this.element.setAttribute('id', 'settingsTab') this.useMatomoAnalytics = null - this.useCopilot = false + this.useCopilot = this.get('settings/copilot/suggest/activate') } setDispatch(dispatch: React.Dispatch) { @@ -102,6 +102,10 @@ module.exports = class SettingsTab extends ViewPlugin { }) } + getCopilotSetting(){ + return this.useCopilot + } + updateMatomoAnalyticsChoice(isChecked) { this.config.set('settings/matomo-analytics', isChecked) this.useMatomoAnalytics = isChecked diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 9bc6e94b47..050cb9d539 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -58,7 +58,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const [ipfsProtocol, setipfsProtocol] = useState('') const [ipfsProjectId, setipfsProjectId] = useState('') const [ipfsProjectSecret, setipfsProjectSecret] = useState('') - const copilotDownload = useRef(null) const intl = useIntl() const initValue = () => { @@ -145,7 +144,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { } const startCopilot = async () => { - copilotActivate(props.config, true, dispatch) + copilotActivate(props.config, props.useCopilot, dispatch) props.plugin.call('terminal', 'log', { type: 'typewriterlog', value: `Solidity copilot activated!` }) } diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 561d49f2de..81c78ea868 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -5,6 +5,7 @@ import React, {useState, useRef, useEffect, useReducer} from 'react' // eslint-d import { FormattedMessage } from 'react-intl' import { Tab, Tabs, TabList, TabPanel } from 'react-tabs' import './remix-ui-tabs.css' +import { values } from 'lodash' const _paq = (window._paq = window._paq || []) /* eslint-disable-next-line */ @@ -64,7 +65,6 @@ export const TabsUI = (props: TabsUIProps) => { const tabsRef = useRef({}) const tabsElement = useRef(null) const [ai_switch, setAI_switch] = useState(false) - const tabs = useRef(props.tabs) tabs.current = props.tabs // we do this to pass the tabs list to the onReady callbacks @@ -77,6 +77,14 @@ export const TabsUI = (props: TabsUIProps) => { } }, [tabsState.selectedIndex]) + const getAI = async() => { + try { + return await props.plugin.call('settings', 'getCopilotSetting') + } catch (e){ + return false + } + } + const getFileDecorationClasses = (tab: any) => { const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => { if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true @@ -92,7 +100,6 @@ export const TabsUI = (props: TabsUIProps) => { const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass const classNameTab = 'nav-item nav-link d-flex justify-content-center align-items-center px-2 py-1 tab' + (index === currentIndexRef.current ? ' active' : '') const invert = props.themeQuality === 'dark' ? 'invert(1)' : 'invert(0)' - return (
{ } const setFileDecorations = (fileStates: fileDecoration[]) => { + getAI().then(value => setAI_switch(value)).catch(error => console.log(error)) dispatch({ type: 'SET_FILE_DECORATIONS', payload: fileStates }) } @@ -208,6 +216,7 @@ export const TabsUI = (props: TabsUIProps) => { +