Fix passing codebaseContext parameter and InputToolbar flickering
This commit is contained in:
parent
a0956e614e
commit
e8add8253a
2 changed files with 30 additions and 2 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
/>
|
||||
<InputToolbar
|
||||
showNoContext={optionKeyHeld}
|
||||
hidden={!(editorFocusedRef.current || props.isMainInput)}
|
||||
hidden={shouldHideToolbar && !props.isMainInput}
|
||||
onAddContextItem={() => {
|
||||
if (editor.getText().endsWith("@")) {
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue