Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): keep Topics treemap tile names from running under the count (#19151)

Lysander Kiesel8e5557d67257
diff --git a/web/src/features/topics/TopicTreemapView.stories.tsx b/web/src/features/topics/TopicTreemapView.stories.tsx
index f6f9994b42..190a25bb6b 100644
--- a/web/src/features/topics/TopicTreemapView.stories.tsx
+++ b/web/src/features/topics/TopicTreemapView.stories.tsx
@@ -88,6 +88,47 @@ const meta = preview.meta({
export const Default = meta.story({});
+const issueTopics = [
+ { name: "Incomplete runs with undelivered results", count: 40 },
+ { name: "Research halted before handback report", count: 35 },
+ { name: "Unfinished work with unverified checks", count: 35 },
+ { name: "Run stopped before delivering final report", count: 18 },
+ { name: "Run halted before delivering requested report", count: 18 },
+ { name: "Partial answers without follow-up", count: 16 },
+].map((topic, index) => ({ ...topic, id: `issue-${index}`, description: "" }));
+
+export const LongNamesOnShortTiles = meta.story({
+ name: "Long names on short tiles",
+ args: {
+ facet: {
+ ...facet,
+ facetId: "issues",
+ name: "Issues",
+ topics: issueTopics,
+ rows: [
+ ...issueTopics.flatMap((topic) =>
+ Array.from({ length: topic.count }, (_, index) => ({
+ ...assignedRows[0],
+ traceId: `${topic.id}-trace-${index}`,
+ summary: `${topic.name} ${index + 1}`,
+ topicId: topic.id,
+ topicName: topic.name,
+ })),
+ ),
+ ...Array.from({ length: 261 }, (_, index) => ({
+ ...rows[rows.length - 1],
+ traceId: `issues-unassigned-${index}`,
+ })),
+ ],
+ },
+ },
+ render: (args) => (
+ <div className="flex flex-col" style={{ width: 1736, height: 1000 }}>
+ <TopicTreemapView {...args} />
+ </div>
+ ),
+});
+
export const SelectTopic = meta.story({
name: "(Test) Selecting a tile lists its traces",
play: async ({ canvasElement }) => {
diff --git a/web/src/features/topics/TopicTreemapView.tsx b/web/src/features/topics/TopicTreemapView.tsx
index c0d4315d5e..12074ab89f 100644
--- a/web/src/features/topics/TopicTreemapView.tsx
+++ b/web/src/features/topics/TopicTreemapView.tsx
@@ -26,6 +26,12 @@ const TILE_PADDING: Record<TileTier, string> = {
tiny: "p-0",
};
+/** Vertical padding, name line height and count+share block height (px) for tiers that show a name. */
+const PADDING_Y_PX = 24;
+const NAME_LINE_PX = { large: 28, medium: 20 };
+const FOOTER_PX = { large: 54, medium: 46 };
+const NAME_CLAMP = ["line-clamp-1", "line-clamp-2", "line-clamp-3"];
+
const COUNT_SIZE: Record<TileTier, string> = {
large: "text-3xl",
medium: "text-xl",
@@ -173,6 +179,18 @@ function TopicTileButton({
onSelect(topic.id);
}
const showName = tier === "large" || tier === "medium";
+ /** Name lines that fit above the count. */
+ const nameLines = showName
+ ? Math.min(
+ 3,
+ Math.max(
+ 1,
+ Math.floor(
+ (rect.height - PADDING_Y_PX - FOOTER_PX[tier]) / NAME_LINE_PX[tier],
+ ),
+ ),
+ )
+ : 0;
return (
<button
{...triggerProps}
@@ -199,7 +217,8 @@ function TopicTileButton({
{showName && (
<span
className={cn(
- "line-clamp-3 font-bold",
+ NAME_CLAMP[nameLines - 1],
+ "font-bold",
tier === "large" ? "text-lg" : "text-sm",
)}
>
@@ -220,7 +239,7 @@ function TopicTileButton({
function tileTier(width: number, height: number): TileTier {
if (width >= 240 && height >= 160) return "large";
- if (width >= 112 && height >= 80) return "medium";
+ if (width >= 112 && height >= 96) return "medium";
if (width >= 40 && height >= 32) return "small";
return "tiny";
}