From 354bf0bd4041ada0ba60ede0099c44330af6a83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tetsing?= Date: Wed, 8 May 2024 12:36:53 +0200 Subject: [PATCH 1/3] enabled AI setting restore --- apps/remix-ide/src/app/tabs/settings-tab.tsx | 8 ++++++-- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 4 ++-- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 11 ++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/settings-tab.tsx b/apps/remix-ide/src/app/tabs/settings-tab.tsx index b32477aa176..49571922eb5 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 a4afd0b1527..0a6b663a61f 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -56,7 +56,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 = () => { @@ -143,8 +142,9 @@ 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!` }) + //props.plugin.call('settings', 'updateCopilotChoice', props.useCopilot) } startCopilot() 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 1a7d1d32da4..8381c03e4a9 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -64,7 +64,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 +76,16 @@ export const TabsUI = (props: TabsUIProps) => { } }, [tabsState.selectedIndex]) + const getAI = async() => { + try { + return await props.plugin.call('settings', 'getCopilotSetting') + } catch (e){ + return false + } + } + + getAI().then(value => setAI_switch(value)).catch(error => console.log(error)) + const getFileDecorationClasses = (tab: any) => { const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => { if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true From 5c2481a061e89e522bb9ac38907cae50be379a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tetsing?= Date: Wed, 8 May 2024 13:50:01 +0200 Subject: [PATCH 2/3] fixed recusion on rendering --- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 8381c03e4a9..b54502b26d5 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 */ @@ -84,8 +85,6 @@ export const TabsUI = (props: TabsUIProps) => { } } - getAI().then(value => setAI_switch(value)).catch(error => console.log(error)) - const getFileDecorationClasses = (tab: any) => { const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => { if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true @@ -101,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 }) } @@ -274,7 +273,7 @@ export const TabsUI = (props: TabsUIProps) => { data-id="remix_ai_switch" id='remix_ai_switch' className="btn ai-switch text-ai pl-2 pr-0 py-0 d-flex" - disabled={!(tabsState.currentExt === 'sol' )} + disabled={ !(tabsState.currentExt === 'sol' ) } onClick={async () => { await props.plugin.call('settings', 'updateCopilotChoice', !ai_switch) setAI_switch(!ai_switch) From 4c6838fa7e68d748ec3b4d85daed8a0fe1b07d9e Mon Sep 17 00:00:00 2001 From: STetsing <41009393+STetsing@users.noreply.github.com> Date: Tue, 14 May 2024 11:04:12 +0200 Subject: [PATCH 3/3] Update remix-ui-settings.tsx rm comment --- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 1 - 1 file changed, 1 deletion(-) 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 0a6b663a61f..a4448ea3380 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -144,7 +144,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const startCopilot = async () => { copilotActivate(props.config, props.useCopilot, dispatch) props.plugin.call('terminal', 'log', { type: 'typewriterlog', value: `Solidity copilot activated!` }) - //props.plugin.call('settings', 'updateCopilotChoice', props.useCopilot) } startCopilot()