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> = () => {}
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()
}

@ -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
})

@ -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 (
<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"}>
<span className="fa-regular fa-microchip-ai ml-1"></span>
<span className="small mx-1">Remix Copilot</span>
<div className="d-flex flex-row p-1 text-white justify-content-center align-items-center">
<span className={copilotActive === false ? "fa-regular fa-microchip-ai ml-1 text-danger" : "fa-regular fa-microchip-ai ml-1"}></span>
<span className={copilotActive === false ? "small mx-1 text-danger" : "small mx-1" }>Remix Copilot</span>
</div>
)
}

@ -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')

Loading…
Cancel
Save