Skip to content

Commit

Permalink
fix: Hotfixes for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Tchayka committed Feb 21, 2024
1 parent a8f7e0d commit 118eb56
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"displayName": "Booster Tutor",
"description": "An AI assistant to help you with your Booster application",
"version": "0.0.1",
"version": "0.0.2",
"publisher": "BoosterFramework",
"engines": {
"vscode": "^1.77.0"
Expand Down
52 changes: 26 additions & 26 deletions apps/extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import * as vscode from "vscode";
import * as process from "node:process";
// import * as process from "node:process";
import * as cp from "node:child_process";
import "./fetch-polyfill";

const apiKeyName = "MSC_OPENAI_API_KEY";
// const apiKeyName = "MSC_OPENAI_API_KEY";

async function getApiKey(
context: vscode.ExtensionContext
): Promise<string | undefined> {
const apiKey = context.globalState.get<string>(apiKeyName);
// async function getApiKey(
// context: vscode.ExtensionContext
// ): Promise<string | undefined> {
// const apiKey = context.globalState.get<string>(apiKeyName);

if (apiKey) {
return apiKey;
}
// if (apiKey) {
// return apiKey;
// }

const inputApiKey = await vscode.window.showInputBox({
prompt: "Enter your OpenAI API key",
placeHolder: "OpenAI API key",
ignoreFocusOut: true,
password: true,
});
// const inputApiKey = await vscode.window.showInputBox({
// prompt: "Enter your OpenAI API key",
// placeHolder: "OpenAI API key",
// ignoreFocusOut: true,
// password: true,
// });

if (inputApiKey) {
await context.globalState.update(apiKeyName, inputApiKey);
}
// if (inputApiKey) {
// await context.globalState.update(apiKeyName, inputApiKey);
// }

return inputApiKey;
}
// return inputApiKey;
// }

export async function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "chat-sidebar" is now active!');

const apiKey = await getApiKey(context);
if (!apiKey) {
vscode.window.showErrorMessage("API key is required");
return;
}
// const apiKey = await getApiKey(context);
// if (!apiKey) {
// vscode.window.showErrorMessage("API key is required");
// return;
// }

const outputChannel = vscode.window.createOutputChannel("Booster Tutor");
context.subscriptions.push(outputChannel);
Expand All @@ -47,7 +47,7 @@ export async function activate(context: vscode.ExtensionContext) {

global.console = { ...console, ...myCustomConsole };

process.env["OPENAI_API_KEY"] = apiKey;
// process.env["OPENAI_API_KEY"] = apiKey;

cp.exec("node --version", (error, stdout, stderr) => {
if (error) {
Expand Down
13 changes: 3 additions & 10 deletions apps/extension/src/webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ export const App: React.FC = () => {
const [userMessage, setUserMessage] = React.useState("");
const [chatMessages, setChatMessages] = React.useState<Array<ChatMessage>>([
new ChatMessage(
"user",
"**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nulla nec odio nec nunc"
"bot",
`## Hello! 🚀
I'm thrilled to assist you with your Booster project! Whether you need guidance on **contributing to Booster**, getting health information from sensors, finding **beginner-friendly or more involved coding tasks**, improving documentation, creating GitHub issues, suggesting enhancements, or even just asking a quick question in the community, **I've got you covered!** Feel free to explore the Booster documentation for detailed instructions and resources, and don't hesitate to reach out if you need any further assistance. **Let's boost your project together!** 🌟`
),
]);
const [loading, setLoading] = React.useState(false);
Expand All @@ -101,13 +102,6 @@ export const App: React.FC = () => {
};

React.useEffect(() => {
const sendInitialMessage = () => {
setTimeout(() => {
sendMessageToExtension(
"Greet me and give me a one paragraph detailed description of how can you help me with my Booster project. Use markdown to highlight the important parts."
);
}, 500);
};
const listener = (event: MessageEvent) => {
if (event.data.type === "from-bot") {
const message = new ChatMessage("bot", event.data.content);
Expand All @@ -121,7 +115,6 @@ export const App: React.FC = () => {
};

window.addEventListener("message", listener);
window.addEventListener("load", sendInitialMessage);
return () => window.removeEventListener("message", listener);
}, []);

Expand Down

0 comments on commit 118eb56

Please sign in to comment.