From 73adade3383b1fa5c873e1eb43233efee5f4e6bb Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 29 Oct 2024 09:46:28 +0100 Subject: [PATCH 01/14] popup panel --- apps/remix-ide/src/app.js | 5 +- .../src/app/components/popup-panel.tsx | 69 +++++++++++++++++++ .../src/app/plugins/remixAIPlugin.tsx | 2 +- .../app/src/lib/remix-app/remix-app.tsx | 1 + 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 apps/remix-ide/src/app/components/popup-panel.tsx diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index a936cc5e33..23addcdf90 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -12,6 +12,7 @@ import { SidePanel } from './app/components/side-panel' import { StatusBar } from './app/components/status-bar' import { HiddenPanel } from './app/components/hidden-panel' import { PinnedPanel } from './app/components/pinned-panel' +import { PopupPanel } from './app/components/popup-panel' import { VerticalIcons } from './app/components/vertical-icons' import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' @@ -450,6 +451,7 @@ class AppComponent { this.sidePanel = new SidePanel() this.hiddenPanel = new HiddenPanel() this.pinnedPanel = new PinnedPanel() + this.popupPanel = new PopupPanel() const pluginManagerComponent = new PluginManagerComponent(appManager, this.engine) const filePanel = new FilePanel(appManager, contentImport) @@ -457,7 +459,7 @@ class AppComponent { const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport) this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor, appManager) - this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel]) + this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel]) // CONTENT VIEWS & DEFAULT PLUGINS const openZeppelinProxy = new OpenZeppelinProxy(blockchain) @@ -540,6 +542,7 @@ class AppComponent { await this.appManager.activatePlugin(['statusBar']) await this.appManager.activatePlugin(['sidePanel']) // activating host plugin separately await this.appManager.activatePlugin(['pinnedPanel']) + await this.appManager.activatePlugin(['popupPanel']) await this.appManager.activatePlugin(['home']) await this.appManager.activatePlugin(['settings', 'config']) await this.appManager.activatePlugin([ diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx new file mode 100644 index 0000000000..c91ab9644c --- /dev/null +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -0,0 +1,69 @@ +import React from 'react' // eslint-disable-line +import { AbstractPanel } from './panel' +import { RemixPluginPanel } from '@remix-ui/panel' +import packageJson from '../../../../../package.json' +import { PluginViewWrapper } from '@remix-ui/helper' + +const profile = { + name: 'popupPanel', + displayName: 'Popup Panel', + description: 'Remix IDE popup panel', + version: packageJson.version, + methods: ['addView', 'removeView', 'showContent'] +} + +export class PopupPanel extends AbstractPanel { + element: HTMLDivElement + dispatch: React.Dispatch = () => {} + constructor(config) { + super(profile) + } + + setDispatch(dispatch: React.Dispatch) { + this.dispatch = dispatch + } + + onActivation() { + this.renderComponent() + } + + focus(name) { + this.emit('focusChanged', name) + super.focus(name) + this.renderComponent() + } + + addView(profile, view) { + super.addView(profile, view) + this.renderComponent() + this.showContent(profile.name) // should be handled by some click + } + + removeView(profile) { + super.removeView(profile) + this.renderComponent() + } + + async showContent(name) { + super.showContent(name) + this.renderComponent() + } + + renderComponent() { + this.dispatch({ + plugins: this.plugins + }) + } + + render() { + return ( +
+ +
+ ) + } + + updateComponent(state: any) { + return } plugins={state.plugins} /> + } +} diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index d6d3c78a48..e307433c69 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -21,7 +21,7 @@ const profile = { icon: 'assets/img/remix-logo-blue.png', description: 'RemixAI provides AI services to Remix IDE.', kind: '', - location: 'sidePanel', + location: 'popupPanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', version: packageJson.version, maintainedBy: 'Remix' diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx index f343310096..dd8a672525 100644 --- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx @@ -244,6 +244,7 @@ const RemixApp = (props: IRemixAppUi) => { }
{props.app.hiddenPanel.render()}
+
{props.app.popupPanel.render()}
{props.app.statusBar.render()}
From 13ef8733823c203b9e0a1ea26faaca2494108984 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 4 Nov 2024 09:30:14 +0100 Subject: [PATCH 02/14] popup for ai --- .../src/app/components/popup-panel.tsx | 54 +++++++++++++++++-- .../plugins/electron/remixAIDesktopPlugin.tsx | 2 +- .../src/app/plugins/remixAIPlugin.tsx | 44 ++++++++++++++- .../remixdesktop/src/plugins/remixAIDektop.ts | 2 +- libs/remix-api/src/lib/plugins/remixai-api.ts | 1 + libs/remix-api/src/lib/remix-api.ts | 8 +++ .../panel/src/lib/plugins/remix-ui-panel.tsx | 15 ++++-- .../remix-ai/src/lib/components/Default.tsx | 4 +- .../remix-ai/src/lib/components/RemixAI.tsx | 18 +++++-- .../remix-ai/src/lib/components/color.css | 36 ++++++++++--- libs/remix-ui/statusbar/src/css/statusbar.css | 5 ++ .../statusbar/src/lib/components/aiStatus.tsx | 53 +++++++++++++++--- .../src/lib/components/scamDetails.tsx | 14 +++-- .../src/lib/remixui-statusbar-panel.tsx | 22 +++++--- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 2 +- 15 files changed, 236 insertions(+), 44 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index c91ab9644c..2f0f5ef049 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -3,20 +3,26 @@ import { AbstractPanel } from './panel' import { RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' import { PluginViewWrapper } from '@remix-ui/helper' +import {EventEmitter} from 'events' const profile = { name: 'popupPanel', displayName: 'Popup Panel', description: 'Remix IDE popup panel', version: packageJson.version, - methods: ['addView', 'removeView', 'showContent'] + events: ['popupPanelShown'], + methods: ['addView', 'removeView', 'showContent', 'showPopupPanel'] } export class PopupPanel extends AbstractPanel { element: HTMLDivElement dispatch: React.Dispatch = () => {} + showPanel: boolean + constructor(config) { super(profile) + this.event = new EventEmitter() + this.showPanel = true } setDispatch(dispatch: React.Dispatch) { @@ -49,21 +55,59 @@ export class PopupPanel extends AbstractPanel { this.renderComponent() } + async showPopupPanel(show) { + console.log("hide in popup-panel =", show) + this.showPanel = show + this.event.emit('popupPanelShown', show) + this.renderComponent() + } + renderComponent() { this.dispatch({ - plugins: this.plugins + plugins: this.plugins, + showPpPanel: this.showPanel }) } render() { return ( -
- +
+ {this.showPanel && }
) } updateComponent(state: any) { - return } plugins={state.plugins} /> + return ( +
+ + + + } + plugins={state.plugins} /> +
) } } diff --git a/apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx b/apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx index e9909ebc1f..1ead4faafd 100644 --- a/apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/electron/remixAIDesktopPlugin.tsx @@ -10,7 +10,7 @@ const desktop_profile = { description: 'RemixAI provides AI services to Remix IDE Desktop.', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', icon: 'assets/img/remix-logo-blue.png', - methods: ['initializeModelBackend', 'code_completion', 'code_insertion', 'code_generation', 'code_explaining', 'error_explaining', 'solidity_answer'], + methods: ['initializeModelBackend', 'code_completion', 'code_insertion', 'code_generation', 'code_explaining', 'error_explaining', 'solidity_answer', 'toggle'], } export class remixAIDesktopPlugin extends ElectronPlugin { diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index e307433c69..eb5ef592a4 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -5,10 +5,15 @@ import { RemixAITab, ChatApi } from '@remix-ui/remix-ai' import React, { useCallback } from 'react'; import { ICompletions, IModel, RemoteInferencer, IRemoteModel, IParams, GenerationParams, CodeExplainAgent } from '@remix/remix-ai-core'; import { CustomRemixApi } from '@remix-api' +import { PluginViewWrapper } from '@remix-ui/helper' type chatRequestBufferT = { [key in keyof T]: T[key] } +enum AIChatViewState { + minimized = 0, + open = 1 +} const profile = { name: 'remixAI', @@ -16,7 +21,8 @@ const profile = { methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "error_explaining", - "initialize", 'chatPipe', 'ProcessChatRequestBuffer', 'isChatRequestPending'], + "initialize", 'chatPipe', 'ProcessChatRequestBuffer', + 'isChatRequestPending', 'toggle'], events: [], icon: 'assets/img/remix-logo-blue.png', description: 'RemixAI provides AI services to Remix IDE.', @@ -37,6 +43,7 @@ export class RemixAIPlugin extends ViewPlugin { chatRequestBuffer: chatRequestBufferT = null agent: CodeExplainAgent useRemoteInferencer:boolean = false + dispatch: any constructor(inDesktop:boolean) { super(profile) @@ -46,6 +53,7 @@ export class RemixAIPlugin extends ViewPlugin { } onActivation(): void { + //this.renderComponent(AIChatViewState.open) if (this.isOnDesktop) { console.log('Activating RemixAIPlugin on desktop') // this.on(this.remixDesktopPluginName, 'activated', () => { @@ -59,6 +67,10 @@ export class RemixAIPlugin extends ViewPlugin { } } + toggle (open: AIChatViewState) { + this.renderComponent(open) + } + async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ if (this.isOnDesktop && !this.useRemoteInferencer) { // on desktop use remote inferencer -> false @@ -201,13 +213,41 @@ export class RemixAIPlugin extends ViewPlugin { return "" } } + isChatRequestPending(){ return this.chatRequestBuffer != null } + setDispatch(dispatch) { + this.dispatch = dispatch + this.renderComponent(AIChatViewState.open) + } + + renderComponent (open: AIChatViewState) { + this.dispatch({ + plugin: this, + openState: open + }) + } + render() { + return
+ +
+ } + + updateComponent(state) { return ( - + ) } } diff --git a/apps/remixdesktop/src/plugins/remixAIDektop.ts b/apps/remixdesktop/src/plugins/remixAIDektop.ts index 6382e28bba..75cf39612c 100644 --- a/apps/remixdesktop/src/plugins/remixAIDektop.ts +++ b/apps/remixdesktop/src/plugins/remixAIDektop.ts @@ -32,7 +32,7 @@ const clientProfile: Profile = { description: 'RemixAI provides AI services to Remix IDE Desktop.', kind: '', documentation: 'https://remix-ide.readthedocs.io/en/latest/remixai.html', - methods: ['initializeModelBackend', 'code_completion', 'code_insertion', 'code_generation', 'code_explaining', 'error_explaining', 'solidity_answer'] + methods: ['initializeModelBackend', 'code_completion', 'code_insertion', 'code_generation', 'code_explaining', 'error_explaining', 'solidity_answer', 'toggle'] } class RemixAIDesktopPluginClient extends ElectronBasePluginClient { diff --git a/libs/remix-api/src/lib/plugins/remixai-api.ts b/libs/remix-api/src/lib/plugins/remixai-api.ts index 0ea1498151..799b180662 100644 --- a/libs/remix-api/src/lib/plugins/remixai-api.ts +++ b/libs/remix-api/src/lib/plugins/remixai-api.ts @@ -19,5 +19,6 @@ export interface IRemixAI { chatPipe(pipeMessage: string): Promise, ProcessChatRequestBuffer(params:IParams): Promise, initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean): Promise, + toggle(boolean) } } \ No newline at end of file diff --git a/libs/remix-api/src/lib/remix-api.ts b/libs/remix-api/src/lib/remix-api.ts index e8dad3b599..da580b7026 100644 --- a/libs/remix-api/src/lib/remix-api.ts +++ b/libs/remix-api/src/lib/remix-api.ts @@ -17,8 +17,15 @@ import { IRemixAI } from "./plugins/remixai-api" import { IRemixAID } from "./plugins/remixAIDesktop-api" import { IMenuIconsApi } from "./plugins/menuicons-api" import { IDgitPlugin } from "./plugins/dgitplugin-api" +import { Api } from "@remixproject/plugin-utils"; + export interface ICustomRemixApi extends IRemixApi { + popupPanel: { + methods: ['showPopupPanel'] + events: ['popupPanelShown'] + showPopupPanel(): void + } & Api dgitApi: IGitApi dgit: IDgitPlugin config: IConfigApi @@ -39,4 +46,5 @@ export interface ICustomRemixApi extends IRemixApi { remixAID: IRemixAID } + export declare type CustomRemixApi = Readonly \ No newline at end of file diff --git a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx index 4e1fa59a2e..71aa3db8b0 100644 --- a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx @@ -14,16 +14,21 @@ export interface RemixPanelProps { export function RemixPluginPanel(props: RemixPanelProps) { return ( - <> +
{props.header}
- {Object.values(props.plugins).map((pluginRecord) => { - return - })} + { Object.values(props.plugins).map((pluginRecord) => { + return + }) }
- +
) } diff --git a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx index 459797294c..1f1ce48323 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx +++ b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx @@ -42,8 +42,8 @@ export const Default = (props) => { }; ChatApi = useAiChatApi(); const conversationStarters: ConversationStarter[] = [ - { prompt: 'Explain briefly the current file in Editor', icon: ⭐️ }, - { prompt: 'Explain what is a solidity contract!' }] + { prompt: 'Explain what is a solidity contract!'}, + { prompt: 'Explain briefly the current file in Editor'}] // Define initial messages const initialMessages: ChatItem[] = [ diff --git a/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx b/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx index d55a3a9256..61b5910913 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx +++ b/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx @@ -1,14 +1,22 @@ import React, { useContext } from 'react' import '../remix-ai.css' import { Default, ChatApi } from './Default' +enum AIChatViewState { + minimized = 0, + open = 1 +} +interface IRemixAITab { + plugin: any, + openState: AIChatViewState +} +export const RemixAITab = (props: IRemixAITab) => { -export const RemixAITab = (props) => { - - const plugin = props.plugin return ( <> -
- +
+
+ +
) diff --git a/libs/remix-ui/remix-ai/src/lib/components/color.css b/libs/remix-ui/remix-ai/src/lib/components/color.css index 836a05f103..40e54d438b 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/color.css +++ b/libs/remix-ui/remix-ai/src/lib/components/color.css @@ -1,11 +1,32 @@ .nlux-theme-remix_ai_theme[data-color-scheme='light'] { --nlux-ChatRoom--BackgroundColor: var(--text-background); + padding-bottom: 0.1rem; } .nlux-theme-remix_ai_theme[data-color-scheme='dark'] { --nlux-ChatRoom--BackgroundColor: var(--text-background); + padding-bottom: 0.1rem; } +.nlux-launchPad-container { + padding-bottom: 2rem; +} + +.nlux-conversationStarters-container { + overflow-y: hidden; +} + +.nlux-comp-conversationStarters { + width: auto !important; + padding: 0px !important +} + +.nlux-conversationStarters-container>.nlux-comp-conversationStarters>.nlux-comp-conversationStarter { + border-width: 1px !important; + border-color: var(--text-background) !important; +} + + .nlux-theme-remix_ai_theme { /* Override top-level chat room colors */ @@ -35,9 +56,13 @@ --nlux-PromptInput-Focus-Outline--Width: 10px; --nlux-PromptInput-Max-Height: 50px; --nlux-PromptInput--BorderWidth: 0; - .nlux-comp-composer > textarea {padding: 8px;} --nlux-PromptInput--BorderRadius: 10px 0 0 10px; - --nlux-PromptInput-Height: 50px; + --nlux-PromptInput-Height: 30px; + --nlux-cvStrt--brdrWd: 0; + --nlux-cvStrt--brdClr: var(--light); + --nlux-cvStrt--brdrWd: 'hidden'; + --nlux-comp-composer > textarea {padding: 8px;} + /* Override input colors */ @@ -49,10 +74,10 @@ --nlux-Composer--Gap: 0; /* Override submit button colors */ - --nlux-SubmitButton--BackgroundColor: var(--primary); - --nlux-SubmitButton-Active--BackgroundColor:var(--primary); + --nlux-SubmitButton--BackgroundColor: var(--light); + --nlux-SubmitButton-Active--BackgroundColor:var(--light); --nlux-SubmitButton-Disabled--BackgroundColor: var(--dark); - --nlux-SubmitButton-Active--TextColor: var(--text); + --nlux-SubmitButton-Active--TextColor: var(--primary); --nlux-SubmitButton-Disabled--TextColor: var(--text); /** Inline code in markdown */ @@ -61,7 +86,6 @@ --nlux-InlineCode--Padding: 0 2px; --nlux-InlineCode--FontSize: 14px; - /*code block */ --nlux-CodeBlock-CopyButton--BackgroundColor: var(--bg-text); --nlux-CodeBlock-CopyButton--TextColor: var(--text); diff --git a/libs/remix-ui/statusbar/src/css/statusbar.css b/libs/remix-ui/statusbar/src/css/statusbar.css index 4792ca77f3..30a5712f89 100644 --- a/libs/remix-ui/statusbar/src/css/statusbar.css +++ b/libs/remix-ui/statusbar/src/css/statusbar.css @@ -1,4 +1,9 @@ +.remixui_statusbar_gitstatus { + position: relative; + left: 20rem; +} + .remixui_statusbar_gitstatus .remixui_statusbar_gitstatus:hover { cursor: pointer; diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index fc6d774ce4..d476fba092 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -12,12 +12,24 @@ interface AIStatusProps { export default function AIStatus(props: AIStatusProps) { const [copilotActive, setCopilotActive] = useState(false) + const [expandAIChat, setExpandAIChat] = useState(true) + useEffect(() => { + const popupPanelListener = async (show) => { + setTimeout(() => setExpandAIChat(show), 0); + }; + + props.plugin.on('popupPanel', 'popupPanelShown', popupPanelListener) + const run = async () => { const aiActivate = await props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') setCopilotActive(aiActivate) } run() + + return () => { + props.plugin.off('popupPanel', 'popupPanelShown') + } }, []) useEffect(() => { @@ -29,15 +41,42 @@ export default function AIStatus(props: AIStatusProps) { } run() }, [props.plugin.isAiActive, props.plugin.isAiActive]) + return ( - -
- +
+ + { + await props.plugin.call('settings' as any, 'updateCopilotChoice', !copilotActive) + }} + > {copilotActive === false ? 'RemixAI Copilot (disabled)' : 'RemixAI Copilot (enabled)'} + +
+
- +
) -} +} \ No newline at end of file diff --git a/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx b/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx index e72bfe62b5..9c9193b933 100644 --- a/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx @@ -18,13 +18,21 @@ export default function ScamDetails ({ refs, floatStyle, scamAlerts }: ScamDetai return (
-
+
{scamAlerts && scamAlerts.map((alert, index) => ( {alert.url.length < 1 ? diff --git a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx index 5099d31286..cfd5caf99c 100644 --- a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx +++ b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx @@ -72,25 +72,35 @@ export function RemixUIStatusBar({ statusBarPlugin }: RemixUIStatusBarProps) { {(platform !== appPlatformTypes.desktop) && showScamDetails && ( - + )}
+ { (platform !== appPlatformTypes.desktop) &&
+ +
}
-
-
- { (platform !== appPlatformTypes.desktop) &&
- -
}
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 eaaffcad15..bae6a258c2 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -279,7 +279,7 @@ export const TabsUI = (props: TabsUIProps) => { methods: ['code_generation', 'code_completion', "solidity_answer", "code_explaining", "code_insertion", "error_explaining", - "initialize", 'chatPipe', 'ProcessChatRequestBuffer', 'isChatRequestPending'], + "initialize", 'chatPipe', 'ProcessChatRequestBuffer', 'isChatRequestPending', 'toggle'], events: [], icon: 'assets/img/remix-logo-blue.png', description: 'RemixAI provides AI services to Remix IDE.', From 14c15bd902d1b534acd6179b9eaaac5f1ee5545d Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 12:50:55 +0100 Subject: [PATCH 03/14] first fixes --- .../src/app/components/popup-panel.tsx | 49 +++++++++++-------- .../app/src/lib/remix-app/actions/app.ts | 2 + .../app/src/lib/remix-app/interface/index.ts | 1 + .../app/src/lib/remix-app/reducer/app.ts | 47 ++++++++++-------- .../app/src/lib/remix-app/state/app.ts | 3 +- .../src/lib/components/PluginViewWrapper.tsx | 14 +++++- .../panel/src/lib/plugins/remix-ui-panel.tsx | 4 +- .../statusbar/src/lib/components/aiStatus.tsx | 10 +--- 8 files changed, 77 insertions(+), 53 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 2f0f5ef049..8388e8a83f 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -1,9 +1,11 @@ import React from 'react' // eslint-disable-line import { AbstractPanel } from './panel' -import { RemixPluginPanel } from '@remix-ui/panel' +import { PluginRecord, RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' import { PluginViewWrapper } from '@remix-ui/helper' -import {EventEmitter} from 'events' +import { EventEmitter } from 'events' +import { AppState } from 'libs/remix-ui/app/src/lib/remix-app/interface' +import { AppAction, appActionTypes } from '@remix-ui/app' const profile = { name: 'popupPanel', @@ -13,22 +15,28 @@ const profile = { events: ['popupPanelShown'], methods: ['addView', 'removeView', 'showContent', 'showPopupPanel'] } +type popupPanelState = { + plugins: Record +} export class PopupPanel extends AbstractPanel { element: HTMLDivElement - dispatch: React.Dispatch = () => {} - showPanel: boolean + dispatch: React.Dispatch = () => { } + appStateDispatch: React.Dispatch = () => { } constructor(config) { super(profile) this.event = new EventEmitter() - this.showPanel = true } setDispatch(dispatch: React.Dispatch) { this.dispatch = dispatch } + setAppStateDispatch(appStateDispatch: React.Dispatch) { + this.appStateDispatch = appStateDispatch + } + onActivation() { this.renderComponent() } @@ -56,23 +64,31 @@ export class PopupPanel extends AbstractPanel { } async showPopupPanel(show) { - console.log("hide in popup-panel =", show) - this.showPanel = show - this.event.emit('popupPanelShown', show) + + this.appStateDispatch({ + type: appActionTypes.setShowPopupPanel, + payload: show + }) this.renderComponent() } renderComponent() { this.dispatch({ - plugins: this.plugins, - showPpPanel: this.showPanel + plugins: this.plugins }) } render() { + return ( + + ) + } + + updateComponent(state: popupPanelState & Partial) { + console.log("state in updateComponent =", state) return (
- {this.showPanel && } -
- ) - } - - updateComponent(state: any) { - return ( -
@@ -108,6 +116,7 @@ export class PopupPanel extends AbstractPanel { } plugins={state.plugins} /> -
) +
+ ) } } diff --git a/libs/remix-ui/app/src/lib/remix-app/actions/app.ts b/libs/remix-ui/app/src/lib/remix-app/actions/app.ts index 716d351e94..246b10cad0 100644 --- a/libs/remix-ui/app/src/lib/remix-app/actions/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/actions/app.ts @@ -17,6 +17,7 @@ export const enum appActionTypes { setCurrentBranch = 'SET_CURRENT_BRANCH', setNeedsGitInit = 'SET_NEEDS_GIT_INIT', setCanUseGit = 'SET_CAN_USE_GIT', + setShowPopupPanel = 'SET_SHOW_POPUP_PANEL', } type AppPayload = { @@ -24,6 +25,7 @@ type AppPayload = { [appActionTypes.setCurrentBranch]: branch, [appActionTypes.setNeedsGitInit]: boolean, [appActionTypes.setCanUseGit]: boolean, + [appActionTypes.setShowPopupPanel]: boolean, } export type AppAction = ActionMap[keyof ActionMap< diff --git a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts index 0c146c98f7..531c2764d0 100644 --- a/libs/remix-ui/app/src/lib/remix-app/interface/index.ts +++ b/libs/remix-ui/app/src/lib/remix-app/interface/index.ts @@ -52,5 +52,6 @@ export interface AppState { currentBranch: branch needsGitInit: boolean canUseGit: boolean + showPopupPanel: boolean } diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts index 6dd37603bc..5abe07626c 100644 --- a/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts @@ -3,29 +3,36 @@ import { AppState } from "../interface"; export const appReducer = (state: AppState, action: AppAction): AppState => { switch (action.type) { - case appActionTypes.setGitHubUser: { - return { - ...state, - gitHubUser: action.payload + case appActionTypes.setGitHubUser: { + return { + ...state, + gitHubUser: action.payload + } } - } - case appActionTypes.setCurrentBranch: { - return { - ...state, - currentBranch: action.payload + case appActionTypes.setCurrentBranch: { + return { + ...state, + currentBranch: action.payload + } } - } - case appActionTypes.setNeedsGitInit: { - return { - ...state, - needsGitInit: action.payload + case appActionTypes.setNeedsGitInit: { + return { + ...state, + needsGitInit: action.payload + } } - } - case appActionTypes.setCanUseGit: { - return { - ...state, - canUseGit: action.payload + case appActionTypes.setCanUseGit: { + return { + ...state, + canUseGit: action.payload + } + } + + case appActionTypes.setShowPopupPanel: { + return { + ...state, + showPopupPanel: action.payload + } } - } } } \ No newline at end of file diff --git a/libs/remix-ui/app/src/lib/remix-app/state/app.ts b/libs/remix-ui/app/src/lib/remix-app/state/app.ts index 8086b75c9c..2778233a09 100644 --- a/libs/remix-ui/app/src/lib/remix-app/state/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/state/app.ts @@ -5,5 +5,6 @@ export const appInitialState: AppState = { gitHubUser: {} as GitHubUser, currentBranch: null, needsGitInit: true, - canUseGit: false + canUseGit: false, + showPopupPanel: true } \ No newline at end of file diff --git a/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx index c88f985ef6..168f1095f2 100644 --- a/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx +++ b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx @@ -1,4 +1,5 @@ -import React from 'react' +import { AppContext } from '@remix-ui/app' +import React, { useContext } from 'react' import { useEffect, useState } from 'react' interface IPluginViewWrapperProps { @@ -7,12 +8,21 @@ interface IPluginViewWrapperProps { export const PluginViewWrapper = (props: IPluginViewWrapperProps) => { const [state, setState] = useState(null) + const appContext = useContext(AppContext) useEffect(() => { if (props.plugin.setDispatch) { props.plugin.setDispatch(setState) } + if(props.plugin.setAppStateDispatch) { + props.plugin.setAppStateDispatch(appContext.appStateDispatch) + } }, []) - return <>{state ? <>{props.plugin.updateComponent(state)} : <>} + return <>{state ? <>{props.plugin.updateComponent( + { + ...state, + ...appContext['appState'] + })} + : <>} } diff --git a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx index 71aa3db8b0..ba6c494a04 100644 --- a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx @@ -14,7 +14,7 @@ export interface RemixPanelProps { export function RemixPluginPanel(props: RemixPanelProps) { return ( -
+ <> {props.header}
@@ -28,7 +28,7 @@ export function RemixPluginPanel(props: RemixPanelProps) { }) }
-
+ ) } diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index d476fba092..55b4fbf43d 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -12,14 +12,8 @@ interface AIStatusProps { export default function AIStatus(props: AIStatusProps) { const [copilotActive, setCopilotActive] = useState(false) - const [expandAIChat, setExpandAIChat] = useState(true) useEffect(() => { - const popupPanelListener = async (show) => { - setTimeout(() => setExpandAIChat(show), 0); - }; - - props.plugin.on('popupPanel', 'popupPanelShown', popupPanelListener) const run = async () => { const aiActivate = await props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') @@ -71,10 +65,10 @@ export default function AIStatus(props: AIStatusProps) { }} className='p-1 alert alert-info border border-info fa-solid fa-message-bot' onClick={async () => { - await props.plugin.call('popupPanel', 'showPopupPanel', !expandAIChat) + await props.plugin.call('popupPanel', 'showPopupPanel', true) }} > - {expandAIChat ? '1' : '0'} +
From f8667db195e0dd0b969550079ea68e2c9b6e9904 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 13:06:24 +0100 Subject: [PATCH 04/14] lianas css --- apps/remix-ide/src/app/components/popup-panel.tsx | 2 +- libs/remix-ui/statusbar/src/css/statusbar.css | 7 ++----- .../statusbar/src/lib/remixui-statusbar-panel.tsx | 10 ++++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 8388e8a83f..2712b0725d 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -97,7 +97,7 @@ export class PopupPanel extends AbstractPanel { position: 'fixed', bottom: '2rem', right: '3.5rem', - zIndex: 2000, + zIndex: 200, boxShadow: '3px 3px var(--secondary), -0.1em 0 1.4em var(--secondary)' }} data-id="popupPanelPluginsContainer" diff --git a/libs/remix-ui/statusbar/src/css/statusbar.css b/libs/remix-ui/statusbar/src/css/statusbar.css index 30a5712f89..11ee870603 100644 --- a/libs/remix-ui/statusbar/src/css/statusbar.css +++ b/libs/remix-ui/statusbar/src/css/statusbar.css @@ -1,9 +1,6 @@ - -.remixui_statusbar_gitstatus { - position: relative; - left: 20rem; +.remixui_statusbar { + white-space: nowrap; } - .remixui_statusbar_gitstatus .remixui_statusbar_gitstatus:hover { cursor: pointer; diff --git a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx index cfd5caf99c..a295239a10 100644 --- a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx +++ b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx @@ -91,13 +91,15 @@ export function RemixUIStatusBar({ statusBarPlugin }: RemixUIStatusBarProps) { { (platform !== appPlatformTypes.desktop) &&
} -
- +
+
+ +
-
+
-
+
From fac93dc375ae5244d8e04edc16c49fed0f1414c8 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 13:36:36 +0100 Subject: [PATCH 05/14] fix state --- .../src/app/components/popup-panel.tsx | 2 +- .../src/app/plugins/remixAIPlugin.tsx | 17 ++++---------- .../src/lib/plugins/popuppanel-api.ts | 10 ++++++++ libs/remix-api/src/lib/plugins/remixai-api.ts | 1 - .../src/lib/plugins/remixaiDesktop-api.ts | 23 ------------------- libs/remix-api/src/lib/remix-api.ts | 7 ++---- .../remix-ai/src/lib/components/RemixAI.tsx | 6 +---- .../statusbar/src/lib/components/aiStatus.tsx | 13 ++++++----- 8 files changed, 25 insertions(+), 54 deletions(-) create mode 100644 libs/remix-api/src/lib/plugins/popuppanel-api.ts delete mode 100644 libs/remix-api/src/lib/plugins/remixaiDesktop-api.ts diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 2712b0725d..3b9af9ff23 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -12,7 +12,7 @@ const profile = { displayName: 'Popup Panel', description: 'Remix IDE popup panel', version: packageJson.version, - events: ['popupPanelShown'], + events: [], methods: ['addView', 'removeView', 'showContent', 'showPopupPanel'] } type popupPanelState = { diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index eb5ef592a4..5bb7ac7e93 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -10,10 +10,6 @@ import { PluginViewWrapper } from '@remix-ui/helper' type chatRequestBufferT = { [key in keyof T]: T[key] } -enum AIChatViewState { - minimized = 0, - open = 1 -} const profile = { name: 'remixAI', @@ -53,7 +49,7 @@ export class RemixAIPlugin extends ViewPlugin { } onActivation(): void { - //this.renderComponent(AIChatViewState.open) + if (this.isOnDesktop) { console.log('Activating RemixAIPlugin on desktop') // this.on(this.remixDesktopPluginName, 'activated', () => { @@ -66,10 +62,6 @@ export class RemixAIPlugin extends ViewPlugin { this.initialize() } } - - toggle (open: AIChatViewState) { - this.renderComponent(open) - } async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ if (this.isOnDesktop && !this.useRemoteInferencer) { @@ -220,13 +212,12 @@ export class RemixAIPlugin extends ViewPlugin { setDispatch(dispatch) { this.dispatch = dispatch - this.renderComponent(AIChatViewState.open) + this.renderComponent() } - renderComponent (open: AIChatViewState) { + renderComponent () { this.dispatch({ plugin: this, - openState: open }) } @@ -247,7 +238,7 @@ export class RemixAIPlugin extends ViewPlugin { updateComponent(state) { return ( - + ) } } diff --git a/libs/remix-api/src/lib/plugins/popuppanel-api.ts b/libs/remix-api/src/lib/plugins/popuppanel-api.ts new file mode 100644 index 0000000000..040a70bc0a --- /dev/null +++ b/libs/remix-api/src/lib/plugins/popuppanel-api.ts @@ -0,0 +1,10 @@ +import { IFilePanel } from '@remixproject/plugin-api' +import { StatusEvents } from '@remixproject/plugin-utils' + +export interface IPopupPanelAPI { + events:{ + } & StatusEvents + methods: { + showPopupPanel(state: boolean): void + } +} diff --git a/libs/remix-api/src/lib/plugins/remixai-api.ts b/libs/remix-api/src/lib/plugins/remixai-api.ts index 799b180662..0ea1498151 100644 --- a/libs/remix-api/src/lib/plugins/remixai-api.ts +++ b/libs/remix-api/src/lib/plugins/remixai-api.ts @@ -19,6 +19,5 @@ export interface IRemixAI { chatPipe(pipeMessage: string): Promise, ProcessChatRequestBuffer(params:IParams): Promise, initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean): Promise, - toggle(boolean) } } \ No newline at end of file diff --git a/libs/remix-api/src/lib/plugins/remixaiDesktop-api.ts b/libs/remix-api/src/lib/plugins/remixaiDesktop-api.ts deleted file mode 100644 index dc9deb7e82..0000000000 --- a/libs/remix-api/src/lib/plugins/remixaiDesktop-api.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { IParams } from "@remix/remix-ai-core"; -import { StatusEvents } from "@remixproject/plugin-utils"; - -export interface IRemixAID { - events: { - activated():void, - onInference():void, - onInferenceDone():void, - onStreamResult(streamText: string):void, - - } & StatusEvents, - methods: { - code_completion(context: string): Promise - code_insertion(msg_pfx: string, msg_sfx: string): Promise, - code_generation(prompt: string): Promise, - code_explaining(code: string, context?: string): Promise, - error_explaining(prompt: string): Promise, - solidity_answer(prompt: string): Promise, - initializeModelBackend(local: boolean, generalModel?, completionModel?): Promise, - chatPipe(pipeMessage: string): Promise, - ProcessChatRequestBuffer(params:IParams): Promise, - } -} \ No newline at end of file diff --git a/libs/remix-api/src/lib/remix-api.ts b/libs/remix-api/src/lib/remix-api.ts index da580b7026..7df4dc7104 100644 --- a/libs/remix-api/src/lib/remix-api.ts +++ b/libs/remix-api/src/lib/remix-api.ts @@ -18,14 +18,11 @@ import { IRemixAID } from "./plugins/remixAIDesktop-api" import { IMenuIconsApi } from "./plugins/menuicons-api" import { IDgitPlugin } from "./plugins/dgitplugin-api" import { Api } from "@remixproject/plugin-utils"; +import { IPopupPanelAPI } from "./plugins/popuppanel-api" export interface ICustomRemixApi extends IRemixApi { - popupPanel: { - methods: ['showPopupPanel'] - events: ['popupPanelShown'] - showPopupPanel(): void - } & Api + popupPanel: IPopupPanelAPI dgitApi: IGitApi dgit: IDgitPlugin config: IConfigApi diff --git a/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx b/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx index 61b5910913..a5aaba4a7d 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx +++ b/libs/remix-ui/remix-ai/src/lib/components/RemixAI.tsx @@ -1,13 +1,9 @@ import React, { useContext } from 'react' import '../remix-ai.css' import { Default, ChatApi } from './Default' -enum AIChatViewState { - minimized = 0, - open = 1 -} + interface IRemixAITab { plugin: any, - openState: AIChatViewState } export const RemixAITab = (props: IRemixAITab) => { diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index 55b4fbf43d..48864811a2 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -1,7 +1,8 @@ // eslint-disable-next-line @nrwl/nx/enforce-module-boundaries import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar' import { CustomTooltip } from '@remix-ui/helper' -import React, { useEffect, useState } from 'react' +import React, { useContext, useEffect, useState } from 'react' +import { appActionTypes, AppContext } from '@remix-ui/app' interface AIStatusProps { plugin: StatusBar @@ -12,7 +13,7 @@ interface AIStatusProps { export default function AIStatus(props: AIStatusProps) { const [copilotActive, setCopilotActive] = useState(false) - + const appContext = useContext(AppContext) useEffect(() => { const run = async () => { @@ -21,9 +22,6 @@ export default function AIStatus(props: AIStatusProps) { } run() - return () => { - props.plugin.off('popupPanel', 'popupPanelShown') - } }, []) useEffect(() => { @@ -65,7 +63,10 @@ export default function AIStatus(props: AIStatusProps) { }} className='p-1 alert alert-info border border-info fa-solid fa-message-bot' onClick={async () => { - await props.plugin.call('popupPanel', 'showPopupPanel', true) + appContext.appStateDispatch({ + type: appActionTypes.setShowPopupPanel, + payload: !appContext.appState.showPopupPanel + }) }} > From cbab1a11fb730502a24b052146a8a576b13717ba Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 13:46:01 +0100 Subject: [PATCH 06/14] clean up --- .../src/app/components/popup-panel.tsx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 3b9af9ff23..f45a9f3d3f 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -23,7 +23,7 @@ export class PopupPanel extends AbstractPanel { element: HTMLDivElement dispatch: React.Dispatch = () => { } appStateDispatch: React.Dispatch = () => { } - + constructor(config) { super(profile) this.event = new EventEmitter() @@ -64,7 +64,7 @@ export class PopupPanel extends AbstractPanel { } async showPopupPanel(show) { - + this.appStateDispatch({ type: appActionTypes.setShowPopupPanel, payload: show @@ -85,7 +85,6 @@ export class PopupPanel extends AbstractPanel { } updateComponent(state: popupPanelState & Partial) { - console.log("state in updateComponent =", state) return (
- - - - } - plugins={state.plugins} /> +
+ + + + } + plugins={state.plugins} /> +
) } From ed896ee6fc5c081b98939615e34b6b43a869c451 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 13:49:45 +0100 Subject: [PATCH 07/14] linting --- .../src/app/components/popup-panel.tsx | 4 +- .../src/app/plugins/remixAIPlugin.tsx | 2 +- libs/remix-ui/app/src/index.ts | 2 +- .../app/src/lib/remix-app/reducer/app.ts | 50 +++++++++---------- .../src/lib/components/PluginViewWrapper.tsx | 2 +- .../remix-ai/src/lib/components/Default.tsx | 4 +- .../statusbar/src/lib/components/aiStatus.tsx | 6 +-- .../src/lib/remixui-statusbar-panel.tsx | 4 +- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index f45a9f3d3f..363d89d2cf 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -4,8 +4,8 @@ import { PluginRecord, RemixPluginPanel } from '@remix-ui/panel' import packageJson from '../../../../../package.json' import { PluginViewWrapper } from '@remix-ui/helper' import { EventEmitter } from 'events' -import { AppState } from 'libs/remix-ui/app/src/lib/remix-app/interface' -import { AppAction, appActionTypes } from '@remix-ui/app' + +import { AppAction, appActionTypes, AppState } from '@remix-ui/app' const profile = { name: 'popupPanel', diff --git a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx index 5bb7ac7e93..34a3a15298 100644 --- a/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx +++ b/apps/remix-ide/src/app/plugins/remixAIPlugin.tsx @@ -62,7 +62,7 @@ export class RemixAIPlugin extends ViewPlugin { this.initialize() } } - + async initialize(model1?:IModel, model2?:IModel, remoteModel?:IRemoteModel, useRemote?:boolean){ if (this.isOnDesktop && !this.useRemoteInferencer) { // on desktop use remote inferencer -> false diff --git a/libs/remix-ui/app/src/index.ts b/libs/remix-ui/app/src/index.ts index 31dea89385..4602431686 100644 --- a/libs/remix-ui/app/src/index.ts +++ b/libs/remix-ui/app/src/index.ts @@ -2,6 +2,6 @@ export { default as RemixApp } from './lib/remix-app/remix-app' export { dispatchModalContext, dispatchModalInterface, AppContext, appProviderContextType, appPlatformTypes, platformContext, onLineContext } from './lib/remix-app/context/context' export { ModalProvider, useDialogDispatchers } from './lib/remix-app/context/provider' export { AppModal } from './lib/remix-app/interface/index' -export { AlertModal } from './lib/remix-app/interface/index' +export { AlertModal, AppState } from './lib/remix-app/interface/index' export { ModalTypes, AppModalCancelTypes } from './lib/remix-app/types/index' export { AppAction, appActionTypes } from './lib/remix-app/actions/app' diff --git a/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts b/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts index 5abe07626c..39d61cab75 100644 --- a/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/reducer/app.ts @@ -3,36 +3,36 @@ import { AppState } from "../interface"; export const appReducer = (state: AppState, action: AppAction): AppState => { switch (action.type) { - case appActionTypes.setGitHubUser: { - return { - ...state, - gitHubUser: action.payload - } + case appActionTypes.setGitHubUser: { + return { + ...state, + gitHubUser: action.payload } - case appActionTypes.setCurrentBranch: { - return { - ...state, - currentBranch: action.payload - } + } + case appActionTypes.setCurrentBranch: { + return { + ...state, + currentBranch: action.payload } - case appActionTypes.setNeedsGitInit: { - return { - ...state, - needsGitInit: action.payload - } + } + case appActionTypes.setNeedsGitInit: { + return { + ...state, + needsGitInit: action.payload } - case appActionTypes.setCanUseGit: { - return { - ...state, - canUseGit: action.payload - } + } + case appActionTypes.setCanUseGit: { + return { + ...state, + canUseGit: action.payload } + } - case appActionTypes.setShowPopupPanel: { - return { - ...state, - showPopupPanel: action.payload - } + case appActionTypes.setShowPopupPanel: { + return { + ...state, + showPopupPanel: action.payload } } + } } \ No newline at end of file diff --git a/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx index 168f1095f2..c29f58d4dc 100644 --- a/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx +++ b/libs/remix-ui/helper/src/lib/components/PluginViewWrapper.tsx @@ -14,7 +14,7 @@ export const PluginViewWrapper = (props: IPluginViewWrapperProps) => { if (props.plugin.setDispatch) { props.plugin.setDispatch(setState) } - if(props.plugin.setAppStateDispatch) { + if (props.plugin.setAppStateDispatch) { props.plugin.setAppStateDispatch(appContext.appStateDispatch) } }, []) diff --git a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx index 1f1ce48323..bdeaacbea7 100644 --- a/libs/remix-ui/remix-ai/src/lib/components/Default.tsx +++ b/libs/remix-ui/remix-ai/src/lib/components/Default.tsx @@ -42,8 +42,8 @@ export const Default = (props) => { }; ChatApi = useAiChatApi(); const conversationStarters: ConversationStarter[] = [ - { prompt: 'Explain what is a solidity contract!'}, - { prompt: 'Explain briefly the current file in Editor'}] + { prompt: 'Explain what is a solidity contract!' }, + { prompt: 'Explain briefly the current file in Editor' }] // Define initial messages const initialMessages: ChatItem[] = [ diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index 48864811a2..53f3de6325 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -15,13 +15,13 @@ export default function AIStatus(props: AIStatusProps) { const [copilotActive, setCopilotActive] = useState(false) const appContext = useContext(AppContext) useEffect(() => { - + const run = async () => { const aiActivate = await props.plugin.call('settings', 'get', 'settings/copilot/suggest/activate') setCopilotActive(aiActivate) } run() - + }, []) useEffect(() => { @@ -40,7 +40,7 @@ export default function AIStatus(props: AIStatusProps) { tooltipText={copilotActive ? "Disable RemixAI Copilot" : "Enable RemixAI Copilot. Switch to .sol file to try it."} > { await props.plugin.call('settings' as any, 'updateCopilotChoice', !copilotActive) diff --git a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx index a295239a10..22b1dac390 100644 --- a/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx +++ b/libs/remix-ui/statusbar/src/lib/remixui-statusbar-panel.tsx @@ -89,8 +89,8 @@ export function RemixUIStatusBar({ statusBarPlugin }: RemixUIStatusBarProps) { )}
{ (platform !== appPlatformTypes.desktop) &&
- -
} + +
}
From 8af1f52dbe32e4724fcbdd4975161155e5c96b3a Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 14:07:23 +0100 Subject: [PATCH 08/14] hide popup --- libs/remix-ui/app/src/lib/remix-app/state/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/app/src/lib/remix-app/state/app.ts b/libs/remix-ui/app/src/lib/remix-app/state/app.ts index 2778233a09..708b22301a 100644 --- a/libs/remix-ui/app/src/lib/remix-app/state/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/state/app.ts @@ -6,5 +6,5 @@ export const appInitialState: AppState = { currentBranch: null, needsGitInit: true, canUseGit: false, - showPopupPanel: true + showPopupPanel: false } \ No newline at end of file From 9734f542d6c40eea315a4931e3dea76b5f5042dc Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 14:32:47 +0100 Subject: [PATCH 09/14] hidescam button --- apps/remix-ide-e2e/src/helpers/init.ts | 3 +++ libs/remix-ui/statusbar/src/lib/components/scamAlertStatus.tsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/helpers/init.ts b/apps/remix-ide-e2e/src/helpers/init.ts index f30ce3dd62..cd6bdb86af 100644 --- a/apps/remix-ide-e2e/src/helpers/init.ts +++ b/apps/remix-ide-e2e/src/helpers/init.ts @@ -27,6 +27,8 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url }) .verifyLoad() .enableClipBoard() + .waitForElementVisible('*[data-id="hTScamAlertButton"]') + .click('*[data-id="hTScamAlertButton"]') .perform((done) => { browser.execute(function () { // hide tooltips function addStyle(styleString) { @@ -76,6 +78,7 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url function initModules(browser: NightwatchBrowser, callback: VoidFunction) { browser + .pause() .click('[data-id="verticalIconsKindpluginManager"]') .scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityStaticAnalysis"]') .scrollAndClick('[data-id="pluginManagerComponentActivateButtondebugger"]') diff --git a/libs/remix-ui/statusbar/src/lib/components/scamAlertStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/scamAlertStatus.tsx index d3cbce68fd..98a8b1fc4c 100644 --- a/libs/remix-ui/statusbar/src/lib/components/scamAlertStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/scamAlertStatus.tsx @@ -15,7 +15,7 @@ export default function ScamAlertStatus ({ refs, getReferenceProps }: ScamAlertS -
+
From d244c909be59381867d4ae89c56dc68e90a9bc69 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 15:16:14 +0100 Subject: [PATCH 10/14] fix bugs --- .../src/app/components/popup-panel.tsx | 6 +-- .../src/lib/components/PluginViewWrapper.tsx | 37 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/remix-ide/src/app/components/popup-panel.tsx b/apps/remix-ide/src/app/components/popup-panel.tsx index 363d89d2cf..b85c3eb8a8 100644 --- a/apps/remix-ide/src/app/components/popup-panel.tsx +++ b/apps/remix-ide/src/app/components/popup-panel.tsx @@ -80,14 +80,14 @@ export class PopupPanel extends AbstractPanel { render() { return ( - + ) } - updateComponent(state: popupPanelState & Partial) { + updateComponent(state: popupPanelState, appState: Partial) { return (
{ +export const PluginViewWrapper = ({ plugin, useAppContext = false }: IPluginViewWrapperProps) => { const [state, setState] = useState(null) - const appContext = useContext(AppContext) + const appContext = useAppContext ? useContext(AppContext) : null useEffect(() => { - if (props.plugin.setDispatch) { - props.plugin.setDispatch(setState) + if (plugin.setDispatch) { + plugin.setDispatch(setState) } - if (props.plugin.setAppStateDispatch) { - props.plugin.setAppStateDispatch(appContext.appStateDispatch) + if (useAppContext && appContext.appStateDispatch && plugin.setAppStateDispatch) { + plugin.setAppStateDispatch(appContext.appStateDispatch) } - }, []) + }, [plugin]) - return <>{state ? <>{props.plugin.updateComponent( - { - ...state, - ...appContext['appState'] - })} - : <>} + if (useAppContext && appContext && appContext.appState) { + return ( + <> + {state ? <>{plugin.updateComponent(state, appContext.appState)} : <>} + + ) + } + + return ( + <> + {state ? <>{plugin.updateComponent(state)} : <>} + + ) } From d3c71d16413d23d8cbb61bde0ca38f40592c1853 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 15:31:20 +0100 Subject: [PATCH 11/14] init --- apps/remix-ide-e2e/src/helpers/init.ts | 3 ++- libs/remix-ui/app/src/lib/remix-app/state/app.ts | 2 +- libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/helpers/init.ts b/apps/remix-ide-e2e/src/helpers/init.ts index cd6bdb86af..a6c303f32d 100644 --- a/apps/remix-ide-e2e/src/helpers/init.ts +++ b/apps/remix-ide-e2e/src/helpers/init.ts @@ -29,6 +29,8 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url .enableClipBoard() .waitForElementVisible('*[data-id="hTScamAlertButton"]') .click('*[data-id="hTScamAlertButton"]') + .waitForElementVisible('*[data-id="aiStatusButton"]') + .click('*[data-id="aiStatusButton"]') .perform((done) => { browser.execute(function () { // hide tooltips function addStyle(styleString) { @@ -78,7 +80,6 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url function initModules(browser: NightwatchBrowser, callback: VoidFunction) { browser - .pause() .click('[data-id="verticalIconsKindpluginManager"]') .scrollAndClick('[data-id="pluginManagerComponentActivateButtonsolidityStaticAnalysis"]') .scrollAndClick('[data-id="pluginManagerComponentActivateButtondebugger"]') diff --git a/libs/remix-ui/app/src/lib/remix-app/state/app.ts b/libs/remix-ui/app/src/lib/remix-app/state/app.ts index 708b22301a..2778233a09 100644 --- a/libs/remix-ui/app/src/lib/remix-app/state/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/state/app.ts @@ -6,5 +6,5 @@ export const appInitialState: AppState = { currentBranch: null, needsGitInit: true, canUseGit: false, - showPopupPanel: false + showPopupPanel: true } \ No newline at end of file diff --git a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx index 53f3de6325..bfdf3f96bb 100644 --- a/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/aiStatus.tsx @@ -61,6 +61,7 @@ export default function AIStatus(props: AIStatusProps) { color: 'var(--ai)', boxShadow: '3px 3px var(--secondary), -0.1em 0 1.4em var(--secondary)' }} + data-id="aiStatusButton" className='p-1 alert alert-info border border-info fa-solid fa-message-bot' onClick={async () => { appContext.appStateDispatch({ From 29fca2194639594a09688ad38f7fff8c6b07fe1a Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 15:58:48 +0100 Subject: [PATCH 12/14] hidescamdetails --- apps/remix-ide-e2e/src/commands/hideToolTips.ts | 5 ++++- apps/remix-ide-e2e/src/helpers/init.ts | 5 +++-- libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/hideToolTips.ts b/apps/remix-ide-e2e/src/commands/hideToolTips.ts index 00a05e26c3..87d7e10b64 100644 --- a/apps/remix-ide-e2e/src/commands/hideToolTips.ts +++ b/apps/remix-ide-e2e/src/commands/hideToolTips.ts @@ -1,4 +1,4 @@ -import {NightwatchBrowser} from 'nightwatch' +import { NightwatchBrowser } from 'nightwatch' import EventEmitter from 'events' class HideToolTips extends EventEmitter { @@ -16,6 +16,9 @@ class HideToolTips extends EventEmitter { .popover { display:none !important; } + #scamDetails { + display:none !important; + } `) }, [], done()) }) diff --git a/apps/remix-ide-e2e/src/helpers/init.ts b/apps/remix-ide-e2e/src/helpers/init.ts index a6c303f32d..5954ce7b38 100644 --- a/apps/remix-ide-e2e/src/helpers/init.ts +++ b/apps/remix-ide-e2e/src/helpers/init.ts @@ -27,8 +27,6 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url }) .verifyLoad() .enableClipBoard() - .waitForElementVisible('*[data-id="hTScamAlertButton"]') - .click('*[data-id="hTScamAlertButton"]') .waitForElementVisible('*[data-id="aiStatusButton"]') .click('*[data-id="aiStatusButton"]') .perform((done) => { @@ -43,6 +41,9 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url .popover { display:none !important; } + #scamDetails { + display:none !important; + } `); }, [], done()) }) diff --git a/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx b/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx index 9c9193b933..6a3108b313 100644 --- a/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/scamDetails.tsx @@ -18,6 +18,7 @@ export default function ScamDetails ({ refs, floatStyle, scamAlerts }: ScamDetai return (
Date: Mon, 4 Nov 2024 16:49:58 +0100 Subject: [PATCH 13/14] hide popup panel --- apps/remix-ide-e2e/src/helpers/init.ts | 2 -- libs/remix-ui/app/src/lib/remix-app/state/app.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/helpers/init.ts b/apps/remix-ide-e2e/src/helpers/init.ts index 5954ce7b38..67e8f1a8fc 100644 --- a/apps/remix-ide-e2e/src/helpers/init.ts +++ b/apps/remix-ide-e2e/src/helpers/init.ts @@ -27,8 +27,6 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url }) .verifyLoad() .enableClipBoard() - .waitForElementVisible('*[data-id="aiStatusButton"]') - .click('*[data-id="aiStatusButton"]') .perform((done) => { browser.execute(function () { // hide tooltips function addStyle(styleString) { diff --git a/libs/remix-ui/app/src/lib/remix-app/state/app.ts b/libs/remix-ui/app/src/lib/remix-app/state/app.ts index 2778233a09..708b22301a 100644 --- a/libs/remix-ui/app/src/lib/remix-app/state/app.ts +++ b/libs/remix-ui/app/src/lib/remix-app/state/app.ts @@ -6,5 +6,5 @@ export const appInitialState: AppState = { currentBranch: null, needsGitInit: true, canUseGit: false, - showPopupPanel: true + showPopupPanel: false } \ No newline at end of file From e958836133c825e23e1a2c9fa1eae914d53d968c Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 4 Nov 2024 16:59:59 +0100 Subject: [PATCH 14/14] hide scam --- apps/remix-ide-e2e/src/commands/refreshPage.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/remix-ide-e2e/src/commands/refreshPage.ts b/apps/remix-ide-e2e/src/commands/refreshPage.ts index 5147ceb839..309892536f 100644 --- a/apps/remix-ide-e2e/src/commands/refreshPage.ts +++ b/apps/remix-ide-e2e/src/commands/refreshPage.ts @@ -20,6 +20,9 @@ class RefreshPage extends EventEmitter { .popover { display:none !important; } + #scamDetails { + display:none !important; + } `) }, [], done()) })