Skip to content

Commit

Permalink
rename feature to copilotSuggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangvi7 committed Aug 19, 2024
1 parent eb97ad2 commit b0a4824
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions querybook/config/user_setting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const BoundQueryEditor = React.forwardRef<
options,
fontSize,
autoCompleteType,
querySuggestionsEnabled,
copilotSuggestionsEnabled,
} = useUserQueryEditorConfig(searchContext);
const combinedOptions = useMemo(
() => ({
Expand Down Expand Up @@ -109,7 +109,7 @@ export const BoundQueryEditor = React.forwardRef<
theme={codeEditorTheme}
autoCompleteType={autoCompleteType}
fontSize={fontSize}
querySuggestionsEnabled={querySuggestionsEnabled}
querySuggestionsEnabled={copilotSuggestionsEnabled}

Check failure on line 112 in querybook/webapp/components/QueryEditor/BoundQueryEditor.tsx

View workflow job for this annotation

GitHub Actions / nodetests

Type '{ ref: MutableRefObject<IQueryEditorHandles>; options: { value?: string | Doc; mode?: string | ModeSpec<ModeSpecOptions>; ... 57 more ...; highlightSelectionMatches?: boolean | HighlightSelectionMatches; }; ... 24 more ...; children?: ReactNode; }' is not assignable to type 'IntrinsicAttributes & IQueryEditorProps & { ref: Ref<IQueryEditorHandles>; } & { children?: ReactNode; }'.
getTableByName={fetchDataTable}
functionDocumentationByNameByLanguage={
functionDocumentationByNameByLanguage
Expand Down
8 changes: 4 additions & 4 deletions querybook/webapp/components/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,7 +116,7 @@ export const QueryEditor: React.FC<
keyMap = {},
className,
autoCompleteType = 'all',
querySuggestionsEnabled,
copilotSuggestionsEnabled,
onFullScreen,

onChange,
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions querybook/webapp/hooks/redux/useUserQueryEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand All @@ -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 =
Expand Down Expand Up @@ -109,6 +109,6 @@ export function useUserQueryEditorConfig(
// From: https://github.com/codemirror/CodeMirror/issues/988
keyMap,
options,
querySuggestionsEnabled: editorSettings.querySuggestionsEnabled,
copilotSuggestionsEnabled: editorSettings.copilotSuggestionsEnabled,
};
}
2 changes: 1 addition & 1 deletion querybook/webapp/lib/codemirror/codemirror-copilot.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 2 additions & 2 deletions querybook/webapp/lib/codemirror/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
Expand Down

0 comments on commit b0a4824

Please sign in to comment.