diff --git a/extensions/void/src/sidebar/Sidebar.tsx b/extensions/void/src/sidebar/Sidebar.tsx
index cfc3e3b4..f0ef90b5 100644
--- a/extensions/void/src/sidebar/Sidebar.tsx
+++ b/extensions/void/src/sidebar/Sidebar.tsx
@@ -1,6 +1,6 @@
-import React, { useState, ChangeEvent, useEffect, useRef, useCallback, FormEvent } from "react"
-import { ApiConfig, LLMMessage, sendLLMMessage } from "../common/sendLLMMessage"
-import { Command, File, Selection, WebviewMessage } from "../shared_types"
+import React, { useState, useEffect, useRef, useCallback, FormEvent } from "react"
+import { ApiConfig, sendLLMMessage } from "../common/sendLLMMessage"
+import { File, Selection, WebviewMessage } from "../shared_types"
import { awaitVSCodeResponse, getVSCodeAPI, resolveAwaitingVSCodeResponse } from "./getVscodeApi"
import { marked } from 'marked';
@@ -8,6 +8,7 @@ import MarkdownRender from "./markdown/MarkdownRender";
import BlockCode from "./markdown/BlockCode";
import * as vscode from 'vscode'
+import { FilesSelector, IncludedFiles } from "./components/Files";
const filesStr = (fullFiles: File[]) => {
@@ -36,40 +37,6 @@ If you make a change, rewrite the entire file.
}
-const FilesSelector = ({ files, setFiles }: { files: vscode.Uri[], setFiles: (files: vscode.Uri[]) => void }) => {
- return files.length !== 0 &&
- Include files:
- {files.map((filename, i) =>
-
- {/* X button on a file */}
-
-
- )}
-
-}
-
-const IncludedFiles = ({ files }: { files: vscode.Uri[] }) => {
- return files.length !== 0 &&
- {files.map((filename, i) =>
-
-
-
- )}
-
-}
-
-
const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {
const role = chatMessage.role
@@ -100,13 +67,6 @@ const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => {
}
-const getBasename = (pathStr: string) => {
- // "unixify" path
- pathStr = pathStr.replace(/[/\\]+/g, '/'); // replace any / or \ or \\ with /
- const parts = pathStr.split('/') // split on /
- return parts[parts.length - 1]
-}
-
type ChatMessage = {
role: 'user'
content: string, // content sent to the llm
@@ -265,62 +225,62 @@ const Sidebar = () => {
{/* chatbar */}
- {/* selection */}
-
- {/* selected files */}
-
- {/* selected code */}
- {!selection?.selectionStr ? null
- : (
-
+
+ {/* selection */}
+ {(files.length || selection?.selectionStr) &&
+ {/* selected files */}
+
+ {/* selected code */}
+ {!!selection?.selectionStr && (
+
- X
+ Remove
-
-
+ )} />
)}
+
}
+
-
diff --git a/extensions/void/src/sidebar/components/Files.tsx b/extensions/void/src/sidebar/components/Files.tsx
new file mode 100644
index 00000000..b6abf5eb
--- /dev/null
+++ b/extensions/void/src/sidebar/components/Files.tsx
@@ -0,0 +1,77 @@
+import React from "react"
+import * as vscode from "vscode"
+
+const getBasename = (pathStr: string) => {
+ // "unixify" path
+ pathStr = pathStr.replace(/[/\\]+/g, "/") // replace any / or \ or \\ with /
+ const parts = pathStr.split("/") // split on /
+ return parts[parts.length - 1]
+}
+
+export const FilesSelector = ({
+ files,
+ setFiles,
+}: {
+ files: vscode.Uri[]
+ setFiles: (files: vscode.Uri[]) => void
+}) => {
+ const onRemove = (index: number) => () =>
+ setFiles([...files.slice(0, index), ...files.slice(index + 1, Infinity)])
+
+ return (
+ files.length !== 0 && (
+
+ {files.map((filename, i) => (
+
+ ))}
+
+ )
+ )
+}
+
+export const IncludedFiles = ({ files }: { files: vscode.Uri[] }) => {
+ return (
+ files.length !== 0 && (
+
+ {files.map((filename, i) => (
+
+
+
+ ))}
+
+ )
+ )
+}
diff --git a/extensions/void/src/sidebar/markdown/BlockCode.tsx b/extensions/void/src/sidebar/markdown/BlockCode.tsx
index 5c45a9f5..59128ddd 100644
--- a/extensions/void/src/sidebar/markdown/BlockCode.tsx
+++ b/extensions/void/src/sidebar/markdown/BlockCode.tsx
@@ -1,5 +1,6 @@
-import React, { useCallback, useEffect, useState } from "react"
+import React, { ReactNode, useCallback, useEffect, useState } from "react"
import { getVSCodeAPI } from "../getVscodeApi"
+import { classNames } from "../utils"
enum CopyButtonState {
Copy = "Copy",
@@ -12,10 +13,14 @@ const COPY_FEEDBACK_TIMEOUT = 1000
// code block with toolbar (Apply, Copy, etc) at top
const BlockCode = ({
text,
+ toolbar,
hideToolbar = false,
+ className,
}: {
text: string
+ toolbar?: ReactNode
hideToolbar?: boolean
+ className?: string
}) => {
const [copyButtonState, setCopyButtonState] = useState(CopyButtonState.Copy)
@@ -38,32 +43,40 @@ const BlockCode = ({
)
}, [text])
+ const defaultToolbar = (
+ <>
+
+
+ >
+ )
+
return (
{!hideToolbar && (
-
-
-
-
+
{toolbar || defaultToolbar}
)}
)
diff --git a/extensions/void/src/sidebar/utils/classNames.ts b/extensions/void/src/sidebar/utils/classNames.ts
new file mode 100644
index 00000000..57c362a5
--- /dev/null
+++ b/extensions/void/src/sidebar/utils/classNames.ts
@@ -0,0 +1,3 @@
+export default function classNames(...classes: any[]) {
+ return classes.filter(Boolean).join(' ')
+ }
\ No newline at end of file
diff --git a/extensions/void/src/sidebar/utils/index.ts b/extensions/void/src/sidebar/utils/index.ts
new file mode 100644
index 00000000..284fc955
--- /dev/null
+++ b/extensions/void/src/sidebar/utils/index.ts
@@ -0,0 +1 @@
+export { default as classNames } from "./classNames";
diff --git a/extensions/void/tailwind.config.js b/extensions/void/tailwind.config.js
index 0a739c8f..8d7d825e 100644
--- a/extensions/void/tailwind.config.js
+++ b/extensions/void/tailwind.config.js
@@ -7,17 +7,19 @@ module.exports = {
extend: {
colors: {
vscode: {
- 'editor-bg': "var(--vscode-editor-background)",
- 'editor-fg': "var(--vscode-editor-foreground)",
- 'input-bg': "var(--vscode-input-background)",
- 'input-fg': "var(--vscode-input-foreground)",
- 'input-border': "var(--vscode-input-border)",
- 'button-fg': "var(--vscode-button-foreground)",
- 'button-bg': "var(--vscode-button-background)",
- 'button-hoverBg': "var(--vscode-button-hoverBackground)",
- 'button-secondary-fg': "var(--vscode-button-secondaryForeground)",
- 'button-secondary-bg': "var(--vscode-button-secondaryBackground)",
- 'button-secondary-hoverBg': "var(--vscode-button-secondaryHoverBackground)",
+ "sidebar-bg": "var(--vscode-sideBar-background)",
+ "editor-bg": "var(--vscode-editor-background)",
+ "editor-fg": "var(--vscode-editor-foreground)",
+ "input-bg": "var(--vscode-input-background)",
+ "input-fg": "var(--vscode-input-foreground)",
+ "input-border": "var(--vscode-input-border)",
+ "button-fg": "var(--vscode-button-foreground)",
+ "button-bg": "var(--vscode-button-background)",
+ "button-hoverBg": "var(--vscode-button-hoverBackground)",
+ "button-secondary-fg": "var(--vscode-button-secondaryForeground)",
+ "button-secondary-bg": "var(--vscode-button-secondaryBackground)",
+ "button-secondary-hoverBg":
+ "var(--vscode-button-secondaryHoverBackground)",
},
},
},