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] Remove explain chart button (#80355)
Sloan Sparger92ab58c48035
diff --git a/docs/ai/metabot.md b/docs/ai/metabot.mdindex 408ad5d0fe4..531dfedebd1 100644--- a/docs/ai/metabot.md+++ b/docs/ai/metabot.md@@ -64,9 +64,9 @@ Hover over Metabot's response to:-When viewing a question, you can click the Metabot icon in the upper right to analyze a visualization. You can also open the command palette to tell Metabot to analyze the chart.+When viewing a question, open the [chat sidebar](#the-metabot-chat-sidebar) and ask Metabot to analyze the chart.-When viewing a table of results, Metabase won't display the Metabot button, but you can open the chat to ask Metabot to analyze the table, and it will produce an [X-ray](../exploration-and-organization/x-rays.md) of the results.+When viewing a table of results, ask Metabot in the chat to analyze the table, and it will produce an [X-ray](../exploration-and-organization/x-rays.md) of the results.You can also ask Metabot to tell you about specific tables in your database.diff --git a/e2e/test/scenarios/metabot/metabot.cy.spec.ts b/e2e/test/scenarios/metabot/metabot.cy.spec.tsindex 5ef6b783d2e..5d4fb37c22e 100644--- a/e2e/test/scenarios/metabot/metabot.cy.spec.ts+++ b/e2e/test/scenarios/metabot/metabot.cy.spec.ts@@ -130,15 +130,6 @@ describe("Metabot UI", () => {H.expectNoBadSnowplowEvents();});- it("should track Metabot chart explainer", () => {- H.visitQuestion(ORDERS_BY_YEAR_QUESTION_ID);- cy.findByLabelText("Explain this chart").should("be.visible").click();-- H.expectUnstructuredSnowplowEvent({- event: "metabot_explain_chart_clicked",- });- });-describe("Metabot chat", () => {beforeEach(() => {cy.visit("/");@@ -229,7 +220,6 @@ describe("Metabot in full-app embedding", () => {});H.appBar().icon("metabot").should("be.visible");- cy.findByLabelText("Explain this chart").should("not.exist");});it("should not show the metabot button when embedded-metabot-enabled? is false", () => {@@ -245,7 +235,6 @@ describe("Metabot in full-app embedding", () => {cy.log("Assert metabot buttons are not rendered");H.appBar().icon("metabot").should("not.exist");- cy.findByLabelText("Explain this chart").should("not.exist");});});diff --git a/frontend/src/metabase/metabot/analytics.ts b/frontend/src/metabase/metabot/analytics.tsindex 27e97446ef7..be8491632db 100644--- a/frontend/src/metabase/metabot/analytics.ts+++ b/frontend/src/metabase/metabot/analytics.ts@@ -20,9 +20,3 @@ export const trackQueryFixClicked = () => {event: "metabot_fix_query_clicked",});};--export const trackExplainChartClicked = () => {- trackSimpleEvent({- event: "metabot_explain_chart_clicked",- });-};diff --git a/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.tsx b/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.tsxdeleted file mode 100644index f933858c788..00000000000--- a/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.tsx+++ /dev/null@@ -1,49 +0,0 @@-import { t } from "ttag";--import { ToolbarButton } from "metabase/common/components/ToolbarButton";-import { useToast } from "metabase/common/hooks/use-toast";-import {- useMetabotAgent,- useUserMetabotPermissions,-} from "metabase/metabot/hooks";-import { useSetting } from "metabase/settings";--import { trackExplainChartClicked } from "../analytics";--import { getMetabotNotConfiguredToastProps } from "./AIProviderConfigurationNotice";--export const AIQuestionAnalysisButton = () => {- const { hasMetabotAccess, canUseMetabot } = useUserMetabotPermissions();- const { submitInput } = useMetabotAgent("omnibot");- const metabotName = useSetting("metabot-name");- const [sendToast] = useToast();-- if (!hasMetabotAccess) {- return null;- }-- const handleClick = () => {- if (!canUseMetabot) {- sendToast(- getMetabotNotConfiguredToastProps({- featureName: metabotName,- }),- );- return;- }-- trackExplainChartClicked();- submitInput("Analyze this chart");- };-- const tooltipLabel = t`Explain this chart`;-- return (- <ToolbarButton- aria-label={tooltipLabel}- tooltipLabel={tooltipLabel}- icon={"metabot"}- onClick={handleClick}- />- );-};diff --git a/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.unit.spec.tsx b/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.unit.spec.tsxdeleted file mode 100644index 7c39ba1f2f9..00000000000--- a/frontend/src/metabase/metabot/components/AIQuestionAnalysisButton.unit.spec.tsx+++ /dev/null@@ -1,112 +0,0 @@-import userEvent from "@testing-library/user-event";--import { setupEnterprisePlugins } from "__support__/enterprise";-import { setupUserMetabotPermissionsEndpoint } from "__support__/server-mocks";-import { mockSettings } from "__support__/settings";-import { renderWithProviders, screen } from "__support__/ui";-import { mockStreamedEndpoint } from "metabase/api/ai-streaming/test-utils";-import { MetabotProvider } from "metabase/metabot/context";-import {- createTestMetabotState,- lastReqBody,-} from "metabase/metabot/tests/utils";-import { createMockState } from "metabase/redux/store/mocks";--import { AIQuestionAnalysisButton } from "./AIQuestionAnalysisButton";--const mockAgentEndpoint = () =>- mockStreamedEndpoint("/api/metabot/agent-streaming", {- events: [- { type: "text-start", id: "t1" },- {- type: "text-delta",- id: "t1",- delta: "Here is an analysis of the chart.",- },- { type: "text-end", id: "t1" },- ],- });--function setup({- isMetabotEnabled = true,- isConfigured = true,-}: { isMetabotEnabled?: boolean; isConfigured?: boolean } = {}) {- const settings = mockSettings({- "llm-metabot-configured?": isConfigured,- "metabot-enabled?": isMetabotEnabled,- });-- setupUserMetabotPermissionsEndpoint();- setupEnterprisePlugins();-- const metabotState = createTestMetabotState({- conversationTitle: "Chart analysis",- });-- renderWithProviders(- <MetabotProvider>- <AIQuestionAnalysisButton />- </MetabotProvider>,- {- // Unjustified type cast. FIXME- storeInitialState: createMockState({- settings,- metabot: metabotState,- } as any),- withUndos: true,- },- );-}--describe("AIQuestionAnalysisButton", () => {- beforeEach(() => {- jest.clearAllMocks();- });-- it("should render the button when metabot is enabled", async () => {- setup({ isMetabotEnabled: true });- expect(- await screen.findByRole("button", { name: "Explain this chart" }),- ).toBeInTheDocument();- });-- it("should render the button when metabot is enabled but not configured", async () => {- setup({ isConfigured: false, isMetabotEnabled: true });- expect(- await screen.findByRole("button", { name: "Explain this chart" }),- ).toBeInTheDocument();- });-- it("should not render the button when metabot is disabled", () => {- setup({ isMetabotEnabled: false });- expect(- screen.queryByRole("button", { name: "Explain this chart" }),- ).not.toBeInTheDocument();- });-- it("should submit analyze prompt when clicked", async () => {- const agentSpy = mockAgentEndpoint();- setup({ isMetabotEnabled: true });-- await userEvent.click(- await screen.findByRole("button", { name: "Explain this chart" }),- );-- const body = await lastReqBody(agentSpy);- expect(body.message).toBe("Analyze this chart");- });-- it("should show the not-configured toast instead of submitting when AI is not configured", async () => {- const agentSpy = mockAgentEndpoint();-- setup({ isConfigured: false, isMetabotEnabled: true });-- await userEvent.click(- await screen.findByRole("button", { name: "Explain this chart" }),- );-- expect(await screen.findByTestId("toast-undo")).toBeInTheDocument();- expect(await screen.findByText(/connect to a model/)).toBeInTheDocument();- expect(agentSpy).not.toHaveBeenCalled();- });-});diff --git a/frontend/src/metabase/metabot/utils/chart-analysis.ts b/frontend/src/metabase/metabot/utils/chart-analysis.tsindex ab5a647fcfb..541bd77a3ae 100644--- a/frontend/src/metabase/metabot/utils/chart-analysis.ts+++ b/frontend/src/metabase/metabot/utils/chart-analysis.ts@@ -1,49 +1,4 @@-import type {- CustomVizDisplayType,- VisualizationDisplay,-} from "metabase-types/api";-import { isCustomVizDisplay } from "metabase-types/guards";--const CHART_ANALYSIS_ENABLED = {- // enabled- area: true,- bar: true,- boxplot: true,- combo: true,- funnel: true,- gauge: true,- line: true,- map: true,- pie: true,- progress: true,- row: true,- sankey: true,- scatter: true,- treemap: true,- waterfall: true,- // disabled- action: false,- "audit-table": false,- heading: false,- iframe: false,- link: false,- object: false,- pivot: false,- placeholder: false,- scalar: false,- smartscalar: false,- table: false,- text: false,- list: false,-} as const satisfies {- [display in Exclude<VisualizationDisplay, CustomVizDisplayType>]: boolean;-};--type EnabledChartTypes = {- [K in keyof typeof CHART_ANALYSIS_ENABLED]: (typeof CHART_ANALYSIS_ENABLED)[K] extends true- ? K- : never;-}[keyof typeof CHART_ANALYSIS_ENABLED];+import type { VisualizationDisplay } from "metabase-types/api";// SVG renderer is faster + preferred, since it clones the existing SVG DOM node. However, in the// following cases we need to fallback to the slower PNG approach:@@ -66,10 +21,6 @@ export const CHART_ANALYSIS_RENDER_FORMATS = {scatter: "svg",treemap: "svg",waterfall: "svg",-} as const satisfies { [display in EnabledChartTypes]: "png" | "svg" | "none" };--export const canAnalyzeQuestion = (display: VisualizationDisplay) => {- return isCustomVizDisplay(display)- ? false- : (CHART_ANALYSIS_ENABLED[display] ?? false);-};+} as const satisfies Partial<+ Record<VisualizationDisplay, "png" | "svg" | "none">+>;diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/ViewTitleHeaderRightSide/ViewTitleHeaderRightSide.tsx b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/ViewTitleHeaderRightSide/ViewTitleHeaderRightSide.tsxindex aa968a28feb..248522c440c 100644--- a/frontend/src/metabase/query_builder/components/view/ViewHeader/components/ViewTitleHeaderRightSide/ViewTitleHeaderRightSide.tsx+++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/components/ViewTitleHeaderRightSide/ViewTitleHeaderRightSide.tsx@@ -4,8 +4,6 @@ import { useCallback } from "react";import { t } from "ttag";import { getUserCanWriteToCollections } from "metabase/current-user";-import { AIQuestionAnalysisButton } from "metabase/metabot/components/AIQuestionAnalysisButton";-import { canAnalyzeQuestion } from "metabase/metabot/utils/chart-analysis";import { useRegisterShortcut } from "metabase/palette/hooks/useRegisterShortcut";import { canExploreResults } from "metabase/query_builder/components/view/ViewHeader/utils";import { RunButtonWithTooltip } from "metabase/querying/components/QueryVisualization/RunButtonWithTooltip";@@ -226,9 +224,6 @@ export function ViewTitleHeaderRightSide({{!isShowingNotebook && (hasSaveButton || isSaved) && (<QuestionSharingMenu question={question} />)}- {!isShowingNotebook && canAnalyzeQuestion(question.card().display) ? (- <AIQuestionAnalysisButton />- ) : null}{isSaved && (<QuestionActionsquestion={question}