From e8add8253a0368bdb63172eafcc2da82df698a27 Mon Sep 17 00:00:00 2001 From: anrgct Date: Tue, 20 Aug 2024 22:20:54 +0800 Subject: [PATCH] Fix passing codebaseContext parameter and InputToolbar flickering --- core/config/load.ts | 4 ++- gui/src/components/mainInput/TipTapEditor.tsx | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index a9b2ba94f..2bb836d73 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -355,9 +355,11 @@ async function intermediateToFinalConfig( // These context providers are always included, regardless of what, if anything, // the user has configured in config.json + + const codebaseContextParams = ((config.contextProviders || []).filter(isContextProviderWithParams).find(cp => cp.name === "codebase") as ContextProviderWithParams | undefined)?.params || {}; const DEFAULT_CONTEXT_PROVIDERS = [ new FileContextProvider({}), - new CodebaseContextProvider({}), + new CodebaseContextProvider(codebaseContextParams), ]; const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS.map( diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 8ab8f190e..83752c95f 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -56,6 +56,7 @@ import { getSlashCommandDropdownOptions, } from "./getSuggestion"; import { ComboBoxItem } from "./types"; +import { debounce } from "lodash"; const InputBoxDiv = styled.div` resize: none; @@ -473,6 +474,31 @@ function TipTapEditor(props: TipTapEditorProps) { }, }); + const [shouldHideToolbar, setShouldHideToolbar] = useState(false); + const debouncedShouldHideToolbar = debounce((value) => { + setShouldHideToolbar(value); + }, 200); + + useEffect(() => { + if (editor) { + const handleFocus = () => { + debouncedShouldHideToolbar(false); + } + + const handleBlur = () => { + debouncedShouldHideToolbar(true); + }; + + editor.on('focus', handleFocus); + editor.on('blur', handleBlur); + + return () => { + editor.off('focus', handleFocus); + editor.off('blur', handleBlur); + }; + } + }, [editor]); + const editorFocusedRef = useUpdatingRef(editor?.isFocused, [editor]); useEffect(() => { @@ -831,7 +857,7 @@ function TipTapEditor(props: TipTapEditorProps) { />