diff --git a/apps/remix-ide/src/app/components/status-bar.tsx b/apps/remix-ide/src/app/components/status-bar.tsx index c78a7a26f3..74f53bdc5c 100644 --- a/apps/remix-ide/src/app/components/status-bar.tsx +++ b/apps/remix-ide/src/app/components/status-bar.tsx @@ -24,6 +24,7 @@ export class StatusBar extends Plugin implements StatusBarInterface { dispatch: React.Dispatch = () => {} currentWorkspaceName: string = '' isGitRepo: boolean = false + isAiActive: boolean = false constructor(filePanel: FilePanelType, veritcalIcons: VerticalIcons) { super(statusBarProfile) this.filePanelPlugin = filePanel @@ -48,9 +49,17 @@ export class StatusBar extends Plugin implements StatusBarInterface { this.renderComponent() } + async isAIActive() { + const aiActive = await this.call('settings', 'get', 'settings/copilot/suggest/activate') + this.isAiActive = aiActive + this.renderComponent() + return aiActive + } + onActivation(): void { this.on('filePanel', 'workspaceInitializationCompleted', async () => { const isGit = await this.call('fileManager', 'isGitRepo') + this.isAIActive() if (!isGit) return const workspaceName = localStorage.getItem('currentWorkspace') workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = '' @@ -65,6 +74,9 @@ export class StatusBar extends Plugin implements StatusBarInterface { const workspaceName = localStorage.getItem('currentWorkspace') workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = 'error' }) + this.on('settings', 'copilotChoiceChanged', (isAiActive) => { + this.isAiActive = isAiActive + }) this.renderComponent() } diff --git a/apps/remix-ide/src/app/tabs/settings-tab.tsx b/apps/remix-ide/src/app/tabs/settings-tab.tsx index 49571922eb..98c40919c4 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.tsx +++ b/apps/remix-ide/src/app/tabs/settings-tab.tsx @@ -97,6 +97,7 @@ module.exports = class SettingsTab extends ViewPlugin { updateCopilotChoice(isChecked) { this.config.set('settings/copilot/suggest/activate', isChecked) this.useCopilot = isChecked + this.emit('copilotChoiceChanged', isChecked) this.dispatch({ ...this }) diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index 46e8eb5dfe..34d0c24004 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -1,6 +1,6 @@ // eslint-disable-next-line @nrwl/nx/enforce-module-boundaries import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar' -import React from 'react' +import React, { useEffect, useState } from 'react' interface AIStatusProps { plugin: StatusBar @@ -9,10 +9,31 @@ interface AIStatusProps { } export default function AIStatus(props: AIStatusProps) { + const [copilotActive, setCopilotActive] = useState(false) + useEffect(() => { + const run = async () => { + props.plugin.on('settings', 'copilotChoiceChanged', (isAiActive) => { + console.log('copilot active', isAiActive) + setCopilotActive(isAiActive) + }) + } + run() + }, [copilotActive, props.plugin.isAiActive]) + + useEffect(() => { + const run = async () => { + props.plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { + const active = await props.plugin.isAIActive() + setCopilotActive(active) + }) + console.log('copilot active', copilotActive) + } + run() + }, [copilotActive, props.plugin.isAiActive]) return ( -
- - Remix Copilot +
+ + Remix Copilot
) } diff --git a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx index 52bd66d446..627e7b3f47 100644 --- a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx @@ -17,12 +17,10 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G plugin.on('filePanel', 'setWorkspace', async (workspace) => { const isGit = await plugin.call('fileManager', 'isGitRepo') if (isGit) { - console.log(plugin.isGitRepo) setGitBranchName(workspace.name) } else { setGitBranchName('Not a git repo') } - console.log('setWorkspace on workspaceswitch',workspace) }) } run() @@ -33,18 +31,25 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { const isGit = await plugin.call('fileManager', 'isGitRepo') if (isGit) { - console.log(plugin.isGitRepo) const workspace = localStorage.getItem('currentWorkspace') setGitBranchName(workspace) } else { setGitBranchName('Not a git repo') } - console.log('setWorkspace on workspaceswitch') }) } run() }, [gitBranchName, plugin.isGitRepo]) + useEffect(() => { + const run = async () => { + plugin.on('settings', 'copilotChoiceChanged', (isAiActive) => { + console.log('copilot active', isAiActive) + }) + } + run() + }, []) + const lightDgitUp = async () => { const isActive = await plugin.call('manager', 'isActive', 'dgit') const isGit = await plugin.call('fileManager', 'isGitRepo')