Skip to content

Commit

Permalink
testing if I broke some thing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiscool committed Dec 19, 2024
1 parent 026087d commit 1a44f86
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 331 deletions.
2 changes: 1 addition & 1 deletion public/ChatManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ export class ChatManager {
const isCodeGood = await doAjax('./applySnippet', { snippet: codeString, targetFile: this.targetFileInput.value });

if (!isCodeGood.success) {
await alert('Merge failed. Please resolve the conflict manually.');
await alert('Merge failed. Please resolve the conflict manually.', 3);
// set the user input to say that the snippet was formatted incorrectly
// and needs to be corrected.

Expand Down
7 changes: 5 additions & 2 deletions public/fileDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ export async function fileDialog(fileListArray) {
padding: '10px 20px', marginTop: '10px', cursor: 'pointer',
backgroundColor: '#66ccff', border: 'none', borderRadius: '4px', color: '#333',
},
onclick: () => {
if (selectedFilePath) resolve(selectedFilePath);
onclick: async () => {
if (selectedFilePath) {
selectedFilePath = './' + selectedFilePath;
resolve(selectedFilePath);
}
else alert('Please select a file.');
document.body.removeChild(modal);
},
Expand Down
59 changes: 47 additions & 12 deletions public/toolsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ export class toolsManager {
if (isStub) {
methodItemElement.style.color = 'red';
methodItemElement.addEventListener('click', async () => {
await this.implementSpecificClassMethod(className, name, lineNumber);
await this.implementSpecificClassMethod(className, name, args, lineNumber);
await this.pullMethodsList(this.onlyStubs);
});
} else {
methodItemElement.style.color = 'green';
methodItemElement.addEventListener('click', async () => {
await this.addToChatPrompt(className, name, lineNumber);
await this.addToChatPrompt(className, name, args, lineNumber);
//console.log('this is the line number ', lineNumber);
await this.pullMethodsList(this.onlyStubs);
});
Expand All @@ -172,13 +172,13 @@ export class toolsManager {
if (isStub) {
functionItemElement.style.color = 'red';
functionItemElement.addEventListener('click', async () => {
await this.implementSpecificFunction(functionName, lineNumber);
await this.implementSpecificFunction(functionName, args, lineNumber);
await this.pullFunctionList(this.onlyStubs);
});
} else {
functionItemElement.style.color = 'green';
functionItemElement.addEventListener('click', async () => {
await this.addFunctionToChatPrompt(functionName, lineNumber);
await this.addFunctionToChatPrompt(functionName, args, lineNumber);
console.log('this is the line number ', lineNumber);
await this.pullFunctionList(this.onlyStubs);
});
Expand All @@ -191,43 +191,78 @@ export class toolsManager {

}
}
async implementSpecificClassMethod(className, methodName, lineNumber) {
async implementSpecificClassMethod(className, methodName, args, lineNumber) {
ctx.tabs.switchToTab('Chat');
await doAjax('./gotoLineNumber', {
lineNumber,
targetFile: ctx.targetFile
});
await ctx.chat.newChat(`Implement ${methodName}.${className}`);
await ctx.chat.addMessage(`Write the ${methodName} method in the ${className} class.`);
await ctx.chat.addMessage(`Write the ${methodName} method in the ${className} class.
Remember to respond with a snippet in the form of the following:
\`\`\`
class ${className} {
${methodName}(${args.join(', ')}) {
// your code here
}
}
\`\`\`
`);
await ctx.chat.callLLM();
}
async addToChatPrompt(className, methodName, lineNumber) {
async addToChatPrompt(className, methodName, args, lineNumber) {
ctx.tabs.switchToTab('Chat');
await doAjax('./gotoLineNumber', {
lineNumber,
targetFile: ctx.targetFile
});
await ctx.chat.newChat(`Modify ${methodName}.${className}`);
await ctx.chat.setInput(`Modify the ${methodName} method in the ${className} class.\nImprove it.`);
await ctx.chat.setInput(`Modify the ${methodName} method in the ${className} class.
Improve it.
Remember to respond with a snippet in the form of the following:
\`\`\`
class ${className} {
${methodName}(${args.join(', ')}) {
// your code here
}
}
\`\`\`
`);
}
async implementSpecificFunction(functionName, lineNumber) {
async implementSpecificFunction(functionName, args, lineNumber) {
ctx.tabs.switchToTab('Chat');
await doAjax('./gotoLineNumber', {
lineNumber,
targetFile: ctx.targetFile
});
await ctx.chat.newChat(`Implement ${functionName}`);
await ctx.chat.addMessage(`Write the ${functionName} function.`);
await ctx.chat.addMessage(`Write the ${functionName} function.
Remember to respond with a snippet in the form of the following:
\`\`\`
function ${functionName}(${args.join(', ')}) {
// your code here
}
\`\`\`
`);
await ctx.chat.callLLM();
}
async addFunctionToChatPrompt(functionName, lineNumber) {
async addFunctionToChatPrompt(functionName, args, lineNumber) {
ctx.tabs.switchToTab('Chat');
await doAjax('./gotoLineNumber', {
lineNumber,
targetFile: ctx.targetFile
});
await ctx.chat.newChat(`Modify ${functionName}`);
await ctx.chat.setInput(`Modify the ${functionName} function.\nImprove it.`);
await ctx.chat.setInput(`Modify the ${functionName} function.
Improve it.
\`\`\`
function ${functionName}(${args.join(', ')}) {
// your code here
}
\`\`\`
`);
}
async verifyTargetFileSpecified() {
if (!ctx.targetFile) {
Expand Down
Loading

0 comments on commit 1a44f86

Please sign in to comment.