🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): comment count uses the score chip shell (#18476)
Trang Nguyen4d5796d25574
diff --git a/web/src/features/comments/CommentCountIcon.stories.tsx b/web/src/features/comments/CommentCountIcon.stories.tsxindex 46daacf084..a2816385b9 100644--- a/web/src/features/comments/CommentCountIcon.stories.tsx+++ b/web/src/features/comments/CommentCountIcon.stories.tsx@@ -1,4 +1,3 @@-import { expect } from "storybook/test";import preview from "../../../.storybook/preview";import { CommentCountIcon } from "./CommentCountIcon";@@ -10,34 +9,3 @@ const meta = preview.meta({export const Single = meta.story({ args: { count: 1 } });export const TwoDigits = meta.story({ args: { count: 42 } });export const Capped = meta.story({ args: { count: 1234 } });--/**- * The count badge overlaps the bubble's corner, and it has to do that from INSIDE- * the icon's own box. Positioned absolutely it hung outside, so it overlapped- * whatever followed it in a flow layout, and a clipping ancestor — the trace- * timeline's metric cluster — cut it mid-glyph at exactly two digits.- */-export const TheCountStaysInsideTheIconsBox = meta.story({- name: "(Test) The Count Stays Inside The Icon's Box",- args: { count: 1234 },- play: async ({ canvasElement }) => {- // By testid, not by text: the icon's own wrapper has the same textContent,- // and a `find` over every span picks the wrapper — which measures nothing.- const badge = canvasElement.querySelector<HTMLElement>(- "[data-testid='comment-count']",- );- if (!badge) throw new Error("no capped count badge");- const icon = badge.parentElement!;- const box = icon.getBoundingClientRect();- const drawn = badge.getBoundingClientRect();- // Fully inside, on every side: the timeline's metric cluster clips both axes,- // so an overhang out of the top is cut just as an overhang out of the right is.- await expect(drawn.right).toBeLessThanOrEqual(box.right + 0.5);- await expect(drawn.left).toBeGreaterThanOrEqual(box.left - 0.5);- await expect(drawn.top).toBeGreaterThanOrEqual(box.top - 0.5);- await expect(drawn.bottom).toBeLessThanOrEqual(box.bottom + 0.5);- // And it still overlaps the bubble rather than sitting beside it.- const bubble = icon.querySelector("svg")!.getBoundingClientRect();- await expect(drawn.left).toBeLessThan(bubble.right);- },-});diff --git a/web/src/features/comments/CommentCountIcon.tsx b/web/src/features/comments/CommentCountIcon.tsxindex 460b48e360..f8383b185e 100644--- a/web/src/features/comments/CommentCountIcon.tsx+++ b/web/src/features/comments/CommentCountIcon.tsx@@ -1,20 +1,12 @@import { MessageSquareMore } from "lucide-react";+import { BadgeShell } from "@/src/components/design-system/Badge/Badge";+export function CommentCountIcon({ count }: { count: number }) {return (- // The count overlaps the bubble's corner by a negative margin rather than by- // `absolute`: positioned absolutely it sat OUTSIDE this span's own box, so it- // overlapped whatever followed in a flow layout, and a clipping ancestor —- // the trace timeline's metric cluster — cut a two-digit count mid-glyph.- // In flow, the overhang is part of the footprint and everything reserves it.- <span className="mr-1 inline-flex items-start text-xs">- <MessageSquareMore className="icon-base shrink-0" />- <span- data-testid="comment-count"- className="border-muted-foreground bg-muted-foreground text-muted dark:bg-muted dark:text-muted-foreground -ml-2 flex max-h-[0.8rem] min-w-[0.8rem] shrink-0 items-center justify-center rounded-sm border px-[0.2rem] text-[8px] shadow-xs"- >- {count > 99 ? "99+" : count}- </span>- </span>+ <BadgeShell color="filled" font="mono" size="md">+ <MessageSquareMore aria-hidden className="icon-sm shrink-0" />+ <span data-testid="comment-count">{count > 99 ? "99+" : count}</span>+ </BadgeShell>);}