Skip to content

Commit

Permalink
input on webview shows searchprompt when using command
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaJaich committed Dec 6, 2022
1 parent 228d5ce commit 658dff6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions media/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
response = '';
break;
}
case "setPrompt": {
document.getElementById("prompt-input").value = message.value;
break;
}
}
});

Expand Down
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ class ChatGPTViewProvider implements vscode.WebviewViewProvider {
searchPrompt = prompt;
}

// modify the input tag to show the search prompt as input value
if (this._view) {
this._view.webview.postMessage({ type: 'setPrompt', value: searchPrompt });
}

console.log("sendMessage");
// Send the search prompt to the ChatGPTAPI instance and store the response
response = await this._chatGPTAPI.sendMessage(searchPrompt, {
Expand Down

0 comments on commit 658dff6

Please sign in to comment.