Skip to content

Commit 287242b

Browse files
authored
Merge pull request #6088 from ethereum/newaichat
Newaichat
2 parents 0861888 + c42e334 commit 287242b

File tree

67 files changed

+3030
-760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3030
-760
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ workflows:
823823
script: ["flaky.sh"]
824824
job: ["nogroup"]
825825
jobsize: ["1"]
826-
parallelism: [5]
826+
parallelism: [1]
827827
run_metamask_tests:
828828
when: << pipeline.parameters.run_metamask_tests >>
829829
jobs:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ stats.json
1818
release
1919
.env
2020
.env.local
21-
21+
.idea/
22+
.yalc/
23+
.yalc
2224

2325
# compiled output
2426
/dist

apps/remix-ide-e2e/nightwatch-firefox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
'javascriptEnabled': true,
3636
'acceptSslCerts': true,
3737
'moz:firefoxOptions': {
38-
args: ['-width=2560', '-height=1440']
38+
args: ['-width=2560', '-height=1440', '--devtools']
3939
}
4040
}
4141
},

apps/remix-ide-e2e/src/commands/addFile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import EventEmitter from 'events'
33

44
class AddFile extends EventEmitter {
55
command(this: NightwatchBrowser, name: string, content: NightwatchContractContent, readMeFile?:string): NightwatchBrowser {
6-
if(!readMeFile)
7-
readMeFile = 'README.txt'
6+
if (!readMeFile)
7+
readMeFile = 'README.txt'
88
this.api.perform((done) => {
99
addFile(this.api, name, content, readMeFile, () => {
1010
done()
@@ -63,7 +63,7 @@ function addFile(browser: NightwatchBrowser, name: string, content: NightwatchCo
6363
})
6464
.setEditorValue(content.content)
6565
.getEditorValue((result) => {
66-
if(result != content.content) {
66+
if (result != content.content) {
6767
browser.setEditorValue(content.content)
6868
}
6969
})
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { NightwatchBrowser } from 'nightwatch'
2+
import EventEmitter from 'events'
3+
4+
class AssistantAddCtx extends EventEmitter {
5+
command(this: NightwatchBrowser, prompt: string): NightwatchBrowser {
6+
this.api.perform((done) => {
7+
selectCtx(this.api, prompt, () => {
8+
done()
9+
this.emit('complete')
10+
})
11+
})
12+
return this
13+
}
14+
}
15+
16+
function selectCtx(browser: NightwatchBrowser, ctx: string, done: VoidFunction) {
17+
browser
18+
.waitForElementVisible('*[data-id="remix-ai-assistant"]')
19+
.waitForElementVisible('*[data-id="composer-ai-add-context"]')
20+
.click({
21+
locateStrategy: 'xpath',
22+
selector: '//*[@data-id="composer-ai-add-context"]'
23+
})
24+
.waitForElementVisible('*[data-id="currentFile-context-option"]')
25+
.perform(async ()=> {
26+
switch (ctx) {
27+
case 'currentFile':
28+
browser.click({
29+
locateStrategy: 'xpath',
30+
selector: '//*[@data-id="currentFile-context-option"]'
31+
});
32+
break;
33+
case 'workspace':
34+
browser.click({
35+
locateStrategy: 'xpath',
36+
selector: '//*[@data-id="workspace-context-option"]'
37+
});
38+
break;
39+
case 'openedFiles':
40+
browser.click({
41+
locateStrategy: 'xpath',
42+
selector: '//*[@data-id="allOpenedFiles-context-option"]'
43+
});
44+
break;
45+
default:
46+
break;
47+
}
48+
})
49+
done()
50+
}
51+
52+
module.exports = AssistantAddCtx;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NightwatchBrowser } from 'nightwatch'
2+
import EventEmitter from 'events'
3+
4+
class AssistantClearChat extends EventEmitter {
5+
command(this: NightwatchBrowser): NightwatchBrowser {
6+
this.api.perform((done) => {
7+
clearChat(this.api, () => {
8+
done()
9+
this.emit('complete')
10+
})
11+
})
12+
return this
13+
}
14+
}
15+
16+
function clearChat(browser: NightwatchBrowser, done: VoidFunction) {
17+
browser
18+
.execute(function () {
19+
(window as any).remixAIChat.current.clearChat();
20+
}, [])
21+
22+
done()
23+
}
24+
25+
module.exports = AssistantClearChat;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { NightwatchBrowser } from 'nightwatch'
2+
import EventEmitter from 'events'
3+
4+
class AssistantGenerate extends EventEmitter {
5+
command(this: NightwatchBrowser, prompt: string, provider: string): NightwatchBrowser {
6+
this.api.perform((done) => {
7+
generate(this.api, prompt, provider, () => {
8+
done()
9+
this.emit('complete')
10+
})
11+
})
12+
return this
13+
}
14+
}
15+
16+
function generate(browser: NightwatchBrowser, prompt: string, provider: string, done: VoidFunction) {
17+
18+
console.log('Generating with prompt:', prompt, 'and provider:', provider)
19+
browser
20+
.waitForElementPresent('*[data-id="remix-ai-assistant-ready"]')
21+
.assistantSetProvider(provider)
22+
.waitForElementPresent({
23+
locateStrategy: 'xpath',
24+
selector: "//*[@data-id='remix-ai-streaming' and @data-streaming='false']",
25+
})
26+
27+
.execute(function (prompt) {
28+
(window as any).remixAIChat.current.sendChat(`/generate ${prompt}`);
29+
}, [prompt])
30+
.waitForElementVisible({
31+
locateStrategy: 'xpath',
32+
selector: `//*[contains(@class,"chat-bubble") and contains(.,"/generate ${prompt}")]`
33+
})
34+
35+
done()
36+
}
37+
38+
module.exports = AssistantGenerate;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NightwatchBrowser } from 'nightwatch'
2+
import EventEmitter from 'events'
3+
4+
class SetAssistantProvider extends EventEmitter {
5+
command(this: NightwatchBrowser, provider: string): NightwatchBrowser {
6+
this.api.perform((done) => {
7+
setAssistant( this.api, provider, () => {
8+
done()
9+
this.emit('complete')
10+
})
11+
})
12+
return this
13+
}
14+
}
15+
16+
function setAssistant(browser: NightwatchBrowser, provider: string, done: VoidFunction) {
17+
browser
18+
.waitForElementPresent('*[data-id="remix-ai-assistant-ready"]')
19+
.execute(function (provider) {
20+
(window as any).remixAIChat.current.sendChat(`/setAssistant ${provider}`);
21+
}, [provider])
22+
.waitForElementVisible({
23+
locateStrategy: 'xpath',
24+
selector: `//*[contains(@class,'chat-bubble') and contains(.,'AI Provider set to')]`,
25+
timeout: 50000,
26+
abortOnFailure: true
27+
})
28+
.waitForElementPresent({
29+
locateStrategy: 'xpath',
30+
selector: "//*[@data-id='remix-ai-streaming' and @data-streaming='false']",
31+
})
32+
//.pause()
33+
.perform(() => done())
34+
}
35+
36+
module.exports = SetAssistantProvider
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { NightwatchBrowser } from 'nightwatch'
2+
import EventEmitter from 'events'
3+
4+
class AssistantWorkspace extends EventEmitter {
5+
command(this: NightwatchBrowser, prompt: string, provider: string): NightwatchBrowser {
6+
this.api.perform((done) => {
7+
workspaceGenerate(this.api, prompt, provider, () => {
8+
done()
9+
this.emit('complete')
10+
})
11+
})
12+
return this
13+
}
14+
}
15+
16+
function workspaceGenerate(browser: NightwatchBrowser, prompt: string, provider: string, done: VoidFunction) {
17+
browser
18+
.waitForElementVisible('*[data-id="remix-ai-assistant"]')
19+
.waitForElementPresent('*[data-id="remix-ai-assistant-ready"]')
20+
.assistantSetProvider(provider)
21+
.execute(function (prompt) {
22+
(window as any).remixAIChat.current.sendChat(`/workspace ${prompt}`);
23+
}, [prompt])
24+
.waitForElementVisible({
25+
locateStrategy: 'xpath',
26+
selector: `//*[contains(@class,"chat-bubble") and contains(.,"/workspace ${prompt}")]`
27+
})
28+
done()
29+
}
30+
31+
module.exports = AssistantWorkspace;

apps/remix-ide-e2e/src/commands/enableClipBoard.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ import { NightwatchBrowser } from 'nightwatch'
22
import EventEmitter from 'events'
33

44
class EnableClipBoard extends EventEmitter {
5-
command (this: NightwatchBrowser, remember:boolean, accept: boolean): NightwatchBrowser {
5+
command (this: NightwatchBrowser,): NightwatchBrowser {
66
const browser = this.api
7-
8-
if(browser.browserName.indexOf('chrome') > -1){
7+
8+
if (browser.browserName.indexOf('chrome') > -1){
99
const chromeBrowser = (browser as any).chrome
1010
chromeBrowser.setPermission('clipboard-read', 'granted')
1111
chromeBrowser.setPermission('clipboard-write', 'granted')
1212
// test it
1313
browser.executeAsyncScript(function (done) {
1414
navigator.clipboard.writeText('test').then(function () {
1515
navigator.clipboard.readText().then(function (text) {
16-
console.log('Pasted content: ', text)
1716
done(text)
1817
}).catch(function (err) {
1918
console.error('Failed to read clipboard contents: ', err)

0 commit comments

Comments
 (0)