Skip to content

Commit

Permalink
[vs-code][1/n] Welcome Page: Scaffolding
Browse files Browse the repository at this point in the history
Just basic scaffolding for now, nothing fancy, will make UI better next diff

Following instructions from https://lastmileai.dev/workbooks/cls5af4s700pkqrsegl64gx3i

## Test Plan
  • Loading branch information
Rossdan Craig [email protected] committed Feb 8, 2024
1 parent c3a55ae commit e89258b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vscode-extension/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tabSize": 2,
}
Empty file removed vscode-extension/log.txt
Empty file.
6 changes: 6 additions & 0 deletions vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"name": "vscode-aiconfig",
"repository": "https://github.com/lastmile-ai/aiconfig",
"publisher": "lastmile-ai",
"author": "LastMile AI",
"displayName": "AIConfig Editor",
"description": "AIConfig notebook editor that turns VSCode into a generative AI studio.",
"version": "0.0.6",
"license": "MIT",
"engines": {
"vscode": "^1.85.0"
},
Expand Down Expand Up @@ -46,6 +48,10 @@
{
"command": "vscode-aiconfig.openModelRegistry",
"title": "AIConfig: Open Custom Model Registry File"
},
{
"command": "vscode-aiconfig.showWelcome",
"title": "AIConfig: Welcome"
}
],
"customEditors": [
Expand Down
21 changes: 21 additions & 0 deletions vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ export function activate(context: vscode.ExtensionContext) {
});
context.subscriptions.push(setupCommand);

context.subscriptions.push(
vscode.commands.registerCommand(COMMANDS.SHOW_WELCOME, () => {
const panel = vscode.window.createWebviewPanel(
"welcomePage",
"Welcome",
vscode.ViewColumn.One,
{}
);
panel.webview.html = getWelcomePageWebviewContent(context.extensionPath);
})
);

const createAIConfigJSONCommand = vscode.commands.registerCommand(
COMMANDS.CREATE_NEW_JSON,
async () => {
Expand Down Expand Up @@ -134,6 +146,15 @@ export function deactivate() {
console.log("Deactivated AIConfig extension");
}

/**
* Read the HTML content for the Welcome Page
*/
function getWelcomePageWebviewContent(extensionPath: string) {
const filePath = path.join(extensionPath, "src", "welcomePage.html");
const fileContent = fs.readFileSync(filePath, "utf8");
return fileContent;
}

/**
* Creates a new AIConfig file in the editor.
*/
Expand Down
1 change: 1 addition & 0 deletions vscode-extension/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const COMMANDS = {
OPEN_CONFIG_FILE: `${EXTENSION_NAME}.openConfigFile`,
OPEN_MODEL_REGISTRY: `${EXTENSION_NAME}.openModelRegistry`,
SHARE: `${EXTENSION_NAME}.share`,
SHOW_WELCOME: `${EXTENSION_NAME}.showWelcome`,
};

export const SUPPORTED_FILE_EXTENSIONS = [".json", ".yaml"];
Expand Down
8 changes: 8 additions & 0 deletions vscode-extension/src/welcomePage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">

<body>
<h1>Welcome to my extension!</h1>
</body>

</html>

0 comments on commit e89258b

Please sign in to comment.