diff --git a/extensions/void/.vscode/settings.json b/extensions/void/.vscode/settings.json index 3e6c33c2..3100dfe2 100644 --- a/extensions/void/.vscode/settings.json +++ b/extensions/void/.vscode/settings.json @@ -8,7 +8,7 @@ "**/.DS_Store": true, "**/Thumbs.db": true, "out": false, - "**/node_modules": false + "**/node_modules": true }, "search.exclude": { "out": true // set this to false to include "out" folder in search results diff --git a/extensions/void/package.json b/extensions/void/package.json index d28ee139..6105806e 100644 --- a/extensions/void/package.json +++ b/extensions/void/package.json @@ -233,8 +233,8 @@ "icon": "$(add)" }, { - "command": "void.openThreadSelector", - "title": "View all your past chats", + "command": "void.toggleThreadSelector", + "title": "View past chats", "icon": "$(history)" }, { "command": "void.openSettings", @@ -280,7 +280,7 @@ "group": "navigation" }, { - "command": "void.openThreadSelector", + "command": "void.toggleThreadSelector", "when": "view == 'void.viewnumberone'", "group": "navigation" }, diff --git a/extensions/void/src/common/sendLLMMessage.ts b/extensions/void/src/common/sendLLMMessage.ts index 9c0227d1..7ab49ab5 100644 --- a/extensions/void/src/common/sendLLMMessage.ts +++ b/extensions/void/src/common/sendLLMMessage.ts @@ -1,7 +1,6 @@ import Anthropic from '@anthropic-ai/sdk'; import OpenAI from 'openai'; import { Ollama } from 'ollama/browser' -import { getVSCodeAPI } from '../sidebar/getVscodeApi'; // always compare these against package.json to make sure every setting in this type can actually be provided by the user diff --git a/extensions/void/src/extension.ts b/extensions/void/src/extension.ts index 017405a1..71c2426a 100644 --- a/extensions/void/src/extension.ts +++ b/extensions/void/src/extension.ts @@ -104,8 +104,8 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('void.startNewThread', async () => { webview.postMessage({ type: 'startNewThread' } satisfies WebviewMessage) })) - context.subscriptions.push(vscode.commands.registerCommand('void.openThreadSelector', async () => { - webview.postMessage({ type: 'openThreadSelector' } satisfies WebviewMessage) + context.subscriptions.push(vscode.commands.registerCommand('void.toggleThreadSelector', async () => { + webview.postMessage({ type: 'toggleThreadSelector' } satisfies WebviewMessage) })) // when config changes, send it to the sidebar diff --git a/extensions/void/src/shared_types.ts b/extensions/void/src/shared_types.ts index f4cb836e..bc56ca47 100644 --- a/extensions/void/src/shared_types.ts +++ b/extensions/void/src/shared_types.ts @@ -40,7 +40,7 @@ type WebviewMessage = ( | { type: 'startNewThread' } // editor -> sidebar - | { type: 'openThreadSelector' } + | { type: 'toggleThreadSelector' } ) diff --git a/extensions/void/src/sidebar/Sidebar.tsx b/extensions/void/src/sidebar/Sidebar.tsx index 21811e08..18540b99 100644 --- a/extensions/void/src/sidebar/Sidebar.tsx +++ b/extensions/void/src/sidebar/Sidebar.tsx @@ -8,8 +8,8 @@ import MarkdownRender from "./markdown/MarkdownRender"; import BlockCode from "./markdown/BlockCode"; import * as vscode from 'vscode' -import { FilesSelector, IncludedFiles } from "./components/Files"; -import { useChat } from "./context"; +import { FilesSelector, SelectedFiles } from "./components/SelectedFiles"; +import { useChat } from "./chatContext"; const filesStr = (fullFiles: File[]) => { @@ -50,7 +50,7 @@ const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => { if (role === 'user') { chatbubbleContents = <> - + {chatMessage.selection?.selectionStr && } {children} @@ -68,21 +68,6 @@ const ChatBubble = ({ chatMessage }: { chatMessage: ChatMessage }) => { } - -// const [stateRef, setState] = useInstantState(initVal) -// setState instantly changes the value of stateRef instead of having to wait until the next render -const useInstantState = (initVal: T) => { - const stateRef = useRef(initVal) - const [_, setS] = useState(initVal) - const setState = useCallback((newVal: T) => { - setS(newVal); - stateRef.current = newVal; - }, []) - return [stateRef as React.RefObject, setState] as const // make s.current readonly - setState handles all changes -} - - - const ThreadSelector = ({ onClose }: { onClose: () => void }) => { const { allThreads, currentThread, switchToThread } = useChat() return ( @@ -173,16 +158,15 @@ const Sidebar = () => { setApiConfig(m.apiConfig) } - - // top navigation bar command - new chat + // if they pressed the + to add a new chat else if (m.type === 'startNewThread') { setIsThreadSelectorOpen(false) startNewThread() } - // top navigation bar command - new chat - else if (m.type === 'openThreadSelector') { - setIsThreadSelectorOpen(true) + // if they opened thread selector + else if (m.type === 'toggleThreadSelector') { + setIsThreadSelectorOpen(v => !v) } } @@ -273,67 +257,66 @@ const Sidebar = () => { {/* selected files */} {/* selected code */} - {!selection?.selectionStr ? null - : ( -
-
- {/* selection */} - {(files.length || selection?.selectionStr) &&
- {/* selected files */} - - {/* selected code */} - {!!selection?.selectionStr && ( - - Remove - - )} /> - )} -
} -
{ if (e.key === 'Enter' && !e.shiftKey) onSubmit(e) }} - onSubmit={(e) => { - console.log('submit!') - e.preventDefault(); - onSubmit(e) - }}> - {/* input */} -