From 757bd0a40ee8a2e22c8864d757e4356cdbac9d4b Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Mon, 28 Oct 2024 11:03:57 +0530 Subject: [PATCH 1/5] chore: Remove ask ai feature --- .../editorComponents/GPT/AskAIButton.tsx | 15 -- .../components/editorComponents/GPT/index.tsx | 44 ---- .../editorComponents/GPT/trigger.tsx | 34 --- .../CodeEditor/commandsHelper.ts | 15 -- .../CodeEditor/generateQuickCommands.tsx | 24 -- .../CodeEditor/hintHelpers.ts | 7 +- .../editorComponents/CodeEditor/index.tsx | 231 ++++++------------ .../CodeEditor/styledComponents.ts | 1 - .../editorComponents/GPT/AskAIButton.tsx | 1 - .../components/editorComponents/GPT/index.tsx | 1 - .../editorComponents/GPT/trigger.tsx | 1 - 11 files changed, 78 insertions(+), 296 deletions(-) delete mode 100644 app/client/src/ce/components/editorComponents/GPT/AskAIButton.tsx delete mode 100644 app/client/src/ce/components/editorComponents/GPT/index.tsx delete mode 100644 app/client/src/ce/components/editorComponents/GPT/trigger.tsx delete mode 100644 app/client/src/ee/components/editorComponents/GPT/AskAIButton.tsx delete mode 100644 app/client/src/ee/components/editorComponents/GPT/index.tsx delete mode 100644 app/client/src/ee/components/editorComponents/GPT/trigger.tsx diff --git a/app/client/src/ce/components/editorComponents/GPT/AskAIButton.tsx b/app/client/src/ce/components/editorComponents/GPT/AskAIButton.tsx deleted file mode 100644 index e98cedd43959..000000000000 --- a/app/client/src/ce/components/editorComponents/GPT/AskAIButton.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import type { - FieldEntityInformation, - TEditorModes, -} from "components/editorComponents/CodeEditor/EditorConfig"; - -interface AskAIButtonProps { - mode: TEditorModes; - onClick: () => void; - entity: FieldEntityInformation; -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function AskAIButton(props: AskAIButtonProps) { - return null; -} diff --git a/app/client/src/ce/components/editorComponents/GPT/index.tsx b/app/client/src/ce/components/editorComponents/GPT/index.tsx deleted file mode 100644 index a23e560fd5a9..000000000000 --- a/app/client/src/ce/components/editorComponents/GPT/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import type { CodeEditorExpected } from "components/editorComponents/CodeEditor"; -import type { - FieldEntityInformation, - TEditorModes, -} from "components/editorComponents/CodeEditor/EditorConfig"; -import type { EntityNavigationData } from "selectors/navigationSelectors"; -import React from "react"; -import type CodeMirror from "codemirror"; - -export type AIEditorContext = Partial<{ - functionName: string; - cursorLineNumber: number; - functionString: string; - cursorPosition: CodeMirror.Position; - cursorCoordinates: { - left: number; - top: number; - bottom: number; - }; - mode: string; -}>; - -export interface TAIWrapperProps { - children?: React.ReactNode; - isOpen: boolean; - currentValue: string; - // TODO: Fix this the next time the file is edited - // eslint-disable-next-line @typescript-eslint/no-explicit-any - update?: (...args: any) => void; - triggerContext?: CodeEditorExpected; - enableAIAssistance: boolean; - dataTreePath?: string; - mode: TEditorModes; - entity: FieldEntityInformation; - entitiesForNavigation: EntityNavigationData; - editor: CodeMirror.Editor; - onOpenChanged: (isOpen: boolean) => void; -} - -export function AIWindow(props: TAIWrapperProps) { - const { children } = props; - //eslint-disable-next-line - return <>{children}; -} diff --git a/app/client/src/ce/components/editorComponents/GPT/trigger.tsx b/app/client/src/ce/components/editorComponents/GPT/trigger.tsx deleted file mode 100644 index b491abc6a22b..000000000000 --- a/app/client/src/ce/components/editorComponents/GPT/trigger.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import type { TEditorModes } from "components/editorComponents/CodeEditor/EditorConfig"; -import type { FeatureFlags } from "ee/entities/FeatureFlag"; -import type { EntityTypeValue } from "ee/entities/DataTree/types"; - -export const APPSMITH_AI = "Appsmith AI"; - -export function isAIEnabled(ff: FeatureFlags, mode: TEditorModes) { - return false; -} - -export const isAISlashCommand = (editor: CodeMirror.Editor) => { - return false; -}; - -export const getAIContext = ({ - cursorPosition, - editor, -}: { - entityType?: EntityTypeValue; - slashIndex?: number; - currentLineValue?: string; - cursorPosition: CodeMirror.Position; - editor: CodeMirror.Editor; -}) => { - return { - functionName: "", - cursorLineNumber: cursorPosition.line, - functionString: "", - mode: editor.getMode().name, - cursorPosition, - cursorCoordinates: editor.cursorCoords(true, "local"), - }; -}; diff --git a/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts b/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts index f2a818606621..17780ae2c805 100644 --- a/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts +++ b/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts @@ -19,7 +19,6 @@ import type { EntityNavigationData, NavigationData, } from "selectors/navigationSelectors"; -import { getAIContext } from "ee/components/editorComponents/GPT/trigger"; import type { Plugin } from "api/PluginApi"; export const getShowHintOptions = ( @@ -128,7 +127,6 @@ export const slashCommandHintHelper: HintHelper = ( entityInfo: FieldEntityInformation, { datasources, - enableAIAssistance, executeCommand, featureFlags, focusEditor, @@ -141,7 +139,6 @@ export const slashCommandHintHelper: HintHelper = ( recentEntities: string[]; entityId: string; featureFlags: FeatureFlags; - enableAIAssistance: boolean; focusEditor: (focusOnLine?: number, chOffset?: number) => void; }, ): boolean => { @@ -168,28 +165,16 @@ export const slashCommandHintHelper: HintHelper = ( if (!shouldShowBinding) return false; - const aiContext = getAIContext({ - currentLineValue, - cursorPosition, - editor, - slashIndex, - entityType, - }); - - if (!aiContext) return false; - const list = generateQuickCommands( filteredEntitiesForSuggestions, currentEntityType, searchText, { - aiContext, datasources, executeCommand, pluginIdToPlugin, recentEntities, featureFlags, - enableAIAssistance, }, editor, focusEditor, diff --git a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx index 5cf8c5db61b1..fd5d4ef3b4a1 100644 --- a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx @@ -10,12 +10,10 @@ import { EntityIcon, JsFileIconV2 } from "pages/Editor/Explorer/ExplorerIcons"; import { getAssetUrl } from "ee/utils/airgapHelpers"; import type { FeatureFlags } from "ee/entities/FeatureFlag"; import { Button, Icon } from "@appsmith/ads"; -import { APPSMITH_AI } from "ee/components/editorComponents/GPT/trigger"; import { DatasourceCreateEntryPoints } from "constants/Datasource"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import BetaCard from "../BetaCard"; import type { NavigationData } from "selectors/navigationSelectors"; -import type { AIEditorContext } from "ee/components/editorComponents/GPT"; import type { EntityTypeValue } from "ee/entities/DataTree/types"; import history, { NavigationMethod } from "utils/history"; import type { Plugin } from "api/PluginApi"; @@ -269,19 +267,15 @@ export const generateQuickCommands = ( currentEntityType: EntityTypeValue, searchText: string, { - aiContext, datasources, - enableAIAssistance, executeCommand, pluginIdToPlugin, }: { - aiContext: AIEditorContext; datasources: Datasource[]; executeCommand: (payload: SlashCommandPayload) => void; pluginIdToPlugin: Record; recentEntities: string[]; featureFlags: FeatureFlags; - enableAIAssistance: boolean; }, editor: CodeMirror.Editor, focusEditor: (focusOnLine?: number, chOffset?: number) => void, @@ -394,24 +388,6 @@ export const generateQuickCommands = ( }); const commonCommands: CommandsCompletion[] = []; - if (enableAIAssistance) { - const askGPT: CommandsCompletion = generateCreateNewCommand({ - text: "", - displayText: APPSMITH_AI, - shortcut: Shortcuts.ASK_AI, - triggerCompletionsPostPick: true, - isBeta: true, - action: () => { - executeCommand({ - actionType: SlashCommand.ASK_AI, - args: aiContext, - }); - }, - }); - - commonCommands.unshift(askGPT); - } - if (currentEntityType !== ENTITY_TYPE.JSACTION) { // New binding command is not applicable in JS Objects commonCommands.push(newBinding); diff --git a/app/client/src/components/editorComponents/CodeEditor/hintHelpers.ts b/app/client/src/components/editorComponents/CodeEditor/hintHelpers.ts index da3517d226c9..a48b71158b11 100644 --- a/app/client/src/components/editorComponents/CodeEditor/hintHelpers.ts +++ b/app/client/src/components/editorComponents/CodeEditor/hintHelpers.ts @@ -14,7 +14,6 @@ import { filterCompletions, getHintDetailsFromClassName, } from "./utils/sqlHint"; -import { isAISlashCommand } from "ee/components/editorComponents/GPT/trigger"; export const bindingHintHelper: HintHelper = (editor: CodeMirror.Editor) => { editor.setOption("extraKeys", { @@ -48,11 +47,7 @@ export const bindingHintHelper: HintHelper = (editor: CodeMirror.Editor) => { let shouldShow = false; if (additionalData?.isJsEditor) { - if (additionalData?.enableAIAssistance) { - shouldShow = !isAISlashCommand(editor); - } else { - shouldShow = true; - } + shouldShow = true; } else { shouldShow = checkIfCursorInsideBinding(editor); } diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index bd236a5e3d21..197b4b029fb0 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -139,10 +139,7 @@ import { } from "./utils/saveAndAutoIndent"; import { getAssetUrl } from "ee/utils/airgapHelpers"; import { selectFeatureFlags } from "ee/selectors/featureFlagsSelectors"; -import { AIWindow } from "ee/components/editorComponents/GPT"; -import { AskAIButton } from "ee/components/editorComponents/GPT/AskAIButton"; import classNames from "classnames"; -import { isAIEnabled } from "ee/components/editorComponents/GPT/trigger"; import { getAllDatasourceTableKeys, selectInstalledLibraries, @@ -239,7 +236,6 @@ export type EditorProps = EditorStyleProps & highlightedTextClassName?: string; handleMouseEnter?: (event: MouseEvent) => void; handleMouseLeave?: () => void; - AIAssisted?: boolean; isReadOnly?: boolean; isRawView?: boolean; isJSObject?: boolean; @@ -259,7 +255,6 @@ export type EditorProps = EditorStyleProps & lineCommentString?: string; evaluatedPopUpLabel?: string; removeHoverAndFocusStyle?: boolean; - customErrors?: LintError[]; }; @@ -279,7 +274,6 @@ interface State { }) | undefined; isDynamic: boolean; - showAIWindow: boolean; ternToolTipActive: boolean; } @@ -304,7 +298,6 @@ class CodeEditor extends Component { private peekOverlayExpressionIdentifier: PeekOverlayExpressionIdentifier; private editorWrapperRef = React.createRef(); currentLineNumber: number | null = null; - AIEnabled = false; private multiplexConfig?: MultiplexingModeConfig; constructor(props: Props) { @@ -318,7 +311,6 @@ class CodeEditor extends Component { changeStarted: false, ctrlPressed: false, peekOverlayProps: undefined, - showAIWindow: false, ternToolTipActive: false, }; this.updatePropertyValue = this.updatePropertyValue.bind(this); @@ -335,12 +327,6 @@ class CodeEditor extends Component { props.input.value, ); this.multiplexConfig = MULTIPLEXING_MODE_CONFIGS[this.props.mode]; - /** - * Decides if AI is enabled by looking at repo, feature flags, props and environment - */ - this.AIEnabled = - isAIEnabled(this.props.featureFlags, this.props.mode) && - Boolean(this.props.AIAssisted); } componentDidMount(): void { @@ -570,30 +556,12 @@ class CodeEditor extends Component { const identifierHasChanged = getEditorIdentifier(this.props) !== getEditorIdentifier(prevProps); - const entityInformation = this.getEntityInformation(); - const isWidgetType = entityInformation.entityType === ENTITY_TYPE.WIDGET; - - const hasFocusedValueChanged = - getEditorIdentifier(this.props) !== this.props.focusedProperty; - - if (hasFocusedValueChanged && isWidgetType) { - if (this.state.showAIWindow) { - this.setState({ showAIWindow: false }); - } - } - - if (identifierHasChanged) { - if (this.state.showAIWindow) { - this.setState({ showAIWindow: false }); - } - - if (shouldFocusOnPropertyControl()) { - setTimeout(() => { - if (this.props.editorIsFocused) { - this.editor.focus(); - } - }, 200); - } + if (identifierHasChanged && shouldFocusOnPropertyControl()) { + setTimeout(() => { + if (this.props.editorIsFocused) { + this.editor.focus(); + } + }, 200); } else if (this.props.editorLastCursorPosition) { // This is for when we want to change cursor positions // for e.g navigating to a line from the debugger @@ -1191,7 +1159,6 @@ class CodeEditor extends Component { pluginIdToPlugin: this.props.pluginIdToPlugin, recentEntities: this.props.recentEntities, featureFlags: this.props.featureFlags, - enableAIAssistance: this.AIEnabled, focusEditor: this.focusEditor, executeCommand: this.props.executeCommand, isJsEditor: this.props.mode === EditorModes.JAVASCRIPT, @@ -1220,13 +1187,7 @@ class CodeEditor extends Component { } }; - handleEditorBlur = (cm: CodeMirror.Editor, event: FocusEvent) => { - if (event && event.relatedTarget instanceof Element) { - if (event.relatedTarget.classList.contains("ai-trigger")) { - return; - } - } - + handleEditorBlur = (cm: CodeMirror.Editor) => { this.props.resetActiveField(); this.handleChange(); this.setState({ isFocused: false }); @@ -1432,7 +1393,6 @@ class CodeEditor extends Component { pluginIdToPlugin: this.props.pluginIdToPlugin, recentEntities: this.props.recentEntities, featureFlags: this.props.featureFlags, - enableAIAssistance: this.AIEnabled, focusEditor: this.focusEditor, executeCommand: this.props.executeCommand, isJsEditor: this.props.mode === EditorModes.JAVASCRIPT, @@ -1628,13 +1588,6 @@ class CodeEditor extends Component { ); }; - updateValueWithAIResponse = (value: string) => { - if (typeof value !== "string") return; - - this.props.input?.onChange?.(value); - this.editor.setValue(value); - }; - render() { const { border, @@ -1675,9 +1628,7 @@ class CodeEditor extends Component { } const showSlashCommandButton = - showLightningMenu !== false && - !this.state.isFocused && - !this.state.showAIWindow; + showLightningMenu !== false && !this.state.isFocused; /* Evaluation results for snippet arguments. The props below can be used to set the validation errors when computed from parent component */ if (this.props.errors) { @@ -1691,7 +1642,6 @@ class CodeEditor extends Component { const showEvaluatedValue = this.showFeatures() && (this.state.isDynamic || isInvalid) && - !this.state.showAIWindow && !this.state.peekOverlayProps && !this.editor.state.completionActive && !this.state.ternToolTipActive; @@ -1726,16 +1676,6 @@ class CodeEditor extends Component { -
- { - this.setState({ showAIWindow: true }); - }} - /> -
- { theme={theme || EditorTheme.LIGHT} useValidationMessage={useValidationMessage} > - { - this.setState({ showAIWindow }); - }} - triggerContext={this.props.expected} - update={this.updateValueWithAIResponse} + onMouseMove={this.handleLintTooltip} + onMouseOver={this.handleMouseMove} + ref={this.editorWrapperRef} + removeHoverAndFocusStyle={this.props?.removeHoverAndFocusStyle} + size={size} > - this.hidePeekOverlay()} + {...this.state.peekOverlayProps} + /> + )} + {this.props.leftIcon && ( + {this.props.leftIcon} + )} + + {this.props.leftImage && ( + img + )} +
- {this.state.peekOverlayProps && ( - this.hidePeekOverlay()} - {...this.state.peekOverlayProps} - /> - )} - {this.props.leftIcon && ( - {this.props.leftIcon} - )} - - {this.props.leftImage && ( - img - )} -
+
+ + {this.props.link && ( + - -
- - {this.props.link && ( - - API documentation - - )} - {this.props.rightIcon && ( - {this.props.rightIcon} - )} -
-
+ API documentation + + )} + {this.props.rightIcon && ( + {this.props.rightIcon} + )} +
); diff --git a/app/client/src/components/editorComponents/CodeEditor/styledComponents.ts b/app/client/src/components/editorComponents/CodeEditor/styledComponents.ts index 5c4cd413679a..df8cc742376b 100644 --- a/app/client/src/components/editorComponents/CodeEditor/styledComponents.ts +++ b/app/client/src/components/editorComponents/CodeEditor/styledComponents.ts @@ -51,7 +51,6 @@ export const EditorWrapper = styled.div<{ codeEditorVisibleOverflow?: boolean; ctrlPressed: boolean; removeHoverAndFocusStyle?: boolean; - AIEnabled?: boolean; mode: string; maxHeight?: string | number; }>` diff --git a/app/client/src/ee/components/editorComponents/GPT/AskAIButton.tsx b/app/client/src/ee/components/editorComponents/GPT/AskAIButton.tsx deleted file mode 100644 index 5f59b4402c9c..000000000000 --- a/app/client/src/ee/components/editorComponents/GPT/AskAIButton.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "ce/components/editorComponents/GPT/AskAIButton"; diff --git a/app/client/src/ee/components/editorComponents/GPT/index.tsx b/app/client/src/ee/components/editorComponents/GPT/index.tsx deleted file mode 100644 index 7048ebdd0524..000000000000 --- a/app/client/src/ee/components/editorComponents/GPT/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "ce/components/editorComponents/GPT"; diff --git a/app/client/src/ee/components/editorComponents/GPT/trigger.tsx b/app/client/src/ee/components/editorComponents/GPT/trigger.tsx deleted file mode 100644 index c313d623a621..000000000000 --- a/app/client/src/ee/components/editorComponents/GPT/trigger.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from "ce/components/editorComponents/GPT/trigger"; From a073766821952a305a7d57914e9d1265906f0abb Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Mon, 28 Oct 2024 11:19:22 +0530 Subject: [PATCH 2/5] Remove enableAI prop --- .../ActionCreator/viewComponents/TextView/index.tsx | 1 - .../editorComponents/form/fields/DynamicTextField.tsx | 2 -- .../src/components/propertyControls/ChartDataControl.tsx | 2 -- .../src/components/propertyControls/CodeEditorControl.tsx | 1 - .../propertyControls/ComputeTablePropertyControl.tsx | 1 - .../src/components/propertyControls/InputTextControl.tsx | 3 --- .../src/components/propertyControls/JSONFormComputeControl.tsx | 1 - .../src/components/propertyControls/ListComputeControl.tsx | 1 - .../propertyControls/MenuButtonDynamicItemsControl.tsx | 1 - .../components/propertyControls/SelectDefaultValueControl.tsx | 1 - .../src/components/propertyControls/TableComputeValue.tsx | 1 - .../propertyControls/TableInlineEditValidationControl.tsx | 1 - .../components/propertyControls/WrappedCodeEditorControl.tsx | 1 - .../src/pages/Editor/JSEditor/JSEditorForm/JSEditorForm.tsx | 1 - .../pages/Editor/JSEditor/JSEditorForm/old/JSEditorForm.tsx | 1 - 15 files changed, 19 deletions(-) diff --git a/app/client/src/components/editorComponents/ActionCreator/viewComponents/TextView/index.tsx b/app/client/src/components/editorComponents/ActionCreator/viewComponents/TextView/index.tsx index 5eea97309236..0fc912b6cdee 100644 --- a/app/client/src/components/editorComponents/ActionCreator/viewComponents/TextView/index.tsx +++ b/app/client/src/components/editorComponents/ActionCreator/viewComponents/TextView/index.tsx @@ -81,7 +81,6 @@ export function TextView(props: TextViewProps) { { theme={this.props.theme} useValidationMessage={useValidationMessage} {...props} - AIAssisted /> ); } diff --git a/app/client/src/components/propertyControls/ComputeTablePropertyControl.tsx b/app/client/src/components/propertyControls/ComputeTablePropertyControl.tsx index aff763f481c8..7ae6b643f67e 100644 --- a/app/client/src/components/propertyControls/ComputeTablePropertyControl.tsx +++ b/app/client/src/components/propertyControls/ComputeTablePropertyControl.tsx @@ -64,7 +64,6 @@ export function InputText(props: { return ( { return (
Date: Mon, 28 Oct 2024 11:47:07 +0530 Subject: [PATCH 3/5] Remove ask ai storage methods and constants --- .../src/ce/constants/ReduxActionConstants.tsx | 6 - app/client/src/entities/Action/index.ts | 1 - app/client/src/sagas/ActionSagas.ts | 38 ------ app/client/src/utils/storage.ts | 109 ------------------ 4 files changed, 154 deletions(-) diff --git a/app/client/src/ce/constants/ReduxActionConstants.tsx b/app/client/src/ce/constants/ReduxActionConstants.tsx index c225e29be85d..1af6b94d3758 100644 --- a/app/client/src/ce/constants/ReduxActionConstants.tsx +++ b/app/client/src/ce/constants/ReduxActionConstants.tsx @@ -1257,11 +1257,6 @@ const OneClickBindingActionTypes = { "SET_ONE_CLICK_BINDING_OPTIONS_VISIBILITY", }; -const AIActionTypes = { - UPDATE_AI_CONTEXT: "UPDATE_AI_CONTEXT", - UPDATE_AI_TRIGGERED: "UPDATE_AI_TRIGGERED", -}; - const PlatformActionErrorTypes = { API_ERROR: "API_ERROR", }; @@ -1270,7 +1265,6 @@ export const ReduxActionTypes = { ...ActionActionTypes, ...AdminSettingsActionTypes, ...AnalyticsActionTypes, - ...AIActionTypes, ...AppCollabActionTypes, ...ApplicationActionTypes, ...AppThemeActionsTypes, diff --git a/app/client/src/entities/Action/index.ts b/app/client/src/entities/Action/index.ts index 2278643cd81e..011d77ab8693 100644 --- a/app/client/src/entities/Action/index.ts +++ b/app/client/src/entities/Action/index.ts @@ -272,7 +272,6 @@ export enum SlashCommand { NEW_API, NEW_QUERY, NEW_INTEGRATION, - ASK_AI, } export interface SlashCommandPayload { diff --git a/app/client/src/sagas/ActionSagas.ts b/app/client/src/sagas/ActionSagas.ts index 92e2a26ef931..657824ff05c8 100644 --- a/app/client/src/sagas/ActionSagas.ts +++ b/app/client/src/sagas/ActionSagas.ts @@ -33,7 +33,6 @@ import type { ApiResponse } from "api/ApiResponses"; import type { FetchPageRequest, FetchPageResponse } from "api/PageApi"; import PageApi from "api/PageApi"; import type { Plugin } from "api/PluginApi"; -import { EditorModes } from "components/editorComponents/CodeEditor/EditorConfig"; import { fixActionPayloadForMongoQuery, getConfigInitialValues, @@ -137,7 +136,6 @@ import { getDynamicBindingsChangesSaga } from "utils/DynamicBindingUtils"; import { getDefaultTemplateActionConfig } from "utils/editorContextUtils"; import { shouldBeDefined } from "utils/helpers"; import history from "utils/history"; -import { setAIPromptTriggered } from "utils/storage"; import { sendAnalyticsEventSaga } from "./AnalyticsSaga"; import { validateResponse } from "./ErrorSagas"; import FocusRetention from "./FocusRetentionSaga"; @@ -1142,42 +1140,6 @@ function* executeCommandSaga(actionPayload: ReduxAction) { if (callback) callback(`{{${API.payload.name}.data}}`); break; - case SlashCommand.ASK_AI: { - const context = get(actionPayload, "payload.args", {}); - const isJavascriptMode = context.mode === EditorModes.TEXT_WITH_BINDING; - - const noOfTimesAIPromptTriggered: number = yield select( - (state) => state.ai.noOfTimesAITriggered, - ); - - const noOfTimesAIPromptTriggeredForQuery: number = yield select( - (state) => state.ai.noOfTimesAITriggeredForQuery, - ); - - const triggerCount = isJavascriptMode - ? noOfTimesAIPromptTriggered - : noOfTimesAIPromptTriggeredForQuery; - - if (triggerCount < 5) { - const currentValue: number = yield setAIPromptTriggered(context.mode); - - yield put({ - type: ReduxActionTypes.UPDATE_AI_TRIGGERED, - payload: { - value: currentValue, - mode: context.mode, - }, - }); - } - - yield put({ - type: ReduxActionTypes.UPDATE_AI_CONTEXT, - payload: { - context, - }, - }); - break; - } } } diff --git a/app/client/src/utils/storage.ts b/app/client/src/utils/storage.ts index dff7c051aaf3..1472b926df6f 100644 --- a/app/client/src/utils/storage.ts +++ b/app/client/src/utils/storage.ts @@ -3,7 +3,6 @@ import moment from "moment"; import localforage from "localforage"; import type { VersionUpdateState } from "../sagas/WebsocketSagas/versionUpdatePrompt"; import { isNumber } from "lodash"; -import { EditorModes } from "components/editorComponents/CodeEditor/EditorConfig"; import type { EditorViewMode } from "ee/entities/IDE/constants"; import type { OverriddenFeatureFlags } from "./hooks/useFeatureFlagOverride"; import { AvailableFeaturesToOverride } from "./hooks/useFeatureFlagOverride"; @@ -29,13 +28,9 @@ export const STORAGE_KEYS: { FIRST_TIME_USER_ONBOARDING_TELEMETRY_CALLOUT_VISIBILITY: "FIRST_TIME_USER_ONBOARDING_TELEMETRY_CALLOUT_VISIBILITY", SIGNPOSTING_APP_STATE: "SIGNPOSTING_APP_STATE", - AI_SUGGESTED_PROMPTS_SHOWN: "AI_SUGGESTED_PROMPTS_SHOWN", - AI_TRIGGERED_FOR_PROPERTY_PANE: "AI_TRIGGERED", - AI_TRIGGERED_FOR_QUERY: "AI_TRIGGERED_FOR_QUERY", FEATURE_WALKTHROUGH: "FEATURE_WALKTHROUGH", USER_SIGN_UP: "USER_SIGN_UP", VERSION_UPDATE_STATE: "VERSION_UPDATE_STATE", - AI_RECENT_QUERIES: "AI_RECENT_QUERIES", CURRENT_ENV: "CURRENT_ENV", AI_KNOWLEDGE_BASE: "AI_KNOWLEDGE_BASE", PARTNER_PROGRAM_CALLOUT: "PARTNER_PROGRAM_CALLOUT", @@ -344,66 +339,6 @@ export const getEnableStartSignposting = async () => { } }; -export const setAIRecentQuery = async ( - applicationId: string, - query: string, - type: string, -) => { - try { - const recentQueries: { - [applicationId: string]: { - [task: string]: string[]; - }; - } | null = (await store.getItem(STORAGE_KEYS.AI_RECENT_QUERIES)) || {}; - const applicationRecentQueries = recentQueries[applicationId] || {}; - let applicationTypeQueries = applicationRecentQueries[type] || []; - - if (!applicationTypeQueries.includes(query)) { - if (applicationTypeQueries.length >= 3) { - applicationTypeQueries.pop(); - } - - applicationTypeQueries = [query, ...applicationTypeQueries]; - } - - await store.setItem(STORAGE_KEYS.AI_RECENT_QUERIES, { - ...recentQueries, - [applicationId]: { - ...applicationRecentQueries, - [type]: applicationTypeQueries, - }, - }); - } catch (error) { - log.error("An error occurred while setting AI_RECENT_QUERIES"); - log.error(error); - } -}; - -export const getApplicationAIRecentQueriesByType = async ( - applicationId: string, - type: string, -) => { - const defaultRecentQueries: string[] = []; - - try { - const recentQueries: { - [applicationId: string]: { - [task: string]: string[]; - }; - } | null = await store.getItem(STORAGE_KEYS.AI_RECENT_QUERIES); - - return ( - recentQueries?.[applicationId]?.[type]?.slice(0, 3) ?? - defaultRecentQueries - ); - } catch (error) { - log.error("An error occurred while fetching AI_RECENT_QUERIES"); - log.error(error); - - return defaultRecentQueries; - } -}; - export const setFirstTimeUserOnboardingApplicationId = async (id: string) => { try { let ids: unknown = await store.getItem( @@ -629,50 +564,6 @@ export const setFirstTimeUserOnboardingTelemetryCalloutVisibility = async ( } }; -export const setAIPromptTriggered = async (mode: string) => { - try { - let noOfTimesAITriggered: number = await getAIPromptTriggered(mode); - - if (noOfTimesAITriggered >= 5) { - return noOfTimesAITriggered; - } - - const storageKey = - mode === EditorModes.TEXT_WITH_BINDING - ? STORAGE_KEYS.AI_TRIGGERED_FOR_PROPERTY_PANE - : STORAGE_KEYS.AI_TRIGGERED_FOR_QUERY; - - noOfTimesAITriggered += 1; - await store.setItem(storageKey, noOfTimesAITriggered); - - return noOfTimesAITriggered; - } catch (error) { - log.error("An error occurred while setting AI_TRIGGERED"); - log.error(error); - - return 0; - } -}; - -export const getAIPromptTriggered = async (mode: string) => { - try { - const storageKey = - mode === EditorModes.TEXT_WITH_BINDING - ? STORAGE_KEYS.AI_TRIGGERED_FOR_PROPERTY_PANE - : STORAGE_KEYS.AI_TRIGGERED_FOR_QUERY; - - const flag: number | null = await store.getItem(storageKey); - - if (flag === null) return 0; - - return flag; - } catch (error) { - log.error("An error occurred while fetching AI_TRIGGERED"); - log.error(error); - - return 0; - } -}; // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any export const setFeatureWalkthroughShown = async (key: string, value: any) => { From ae3008bb8571a8b1364fbb05fe7dfb68c123883b Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Mon, 28 Oct 2024 12:00:34 +0530 Subject: [PATCH 4/5] Remove ask ai usage in AppEditorEngine --- .../src/entities/Engine/AppEditorEngine.ts | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/app/client/src/entities/Engine/AppEditorEngine.ts b/app/client/src/entities/Engine/AppEditorEngine.ts index d2ff14faf778..ac1aa61d9af1 100644 --- a/app/client/src/entities/Engine/AppEditorEngine.ts +++ b/app/client/src/entities/Engine/AppEditorEngine.ts @@ -53,9 +53,8 @@ import { } from "ee/sagas/userSagas"; import { getFirstTimeUserOnboardingComplete } from "selectors/onboardingSelectors"; import { isAirgapped } from "ee/utils/airgapHelpers"; -import { getAIPromptTriggered, setLatestGitBranchInLocal } from "utils/storage"; +import { setLatestGitBranchInLocal } from "utils/storage"; import { trackOpenEditorTabs } from "../../utils/editor/browserTabsTracking"; -import { EditorModes } from "components/editorComponents/CodeEditor/EditorConfig"; import { waitForFetchEnvironments } from "ee/sagas/EnvironmentSagas"; import { getPageDependencyActions } from "ee/entities/Engine/actionHelpers"; import { getCurrentWorkspaceId } from "ee/selectors/selectedWorkspaceSelectors"; @@ -329,29 +328,6 @@ export default class AppEditorEngine extends AppEngine { }); } - const noOfTimesAIPromptTriggered: number = yield getAIPromptTriggered( - EditorModes.TEXT_WITH_BINDING, - ); - - yield put({ - type: ReduxActionTypes.UPDATE_AI_TRIGGERED, - payload: { - value: noOfTimesAIPromptTriggered, - mode: EditorModes.TEXT_WITH_BINDING, - }, - }); - - const noOfTimesAIPromptTriggeredForQuery: number = - yield getAIPromptTriggered(EditorModes.POSTGRESQL_WITH_BINDING); - - yield put({ - type: ReduxActionTypes.UPDATE_AI_TRIGGERED, - payload: { - value: noOfTimesAIPromptTriggeredForQuery, - mode: EditorModes.POSTGRESQL_WITH_BINDING, - }, - }); - yield call(waitForWidgetConfigBuild); yield spawn(reportSWStatus); From 38e88ca2f0629fc05486ab2cc05712b3c035915f Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Mon, 28 Oct 2024 12:10:54 +0530 Subject: [PATCH 5/5] Remove ask ai icon code --- .../editorComponents/CodeEditor/generateQuickCommands.tsx | 2 -- .../PartialImportExport/PartialExportModal/unitTestUtils.ts | 3 --- 2 files changed, 5 deletions(-) diff --git a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx index fd5d4ef3b4a1..ab16d0ea106b 100644 --- a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx @@ -24,7 +24,6 @@ export enum Shortcuts { PLUS = "PLUS", BINDING = "BINDING", FUNCTION = "FUNCTION", - ASK_AI = "ASK_AI", SHOW_MORE = "SHOW_MORE", } @@ -131,7 +130,6 @@ export const iconsByType = { [Shortcuts.FUNCTION]: ( ), - [Shortcuts.ASK_AI]: , [Shortcuts.SHOW_MORE]: ( ), diff --git a/app/client/src/components/editorComponents/PartialImportExport/PartialExportModal/unitTestUtils.ts b/app/client/src/components/editorComponents/PartialImportExport/PartialExportModal/unitTestUtils.ts index 5fde2d76c5bf..1c048548b637 100644 --- a/app/client/src/components/editorComponents/PartialImportExport/PartialExportModal/unitTestUtils.ts +++ b/app/client/src/components/editorComponents/PartialImportExport/PartialExportModal/unitTestUtils.ts @@ -12767,14 +12767,11 @@ export const defaultAppState = { release_side_by_side_ide_enabled: false, release_global_add_pane_enabled: false, license_git_unlimited_repo_enabled: false, - ask_ai_js: false, license_connection_pool_size_enabled: false, ab_ai_js_function_completion_enabled: true, release_workflows_enabled: false, license_scim_enabled: false, - ask_ai: false, license_audit_logs_enabled: false, - ask_ai_sql: false, release_query_module_enabled: false, ab_onboarding_flow_start_with_data_dev_only_enabled: false, license_session_limit_enabled: false,