From b0a4824637908d5db240c354fd07fa32a68b6ffe Mon Sep 17 00:00:00 2001 From: rongzhang Date: Mon, 19 Aug 2024 23:11:48 +0000 Subject: [PATCH] rename feature to copilotSuggestions --- querybook/config/user_setting.yaml | 4 ++-- .../webapp/components/QueryEditor/BoundQueryEditor.tsx | 4 ++-- querybook/webapp/components/QueryEditor/QueryEditor.tsx | 8 ++++---- querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts | 8 ++++---- querybook/webapp/lib/codemirror/codemirror-copilot.ts | 2 +- querybook/webapp/lib/codemirror/index.ts | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/querybook/config/user_setting.yaml b/querybook/config/user_setting.yaml index 508575e89..5ca67da41 100644 --- a/querybook/config/user_setting.yaml +++ b/querybook/config/user_setting.yaml @@ -50,13 +50,13 @@ show_full_view: - disabled helper: Instead of modal, show full view when opening table/execution/snippet -query_suggestions: +copilot_suggestions: default: disabled tab: editor options: - enabled - disabled - helper: Enable to receive inline LLM generated query suggestions as you type from within the editor. + helper: (Experimental) Enable to receive inline AI generated query suggestions as you type from within the editor. editor_font_size: default: medium diff --git a/querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx b/querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx index fd6f1ef50..a42b890a9 100644 --- a/querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx +++ b/querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx @@ -55,7 +55,7 @@ export const BoundQueryEditor = React.forwardRef< options, fontSize, autoCompleteType, - querySuggestionsEnabled, + copilotSuggestionsEnabled, } = useUserQueryEditorConfig(searchContext); const combinedOptions = useMemo( () => ({ @@ -109,7 +109,7 @@ export const BoundQueryEditor = React.forwardRef< theme={codeEditorTheme} autoCompleteType={autoCompleteType} fontSize={fontSize} - querySuggestionsEnabled={querySuggestionsEnabled} + querySuggestionsEnabled={copilotSuggestionsEnabled} getTableByName={fetchDataTable} functionDocumentationByNameByLanguage={ functionDocumentationByNameByLanguage diff --git a/querybook/webapp/components/QueryEditor/QueryEditor.tsx b/querybook/webapp/components/QueryEditor/QueryEditor.tsx index dd754b0a0..5dfb6f693 100644 --- a/querybook/webapp/components/QueryEditor/QueryEditor.tsx +++ b/querybook/webapp/components/QueryEditor/QueryEditor.tsx @@ -57,7 +57,7 @@ export interface IQueryEditorProps extends IStyledQueryEditorProps { keyMap?: CodeMirrorKeyMap; className?: string; autoCompleteType?: AutoCompleteType; - querySuggestionsEnabled?: boolean; + copilotSuggestionsEnabled?: boolean; /** * If provided, then the container component will handle the fullscreen logic @@ -116,7 +116,7 @@ export const QueryEditor: React.FC< keyMap = {}, className, autoCompleteType = 'all', - querySuggestionsEnabled, + copilotSuggestionsEnabled, onFullScreen, onChange, @@ -623,9 +623,9 @@ export const QueryEditor: React.FC< (editor: CodeMirror.Editor) => { editorRef.current = editor; - if (querySuggestionsEnabled) { + if (copilotSuggestionsEnabled) { // Enable copilot suggestion feature - editor.querySuggestions(); + editor.copilotSuggestions(); } // There is a strange bug where codemirror would start with the wrong height (on Execs tab) diff --git a/querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts b/querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts index b68cd598b..e48d7189f 100644 --- a/querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts +++ b/querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts @@ -17,7 +17,7 @@ export function useUserQueryEditorConfig( keyMap: CodeMirrorKeyMap; options: CodeMirror.EditorConfiguration; autoCompleteType: AutoCompleteType; - querySuggestionsEnabled: boolean; + copilotSuggestionsEnabled: boolean; } { const editorSettings = useShallowSelector((state: IStoreState) => ({ theme: getCodeEditorTheme(state.user.computedSettings['theme']), @@ -27,8 +27,8 @@ export function useUserQueryEditorConfig( ], autoComplete: state.user.computedSettings['auto_complete'], tab: state.user.computedSettings['tab'], - querySuggestionsEnabled: - state.user.computedSettings['query_suggestions'] === 'enabled', + copilotSuggestionsEnabled: + state.user.computedSettings['copilot_suggestions'] === 'enabled', })); const indentWithTabs = editorSettings.tab === 'tab'; const tabSize = @@ -109,6 +109,6 @@ export function useUserQueryEditorConfig( // From: https://github.com/codemirror/CodeMirror/issues/988 keyMap, options, - querySuggestionsEnabled: editorSettings.querySuggestionsEnabled, + copilotSuggestionsEnabled: editorSettings.copilotSuggestionsEnabled, }; } diff --git a/querybook/webapp/lib/codemirror/codemirror-copilot.ts b/querybook/webapp/lib/codemirror/codemirror-copilot.ts index 9b30d8827..1f4808c07 100644 --- a/querybook/webapp/lib/codemirror/codemirror-copilot.ts +++ b/querybook/webapp/lib/codemirror/codemirror-copilot.ts @@ -1,6 +1,6 @@ import CodeMirror from 'codemirror'; -CodeMirror.defineExtension('querySuggestions', function () { +CodeMirror.defineExtension('copilotSuggestions', function () { this.on('keyup', async (editor, event) => { if (event.code === 'Space') { console.log('CodeMirror Query Suggestions Extension'); diff --git a/querybook/webapp/lib/codemirror/index.ts b/querybook/webapp/lib/codemirror/index.ts index b00c45ce3..08b1d0275 100644 --- a/querybook/webapp/lib/codemirror/index.ts +++ b/querybook/webapp/lib/codemirror/index.ts @@ -25,7 +25,7 @@ import 'codemirror/theme/duotone-light.css'; import 'codemirror/theme/material-palenight.css'; import 'codemirror/theme/monokai.css'; import 'codemirror/theme/solarized.css'; -// Query Suggestions +// AI Query Suggestions import 'lib/codemirror/codemirror-copilot'; // This should apply the hover option to codemirror import 'lib/codemirror/codemirror-hover'; @@ -35,7 +35,7 @@ import './editor_styles.scss'; declare module 'codemirror' { interface Editor { - querySuggestions(): void; + copilotSuggestions(): void; } // This is copied from runmode.d.ts. Not sure how to import it :( function runMode(