pull/5370/head
Joseph Izang 6 months ago
parent f7cd727db9
commit c4c09b6ab3
  1. 12
      apps/remix-ide/src/app/components/status-bar.tsx
  2. 1
      apps/remix-ide/src/app/tabs/settings-tab.tsx
  3. 29
      libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx
  4. 13
      libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx

@ -24,6 +24,7 @@ export class StatusBar extends Plugin implements StatusBarInterface {
dispatch: React.Dispatch<any> = () => {} dispatch: React.Dispatch<any> = () => {}
currentWorkspaceName: string = '' currentWorkspaceName: string = ''
isGitRepo: boolean = false isGitRepo: boolean = false
isAiActive: boolean = false
constructor(filePanel: FilePanelType, veritcalIcons: VerticalIcons) { constructor(filePanel: FilePanelType, veritcalIcons: VerticalIcons) {
super(statusBarProfile) super(statusBarProfile)
this.filePanelPlugin = filePanel this.filePanelPlugin = filePanel
@ -48,9 +49,17 @@ export class StatusBar extends Plugin implements StatusBarInterface {
this.renderComponent() this.renderComponent()
} }
async isAIActive() {
const aiActive = await this.call('settings', 'get', 'settings/copilot/suggest/activate')
this.isAiActive = aiActive
this.renderComponent()
return aiActive
}
onActivation(): void { onActivation(): void {
this.on('filePanel', 'workspaceInitializationCompleted', async () => { this.on('filePanel', 'workspaceInitializationCompleted', async () => {
const isGit = await this.call('fileManager', 'isGitRepo') const isGit = await this.call('fileManager', 'isGitRepo')
this.isAIActive()
if (!isGit) return if (!isGit) return
const workspaceName = localStorage.getItem('currentWorkspace') const workspaceName = localStorage.getItem('currentWorkspace')
workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = '' 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') const workspaceName = localStorage.getItem('currentWorkspace')
workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = 'error' workspaceName && workspaceName.length > 0 ? this.currentWorkspaceName = workspaceName : this.currentWorkspaceName = 'error'
}) })
this.on('settings', 'copilotChoiceChanged', (isAiActive) => {
this.isAiActive = isAiActive
})
this.renderComponent() this.renderComponent()
} }

@ -97,6 +97,7 @@ module.exports = class SettingsTab extends ViewPlugin {
updateCopilotChoice(isChecked) { updateCopilotChoice(isChecked) {
this.config.set('settings/copilot/suggest/activate', isChecked) this.config.set('settings/copilot/suggest/activate', isChecked)
this.useCopilot = isChecked this.useCopilot = isChecked
this.emit('copilotChoiceChanged', isChecked)
this.dispatch({ this.dispatch({
...this ...this
}) })

@ -1,6 +1,6 @@
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries // eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar' import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar'
import React from 'react' import React, { useEffect, useState } from 'react'
interface AIStatusProps { interface AIStatusProps {
plugin: StatusBar plugin: StatusBar
@ -9,10 +9,31 @@ interface AIStatusProps {
} }
export default function AIStatus(props: 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 ( return (
<div className={props.aiActive() ? "d-flex flex-row p-1 text-white justify-content-center align-items-center bg-body-tertiary" : "d-flex flex-row p-1 text-white justify-content-center align-items-center"}> <div className="d-flex flex-row p-1 text-white justify-content-center align-items-center">
<span className="fa-regular fa-microchip-ai ml-1"></span> <span className={copilotActive === false ? "fa-regular fa-microchip-ai ml-1 text-danger" : "fa-regular fa-microchip-ai ml-1"}></span>
<span className="small mx-1">Remix Copilot</span> <span className={copilotActive === false ? "small mx-1 text-danger" : "small mx-1" }>Remix Copilot</span>
</div> </div>
) )
} }

@ -17,12 +17,10 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
plugin.on('filePanel', 'setWorkspace', async (workspace) => { plugin.on('filePanel', 'setWorkspace', async (workspace) => {
const isGit = await plugin.call('fileManager', 'isGitRepo') const isGit = await plugin.call('fileManager', 'isGitRepo')
if (isGit) { if (isGit) {
console.log(plugin.isGitRepo)
setGitBranchName(workspace.name) setGitBranchName(workspace.name)
} else { } else {
setGitBranchName('Not a git repo') setGitBranchName('Not a git repo')
} }
console.log('setWorkspace on workspaceswitch',workspace)
}) })
} }
run() run()
@ -33,18 +31,25 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { plugin.on('filePanel', 'workspaceInitializationCompleted', async () => {
const isGit = await plugin.call('fileManager', 'isGitRepo') const isGit = await plugin.call('fileManager', 'isGitRepo')
if (isGit) { if (isGit) {
console.log(plugin.isGitRepo)
const workspace = localStorage.getItem('currentWorkspace') const workspace = localStorage.getItem('currentWorkspace')
setGitBranchName(workspace) setGitBranchName(workspace)
} else { } else {
setGitBranchName('Not a git repo') setGitBranchName('Not a git repo')
} }
console.log('setWorkspace on workspaceswitch')
}) })
} }
run() run()
}, [gitBranchName, plugin.isGitRepo]) }, [gitBranchName, plugin.isGitRepo])
useEffect(() => {
const run = async () => {
plugin.on('settings', 'copilotChoiceChanged', (isAiActive) => {
console.log('copilot active', isAiActive)
})
}
run()
}, [])
const lightDgitUp = async () => { const lightDgitUp = async () => {
const isActive = await plugin.call('manager', 'isActive', 'dgit') const isActive = await plugin.call('manager', 'isActive', 'dgit')
const isGit = await plugin.call('fileManager', 'isGitRepo') const isGit = await plugin.call('fileManager', 'isGitRepo')

Loading…
Cancel
Save