diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index 517b3f200..552eef11c 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -79,7 +79,7 @@ let configContext: Readonly = { ARCADIA_LIVY_ENDPOINT_DNS_ZONE: "dev.azuresynapse.net", GITHUB_CLIENT_ID: "6cb2f63cf6f7b5cbdeca", // Registered OAuth app: https://github.com/organizations/AzureCosmosDBNotebooks/settings/applications/1189306 GITHUB_TEST_ENV_CLIENT_ID: "b63fc8cbf87fd3c6e2eb", // Registered OAuth app: https://github.com/organizations/AzureCosmosDBNotebooks/settings/applications/1777772 - JUNO_ENDPOINT: JunoEndpoints.Prod, + JUNO_ENDPOINT: JunoEndpoints.Stage, BACKEND_ENDPOINT: "https://main.documentdb.ext.azure.com", isTerminalEnabled: false, isPhoenixEnabled: false, diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 991829441..755e4a6ab 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -1388,8 +1388,9 @@ export default class Explorer { if (userContext.apiType !== "SQL") { return; } - const copilotEnabled = await getCopilotEnabled(); - const copilotUserDBEnabled = await isCopilotFeatureRegistered(userContext.subscriptionId); + const copilotEnabledPromise = getCopilotEnabled(); + const copilotUserDBEnabledPromise = isCopilotFeatureRegistered(userContext.subscriptionId); + const [copilotEnabled, copilotUserDBEnabled] = await Promise.all([copilotEnabledPromise, copilotUserDBEnabledPromise]) useQueryCopilot.getState().setCopilotEnabled(copilotEnabled); useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled); } diff --git a/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.test.tsx b/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.test.tsx index 4c805ad36..e4f54a107 100644 --- a/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.test.tsx +++ b/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.test.tsx @@ -1,4 +1,4 @@ -import { Checkbox, ChoiceGroup, DefaultButton, IconButton, PrimaryButton, TextField } from "@fluentui/react"; +import { Checkbox, DefaultButton, IconButton, PrimaryButton, TextField } from "@fluentui/react"; import Explorer from "Explorer/Explorer"; import { QueryCopilotFeedbackModal } from "Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal"; import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext"; @@ -83,42 +83,6 @@ describe("Query Copilot Feedback Modal snapshot test", () => { expect(wrapper).toMatchSnapshot(); }); - it("should record user contact choice no", () => { - const wrapper = shallow( - , - ); - const contactAllowed = wrapper.find(ChoiceGroup); - - contactAllowed.simulate("change", {}, { key: "no" }); - - expect(getUserEmail).toHaveBeenCalledTimes(3); - expect(wrapper.find(ChoiceGroup).props().selectedKey).toEqual("no"); - expect(wrapper).toMatchSnapshot(); - }); - - it("should record user contact choice yes", () => { - const wrapper = shallow( - , - ); - const contactAllowed = wrapper.find(ChoiceGroup); - - contactAllowed.simulate("change", {}, { key: "yes" }); - - expect(getUserEmail).toHaveBeenCalledTimes(4); - expect(wrapper.find(ChoiceGroup).props().selectedKey).toEqual("yes"); - expect(wrapper).toMatchSnapshot(); - }); - it("should not render dont show again button", () => { const wrapper = shallow( { generatedQuery: "test query", userPrompt: "test prompt", description: "", - contact: getUserEmail(), }, explorer: explorer, }); diff --git a/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.tsx b/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.tsx index 6cea9ff68..cab440efa 100644 --- a/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.tsx +++ b/src/Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal.tsx @@ -1,6 +1,5 @@ import { Checkbox, - ChoiceGroup, DefaultButton, IconButton, Link, @@ -8,13 +7,12 @@ import { PrimaryButton, Stack, Text, - TextField, + TextField } from "@fluentui/react"; import Explorer from "Explorer/Explorer"; import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext"; import { SubmitFeedback } from "Explorer/QueryCopilot/Shared/QueryCopilotClient"; import React from "react"; -import { getUserEmail } from "../../../Utils/UserUtils"; export const QueryCopilotFeedbackModal = ({ explorer, @@ -35,16 +33,14 @@ export const QueryCopilotFeedbackModal = ({ closeFeedbackModal, setHideFeedbackModalForLikedQueries, } = useCopilotStore(); - const [isContactAllowed, setIsContactAllowed] = React.useState(false); const [description, setDescription] = React.useState(""); const [doNotShowAgainChecked, setDoNotShowAgainChecked] = React.useState(false); - const [contact, setContact] = React.useState(getUserEmail()); const handleSubmit = () => { closeFeedbackModal(); setHideFeedbackModalForLikedQueries(doNotShowAgainChecked); SubmitFeedback({ - params: { generatedQuery, likeQuery, description, userPrompt, contact }, + params: { generatedQuery, likeQuery, description, userPrompt }, explorer, databaseId, containerId, @@ -77,30 +73,6 @@ export const QueryCopilotFeedbackModal = ({ defaultValue={generatedQuery} readOnly /> - { - setIsContactAllowed(option.key === "yes"); - setContact(option.key === "yes" ? getUserEmail() : ""); - }} - > By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the{" "} { diff --git a/src/Explorer/QueryCopilot/Modal/__snapshots__/QueryCopilotFeedbackModal.test.tsx.snap b/src/Explorer/QueryCopilot/Modal/__snapshots__/QueryCopilotFeedbackModal.test.tsx.snap index d0b2a3481..f56c85581 100644 --- a/src/Explorer/QueryCopilot/Modal/__snapshots__/QueryCopilotFeedbackModal.test.tsx.snap +++ b/src/Explorer/QueryCopilot/Modal/__snapshots__/QueryCopilotFeedbackModal.test.tsx.snap @@ -76,43 +76,6 @@ exports[`Query Copilot Feedback Modal snapshot test shoud render and match snaps } } /> - - - - - - - By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the - - - Privacy statement - - - for more information. - - - - Submit - - - Cancel - - - - - -`; - -exports[`Query Copilot Feedback Modal snapshot test should record user contact choice no 1`] = ` - -
- - - - Send feedback to Microsoft - - - - - Your feedback will help improve the experience. - - - - - - By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the - - - Privacy statement - - - for more information. - - - - Submit - - - Cancel - - - -
-
-`; - -exports[`Query Copilot Feedback Modal snapshot test should record user contact choice yes 1`] = ` - -
- - - - Send feedback to Microsoft - - - - - Your feedback will help improve the experience. - - - - - - = ({ @@ -98,6 +107,7 @@ export const QueryCopilotPromptbar: React.FC = ({ setGeneratedQueryComments, setQueryResults, setErrorMessage, + errorMessage } = useCopilotStore(); const sampleProps: SamplePromptsProps = { @@ -230,6 +240,16 @@ export const QueryCopilotPromptbar: React.FC = ({ responseCode: response.status, }); } + } else if (response?.status === HttpStatusCodes.TooManyRequests) { + handleError(JSON.stringify(generateSQLQueryResponse), "copilotTooManyRequestError"); + useTabs.getState().setIsQueryErrorThrown(true); + setShowErrorMessageBar(true); + setErrorMessage("Ratelimit exceeded 5 per 1 minute. Please try again after sometime") + TelemetryProcessor.traceFailure(Action.QueryGenerationFromCopilotPrompt, { + databaseName: databaseId, + collectionId: containerId, + responseCode: response.status, + }); } else { handleError(JSON.stringify(generateSQLQueryResponse), "copilotInternalServerError"); useTabs.getState().setIsQueryErrorThrown(true); @@ -361,7 +381,7 @@ export const QueryCopilotPromptbar: React.FC = ({ {isGeneratingQuery && } {showSamplePrompts && ( setShowSamplePrompts(false)} @@ -393,7 +413,7 @@ export const QueryCopilotPromptbar: React.FC = ({ setShowSamplePrompts(false); inputEdited.current = true; }} - onRenderIcon={() => } + onRenderIcon={() => } styles={promptStyles} > {history} @@ -469,7 +489,7 @@ export const QueryCopilotPromptbar: React.FC = ({ {showErrorMessageBar && ( - We ran into an error and were not able to execute query. + {errorMessage ? errorMessage : "We ran into an error and were not able to execute query."} )} {showInvalidQueryMessageBar && ( diff --git a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx index 4793f3791..990bac5c9 100644 --- a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx +++ b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx @@ -443,7 +443,7 @@ export default class QueryTabComponent extends React.Component { this._toggleCopilot(!this.state.copilotActive); }, - commandButtonLabel: "Copilot", + commandButtonLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot", ariaLabel: "Copilot", hasPopup: false, }; diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 24aca7295..30689da49 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -58,19 +58,21 @@ export function useKnockoutExplorer(platform: Platform): Explorer { userContext.features.phoenixNotebooks = true; userContext.features.phoenixFeatures = true; } + let explorer: Explorer; if (platform === Platform.Hosted) { - const explorer = await configureHosted(); - setExplorer(explorer); + explorer = await configureHosted(); } else if (platform === Platform.Emulator) { - const explorer = configureEmulator(); - setExplorer(explorer); + explorer = configureEmulator(); } else if (platform === Platform.Portal) { - const explorer = await configurePortal(); - setExplorer(explorer); + explorer = await configurePortal(); } else if (platform === Platform.Fabric) { - const explorer = await configureFabric(); - setExplorer(explorer); + explorer = await configureFabric(); } + if (explorer && userContext.features.enableCopilot) { + await updateContextForCopilot(explorer); + await updateContextForSampleData(explorer); + } + setExplorer(explorer); } }; effect(); @@ -79,9 +81,6 @@ export function useKnockoutExplorer(platform: Platform): Explorer { useEffect(() => { if (explorer) { applyExplorerBindings(explorer); - if (userContext.features.enableCopilot) { - updateContextForCopilot(explorer).then(() => updateContextForSampleData(explorer)); - } } }, [explorer]);