Skip to content

Commit 4bf0d5c

Browse files
committed
bugfix(webview): don't allow to send empty message in chat and small refactoring
1 parent 0a7f990 commit 4bf0d5c

File tree

9 files changed

+12
-39
lines changed

9 files changed

+12
-39
lines changed

webviews/public/favicon.ico

-3.78 KB
Binary file not shown.

webviews/public/index.html

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
65
<meta name="viewport" content="width=device-width, initial-scale=1" />
76
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
7+
<meta name="description" content="Webviews for FireCoder" />
138
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
14-
<title>Hello World</title>
9+
<title>FireCoder</title>
1510
</head>
1611
<body>
1712
<noscript>You need to enable JavaScript to run this app.</noscript>

webviews/public/logo192.png

-5.22 KB
Binary file not shown.

webviews/public/logo512.png

-9.44 KB
Binary file not shown.

webviews/public/manifest.json

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
{
2-
"short_name": "React App",
3-
"name": "Create React App Sample",
4-
"icons": [
5-
{
6-
"src": "favicon.ico",
7-
"sizes": "64x64 32x32 24x24 16x16",
8-
"type": "image/x-icon"
9-
},
10-
{
11-
"src": "logo192.png",
12-
"type": "image/png",
13-
"sizes": "192x192"
14-
},
15-
{
16-
"src": "logo512.png",
17-
"type": "image/png",
18-
"sizes": "512x512"
19-
}
20-
],
2+
"short_name": "FireCoder",
3+
"name": "Webviews for FireCoder",
214
"start_url": ".",
225
"display": "standalone",
236
"theme_color": "#000000",
247
"background_color": "#ffffff"
25-
}
8+
}

webviews/src/App.css

-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ body {
1515
overflow: auto;
1616
display: flex;
1717
flex-direction: column;
18-
/* max-height: 92vh; */
1918
}
2019

2120
.chat-input-block {
22-
/* min-height: 8vh; */
2321
display: flex;
2422
flex-direction: row;
2523
width: calc(100% - 40px);

webviews/src/App.tsx

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import { vscode } from "./utilities/vscode";
2-
import {
3-
VSCodeButton,
4-
VSCodeProgressRing,
5-
VSCodeTextArea,
6-
VSCodeTextField,
7-
} from "@vscode/webview-ui-toolkit/react";
2+
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react";
83
import "./App.css";
9-
// import "./codicon.css";
104
import { ChatMessage } from "./components/ChatMessage";
115
import { useState } from "react";
126
import { ChatHelloMessage } from "./components/ChatHelloMessage";
137
import { useMessageListener } from "./hooks/messageListener";
148
import { randomMessageId } from "./utilities/messageId";
159
import TextArea from "./components/TextArea";
16-
// import ProgressDivider from "./components/VsCodeDividerProgress";
1710

1811
export const App = () => {
1912
const [input, setInput] = useState("");
@@ -65,6 +58,10 @@ export const App = () => {
6558
if (isLoading) {
6659
return;
6760
}
61+
if (input === "") {
62+
return;
63+
}
64+
6865
setChatHistory((value) => {
6966
const messageId = randomMessageId();
7067

webviews/src/components/ChatMessage/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { VSCodeDivider } from "@vscode/webview-ui-toolkit/react";
22
import Markdown from "react-markdown";
33
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
44
import { vscDarkPlus as vscodeHighlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
5-
import "./Component.css";
5+
import styles from "./styles.module.css";
66

77
export const ChatMessage = (props: { role: string; content: string }) => {
88
const title = props.role === "ai" ? "FireCoder" : "You";
99
return (
1010
<>
11-
<div className="chat-message">
11+
<div className={styles["chat-message"]}>
1212
<h4>{title}</h4>
1313
<Markdown
1414
components={{

0 commit comments

Comments
 (0)