From 4ff229408a1b692be15b34bcfdf65f7be7a07b18 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 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 a4afd0b152..0a6b663a61 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 1a7d1d32da..8381c03e4a 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 76e0fc2cd91684f635a025f6c25b0707ff11eb8c 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 8381c03e4a..b54502b26d 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 8a1d65ad280f47eb86e8723475a3d09122aecf05 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 0a6b663a61..a4448ea338 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()