Skip to content

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

Show running subexplorations in the sidebar, change the icon (#82517)

Kevin Kelleherc9246e3a02e6
diff --git a/frontend/src/metabase-types/api/icon.ts b/frontend/src/metabase-types/api/icon.ts
index b5459f9b796..c226ccd56a6 100644
--- a/frontend/src/metabase-types/api/icon.ts
+++ b/frontend/src/metabase-types/api/icon.ts
@@ -70,6 +70,7 @@ export type IconName =
| "connections"
| "contract"
| "copy"
+ | "corner_down_right"
| "corner_up_right"
| "curved"
| "database"
diff --git a/frontend/src/metabase/explorations/components/ExplorationSidebar/ExplorationTreeNode.tsx b/frontend/src/metabase/explorations/components/ExplorationSidebar/ExplorationTreeNode.tsx
index fd4d75b2bcd..3c6681f5b07 100644
--- a/frontend/src/metabase/explorations/components/ExplorationSidebar/ExplorationTreeNode.tsx
+++ b/frontend/src/metabase/explorations/components/ExplorationSidebar/ExplorationTreeNode.tsx
@@ -64,7 +64,7 @@ const HEADING_ICON: Record<
{ name: IconProps["name"]; color: IconProps["c"] }
> = {
root: { name: "insight", color: "brand" },
- "sub-exploration": { name: "git_branch", color: "brand" },
+ "sub-exploration": { name: "corner_down_right", color: "brand" },
"metric-group": { name: "metric", color: "text-secondary" },
};
diff --git a/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.ts b/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.ts
index 5bd0d156c84..3e60263e8a1 100644
--- a/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.ts
+++ b/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.ts
@@ -67,6 +67,12 @@ export interface ExplorationTreeDocument {
type: "document";
}
+function isExplorationTreeHeading(
+ node: ITreeNodeItem<ExplorationTreeNode>,
+): node is ITreeNodeItem<ExplorationTreeHeading> {
+ return node.data?.type === "heading";
+}
+
function isExplorationTreePage(
node: ITreeNodeItem<ExplorationTreeNode>,
): node is ITreeNodeItem<ExplorationTreePage> {
@@ -108,7 +114,10 @@ export type InitialSidebarEntity =
export type SelectedSidebarEntity = InitialSidebarEntity;
-type TreeItemFilter = (treeItem: ITreeNodeItem<ExplorationTreeNode>) => boolean;
+type TreeItemFilter = (treeItem: ITreeNodeItem<ExplorationTreeItem>) => boolean;
+type TreeHeadingFilter = (
+ treeHeading: ITreeNodeItem<ExplorationTreeHeading>,
+) => boolean;
function collectHeadingPages(
nodes: ITreeNodeItem<ExplorationTreeNode>[],
@@ -145,13 +154,11 @@ function getSummaryDocumentNode(
};
}
-export function getExplorationSidebarTree(
+function getExplorationSidebarTree(
exploration: Exploration,
treeItemFilter: TreeItemFilter,
+ treeHeadingFilter: TreeHeadingFilter,
sortOrder: ExplorationSortOrder = DEFAULT_SORT_ORDER,
- {
- keepEmptyRestartableThreads = false,
- }: { keepEmptyRestartableThreads?: boolean } = {},
): ITreeNodeItem<ExplorationTreeNode>[] {
const threads = exploration.threads ?? [];
const initialThreadId = threads[0]?.id;
@@ -245,7 +252,7 @@ export function getExplorationSidebarTree(
}
});
- const pruned = pruneEmptyHeadings(topLevel, keepEmptyRestartableThreads);
+ const pruned = pruneHeadings(topLevel, treeHeadingFilter);
const summaryNode = getSummaryDocumentNode(exploration.document);
if (summaryNode != null && treeItemFilter(summaryNode)) {
@@ -304,38 +311,21 @@ function getInterestingnessByPageKey(
return interestingnessByPageKey;
}
-function isEmptyRestartableThreadHeading(
- node: ITreeNodeItem<ExplorationTreeNode>,
-): boolean {
- const data = node.data;
- return (
- data?.type === "heading" &&
- data.thread != null &&
- isRestartableExplorationThreadStatus(data.thread.status)
- );
-}
-
-function pruneEmptyHeadings(
+function pruneHeadings(
nodes: ITreeNodeItem<ExplorationTreeNode>[],
- keepEmptyRestartableThreads: boolean,
+ treeHeadingFilter: TreeHeadingFilter,
): ITreeNodeItem<ExplorationTreeNode>[] {
return nodes
.map((node) =>
node.children?.length
? {
...node,
- children: pruneEmptyHeadings(
- node.children,
- keepEmptyRestartableThreads,
- ),
+ children: pruneHeadings(node.children, treeHeadingFilter),
}
: node,
)
.filter(
- (node) =>
- node.data?.type !== "heading" ||
- (node.children?.length ?? 0) > 0 ||
- (keepEmptyRestartableThreads && isEmptyRestartableThreadHeading(node)),
+ (node) => !isExplorationTreeHeading(node) || treeHeadingFilter(node),
);
}
@@ -403,7 +393,7 @@ function getExplorationQueryTree(
const headings: ITreeNodeItem<ExplorationTreeNode>[] = blocks.map((block) => {
const children: ITreeNodeItem<ExplorationTreeNode>[] = block.pages
- .map((page): ITreeNodeItem<ExplorationTreeNode> | null => {
+ .map((page): ITreeNodeItem<ExplorationTreeItem> | null => {
const queries = page.query_ids
.map((id) => queriesById.get(id))
.filter((q): q is ExplorationQuery => q != null);
@@ -435,7 +425,7 @@ function getExplorationQueryTree(
};
})
.filter(
- (node): node is ITreeNodeItem<ExplorationTreeNode> =>
+ (node): node is ITreeNodeItem<ExplorationTreeItem> =>
node != null && treeItemFilter(node),
);
@@ -615,25 +605,24 @@ export function getExplorationSidebarModel({
showHidden: boolean;
sortOrder?: ExplorationSortOrder;
}): ExplorationSidebarModel {
- const tabFilter = tabsInfo[selectedSidebarTab].treeItemFilter;
+ const { treeItemFilter: tabItemFilter, treeHeadingFilter } =
+ tabsInfo[selectedSidebarTab];
const treeItemFilter = showHidden
- ? tabFilter
- : (node: ITreeNodeItem<ExplorationTreeNode>) =>
- tabFilter(node) && !isHiddenTreeItem(node);
+ ? tabItemFilter
+ : (node: ITreeNodeItem<ExplorationTreeItem>) =>
+ tabItemFilter(node) && !isHiddenTreeItem(node);
- // Empty failed/canceled threads only belong on All
- const keepEmptyRestartableThreads = selectedSidebarTab === "all";
const tree = getExplorationSidebarTree(
exploration,
treeItemFilter,
+ treeHeadingFilter,
sortOrder,
- { keepEmptyRestartableThreads },
);
const treeWithHidden = getExplorationSidebarTree(
exploration,
- tabFilter,
+ tabItemFilter,
+ treeHeadingFilter,
sortOrder,
- { keepEmptyRestartableThreads },
);
const hasPages = treeHasPages(tree);
@@ -688,6 +677,7 @@ export type ExplorationSidebarTabsInfo = Record<
value: ExplorationSidebarTab;
label: string;
treeItemFilter: TreeItemFilter;
+ treeHeadingFilter: TreeHeadingFilter;
emptyTreeMessage: string;
}
>;
@@ -710,6 +700,19 @@ export function getExplorationSidebarTabsInfo(
value: "all",
label: t`All`,
treeItemFilter: () => true,
+ treeHeadingFilter: (node) => {
+ if ((node.children?.length ?? 0) > 0) {
+ return true;
+ }
+ const status = node.data?.thread?.status;
+ // Empty pending/running threads still show a loading row; empty
+ // failed/canceled threads stay so Restart remains reachable.
+ return (
+ status === "pending" ||
+ status === "running" ||
+ (status != null && isRestartableExplorationThreadStatus(status))
+ );
+ },
emptyTreeMessage: t`Nothing to see here yet.`,
},
stars: {
@@ -719,6 +722,7 @@ export function getExplorationSidebarTabsInfo(
isExplorationTreePage(node) &&
node.data?.page_id != null &&
starredPageIds.has(node.data.page_id),
+ treeHeadingFilter: (node) => (node.children?.length ?? 0) > 0,
emptyTreeMessage: t`Nothing's been starred yet.`,
},
discussions: {
@@ -728,6 +732,7 @@ export function getExplorationSidebarTabsInfo(
isExplorationTreePage(node) &&
node.data?.page_id != null &&
discussionPageIds.has(node.data.page_id),
+ treeHeadingFilter: (node) => (node.children?.length ?? 0) > 0,
emptyTreeMessage: t`No discussions yet.`,
},
};
diff --git a/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.unit.spec.ts b/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.unit.spec.ts
index e81fb2dd38d..84f04a7f83d 100644
--- a/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.unit.spec.ts
+++ b/frontend/src/metabase/explorations/components/ExplorationSidebar/utils.unit.spec.ts
@@ -16,29 +16,41 @@ import {
getCompactRelativeTime,
getExplorationSidebarModel,
getExplorationSidebarTabsInfo,
- getExplorationSidebarTree,
getShimmerDelayStyle,
isHiddenTreeItem,
pickInitialSidebarEntity,
pickInitialSidebarPage,
} from "./utils";
-const allTreeFilter = getExplorationSidebarTabsInfo().all.treeItemFilter;
-
-function getAllTabExplorationSidebarTree(
- opts: Parameters<typeof createExploration>[0],
-) {
- return getExplorationSidebarTree(
- createExploration(opts),
- allTreeFilter,
- undefined,
- {
- keepEmptyRestartableThreads: true,
- },
- );
+function sidebarModel({
+ exploration,
+ tab = "all",
+ comments,
+ showHidden = false,
+ sortOrder,
+ ...createOpts
+}: {
+ exploration?: ReturnType<typeof createExploration>;
+ tab?: keyof ReturnType<typeof getExplorationSidebarTabsInfo>;
+ comments?: Parameters<typeof getExplorationSidebarTabsInfo>[1];
+ showHidden?: boolean;
+ sortOrder?: Parameters<typeof getExplorationSidebarModel>[0]["sortOrder"];
+} & Parameters<typeof createExploration>[0] = {}) {
+ const resolvedExploration = exploration ?? createExploration(createOpts);
+ return getExplorationSidebarModel({
+ exploration: resolvedExploration,
+ selectedSidebarTab: tab,
+ tabsInfo: getExplorationSidebarTabsInfo(resolvedExploration, comments),
+ showHidden,
+ sortOrder,
+ });
}
-function getMetricHeadings(tree: ReturnType<typeof getExplorationSidebarTree>) {
+function sidebarTree(opts: Parameters<typeof sidebarModel>[0] = {}) {
+ return sidebarModel(opts).tree;
+}
+
+function getMetricHeadings(tree: ReturnType<typeof sidebarTree>) {
return tree[0]?.children ?? [];
}
@@ -58,9 +70,7 @@ function getPageData(
return leaf?.data?.type === "page" ? leaf.data : undefined;
}
-function getAllPageIds(
- tree: ReturnType<typeof getExplorationSidebarTree>,
-): string[] {
+function getAllPageIds(tree: ReturnType<typeof sidebarTree>): string[] {
const ids: string[] = [];
function walk(nodes: ITreeNodeItem<ExplorationTreeNode>[]) {
for (const node of nodes) {
@@ -76,24 +86,13 @@ function getAllPageIds(
return ids;
}
-function hasSummaryNode(
- tree: ReturnType<typeof getExplorationSidebarTree>,
-): boolean {
+function hasSummaryNode(tree: ReturnType<typeof sidebarTree>): boolean {
return tree.some(
(node) =>
node.id === EXPLORATION_SUMMARY_TREE_ID || node.data?.type === "document",
);
}
-function getFilteredSidebarTree(
- exploration: ReturnType<typeof createExploration>,
- tab: keyof ReturnType<typeof getExplorationSidebarTabsInfo>,
- comments?: Parameters<typeof getExplorationSidebarTabsInfo>[1],
-) {
- const tabsInfo = getExplorationSidebarTabsInfo(exploration, comments);
- return getExplorationSidebarTree(exploration, tabsInfo[tab].treeItemFilter);
-}
-
describe("getExplorationSidebarTree sorting", () => {
const METRIC_A_BLOCK_ID = 10;
const METRIC_B_BLOCK_ID = 20;
@@ -112,7 +111,7 @@ describe("getExplorationSidebarTree sorting", () => {
interestingness_score: 0.9,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [low, high],
blocks: [
createBlock({
@@ -170,11 +169,7 @@ describe("getExplorationSidebarTree sorting", () => {
],
});
- const tree = getExplorationSidebarTree(
- exploration,
- allTreeFilter,
- "alphabetical",
- );
+ const tree = sidebarTree({ exploration, sortOrder: "alphabetical" });
// Apple (id 2, lower score) sorts before Banana (id 1) by name.
expect(getLeafIds(getMetricHeadings(tree)[0])).toEqual(["2", "1"]);
@@ -199,7 +194,7 @@ describe("getExplorationSidebarTree sorting", () => {
interestingness_score: 0.2,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [doneSegment, pendingSegment, doneSingleton],
blocks: [
createBlock({
@@ -247,7 +242,7 @@ describe("getExplorationSidebarTree sorting", () => {
error_message: "boom",
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [error, running, done],
blocks: [
createBlock({
@@ -295,7 +290,7 @@ describe("getExplorationSidebarTree sorting", () => {
row_count: 0,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [empty, running, done],
blocks: [
createBlock({
@@ -345,7 +340,7 @@ describe("getExplorationSidebarTree sorting", () => {
interestingness_score: 0.3,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [metricBLeaf, metricALeaf],
blocks: [
createBlock({
@@ -397,7 +392,7 @@ describe("getExplorationSidebarTree sorting", () => {
interestingness_score: 0.5,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [first, second],
blocks: [
createBlock({
@@ -525,7 +520,7 @@ describe("getExplorationSidebarTree sorting", () => {
],
});
- const tree = getExplorationSidebarTree(exploration, allTreeFilter);
+ const tree = sidebarTree({ exploration });
const followUpNode = tree.find((node) => node.id === 2);
const followUpPageIds = (followUpNode?.children ?? [])
.filter((child) => child.data?.type === "page")
@@ -566,7 +561,7 @@ describe("getExplorationSidebarTree sorting", () => {
contextual_interestingness_score: 0.85,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [groupedLowContextual, groupedHighContextual],
blocks: [
createBlock({
@@ -609,7 +604,7 @@ describe("getExplorationSidebarTree passes BE-computed names through", () => {
interestingness_score: 0.8,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [country, plan],
blocks: [
createBlock({
@@ -665,7 +660,7 @@ describe("pickInitialSidebarPage", () => {
interestingness_score: 0.2,
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [doneSegment, pendingSegment, doneSingleton],
blocks: [
createBlock({
@@ -733,7 +728,7 @@ describe("pickInitialSidebarEntity", () => {
updated_at: "2026-01-01T00:00:00Z",
};
return {
- tree: getExplorationSidebarTree(exploration, () => true),
+ tree: sidebarTree({ exploration }),
document: exploration.document,
};
}
@@ -768,7 +763,7 @@ describe("getExplorationSidebarTree inherits a heading status from its pages", (
const queries = statuses.map((status, i) =>
createQuery({ id: i + 1, name: `Q${i + 1}`, status }),
);
- return getAllTabExplorationSidebarTree({
+ return sidebarTree({
queries,
blocks: [
createBlock({
@@ -816,7 +811,7 @@ describe("getExplorationSidebarTree inherits a heading status from its pages", (
});
it("uses the terminal server thread status instead of shimmering 'running' when the thread has no queries", () => {
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [createQuery({ id: 1, name: "Q1", status: "done" })],
thread: { status: "failed", completed_at: "2026-04-30T00:01:00Z" },
});
@@ -834,7 +829,7 @@ describe("getExplorationSidebarTree omits failed variant pages", () => {
defaultQuery: ReturnType<typeof createQuery>,
variantQuery: ReturnType<typeof createQuery>,
) {
- return getAllTabExplorationSidebarTree({
+ return sidebarTree({
queries: [defaultQuery, variantQuery],
blocks: [
createBlock({
@@ -917,7 +912,7 @@ describe("getExplorationSidebarTree omits failed variant pages", () => {
dimension_id: "user_id",
query_type: "top-n-other",
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [variant],
blocks: [
createBlock({
@@ -948,7 +943,7 @@ describe("getExplorationSidebarTree omits failed variant pages", () => {
card_id: 10,
dimension_id: "created_at",
});
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [erroredDefault],
blocks: [
createBlock({
@@ -977,7 +972,7 @@ describe("getExplorationSidebarTree last-activity timestamps", () => {
}
it("derives the thread heading's last activity from the newest query finished_at", () => {
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [
createQuery({
id: 1,
@@ -999,7 +994,7 @@ describe("getExplorationSidebarTree last-activity timestamps", () => {
});
it("leaves last activity undefined when no query has finished", () => {
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [createQuery({ id: 1, name: "Q1", status: "pending" })],
});
@@ -1107,7 +1102,10 @@ describe("getExplorationSidebarTabsInfo", () => {
describe("stars filter", () => {
it("includes only pages marked starred on the backend", () => {
- const tree = getFilteredSidebarTree(mixedPagesExploration, "stars");
+ const tree = sidebarTree({
+ exploration: mixedPagesExploration,
+ tab: "stars",
+ });
expect(getAllPageIds(tree)).toEqual([String(STARRED_PAGE_ID)]);
});
@@ -1134,9 +1132,9 @@ describe("getExplorationSidebarTabsInfo", () => {
});
// The initial thread heading is always retained, but it carries no pages.
- expect(
- getAllPageIds(getFilteredSidebarTree(exploration, "stars")),
- ).toEqual([]);
+ expect(getAllPageIds(sidebarTree({ exploration, tab: "stars" }))).toEqual(
+ [],
+ );
});
});
@@ -1150,11 +1148,11 @@ describe("getExplorationSidebarTabsInfo", () => {
}),
];
- const tree = getFilteredSidebarTree(
- mixedPagesExploration,
- "discussions",
+ const tree = sidebarTree({
+ exploration: mixedPagesExploration,
+ tab: "discussions",
comments,
- );
+ });
expect(getAllPageIds(tree)).toEqual([String(DISCUSSED_PAGE_ID)]);
});
@@ -1163,7 +1161,10 @@ describe("getExplorationSidebarTabsInfo", () => {
// The initial thread heading is always retained, but it carries no pages.
expect(
getAllPageIds(
- getFilteredSidebarTree(mixedPagesExploration, "discussions"),
+ sidebarTree({
+ exploration: mixedPagesExploration,
+ tab: "discussions",
+ }),
),
).toEqual([]);
});
@@ -1210,13 +1211,19 @@ describe("getExplorationSidebarTabsInfo", () => {
}
it("includes Summary on the All tab", () => {
- const tree = getFilteredSidebarTree(explorationWithSummary(), "all");
+ const tree = sidebarTree({
+ exploration: explorationWithSummary(),
+ tab: "all",
+ });
expect(hasSummaryNode(tree)).toBe(true);
expect(tree[0]?.id).toBe(EXPLORATION_SUMMARY_TREE_ID);
});
it("excludes Summary from the Stars tab", () => {
- const tree = getFilteredSidebarTree(explorationWithSummary(), "stars");
+ const tree = sidebarTree({
+ exploration: explorationWithSummary(),
+ tab: "stars",
+ });
expect(hasSummaryNode(tree)).toBe(false);
expect(getAllPageIds(tree)).toEqual([String(STARRED_PAGE_ID)]);
});
@@ -1230,7 +1237,11 @@ describe("getExplorationSidebarTabsInfo", () => {
child_target_id: String(DISCUSSED_PAGE_ID),
}),
];
- const tree = getFilteredSidebarTree(exploration, "discussions", comments);
+ const tree = sidebarTree({
+ exploration,
+ tab: "discussions",
+ comments,
+ });
expect(hasSummaryNode(tree)).toBe(false);
expect(getAllPageIds(tree)).toEqual([String(DISCUSSED_PAGE_ID)]);
});
@@ -1275,12 +1286,12 @@ describe("hidden pages", () => {
],
});
- const dropHidden = (node: ITreeNodeItem<ExplorationTreeNode>) =>
- allTreeFilter(node) && !isHiddenTreeItem(node);
-
it("threads the hidden flag onto page tree data", () => {
const heading = getMetricHeadings(
- getExplorationSidebarTree(explorationWithHiddenPage, allTreeFilter),
+ sidebarTree({
+ exploration: explorationWithHiddenPage,
+ showHidden: true,
+ }),
)[0];
expect(getPageData(heading, String(HIDDEN_PAGE_ID))?.hidden).toBe(true);
expect(getPageData(heading, String(VISIBLE_PAGE_ID))?.hidden).toBe(false);
@@ -1288,7 +1299,10 @@ describe("hidden pages", () => {
it("isHiddenTreeItem is true only for hidden pages, never headings", () => {
const heading = getMetricHeadings(
- getExplorationSidebarTree(explorationWithHiddenPage, allTreeFilter),
+ sidebarTree({
+ exploration: explorationWithHiddenPage,
+ showHidden: true,
+ }),
)[0];
const hiddenNode = heading?.children?.find(
(child) => child.id === String(HIDDEN_PAGE_ID),
@@ -1303,14 +1317,15 @@ describe("hidden pages", () => {
it("excludes hidden pages when the filter drops them, keeps them otherwise", () => {
expect(
- getAllPageIds(
- getExplorationSidebarTree(explorationWithHiddenPage, dropHidden),
- ),
+ getAllPageIds(sidebarTree({ exploration: explorationWithHiddenPage })),
).toEqual([String(VISIBLE_PAGE_ID)]);
expect(
getAllPageIds(
- getExplorationSidebarTree(explorationWithHiddenPage, allTreeFilter),
+ sidebarTree({
+ exploration: explorationWithHiddenPage,
+ showHidden: true,
+ }),
).sort(),
).toEqual([String(HIDDEN_PAGE_ID), String(VISIBLE_PAGE_ID)].sort());
});
@@ -1335,9 +1350,9 @@ describe("hidden pages", () => {
});
// The block heading is pruned; the initial thread heading is retained but
// carries no block headings.
- expect(
- getMetricHeadings(getExplorationSidebarTree(onlyHidden, dropHidden)),
- ).toEqual([]);
+ expect(getMetricHeadings(sidebarTree({ exploration: onlyHidden }))).toEqual(
+ [],
+ );
});
});
@@ -1373,7 +1388,7 @@ describe("group pageIds", () => {
...createExploration(),
threads: [thread1, thread2],
};
- const tree = getExplorationSidebarTree(exploration, allTreeFilter);
+ const tree = sidebarTree({ exploration });
expect(tree[0]?.data?.type).toBe("heading");
// Unjustified type cast. FIXME
@@ -1392,7 +1407,7 @@ describe("group pageIds", () => {
it("collects every descendant page id onto the thread heading", () => {
const q1 = createQuery({ id: 1, name: "Q1", status: "done" });
const q2 = createQuery({ id: 2, name: "Q2", status: "done" });
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [q1, q2],
blocks: [
createBlock({
@@ -1419,8 +1434,9 @@ describe("group pageIds", () => {
it("flags a heading allHidden only when every page beneath it is hidden", () => {
const q1 = createQuery({ id: 1, name: "Q1", status: "done" });
const q2 = createQuery({ id: 2, name: "Q2", status: "done" });
- const tree = getAllTabExplorationSidebarTree({
+ const tree = sidebarTree({
queries: [q1, q2],
+ showHidden: true,
blocks: [
createBlock({
id: 10,
@@ -1506,7 +1522,7 @@ describe("getExplorationSidebarTree sub-exploration nesting", () => {
threads: [initialThread(), followUpThread()],
});
- const tree = getExplorationSidebarTree(exploration, allTreeFilter);
+ const tree = sidebarTree({ exploration });
const followUpNode = tree.find((node) => node.id === 2);
// The redundant "Revenue" metric-group row is folded away; its page is
@@ -1545,7 +1561,7 @@ describe("getExplorationSidebarTree sub-exploration nesting", () => {
threads: [initialThread(), followUpThread(), nestedThread],
});
- const tree = getExplorationSidebarTree(exploration, allTreeFilter);
+ const tree = sidebarTree({ exploration });
// The nested drill is not a top-level node...
expect(tree.map((node) => node.id)).toEqual([1, 2]);
@@ -1583,7 +1599,7 @@ describe("getExplorationSidebarTree sub-exploration nesting", () => {
threads: [initialThread(), orphanThread],
});
- const tree = getExplorationSidebarTree(exploration, allTreeFilter);
+ const tree = sidebarTree({ exploration });
expect(tree.map((node) => node.id)).toEqual([1, 4]);
// No parent to derive a metric prefix from — and no folding trigger, so
@@ -1619,38 +1635,13 @@ describe("getShimmerDelayStyle", () => {
});
describe("getExplorationSidebarModel", () => {
- function modelFor(
- opts: Parameters<typeof createExploration>[0] = {},
- {
- tab = "all" as const,
- showHidden = false,
- }: { tab?: "all" | "stars" | "discussions"; showHidden?: boolean } = {},
- ) {
- const exploration = createExploration(opts);
- return getExplorationSidebarModel({
- exploration,
- selectedSidebarTab: tab,
- tabsInfo: getExplorationSidebarTabsInfo(exploration),
- showHidden,
- });
- }
-
- it("detects initial-thread loading on the All tab", () => {
- expect(
- modelFor({
- queries: [],
- thread: { status: "running", started_at: "2026-04-30T00:00:00Z" },
- }).contentMode,
- ).toBe("loading");
- });
-
- it("does not treat explore-further planning as a full-sidebar loading state", () => {
+ function explorationWithEmptyFollowUp(followUpStatus: "pending" | "running") {
const existingQuery = createQuery({
id: 1,
name: "Existing chart",
status: "done",
});
- const exploration = createExploration({
+ return createExploration({
threads: [
createThread({
id: 1,
@@ -1666,6 +1657,7 @@ describe("getExplorationSidebarModel", () => {
id: 1,
name: "Existing chart",
query_ids: [1],
+ starred: true,
}),
],
}),
@@ -1673,7 +1665,7 @@ describe("getExplorationSidebarModel", () => {
}),
createThread({
id: 2,
- status: "running",
+ status: followUpStatus,
started_at: "2026-04-30T00:00:00Z",
position: 1,
queries: [],
@@ -1681,20 +1673,50 @@ describe("getExplorationSidebarModel", () => {
}),
],
});
- const model = getExplorationSidebarModel({
- exploration,
- selectedSidebarTab: "all",
- tabsInfo: getExplorationSidebarTabsInfo(exploration),
- showHidden: false,
- });
+ }
- expect(model.contentMode).toBe("tree");
- expect(model.tree.length).toBeGreaterThan(0);
- });
+ it.each(["pending", "running"] as const)(
+ "treats an empty %s initial thread as a full-sidebar loading state on the All tab",
+ (status) => {
+ expect(
+ sidebarModel({
+ queries: [],
+ thread: { status, started_at: "2026-04-30T00:00:00Z" },
+ }).contentMode,
+ ).toBe("loading");
+ },
+ );
+
+ it.each(["pending", "running"] as const)(
+ "keeps an empty %s follow-up thread on the All tab so its loading row is visible",
+ (status) => {
+ const exploration = explorationWithEmptyFollowUp(status);
+ const model = sidebarModel({ exploration });
+
+ expect(model.contentMode).toBe("tree");
+ expect(model.tree.map((node) => node.id)).toEqual([1, 2]);
+ expect(model.tree[1]?.data).toMatchObject({
+ type: "heading",
+ headingKind: "sub-exploration",
+ });
+ expect(model.tree[1]?.children ?? []).toHaveLength(0);
+ },
+ );
+
+ it.each(["pending", "running"] as const)(
+ "does not keep an empty %s follow-up thread on the Stars tab",
+ (status) => {
+ const exploration = explorationWithEmptyFollowUp(status);
+ const model = sidebarModel({ exploration, tab: "stars" });
+
+ expect(model.contentMode).toBe("tree");
+ expect(model.tree.map((node) => node.id)).toEqual([1]);
+ },
+ );
it("detects permission denial from forbidden thread status", () => {
expect(
- modelFor({
+ sidebarModel({
queries: [],
thread: {
status: "forbidden",
@@ -1707,7 +1729,7 @@ describe("getExplorationSidebarModel", () => {
it.each(["failed", "canceled"] as const)(
"keeps an empty %s initial thread on the All tab so Restart stays reachable",
(status) => {
- const model = modelFor({
+ const model = sidebarModel({
queries: [],
thread: {
status,
@@ -1730,7 +1752,7 @@ describe("getExplorationSidebarModel", () => {
);
it("still prunes an empty planner-empty thread on the All tab", () => {
- const model = modelFor({
+ const model = sidebarModel({
queries: [],
thread: {
status: "empty",
@@ -1743,16 +1765,14 @@ describe("getExplorationSidebarModel", () => {
});
it("does not keep an empty failed thread on the Stars tab", () => {
- const model = modelFor(
- {
- queries: [],
- thread: {
- status: "failed",
- completed_at: "2026-04-30T00:01:00Z",
- },
+ const model = sidebarModel({
+ queries: [],
+ thread: {
+ status: "failed",
+ completed_at: "2026-04-30T00:01:00Z",
},
- { tab: "stars" },
- );
+ tab: "stars",
+ });
expect(model.contentMode).toBe("empty");
expect(model.tree).toHaveLength(0);
@@ -1764,31 +1784,29 @@ describe("getExplorationSidebarModel", () => {
name: "Hidden chart",
status: "done",
});
- const model = modelFor(
- {
- queries: [hiddenQuery],
- blocks: [
- createBlock({
- id: 1,
- name: "Revenue",
- pages: [
- createPage({
- id: 900,
- name: "Hidden chart",
- query_ids: [9],
- hidden: true,
- starred: true,
- }),
- ],
- }),
- ],
- thread: {
- status: "completed",
- completed_at: "2026-04-30T00:01:00Z",
- },
+ const model = sidebarModel({
+ queries: [hiddenQuery],
+ blocks: [
+ createBlock({
+ id: 1,
+ name: "Revenue",
+ pages: [
+ createPage({
+ id: 900,
+ name: "Hidden chart",
+ query_ids: [9],
+ hidden: true,
+ starred: true,
+ }),
+ ],
+ }),
+ ],
+ thread: {
+ status: "completed",
+ completed_at: "2026-04-30T00:01:00Z",
},
- { tab: "stars" },
- );
+ tab: "stars",
+ });
expect(model.contentMode).toBe("all-hidden");
});
diff --git a/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.module.css b/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.module.css
index c0bae3af406..c55ef36ec2f 100644
--- a/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.module.css
+++ b/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.module.css
@@ -16,10 +16,6 @@
cursor: default;
}
-.commentTagArrow {
- transform: scaleY(-1);
-}
-
/* User mentions (SmartLink user nodes) read as plain colored text here, not
* bold — scoped so document comments keep their own styling. */
.stream :global([data-type="smart-link"] > span) {
diff --git a/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.tsx b/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.tsx
index 1e5a072f0bc..f54f73a4d52 100644
--- a/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.tsx
+++ b/frontend/src/metabase/explorations/components/ExplorationVisualization/ExplorationComments.tsx
@@ -452,13 +452,7 @@ function CommentTags({
return (
<Group gap="xxs" wrap="wrap">
- <Icon
- name="corner_up_right"
- size={12}
- c="text-secondary"
- className={S.commentTagArrow}
- aria-hidden
- />
+ <Icon name="corner_down_right" size={12} c="text-secondary" aria-hidden />
{highlightLabel && (
<CommentBadge
label={highlightLabel}
diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/corner_down_right.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/corner_down_right.svg
new file mode 100644
index 00000000000..45b8c983a19
--- /dev/null
+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/corner_down_right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
+ <path d="M14.293 20.70703C14.6834 21.0975 15.3155 21.09739 15.7061 20.70703L20.707 15.70801C20.7378 15.67722 20.7651 15.64392 20.791 15.61035C20.8048 15.59248 20.8185 15.57447 20.8311 15.55566C20.8762 15.48815 20.9115 15.41616 20.9385 15.3418C20.9774 15.23509 21 15.12016 21 15C21 14.88041 20.977 14.76643 20.9385 14.66016C20.9328 14.64447 20.9274 14.62872 20.9209 14.61328C20.9007 14.56527 20.8768 14.51943 20.8496 14.47559C20.8435 14.46577 20.8375 14.45594 20.8311 14.44629C20.7944 14.3914 20.7536 14.33946 20.707 14.29297L15.7061 9.293C15.3156 8.903 14.6834 8.9029 14.293 9.293C13.9025 9.6835 13.9026 10.3165 14.293 10.707L17.584 14H8C7.20444 13.9999 6.44146 13.6836 5.87891 13.1211C5.31635 12.5585 5.00006 11.7956 5 11V4C4.99987 3.4479 4.55209 3.0001 4 3C3.4478 3 3.00013 3.4478 3 4V11C3.00006 12.326 3.52624 13.5985 4.46387 14.53613C5.40149 15.47376 6.67401 15.99994 8 16H17.5859L14.293 19.29395C13.9026 19.68448 13.9025 20.31656 14.293 20.70703Z" fill="currentColor"/>
+</svg>
diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts b/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
index 73f1bffbf89..92d546b7537 100644
--- a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts
@@ -71,6 +71,7 @@ import compare_component from "./compare.svg?component";
import connections_component from "./connections.svg?component";
import contract_component from "./contract.svg?component";
import copy_component from "./copy.svg?component";
+import corner_down_right_component from "./corner_down_right.svg?component";
import corner_up_right_component from "./corner_up_right.svg?component";
import currency_component from "./currency.svg?component";
import curve_component from "./curve.svg?component";
@@ -375,6 +376,7 @@ export const Icons: Record<IconName, React.VFC> = {
connections: connections_component,
contract: contract_component,
copy: copy_component,
+ corner_down_right: corner_down_right_component,
corner_up_right: corner_up_right_component,
currency: currency_component,
curved: curved_component,