Skip to content

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

fix(web): `MarkdownViewer` styling issues around bullet-points (#16879)

Ben Bachem1ff6fdf7c976
diff --git a/web/src/components/ui/MarkdownViewer.clienttest.tsx b/web/src/components/ui/MarkdownViewer.clienttest.tsx
index 8307b89a1f..0eaf375ca5 100644
--- a/web/src/components/ui/MarkdownViewer.clienttest.tsx
+++ b/web/src/components/ui/MarkdownViewer.clienttest.tsx
@@ -61,6 +61,30 @@ describe("MarkdownView link rendering", () => {
});
});
+const NESTED_BULLET_MARKDOWN = `Langfuse is an open-source observability and analytics tool for LLM applications.
+
+In practical terms, it helps you:
+
+- **Track and debug LLM calls**
+ - Log prompts, model responses, latency, errors, and metadata
+- **Evaluate quality**
+ - Run evaluations on outputs (automatic metrics or human feedback)
+- **Monitor in production**
+ - Dashboards for usage, cost, latency, and failure rates`;
+
+const NESTED_ORDERED_MARKDOWN = `Steps:
+
+1. **Prepare the dataset**
+ 1. Collect traces
+ 2. Label outcomes
+2. **Run the eval**
+ 1. Score outputs`;
+
+const directChildren = (parent: Element, tagName: string) =>
+ Array.from(parent.children).filter(
+ (child) => child.tagName === tagName.toUpperCase(),
+ );
+
describe("MarkdownView ordered lists", () => {
it("preserves an explicit ordered-list start number", () => {
const { container } = renderMarkdown("2.");
@@ -69,6 +93,67 @@ describe("MarkdownView ordered lists", () => {
});
});
+describe("MarkdownView list item layout", () => {
+ // A list item that also contains a nested list has a block sibling
+ // after the label. Markers use list-outside and matching left padding
+ // so they sit in the gutter beside the first line.
+ it("places nested bullet markers outside the item content box", () => {
+ const { container } = renderMarkdown(NESTED_BULLET_MARKDOWN);
+
+ const topList = container.querySelector("ul");
+ expect(topList).not.toBeNull();
+ expect(topList?.className).toContain("list-outside");
+ expect(topList?.className).not.toContain("list-inside");
+ expect(topList?.className).toContain("pl-6");
+
+ const topItems = directChildren(topList!, "li");
+ expect(topItems).toHaveLength(3);
+ expect(
+ topItems.map((item) => item.querySelector("strong")?.textContent),
+ ).toEqual([
+ "Track and debug LLM calls",
+ "Evaluate quality",
+ "Monitor in production",
+ ]);
+
+ for (const item of topItems) {
+ const nested = item.querySelector(":scope > ul");
+ expect(nested).not.toBeNull();
+ expect(nested?.className).toContain("pl-6");
+ expect(item.className).not.toContain("[&>ul]:pl-4");
+ }
+ });
+
+ it("places nested numbered-list markers outside the item content box", () => {
+ const { container } = renderMarkdown(NESTED_ORDERED_MARKDOWN);
+
+ const topList = container.querySelector("ol");
+ expect(topList).not.toBeNull();
+ expect(topList?.className).toContain("list-outside");
+ expect(topList?.className).not.toContain("list-inside");
+ expect(topList?.className).toContain("pl-6");
+
+ const topItems = directChildren(topList!, "li");
+ expect(topItems).toHaveLength(2);
+
+ for (const item of topItems) {
+ const nested = item.querySelector(":scope > ol");
+ expect(nested).not.toBeNull();
+ expect(nested?.className).toContain("pl-6");
+ expect(item.className).not.toContain("[&>ol]:pl-4");
+ }
+ });
+
+ it("does not emit an empty trailing list item for a nested bullet list", () => {
+ const { container } = renderMarkdown(NESTED_BULLET_MARKDOWN);
+ const topItems = directChildren(container.querySelector("ul")!, "li");
+
+ expect(
+ topItems.every((item) => (item.textContent ?? "").trim().length > 0),
+ ).toBe(true);
+ });
+});
+
describe("MarkdownView code blocks", () => {
// A random React key (and an inline `code` renderer, which is a new
// component type every parent render) remounted CodeBlock and dropped
diff --git a/web/src/components/ui/MarkdownViewer.stories.tsx b/web/src/components/ui/MarkdownViewer.stories.tsx
new file mode 100644
index 0000000000..1dc889ec49
--- /dev/null
+++ b/web/src/components/ui/MarkdownViewer.stories.tsx
@@ -0,0 +1,154 @@
+import preview from "../../../.storybook/preview";
+import { MarkdownView } from "./MarkdownViewer";
+
+const meta = preview.meta({
+ component: MarkdownView,
+ args: {
+ title: "assistant",
+ },
+});
+
+export const Default = meta.story({
+ args: {
+ markdown:
+ "Langfuse is an **open-source** observability tool for LLM apps. Use `trace.generation()` to record a model call.",
+ },
+});
+
+export const NestedLists = meta.story({
+ args: {
+ markdown: `In practical terms, it helps you:
+
+- **Track and debug LLM calls**
+ - Log prompts, model responses, latency, errors, and metadata
+- **Evaluate quality**
+ - Run evaluations on outputs (automatic metrics or human feedback)
+- **Monitor in production**
+ - Dashboards for usage, cost, latency, and failure rates`,
+ },
+});
+
+export const TightLists = meta.story({
+ args: {
+ markdown: `Simple bullets stay on one line:
+
+- First item
+- Second item
+- Third item with **bold** and \`inline code\``,
+ },
+});
+
+export const OrderedLists = meta.story({
+ args: {
+ markdown: `Numbered steps:
+
+1. Collect traces
+2. Label outcomes
+3. Run the eval
+
+Resume a later list:
+
+10. Double-digit markers need gutter space
+11. Next item
+12. Last item`,
+ },
+});
+
+export const NestedOrderedLists = meta.story({
+ args: {
+ markdown: `Steps:
+
+1. **Prepare the dataset**
+ 1. Collect traces
+ 2. Label outcomes
+2. **Run the eval**
+ 1. Score outputs
+ 2. Compare baselines`,
+ },
+});
+
+export const Headings = meta.story({
+ args: {
+ markdown: `# Heading 1
+## Heading 2
+### Heading 3
+#### Heading 4
+##### Heading 5
+###### Heading 6
+
+Paragraph after headings.`,
+ },
+});
+
+export const CodeBlocks = meta.story({
+ args: {
+ markdown: `Wrap a model call:
+
+\`\`\`typescript
+const generation = trace.generation({
+ name: "support-answer",
+ model: "example-model",
+});
+\`\`\`
+
+Inline code looks like \`trace.id\`.`,
+ },
+});
+
+export const Table = meta.story({
+ args: {
+ markdown: `| Metric | Value |
+| --- | --- |
+| Latency | 842ms |
+| Tokens | 1,204 |
+| Cost | $0.012 |`,
+ },
+});
+
+export const Blockquote = meta.story({
+ args: {
+ markdown: `> Prefer traces over logs when debugging a single request.
+>
+> Keep the observation tree intact.`,
+ },
+});
+
+export const TaskList = meta.story({
+ args: {
+ markdown: `- [x] Record the generation
+- [x] Attach scores
+- [ ] Share the trace`,
+ },
+});
+
+export const Links = meta.story({
+ args: {
+ markdown:
+ "See the [tracing docs](https://langfuse.com/docs) or an unsafe [script](javascript:alert(1)).",
+ },
+});
+
+export const MixedContent = meta.story({
+ args: {
+ markdown: `## How to debug a slow trace
+
+1. Open the generation
+2. Compare **input** and **output**
+3. Check the table:
+
+| Field | Expected |
+| --- | --- |
+| model | example-model |
+| stream | true |
+
+Then wrap the call:
+
+\`\`\`ts
+trace.generation({ name: "answer" });
+\`\`\`
+
+- Nested follow-ups
+ - Re-run with a tighter prompt
+ - Compare cost`,
+ },
+});
diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsx
index ada39e2d7d..5873b2da60 100644
--- a/web/src/components/ui/MarkdownViewer.tsx
+++ b/web/src/components/ui/MarkdownViewer.tsx
@@ -315,21 +315,19 @@ const markdownComponents: NonNullable<Options["components"]> = {
ul({ children }) {
if (isChecklist(children)) return <ul className="list-none">{children}</ul>;
- return <ul className="list-inside list-disc">{children}</ul>;
+ // Nested items contain a block list after the label. list-outside
+ // plus left padding keeps the marker in the gutter beside that line.
+ return <ul className="list-outside list-disc pl-6">{children}</ul>;
},
ol({ children, start }) {
return (
- <ol start={start} className="list-inside list-decimal">
+ <ol start={start} className="list-outside list-decimal pl-6">
{children}
</ol>
);
},
li({ children }) {
- return (
- <li className="mt-1 [&>ol]:pl-4 [&>ul]:pl-4">
- {transformListItemChildren(children)}
- </li>
- );
+ return <li className="mt-1">{transformListItemChildren(children)}</li>;
},
pre({ children }) {
return <pre className="rounded p-2">{children}</pre>;
diff --git a/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx b/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx
index 6d6a05eda4..b48a2bbf43 100644
--- a/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx
+++ b/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx
@@ -85,6 +85,32 @@ generation.end({ output: "Your response" });
},
});
+export const NestedMarkdownLists = meta.story({
+ args: {
+ input: {
+ messages: [
+ {
+ role: "user",
+ content: "What is Langfuse useful for?",
+ },
+ ],
+ },
+ output: {
+ role: "assistant",
+ content: `Langfuse is an open-source observability and analytics tool for LLM applications.
+
+In practical terms, it helps you:
+
+- **Track and debug LLM calls**
+ - Log prompts, model responses, latency, errors, and metadata
+- **Evaluate quality**
+ - Run evaluations on outputs (automatic metrics or human feedback)
+- **Monitor in production**
+ - Dashboards for usage, cost, latency, and failure rates`,
+ },
+ },
+});
+
export const ToolCall = meta.story({
args: {
input: {