Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): prevent inline math overlap in markdown tables
chengyongrue71bc95364b8
diff --git a/webui/browser/typography-fixture.tsx b/webui/browser/typography-fixture.tsxindex fae612633..f36f4cc46 100644--- a/webui/browser/typography-fixture.tsx+++ b/webui/browser/typography-fixture.tsx@@ -41,6 +41,10 @@ const content = `# 阅读,让思路自然延续| 标题 Heading | 清楚的内容层级 | 保留结构,而非所有文字同大 || Code | configuration.readingTextSize | 完整显示,必要时在局部滚动 |+| $T$ | $q-p$ | 实测梯度 $\\frac{1}{T}(q-p)$ | 式(4)预测 $\\frac{\\delta}{NT^2}$ |+| --- | --- | --- | --- |+| 1 | $[0.0208,\\ -0.0179,\\ -0.0031]$ | $[1.45,-0.52,-0.93]\\times10^{-3}$ | $[1.33,-0.33,-1.00]\\times10^{-3}$ |+\`\`\`typescript// 中文注释与 English codeconst preference = { readingTextSize: "standard" };diff --git a/webui/browser/typography.spec.ts b/webui/browser/typography.spec.tsindex 2ddf65a6c..900c777f0 100644--- a/webui/browser/typography.spec.ts+++ b/webui/browser/typography.spec.ts@@ -33,6 +33,11 @@ for (const narrow of [false, true]) {await expect(group.getByRole("radio", { name: "阅读字号:标准", exact: true })).toBeChecked();await expect(group.getByRole("radio")).toHaveCount(3);const stable = await metrics(page.locator(".settings-row").first().locator(".text-control-label"));+ const tables = page.getByTestId("markdown-data-table");+ const formulaTable = tables.last();+ await expect(tables).toHaveCount(2);+ await expect(formulaTable.locator(".katex")).toHaveCount(7);+ await page.evaluate(() => document.fonts.ready);const observations = [];for (const [size, label, bodySize] of [["small", "阅读字号:小", narrow ? 15 : 16],@@ -59,6 +64,26 @@ for (const narrow of [false, true]) {for (const selector of ["table", "th", "td"]) {expect((await metrics(page.locator(`.markdown-content ${selector}`).first())).size).toBeCloseTo(bodySize * 0.875);}+ expect(await tables.first().evaluate(node => node.scrollWidth <= node.clientWidth + 1)).toBe(true);+ await expect.poll(() => formulaTable.locator(".katex-html > .base").evaluateAll((nodes) => nodes.every((node) => {+ const formula = node.getBoundingClientRect();+ const cell = node.closest("th, td")!;+ const bounds = cell.getBoundingClientRect();+ const style = getComputedStyle(cell);+ return formula.width > 0+ && formula.left >= bounds.left + parseFloat(style.paddingLeft) - 1+ && formula.right <= bounds.right - parseFloat(style.paddingRight) + 1;+ }))).toBe(true);+ if (narrow) {+ expect(await formulaTable.evaluate(node => node.scrollWidth > node.clientWidth)).toBe(true);+ await formulaTable.evaluate(node => { node.scrollLeft = node.scrollWidth; });+ await expect.poll(() => formulaTable.evaluate((node) => {+ const bounds = node.getBoundingClientRect();+ const lastCell = node.querySelector("tbody td:last-child")!.getBoundingClientRect();+ return lastCell.left >= bounds.left - 1 && lastCell.right <= bounds.right + 1;+ })).toBe(true);+ await formulaTable.evaluate(node => { node.scrollLeft = 0; });+ }expect((await metrics(page.locator(".code-content pre"))).size).toBeCloseTo(bodySize * 0.875);expect((await metrics(page.locator(".markdown-inline-code"))).size).toBeCloseTo(bodySize * 0.875);expect((await metrics(page.locator("textarea"))).size).toBe(Math.max(16, bodySize));diff --git a/webui/src/components/MarkdownTextRenderer.tsx b/webui/src/components/MarkdownTextRenderer.tsxindex 9e88aca27..7d86871e3 100644--- a/webui/src/components/MarkdownTextRenderer.tsx+++ b/webui/src/components/MarkdownTextRenderer.tsx@@ -699,7 +699,7 @@ export default function MarkdownTextRenderer({><tableclassName={cn(- "w-full table-fixed border-collapse text-reading-small",+ "w-full table-auto border-collapse text-reading-small","[&_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]:whitespace-normal",diff --git a/webui/src/tests/markdown-text-renderer.test.tsx b/webui/src/tests/markdown-text-renderer.test.tsxindex 090678194..d6b9cc908 100644--- a/webui/src/tests/markdown-text-renderer.test.tsx+++ b/webui/src/tests/markdown-text-renderer.test.tsx@@ -740,9 +740,7 @@ describe("MarkdownTextRenderer", () => {expect(surface).toHaveAccessibleName("Data table");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",