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] Reasoning style updates (#80127)
Sloan Sparger8ed4b9d8dc85
diff --git a/frontend/src/metabase/metabot/components/AIMarkdown/AIMarkdown.module.css b/frontend/src/metabase/metabot/components/AIMarkdown/AIMarkdown.module.cssindex d5ad83a729a..e316322926d 100644--- a/frontend/src/metabase/metabot/components/AIMarkdown/AIMarkdown.module.css+++ b/frontend/src/metabase/metabot/components/AIMarkdown/AIMarkdown.module.css@@ -122,13 +122,16 @@}.aiMarkdown code {+ background: var(--mb-color-background_surface-secondary);color: var(--mb-color-text-primary);padding: 0.125rem 0.375rem;+ border-color: var(--mb-color-border-neutral-strong);}.aiMarkdown pre code {font-size: 0.6875rem;line-height: 1.5;+ background: transparent;padding: 0;}@@ -165,12 +168,7 @@font-weight: 700;padding: 0.125rem;border-radius: var(--mantine-radius-sm);- transition: 200ms background-color;outline: none;-- &:hover {- background-color: var(--mb-color-background_surface-hover);- }}.smartLinkInner {diff --git a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.module.css b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.module.cssindex 7c158e0eaa8..204fb5b533a 100644--- a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.module.css+++ b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.module.css@@ -7,7 +7,11 @@align-items: center;gap: 0.375rem;width: 100%;- color: var(--mb-color-text-tertiary);+ color: var(--mb-color-text-secondary);+}++.trigger:hover {+ color: var(--mb-color-text-primary);}.headerLabel {@@ -28,72 +32,6 @@transform: rotate(90deg);}-/* background-clip:text can't reach an SVG, so the caret fakes the shimmer with a- color with %'s timed to shimmer animation */-.chevronShimmer {- animation: chevron-pulse 1500ms linear infinite;-}--@keyframes chevron-pulse {- 0%,- 47% {- color: var(--mb-color-text-tertiary);- }-- 57% {- color: var(--mb-color-border-neutral);- }-- 100% {- color: var(--mb-color-text-tertiary);- }-}--@media (prefers-reduced-motion: reduce) {- .chevronShimmer {- animation: none;- }-}--.shimmer {- /* both colors stay in the text family (a lighter highlight over the resting- tone) so the sweep reads as a sheen rather than a spotlight */- --base-color: var(--mb-color-text-tertiary);- --highlight-color: var(--mb-color-border-neutral);-- color: transparent !important;- background-clip: text;- -webkit-background-clip: text;- background-size: 200% 100%;- background-image: linear-gradient(- 135deg,- var(--base-color) 15%,- var(--highlight-color) 50%,- var(--base-color) 85%- );- background-position: 110% 0;- animation: rotate-background 1500ms linear infinite;-}--/* 200% of travel = one full tile, so the loop is pixel-identical at the seam */-@keyframes rotate-background {- 0% {- background-position: 110% 0;- }-- 100% {- background-position: -90% 0;- }-}--@media (prefers-reduced-motion: reduce) {- .shimmer {- animation: none;- color: var(--base-color) !important;- background-image: none;- }-}-.step {display: flex;flex-direction: column;@@ -118,23 +56,36 @@gap: 0.5rem;width: 100%;line-height: 1.57;- color: var(--mb-color-text-tertiary);+ color: var(--mb-color-text-secondary);+}++.toolRow:not(.toolRowStatic):hover {+ color: var(--mb-color-text-primary);}.toolRowStatic {cursor: default;}+/* the loader inherits the row's text color instead of the brand color so an+ * in-progress step reads as one unit, hover included */+.stepLoader {+ flex-shrink: 0;+ margin-right: -0.0625rem;++ --loader-color: currentcolor;+}+.toolRow a,.headerLabel a {- color: var(--mb-color-text-tertiary);- font-weight: 500;+ color: inherit;+ font-weight: 700;text-decoration: none;}.toolRow a span,.headerLabel a span {- border-bottom-color: var(--mb-color-border-subtle);+ border-bottom: none;}.toolRow a svg,@@ -149,11 +100,6 @@text-decoration: none;}-.toolRow a:hover span,-.headerLabel a:hover span {- border-bottom-color: var(--mb-color-brand);-}-/* carets stay out of the way until the step is hovered/focused */.toolRow .chevron {opacity: 0;@@ -172,10 +118,14 @@color: var(--mb-color-text-secondary);}+.nested {+ margin-left: 1rem;+}+.resultCount {margin-left: 0.375rem;font-variant-numeric: tabular-nums;- opacity: 0.6;+ color: var(--mb-color-text-tertiary);}.resultsList {@@ -220,10 +170,10 @@text-overflow: ellipsis;white-space: nowrap;font-size: 0.75rem;- color: var(--mb-color-text-tertiary);+ color: var(--mb-color-text-secondary);}.contextSeparator {margin: 0 0.25rem;- color: var(--mb-color-text-tertiary);+ color: var(--mb-color-text-secondary);}diff --git a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.tsx b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.tsxindex a494cd82b9c..397362e8f48 100644--- a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.tsx+++ b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/MetabotChainOfThought.tsx@@ -30,7 +30,7 @@ export const MetabotChainOfThought = ({}) => {const { open, toggle } = useAutoCollapseOnSettle(isStreaming);const now = useNow(isStreaming);- const preview = useMeteredLabel(latestPreviewLabel(message.steps));+ const preview = useMeteredLabel(latestPreviewLabel(message.steps), !open);const renderableItems = buildDisplayItems(message.steps);@@ -78,22 +78,13 @@ export const MetabotChainOfThought = ({onClick={toggle}data-testid="metabot-chain-of-thought-header">- <Text- component="span"- className={cx(S.headerLabel, isStreaming && S.shimmer)}- c="currentColor"- >+ <Text component="span" className={S.headerLabel} c="currentColor">{headerContent}</Text><Iconname="chevronright"size={10}- className={cx(- S.chevron,- Animation.fadeIn,- isStreaming && S.chevronShimmer,- open && S.chevronOpen,- )}+ className={cx(S.chevron, Animation.fadeIn, open && S.chevronOpen)}/></UnstyledButton><Collapse in={open}>diff --git a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/ReasoningStep.tsx b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/ReasoningStep.tsxindex 3463d651313..11e1b5a3379 100644--- a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/ReasoningStep.tsx+++ b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/ReasoningStep.tsx@@ -35,7 +35,7 @@ export const ReasoningStep = ({/></UnstyledButton><Collapse in={open}>- <div className={cx(S.reasoningBody, Animation.fadeIn)}>+ <div className={cx(S.reasoningBody, S.nested, Animation.fadeIn)}><AIMarkdown isStreaming={active}>{text}</AIMarkdown></div></Collapse>diff --git a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/SearchResults.tsx b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/SearchResults.tsxindex 0e843723ad2..eb8b07b590e 100644--- a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/SearchResults.tsx+++ b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/SearchResults.tsx@@ -95,7 +95,7 @@ export const SearchResultsList = ({return null;}return (- <div className={S.resultsList}>+ <div className={cx(S.resultsList, S.nested)}>{step.searchResults.results.map((result, i) => (<SearchResultRowkey={`${result.type}-${result.id}`}diff --git a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/hooks.ts b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/hooks.tsindex 81ea7d55da8..8ef671fef00 100644--- a/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/hooks.ts+++ b/frontend/src/metabase/metabot/components/MetabotChat/MetabotChainOfThought/hooks.ts@@ -24,13 +24,21 @@ export const useAutoCollapseOnSettle = (isStreaming: boolean) => {return { open, toggle };};-export const useMeteredLabel = (target: string): string => {+// meter quick bursts of steps to prevent strobing when enabled+export const useMeteredLabel = (target: string, enabled: boolean): string => {const [shown, setShown] = useState(target);const queueRef = useRef<string[]>([]);const lastRef = useRef(target);const lockedRef = useRef(false);useEffect(() => {+ if (!enabled) {+ queueRef.current = [];+ lockedRef.current = false;+ lastRef.current = target;+ setShown(target);+ return;+ }if (target === lastRef.current) {return;}@@ -41,7 +49,7 @@ export const useMeteredLabel = (target: string): string => {lockedRef.current = true;setShown(target);}- }, [target]);+ }, [target, enabled]);useEffect(() => {if (!lockedRef.current) {@@ -58,5 +66,5 @@ export const useMeteredLabel = (target: string): string => {return () => clearTimeout(id);}, [shown]);- return shown;+ return enabled ? shown : target;};