From a52eba91c99aac11fb1cbef367a5ace771595963 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Thu, 5 Dec 2024 22:57:55 -0800 Subject: [PATCH] react updates --- src/tsconfig.json | 4 ++-- .../react/src/sidebar-tsx/SidebarChat.tsx | 4 ++-- .../react/src/sidebar-tsx/SidebarSettings.tsx | 14 +++++++------- .../browser/react/src/sidebar-tsx/inputs.tsx | 18 +++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/tsconfig.json b/src/tsconfig.json index 36fa8508..3e110f9a 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -52,10 +52,10 @@ "./typings", "./vs/**/*.ts", "vscode-dts/vscode.proposed.*.d.ts", - "vscode-dts/vscode.d.ts" + "vscode-dts/vscode.d.ts", // Void added these: - // "./vs/**/*.tsx", + // "./vs/workbench/contrib/void/browser/**.tsx", // "./vs/**/*.d.mts", ] } diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 2c44a9ad..c0e48a6a 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -19,7 +19,7 @@ import { IDisposable } from '../../../../../../../base/common/lifecycle.js'; import { ErrorDisplay } from './ErrorDisplay.js'; import { LLMMessageServiceParams } from '../../../../../../../platform/void/common/llmMessageTypes.js'; import { getCmdKey } from '../../../getCmdKey.js' -import { InputBox } from './inputs.js'; +import { VoidInputBox } from './inputs.js'; import { HistoryInputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js'; // read files from VSCode @@ -295,7 +295,7 @@ export const SidebarChat = () => { }}> {/* input */} - { configStateService.setField(field, param, newValue) @@ -28,13 +29,12 @@ const SettingOfFieldAndParam = ({ field, param, configState, configStateService const selectBoxRef = useRef(null); const forceState = useCallback((newValue: string) => { if (inputBoxRef.current) { - // inputBoxRef.current.addToHistory(); inputBoxRef.current.value = newValue; } if (selectBoxRef.current) { selectBoxRef.current.select(enumArr?.indexOf(newValue) ?? 0); } - updateState(newValue); + // updateState is called automatically when the change happens }, [enumArr, updateState]) @@ -54,9 +54,9 @@ const SettingOfFieldAndParam = ({ field, param, configState, configStateService const inputElement = enumArr === undefined ? // string - ( : // enum - () diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx index ed7c4f31..877d9d52 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx @@ -1,13 +1,13 @@ import React, { useEffect, useRef } from 'react'; import { useService } from '../util/services.js'; -import { HistoryInputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js'; +import { HistoryInputBox, InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js'; import { defaultInputBoxStyles } from '../../../../../../../platform/theme/browser/defaultStyles.js'; import { SelectBox, unthemedSelectBoxStyles } from '../../../../../../../base/browser/ui/selectBox/selectBox.js'; -export const InputBox = ({ onChangeText, initVal, placeholder, inputBoxRef, multiline }: { +export const VoidInputBox = ({ onChangeText, initVal, placeholder, inputBoxRef, multiline }: { onChangeText: (value: string) => void; placeholder: string; - inputBoxRef: React.MutableRefObject; + inputBoxRef: React.MutableRefObject; multiline: boolean; initVal: string; }) => { @@ -19,7 +19,7 @@ export const InputBox = ({ onChangeText, initVal, placeholder, inputBoxRef, mult if (!containerRef.current) return; // create and mount the HistoryInputBox - inputBoxRef.current = new HistoryInputBox( + inputBoxRef.current = new InputBox( containerRef.current, contextViewProvider, { @@ -28,20 +28,20 @@ export const InputBox = ({ onChangeText, initVal, placeholder, inputBoxRef, mult inputBackground: 'transparent', }, placeholder, - history: [initVal], flexibleHeight: multiline, flexibleMaxHeight: 500, flexibleWidth: false, } ); + inputBoxRef.current.value = initVal; + inputBoxRef.current.onDidChange((newStr) => { console.log('CHANGE TEXT on inputbox', newStr) onChangeText(newStr) }) - // cleanup return () => { if (inputBoxRef.current) { @@ -54,14 +54,14 @@ export const InputBox = ({ onChangeText, initVal, placeholder, inputBoxRef, mult inputBoxRef.current = null; } }; - }, [inputBoxRef, onChangeText, placeholder, contextViewProvider, initVal, multiline]); // Empty dependency array since we only want to mount/unmount once + }, [inputBoxRef, contextViewProvider, placeholder, multiline, initVal, onChangeText]); // Empty dependency array since we only want to mount/unmount once return
; }; -export const EnumInputBox = ({ onChangeSelection, initVal, selectBoxRef, options }: { +export const VoidSelectBox = ({ onChangeSelection, initVal, selectBoxRef, options }: { onChangeSelection: (value: string) => void; initVal: string; selectBoxRef: React.MutableRefObject; @@ -98,7 +98,7 @@ export const EnumInputBox = ({ onChangeSelection, initVal, selectBoxRef, options } } }; - }, [options, initVal, onChangeSelection, contextViewProvider]); + }, [options, initVal, onChangeSelection, contextViewProvider, selectBoxRef]); return
; };