diff --git a/src/SidebarProvider.ts b/src/SidebarProvider.ts index d91d721..61e66c6 100644 --- a/src/SidebarProvider.ts +++ b/src/SidebarProvider.ts @@ -122,7 +122,7 @@ export class SidebarProvider implements vscode.WebviewViewProvider { const apiResponse = this._context.globalState.get('apiResponse') || "No response"; const signedIn = this._context.globalState.get('SignedOthers') || "false"; const progressBarVisible = this._context.globalState.get('progressVisible') ?? true; - + console.log("signedIn others value", signedIn); @@ -421,19 +421,13 @@ export class SidebarProvider implements vscode.WebviewViewProvider { case "keployGenWithAdditionalPrompts":{ try{ const additional_prompts = data.prompt; - const editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showErrorMessage("No file is currently open."); - return; - } - - const fileUri = editor.document.uri; - console.log("additional prompts and uri: ", additional_prompts , fileUri); - await vscode.commands.executeCommand('keploy.utg' , fileUri , additional_prompts ); + // const editor = vscode.window.activeTextEditor; + + console.log("additional prompts and uri: ", additional_prompts ); + await vscode.commands.executeCommand('keploy.runAdditionalPrompts',additional_prompts); }catch(error){ console.error("Error executing keploy.utg command:", error); } - break; } case "progressStatus":{ if(progressBarVisible == true && data.value == "false"){ diff --git a/src/Utg.ts b/src/Utg.ts index ea4e973..f116caf 100644 --- a/src/Utg.ts +++ b/src/Utg.ts @@ -101,6 +101,8 @@ async function Utg(context: vscode.ExtensionContext , additional_prompts?:string vscode.window.showErrorMessage(`Unsupported file type: ${extension}`); return; } + + console.log("additional_prompts" , additional_prompts); if(!additional_prompts){ additional_prompts = ""; } diff --git a/src/extension.ts b/src/extension.ts index 896b693..46121fc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -155,7 +155,7 @@ class KeployCodeLensProvider implements vscode.CodeLensProvider { codeLenses.push(new vscode.CodeLens(range, { title: '🐰 Additional Prompts', command: 'keploy.showSidebar', - arguments: [document.uri.fsPath] + arguments: [document.uri.fsPath,functionName,fileExtension] })); console.log('🐰 Found arrow function:', node.firstChild?.text); } else if (fileName.endsWith('.js') || fileName.endsWith('.ts')) { @@ -175,7 +175,7 @@ class KeployCodeLensProvider implements vscode.CodeLensProvider { codeLenses.push(new vscode.CodeLens(range, { title: '🐰 Additional Prompts', command: 'keploy.showSidebar', - arguments: [document.uri.fsPath] + arguments: [document.uri.fsPath,functionName,fileExtension] })); console.log('🐰 Found arrow function:', node.firstChild?.text); } @@ -193,7 +193,7 @@ class KeployCodeLensProvider implements vscode.CodeLensProvider { codeLenses.push(new vscode.CodeLens(range, { title: '🐰 Additional Prompts', command: 'keploy.showSidebar', - arguments: [document.uri.fsPath] + arguments: [document.uri.fsPath,functionName,fileExtension] })); } else if (fileName.endsWith('.java') && (node.type === 'method_declaration' || node.type === 'constructor_declaration')) { const line = document.positionAt(node.startIndex).line; @@ -209,7 +209,7 @@ class KeployCodeLensProvider implements vscode.CodeLensProvider { codeLenses.push(new vscode.CodeLens(range, { title: '🐰 Additional Prompts', command: 'keploy.showSidebar', - arguments: [document.uri.fsPath] + arguments: [document.uri.fsPath,functionName,fileExtension] })); } else if (fileName.endsWith('.go') && (node.type === 'function_declaration' || node.type === 'method_declaration')) { const line = document.positionAt(node.startIndex).line; @@ -226,7 +226,7 @@ class KeployCodeLensProvider implements vscode.CodeLensProvider { codeLenses.push(new vscode.CodeLens(range, { title: '🐰 Additional Prompts', command: 'keploy.showSidebar', - arguments: [document.uri.fsPath] + arguments: [document.uri.fsPath,functionName,fileExtension] })); } @@ -458,7 +458,9 @@ export function activate(context: vscode.ExtensionContext) { // vscode.commands.executeCommand('setContext', 'keploy.signedIn', true); // sidebarProvider.postMessage('navigateToHome', 'KeployHome'); // } - + let functionName=""; + let ExtentionName=""; + let FunctionFilePath = ""; let accessToken = context.globalState.get('JwtToken'); // Check if the access token is already present in the global state @@ -513,7 +515,7 @@ export function activate(context: vscode.ExtensionContext) { vscode.window.showInformationMessage('Failed to sign in Keploy!'); } }); - + context.subscriptions.push(signInCommand); } let signInWithOthersCommand = vscode.commands.registerCommand('keploy.SignInWithOthers', async () => { @@ -620,15 +622,23 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(updateKeployDisposable); - let showSidebarDisposable = vscode.commands.registerCommand('keploy.showSidebar', async () => { + let showSidebarDisposable = vscode.commands.registerCommand('keploy.showSidebar', async (filePath:string,FunctionName:string,FileExtentionName:string) => { // Show the sidebar when this command is executed + functionName=FunctionName; + ExtentionName=FileExtentionName; + FunctionFilePath = filePath; vscode.commands.executeCommand('workbench.view.extension.Keploy-Sidebar'); sidebarProvider.postMessage("KeployChatBot") - vscode.window.showInformationMessage('Sidebar opened for additional prompts.'); }); context.subscriptions.push(showSidebarDisposable); + let runAdditionalPrompts = vscode.commands.registerCommand('keploy.runAdditionalPrompts',async(additionalPrompts:string)=>{ + console.log("value inside the function: ",functionName,ExtentionName,additionalPrompts); + await vscode.commands.executeCommand('keploy.utg' , FunctionFilePath,functionName, ExtentionName , additionalPrompts); + }) + + context.subscriptions.push(runAdditionalPrompts); // Register the command let disposable = vscode.commands.registerCommand('keploy.utg', async (filePath: string, functionName: string, fileExtension: string, additional_prompts?: string) => { @@ -673,13 +683,16 @@ export function activate(context: vscode.ExtensionContext) { if (updatedSubscriptionEnded === false) { // If SubscriptionEnded is false or undefined, continue running Utg + if(additional_prompts){ + console.log("additional_prompts are present: ",additional_prompts); + } const testFilesPath = await findTestCasesForFunction(functionName, fileExtension); // Call the function here if (testFilesPath) { console.log("testFiles path: ", testFilesPath); } else { console.log("no path found") } - + console.log("additional prompts inside the keploy.utg " , additional_prompts); vscode.window.showInformationMessage('Welcome to Keploy!'); await Utg(context, additional_prompts, testFilesPath); } diff --git a/webviews/components/KeployChat.svelte b/webviews/components/KeployChat.svelte index b72c443..fabfe4f 100644 --- a/webviews/components/KeployChat.svelte +++ b/webviews/components/KeployChat.svelte @@ -1,7 +1,7 @@