Skip to content

Commit 354bf0b

Browse files
committed
enabled AI setting restore
1 parent b04745e commit 354bf0b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

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/settings/src/lib/remix-ui-settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
5656
const [ipfsProtocol, setipfsProtocol] = useState('')
5757
const [ipfsProjectId, setipfsProjectId] = useState('')
5858
const [ipfsProjectSecret, setipfsProjectSecret] = useState('')
59-
const copilotDownload = useRef(null)
6059

6160
const intl = useIntl()
6261
const initValue = () => {
@@ -143,8 +142,9 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
143142
}
144143

145144
const startCopilot = async () => {
146-
copilotActivate(props.config, true, dispatch)
145+
copilotActivate(props.config, props.useCopilot, dispatch)
147146
props.plugin.call('terminal', 'log', { type: 'typewriterlog', value: `Solidity copilot activated!` })
147+
//props.plugin.call('settings', 'updateCopilotChoice', props.useCopilot)
148148
}
149149

150150
startCopilot()

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export const TabsUI = (props: TabsUIProps) => {
6464
const tabsRef = useRef({})
6565
const tabsElement = useRef(null)
6666
const [ai_switch, setAI_switch] = useState<boolean>(false)
67-
6867
const tabs = useRef(props.tabs)
6968
tabs.current = props.tabs // we do this to pass the tabs list to the onReady callbacks
7069

@@ -77,6 +76,16 @@ export const TabsUI = (props: TabsUIProps) => {
7776
}
7877
}, [tabsState.selectedIndex])
7978

79+
const getAI = async() => {
80+
try {
81+
return await props.plugin.call('settings', 'getCopilotSetting')
82+
} catch (e){
83+
return false
84+
}
85+
}
86+
87+
getAI().then(value => setAI_switch(value)).catch(error => console.log(error))
88+
8089
const getFileDecorationClasses = (tab: any) => {
8190
const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => {
8291
if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true

0 commit comments

Comments
 (0)