Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

feat(sdk-bundle, embed-js): stacked layout updates for metabot question (#64573)

Phoomparin Mano2feb85417dc6
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
index b14ef150b26..a7228aed53b 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
@@ -413,6 +413,11 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
"data-layout",
"sidebar",
);
+
+ cy.log("should show disclaimer text in sidebar layout");
+ cy.findAllByText("AI isn't perfect. Double-check results.").should(
+ "be.visible",
+ );
});
});
@@ -426,6 +431,11 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
H.getSimpleEmbedIframeContent()
.findByTestId("metabot-question-container")
.should("have.attr", "data-layout", "stacked");
+
+ cy.log("should show disclaimer text in stacked layout");
+ H.getSimpleEmbedIframeContent()
+ .findAllByText("AI isn't perfect. Double-check results.")
+ .should("be.visible");
});
});
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatHistory.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatHistory.tsx
index 684f74ee289..85b0a1c3eba 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatHistory.tsx
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatHistory.tsx
@@ -9,6 +9,8 @@ import {
} from "metabase-enterprise/metabot/hooks";
import { useMetabotReactions } from "metabase-enterprise/metabot/hooks/use-metabot-reactions";
+import S from "./MetabotQuestion.module.css";
+
export function MetabotChatHistory() {
const metabot = useMetabotAgent();
const { messages, errorMessages } = metabot;
@@ -33,6 +35,7 @@ export function MetabotChatHistory() {
gap={0}
style={{ overflowY: "auto" }}
p="md"
+ className={S.chatHistory}
>
{hasMessages ? (
<Messages
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatInput.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatInput.tsx
index 0c081008e64..0ff65fcff3b 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatInput.tsx
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotChatInput.tsx
@@ -1,3 +1,4 @@
+import cx from "classnames";
import { t } from "ttag";
import { useSdkDispatch } from "embedding-sdk-bundle/store";
@@ -91,9 +92,8 @@ export function MetabotChatInput() {
<Flex align="center" justify="center" gap="xs">
{metabot.isDoingScience && (
<UnstyledButton
- data-testid="metabot-cancel-request"
onClick={cancelRequest}
- className={S.chatButton}
+ className={cx(S.chatButton, S.stopGenerationButton)}
>
<Tooltip label={t`Stop generation`}>
<Icon name="stop" c="var(--mb-color-text-secondary)" />
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.module.css b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.module.css
index 0a3833fb7b6..37de4c33539 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.module.css
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.module.css
@@ -18,7 +18,12 @@
border-left: 1px solid var(--mb-color-border);
}
- .stackedOverflowButton {
+ /**
+ We already have disclaimer in the sidebar, so we don't
+ need to repeat it in the empty state.
+ */
+ .stackedOverflowButton,
+ .emptyStateDisclaimerText {
display: none;
}
}
@@ -37,7 +42,6 @@
height: 40%;
width: 100%;
max-width: none;
- border-top: 1px solid var(--mb-color-border);
border-left: none;
}
@@ -57,6 +61,16 @@
background-color: var(--mb-color-brand-lighter);
}
}
+
+ .stopGenerationButton {
+ width: 1.3rem;
+ height: 1.3rem;
+ }
+
+ /** Only show the top border when there are messages. */
+ .chatHistory:not(:empty) {
+ border-top: 1px solid var(--mb-color-border);
+ }
}
}
@@ -72,7 +86,7 @@
text-align: left;
line-height: 1.4;
padding: 0.5rem 0.75rem;
- width: 100%;
+ width: fit-content;
border-radius: 8px;
border: 1px solid var(--mb-color-border);
background-color: var(--mb-color-bg-white);
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.stories.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.stories.tsx
index 1ef16d099eb..b1ab1e2990e 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.stories.tsx
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestion.stories.tsx
@@ -33,17 +33,9 @@ export const FullWidth = {
export const Centered = {
render() {
return (
- <Stack align="center" justify="center">
- <Flex
- m="40px"
- style={{
- border: "1px solid var(--mb-color-border)",
- borderRadius: "16px",
- }}
- >
- <MetabotQuestion height="calc(100vh - 90px)" />
- </Flex>
- </Stack>
+ <CenteredLayoutPreview>
+ <MetabotQuestion height="calc(100vh - 90px)" />
+ </CenteredLayoutPreview>
);
},
};
@@ -90,17 +82,9 @@ export const MultipleInstances = {
export const SidebarLayout = {
render() {
return (
- <Stack align="center" justify="center">
- <Flex
- m="40px"
- style={{
- border: "1px solid var(--mb-color-border)",
- borderRadius: "16px",
- }}
- >
- <MetabotQuestion height="calc(100vh - 90px)" layout="sidebar" />
- </Flex>
- </Stack>
+ <CenteredLayoutPreview>
+ <MetabotQuestion height="calc(100vh - 90px)" layout="sidebar" />
+ </CenteredLayoutPreview>
);
},
};
@@ -108,17 +92,24 @@ export const SidebarLayout = {
export const StackedLayout = {
render() {
return (
- <Stack align="center" justify="center">
- <Flex
- m="40px"
- style={{
- border: "1px solid var(--mb-color-border)",
- borderRadius: "16px",
- }}
- >
- <MetabotQuestion height="calc(100vh - 90px)" layout="stacked" />
- </Flex>
- </Stack>
+ <CenteredLayoutPreview>
+ <MetabotQuestion height="calc(100vh - 90px)" layout="stacked" />
+ </CenteredLayoutPreview>
);
},
};
+
+const CenteredLayoutPreview = ({ children }: { children: React.ReactNode }) => (
+ <Stack align="center" justify="center">
+ <Flex
+ m="40px"
+ bg="var(--mb-color-background)"
+ style={{
+ border: "1px solid var(--mb-color-border)",
+ borderRadius: "16px",
+ }}
+ >
+ {children}
+ </Flex>
+ </Stack>
+);
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestionEmptyState.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestionEmptyState.tsx
index a67c5a63242..b2e570bcbbd 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestionEmptyState.tsx
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/public/MetabotQuestion/MetabotQuestionEmptyState.tsx
@@ -2,13 +2,22 @@ import { t } from "ttag";
import { Icon, Stack, Text } from "metabase/ui";
+import S from "./MetabotQuestion.module.css";
+
export const MetabotQuestionEmptyState = () => (
- <Stack h="100%" w="100%" gap="lg" align="center" justify="center">
- <Icon name="ai" c="var(--mb-color-bg-black)" size="5rem" opacity={0.25} />
+ <Stack h="100%" w="100%" gap="sm" align="center" justify="center">
+ <Icon name="ai" c="text-tertiary" size="3rem" opacity={0.7} />
<Stack gap="xs" align="center">
- <Text lh="md">{t`Ask questions to AI.`}</Text>
- <Text lh="md">{t`Results will appear here.`}</Text>
+ <Text lh="sm">{t`Ask questions to AI.`}</Text>
+ <Text lh="sm">{t`Results will appear here.`}</Text>
</Stack>
+
+ <Text
+ className={S.emptyStateDisclaimerText}
+ lh="sm"
+ fz="sm"
+ c="text-tertiary"
+ >{t`AI isn't perfect. Double-check results.`}</Text>
</Stack>
);