The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
[Metabot] Send `transforms_codegen` profile on transforms pages again (#68433)
Sloan Spargerd6bb46208f43
diff --git a/e2e/test/scenarios/metabot/transforms-codegen.cy.spec.ts b/e2e/test/scenarios/metabot/transforms-codegen.cy.spec.tsindex e702e52c8cd..842ac058ec9 100644--- a/e2e/test/scenarios/metabot/transforms-codegen.cy.spec.ts+++ b/e2e/test/scenarios/metabot/transforms-codegen.cy.spec.ts@@ -60,6 +60,13 @@ const assertEditorDiffState = (opts: { exists: boolean }) => {.should(should);};+const sendCodgeBotMessage = (message: string) => {+ H.sendMetabotMessage(message);+ cy.wait("@metabotAgent").its("request.body").should("deep.include", {+ profile_id: "transforms_codegen",+ });+};+const assertAcceptRejectUI = (opts: { visible: boolean }) => {const should = opts.visible ? "be.visible" : "not.exist";acceptSuggestionBtn().should(should);@@ -96,7 +103,7 @@ describe(createMockNativeTransformJSON(null, WRITABLE_DB_ID, "SELECT 1"),),});- H.sendMetabotMessage(+ sendCodgeBotMessage("Create a new native SQL transform that gives me the number 1",);assertSuggestionInSidebar({ newSourcePartial: "SELECT 1" });@@ -115,7 +122,7 @@ describe(createMockNativeTransformJSON(null, WRITABLE_DB_ID, "SELECT 2"),),});- H.sendMetabotMessage("Make this give me the number 2 instead");+ sendCodgeBotMessage("Make this give me the number 2 instead");assertSuggestionInSidebar({oldSourcePartial: "SELECT 1",newSourcePartial: "SELECT 2",@@ -137,7 +144,7 @@ describe(createMockNativeTransformJSON(null, WRITABLE_DB_ID, "SELECT 4"),),});- H.sendMetabotMessage("Make this give me the number 4 instead");+ sendCodgeBotMessage("Make this give me the number 4 instead");assertSuggestionInSidebar({oldSourcePartial: "SELECT 3",newSourcePartial: "SELECT 4",@@ -166,7 +173,7 @@ describe(),),});- H.sendMetabotMessage(+ sendCodgeBotMessage("Create a new native python transform that gives me the number 1",);assertSuggestionInSidebar({@@ -192,7 +199,7 @@ describe(),),});- H.sendMetabotMessage("Make this give me the number 2 instead");+ sendCodgeBotMessage("Make this give me the number 2 instead");assertSuggestionInSidebar({oldSourcePartial: "pd.DataFrame({'value': [1]})",newSourcePartial: "pd.DataFrame({'value': [2]})",@@ -226,7 +233,7 @@ describe(),),});- H.sendMetabotMessage("Make this give me the number 4 instead");+ sendCodgeBotMessage("Make this give me the number 4 instead");assertSuggestionInSidebar({oldSourcePartial: "pd.DataFrame({'value': [3]})",newSourcePartial: "pd.DataFrame({'value': [4]})",@@ -274,7 +281,7 @@ describe(),),});- H.sendMetabotMessage(+ sendCodgeBotMessage("Create a transform that queries the Test Model",);assertSuggestionInSidebar({ newSourcePartial: "SELECT * FROM" });@@ -319,7 +326,7 @@ describe(),});});- H.sendMetabotMessage(+ sendCodgeBotMessage("Update my SQL transform to select 2 instead of 1.",);assertSuggestionInSidebar({@@ -352,7 +359,7 @@ describe(),});});- H.sendMetabotMessage("Make this give me the number 4 instead");+ sendCodgeBotMessage("Make this give me the number 4 instead");assertSuggestionInSidebar({oldSourcePartial: "SELECT 3",newSourcePartial: "SELECT 4",@@ -396,7 +403,7 @@ describe(),});});- H.sendMetabotMessage(+ sendCodgeBotMessage("Update my SQL transform to select 2 instead of 1.",);assertSuggestionInSidebar({@@ -438,7 +445,7 @@ describe(),),});- H.sendMetabotMessage("Make this give me the number 4 instead");+ sendCodgeBotMessage("Make this give me the number 4 instead");assertSuggestionInSidebar({oldSourcePartial: "pd.DataFrame({'value': [3]})",newSourcePartial: "pd.DataFrame({'value': [4]})",diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/hooks/use-metabot-agent.ts b/enterprise/frontend/src/metabase-enterprise/metabot/hooks/use-metabot-agent.tsindex 92b083374e5..c41dae91263 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/hooks/use-metabot-agent.ts+++ b/enterprise/frontend/src/metabase-enterprise/metabot/hooks/use-metabot-agent.ts@@ -19,7 +19,6 @@ import {getMetabotReactionsState,getMetabotRequestId,getMetabotVisible,- getProfileOverride,resetConversation as resetConversationAction,retryPrompt,setProfileOverride as setProfileOverrideAction,@@ -172,9 +171,6 @@ export const useMetabotAgent = (agentId: MetabotAgentId = "omnibot") => {getActiveToolCalls(state, agentId),),debugMode: useMetabotSelector(getDebugMode),- profileOverride: useMetabotSelector((state) =>- getProfileOverride(state, agentId),- ),reactions: useMetabotSelector(getMetabotReactionsState),};};diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/state/selectors.ts b/enterprise/frontend/src/metabase-enterprise/metabot/state/selectors.tsindex 855e3d5c900..ca10a262b71 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/state/selectors.ts+++ b/enterprise/frontend/src/metabase-enterprise/metabot/state/selectors.ts@@ -1,7 +1,9 @@import { createSelector } from "@reduxjs/toolkit";+import { match } from "ts-pattern";import _ from "underscore";import { getIsEmbedding } from "metabase/selectors/embed";+import { Urls } from "metabase-enterprise/urls";import type { TransformId } from "metabase-types/api";import {@@ -195,17 +197,34 @@ export const getProfileOverride = createSelector((convo) => convo.profileOverride,);+export const getProfile = createSelector(+ [getProfileOverride, getDebugMode],+ (profileOverride, debugMode) => {+ const isTransformsPage = location.pathname.startsWith(Urls.transformList());+ return match({ debugMode, isTransformsPage })+ .with(+ { debugMode: false, isTransformsPage: true },+ () => "transforms_codegen",+ )+ .with(+ { debugMode: true, isTransformsPage: true },+ () => profileOverride ?? "transforms_codegen",+ )+ .otherwise(() => profileOverride);+ },+);+export const getAgentRequestMetadata = createSelector(getHistory,getMetabotRequestState,- getProfileOverride,- (history, state, profileOverride) => ({+ getProfile,+ (history, state, profile) => ({state,// NOTE: need end to end support for ids on messages as BE will error if ids are presenthistory: history.map((h) =>h.id && h.id.startsWith(`msg_`) ? _.omit(h, "id") : h,),- ...(profileOverride ? { profile_id: profileOverride } : {}),+ ...(profile ? { profile_id: profile } : {}),}),);