Skip to content

Your lightweight open-source personal agent.

fix(webui): wrap markdown table content

chengyongru99a7ec256f60
diff --git a/webui/src/components/MarkdownTextRenderer.tsx b/webui/src/components/MarkdownTextRenderer.tsx
index 9c5019d43..5f8849a09 100644
--- a/webui/src/components/MarkdownTextRenderer.tsx
+++ b/webui/src/components/MarkdownTextRenderer.tsx
@@ -714,11 +714,13 @@ export default function MarkdownTextRenderer({
>
<table
className={cn(
- "w-full min-w-max border-collapse text-[13px] leading-5",
+ "w-full table-fixed border-collapse text-[13px] leading-5",
"[&_thead]:bg-muted/45 [&_thead]:text-muted-foreground",
"[&_th]:border-b [&_th]:border-border/65 [&_th]:px-3 [&_th]:py-2",
- "[&_th]:text-left [&_th]:font-medium",
+ "[&_th]:text-left [&_th]:font-medium [&_th]:whitespace-normal",
+ "[&_th]:[overflow-wrap:anywhere]",
"[&_td]:border-b [&_td]:border-border/55 [&_td]:px-3 [&_td]:py-2",
+ "[&_td]:whitespace-normal [&_td]:[overflow-wrap:anywhere]",
"[&_th:not(:last-child)]:border-r [&_th:not(:last-child)]:border-border/45",
"[&_td:not(:last-child)]:border-r [&_td:not(:last-child)]:border-border/45",
"[&_tbody_tr:last-child_td]:border-b-0",
diff --git a/webui/src/globals.css b/webui/src/globals.css
index 522ab22a8..3380b25fb 100644
--- a/webui/src/globals.css
+++ b/webui/src/globals.css
@@ -717,10 +717,9 @@
display: inline;
}
- /* Wide markdown tables scroll horizontally within the conversation column.
- Tables are wrapped in an overflow-x:auto <div> by the markdown renderer's
- custom `table` component (see MarkdownTextRenderer); min-w-max on the
- <table> keeps natural column widths so it scrolls instead of shrinking. */
+ /* Markdown tables wrap cell text to fit the conversation column. The
+ renderer's overflow-x:auto wrapper remains a fallback for content that
+ cannot shrink. */
/* Clip any residual horizontal bleed at the thread column edge. Vertical
scrolling and internal code-block scroll are unaffected. */
diff --git a/webui/src/tests/markdown-text-renderer.test.tsx b/webui/src/tests/markdown-text-renderer.test.tsx
index 142f4921c..a17cd9c61 100644
--- a/webui/src/tests/markdown-text-renderer.test.tsx
+++ b/webui/src/tests/markdown-text-renderer.test.tsx
@@ -483,7 +483,16 @@ describe("MarkdownTextRenderer", () => {
expect(surface).toHaveAttribute("role", "region");
expect(surface).toHaveAttribute("tabindex", "0");
expect(surface).toHaveAccessibleName("Data table");
- expect(screen.getByRole("table")).toHaveTextContent("nanobot");
+ const table = screen.getByRole("table");
+ expect(table).toHaveTextContent("nanobot");
+ expect(table).not.toHaveClass("min-w-max");
+ expect(table).toHaveClass(
+ "table-fixed",
+ "[&_th]:whitespace-normal",
+ "[&_th]:[overflow-wrap:anywhere]",
+ "[&_td]:whitespace-normal",
+ "[&_td]:[overflow-wrap:anywhere]",
+ );
expect(container.firstElementChild).toHaveClass("space-y-4");
expect(container.firstElementChild).not.toHaveClass("space-y-0");
});