diff --git a/apps/remix-ide/src/app/plugins/solcoderAI.tsx b/apps/remix-ide/src/app/plugins/solcoderAI.tsx index 45799ae784..473081c0c2 100644 --- a/apps/remix-ide/src/app/plugins/solcoderAI.tsx +++ b/apps/remix-ide/src/app/plugins/solcoderAI.tsx @@ -20,6 +20,7 @@ export class SolCoder extends Plugin { } async code_generation(prompt): Promise { + this.emit("aiInfering") this.call('layout', 'maximizeTerminal') this.call('terminal', 'log', 'Waiting for Solcoder answer...') let result @@ -34,14 +35,17 @@ export class SolCoder extends Plugin { body: JSON.stringify({"data":[prompt,false,1000,0.2,0.8,50]}), }) ).json() - return result.data[0] + return result.data[0] } catch (e) { this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) return + }finally { + this.emit("aiInferingDone") } } async solidity_answer(prompt): Promise { + this.emit("aiInfering") this.call('layout', 'maximizeTerminal') this.call('terminal', 'log', 'Waiting for Solcoder answer...') let result @@ -59,6 +63,8 @@ export class SolCoder extends Plugin { } catch (e) { this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) return + }finally { + this.emit("aiInferingDone") } if (result) { this.call('terminal', 'log', { type: 'typewriterwarning', value: result.data[0]}) @@ -70,6 +76,7 @@ export class SolCoder extends Plugin { async code_completion(prompt, options:SuggestOptions=null): Promise { + this.emit("aiInfering") let result try { result = await( @@ -103,6 +110,8 @@ export class SolCoder extends Plugin { } catch (e) { this.call('terminal', 'log', { type: 'typewritererror', value: `Unable to get a response ${e.message}` }) return + } finally { + this.emit("aiInferingDone") } } diff --git a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts index ec86a44e43..bd81c26fc4 100644 --- a/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/inlineCompletionProvider.ts @@ -2,6 +2,8 @@ import { EditorUIProps, monacoTypes } from '@remix-ui/editor'; import axios, {AxiosResponse} from 'axios' import { slice } from 'lodash'; +const _paq = (window._paq = window._paq || []) + const controller = new AbortController(); const { signal } = controller; const result: string = '' @@ -27,6 +29,7 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli endLineNumber: position.lineNumber, endColumn: position.column, }); + if (!word.endsWith(' ') && !word.endsWith('\n') && @@ -65,6 +68,15 @@ export class RemixInLineCompletionProvider implements monacoTypes.languages.Inli } catch (e) { console.error(e) } + + if (word.split('\n').at(-1).trimStart().startsWith('//') || + word.split('\n').at(-1).trimStart().startsWith('/*') || + word.split('\n').at(-1).trimStart().startsWith('*') || + word.split('\n').at(-1).trimStart().startsWith('*/') + ){ + return; // do not do completion on single and multiline comment + } + // abort if there is a signal if (token.isCancellationRequested) { diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 1cea4662a0..4064d8961a 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -44,6 +44,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { const [cmdHistory, cmdHistoryDispatch] = useReducer(addCommandHistoryReducer, initialState) const [, scriptRunnerDispatch] = useReducer(registerScriptRunnerReducer, initialState) const [toaster, setToaster] = useState(false) + const [aiLoading, setAILoading] = useState(false) const [toastProvider, setToastProvider] = useState({ show: false, fileName: '', @@ -103,6 +104,14 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { setIsVM(provider.startsWith('vm-')) }) + props.plugin.on('solcoder', 'aiInfering', () => { + setAILoading(true) + }) + + props.plugin.on('solcoder', 'aiInferingDone', () => { + setAILoading(false) + }) + props.onReady({ logHtml: (html) => { scriptRunnerDispatch({ @@ -649,6 +658,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { data-id="terminalInputSearch" /> + {aiLoading &&
+ + AI Running +
} +