Skip to content

Commit 61176bd

Browse files
author
Nick Tchayka
committed
Bump
1 parent 99978cd commit 61176bd

File tree

7 files changed

+391
-28
lines changed

7 files changed

+391
-28
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
enable-pre-post-scripts = true
1+
# enable-pre-post-scripts = true

apps/extension/media/styles.css

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ body {
44
padding: 0;
55
}
66

7+
code {
8+
background-color: transparent !important;
9+
}
10+
711
#chat-container {
812
display: flex;
913
flex-direction: column;

apps/extension/package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "monkey-studio-code",
33
"private": true,
44
"displayName": "monkey-studio-code",
5-
"description": "Monkey Studio Code",
5+
"description": "Booster Tutor",
66
"version": "0.0.1",
77
"engines": {
88
"vscode": "^1.74.0"
@@ -19,7 +19,7 @@
1919
"activitybar": [
2020
{
2121
"id": "chatSidebar",
22-
"title": "Monkey Studio Code",
22+
"title": "Booster Tutor",
2323
"icon": "media/monkey.png"
2424
}
2525
]
@@ -29,9 +29,9 @@
2929
{
3030
"type": "webview",
3131
"id": "chatSidebar",
32-
"name": "Monkey Studio Code",
32+
"name": "Booster Tutor",
3333
"icon": "media/monkey.png",
34-
"contextualTitle": "Monkey Studio Code"
34+
"contextualTitle": "Booster Tutor"
3535
}
3636
]
3737
},
@@ -65,6 +65,7 @@
6565
"@types/node": "^16.11.7",
6666
"@types/react": "^18.0.37",
6767
"@types/react-dom": "^18.0.11",
68+
"@types/react-scroll": "^1.8.10",
6869
"@types/vscode": "^1.77.0",
6970
"@typescript-eslint/eslint-plugin": "^5.54.0",
7071
"@typescript-eslint/parser": "^5.54.0",
@@ -95,10 +96,15 @@
9596
"@vscode/codicons": "^0.0.32",
9697
"@vscode/webview-ui-toolkit": "^1.2.2",
9798
"cross-fetch": "^3.1.5",
99+
"highlight.js": "^11.9.0",
98100
"langchain": "0.0.63",
101+
"marked": "^12.0.0",
102+
"marked-react": "^2.0.0",
99103
"path-browserify": "^1.0.1",
100104
"process": "^0.11.10",
101105
"react": "^18.2.0",
102-
"react-dom": "^18.2.0"
106+
"react-dom": "^18.2.0",
107+
"react-scroll": "^1.9.0",
108+
"react-syntax-highlighter": "^15.5.0"
103109
}
104110
}

apps/extension/src/extension.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as vscode from "vscode";
22
import * as process from "node:process";
3-
import monkeyAgent from "./agent/monkey-agent";
43
import * as cp from "node:child_process";
54
import "./fetch-polyfill";
65

@@ -38,7 +37,7 @@ export async function activate(context: vscode.ExtensionContext) {
3837
return;
3938
}
4039

41-
const outputChannel = vscode.window.createOutputChannel("Monkey Studio Code");
40+
const outputChannel = vscode.window.createOutputChannel("Booster Tutor");
4241
context.subscriptions.push(outputChannel);
4342

4443
const myCustomConsole = {
@@ -109,7 +108,6 @@ class ChatSidebarViewProvider implements vscode.WebviewViewProvider {
109108
let response: string;
110109
try {
111110
setLoading(true);
112-
// Perform a call like { "question": "How can I create a command that represents the level up of a player?"} to https://asktoai.boosterframework.com/api/answer using cross-fetch
113111
response = await fetch(
114112
"https://asktoai.boosterframework.com/api/answer",
115113
{

apps/extension/src/webview.tsx

+46-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import * as React from "react";
22
import * as ReactDOM from "react-dom";
33
import typingSource from "./assets/typing.gif";
4+
import Markdown from "marked-react";
5+
import "../media/styles.css";
6+
import { Element, scroller } from "react-scroll";
7+
import SyntaxHighlighter from "react-syntax-highlighter";
48

59
const {
610
VSCodeButton,
@@ -11,6 +15,14 @@ declare var acquireVsCodeApi: any;
1115

1216
const vscode = acquireVsCodeApi();
1317

18+
const renderer = {
19+
code(snippet: string) {
20+
return (
21+
<SyntaxHighlighter language="typescript">{snippet}</SyntaxHighlighter>
22+
);
23+
},
24+
};
25+
1426
const sendMessageToExtension = (message: string) => {
1527
vscode.postMessage(
1628
{
@@ -24,7 +36,10 @@ const sendMessageToExtension = (message: string) => {
2436
type From = "user" | "bot";
2537

2638
class ChatMessage {
27-
constructor(readonly from: From, readonly contents: string) {}
39+
constructor(
40+
readonly from: From,
41+
readonly contents: string
42+
) {}
2843
}
2944

3045
type ChatBubbleProperties = { message: ChatMessage };
@@ -43,38 +58,53 @@ const ChatBubble: React.FC<ChatBubbleProperties> = ({ message }) => {
4358
};
4459
const alignStyle =
4560
message.from === "bot"
46-
? { backgroundColor: "var(--vscode-button-secondaryBackground)" }
47-
: { backgroundColor: "var(--vscode-button-background)" };
61+
? {
62+
backgroundColor: "var(--vscode-button-secondaryBackground)",
63+
color: "var(--vscode-button-secondaryForeground)",
64+
}
65+
: {
66+
backgroundColor: "var(--vscode-button-background)",
67+
color: "var(--vscode-button-foreground)",
68+
};
4869
const containerStyle = {
4970
display: "flex",
5071
justifyContent: message.from === "bot" ? "flex-start" : "flex-end",
5172
};
5273
return (
5374
<div style={containerStyle}>
5475
<div style={{ ...bubbleStyle, ...alignStyle }}>
55-
<div style={{ whiteSpace: "pre-wrap" }}>{message.contents}</div>
76+
<div style={{ whiteSpace: "pre-wrap" }}>
77+
<Markdown value={message.contents} renderer={renderer} />
78+
</div>
5679
</div>
5780
</div>
5881
);
5982
};
6083

6184
export const App: React.FC = () => {
6285
const [userMessage, setUserMessage] = React.useState("");
63-
const [chatMessages, setChatMessages] = React.useState<Array<ChatMessage>>(
64-
[]
65-
);
86+
const [chatMessages, setChatMessages] = React.useState<Array<ChatMessage>>([
87+
new ChatMessage(
88+
"user",
89+
"**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nulla nec odio nec nunc"
90+
),
91+
]);
6692
const [loading, setLoading] = React.useState(false);
67-
const appendChatMessage = (message: ChatMessage) =>
93+
const appendChatMessage = async (message: ChatMessage) => {
6894
setChatMessages((previousChatMessages) => [
6995
...previousChatMessages,
7096
message,
7197
]);
98+
scroller.scrollTo("lastMessage", {
99+
containerId: "messages-root",
100+
});
101+
};
72102

73103
React.useEffect(() => {
74104
const sendInitialMessage = () => {
75105
setTimeout(() => {
76106
sendMessageToExtension(
77-
"Hello, what's your name and how can you help me?"
107+
"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."
78108
);
79109
}, 500);
80110
};
@@ -119,9 +149,14 @@ export const App: React.FC = () => {
119149
display: "flex",
120150
flexDirection: "column",
121151
}}
152+
id="messages-root"
122153
>
123-
{chatMessages.map((message) => (
124-
<ChatBubble key={message.contents} message={message} />
154+
{chatMessages.map((message, index) => (
155+
<Element
156+
name={index === chatMessages.length - 1 ? "lastMessage" : ""}
157+
>
158+
<ChatBubble key={message.contents} message={message} />
159+
</Element>
125160
))}
126161
<img
127162
style={{

apps/extension/webpack.webview.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const webviewConfig = {
2828
},
2929
],
3030
},
31+
{
32+
test: /\.css$/i,
33+
use: ["style-loader", "css-loader"],
34+
},
3135
{
3236
test: /\.(ts|tsx)$/,
3337
exclude: /node_modules/,

0 commit comments

Comments
 (0)