Commit 6d8a8886f for llama.cpp

commit 6d8a8886fa44a4a404c58ace93052ea680193981
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Fri Nov 27 17:20:19 2026 +0100

    ui: draw markdown tables with row rules instead of a cell grid (#33195)

    A table in a chat column drew a rule around every cell, a band behind the
    header and a frame around its scroll wrapper. The lines did the separating
    twice over, so the table read heavier than the prose around it.

    A hairline under each row carries the structure on its own now: no cell grid,
    no header band, no frame, and the outer columns line up with the text above
    and below. GFM column alignment arrives as an align attribute, which an
    authored text-align beats, so the three values are restated and a
    right-aligned column keeps its figures under its header. Numbers take tabular
    figures, code in a cell stays one token, and a table of six or more columns
    keeps a width a word sits on and scrolls in its wrapper.

    The Tables story covers it: alignment, code and links in cells, a list and a
    line break in a cell, escaped pipes and an empty cell, and a table wider than
    the column.

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css
index ed0bc932c..fc6aa1864 100644
--- a/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css
+++ b/ui/apps/chat/src/lib/components/app/content/MarkdownContent/markdown-content.css
@@ -197,39 +197,92 @@
 	border-radius: 0 0.375rem 0.375rem 0;
 }

-/* Tables */
+/* Tables: one hairline under each row, no cell grid and no outer frame. The
+   header is set heavier instead of filled, so it reads without a band. */
 .markdown-content :global(table) {
+	/* one line colour for the whole table, so a tinted surface can retint it once */
+	--table-line: color-mix(in oklch, var(--line-default) 55%, transparent);
+
 	width: 100%;
-	margin: 1.5rem 0;
+	margin: 1rem 0;
 	border-collapse: collapse;
-	border: 1px solid var(--line-default);
-	border-radius: 0.375rem;
-	overflow: hidden;
+	/* a table is reference material, so it sits a step under the prose */
+	font-size: 0.875rem;
+	line-height: 1.5;
+	/* a column of numbers keeps its digits under each other */
+	font-variant-numeric: tabular-nums;
+}
+
+.markdown-content :global(th),
+.markdown-content :global(td) {
+	/* wide gutters carry the column separation that the vertical rules used to */
+	padding: 0.5rem 1.25rem;
+	text-align: start;
+	vertical-align: top;
+	border-bottom: 1px solid var(--table-line);
+}
+
+/* the outer columns line up with the prose above and below the table */
+.markdown-content :global(:is(th, td):first-child) {
+	padding-inline-start: 0;
+}
+
+.markdown-content :global(:is(th, td):last-child) {
+	padding-inline-end: 0;
 }

 .markdown-content :global(th) {
-	background: hsl(var(--surface-muted) / 0.3);
-	border: 1px solid var(--line-default);
-	padding: 0.5rem 0.75rem;
-	text-align: left;
+	/* a header that wraps to two lines keeps its second line on the rule */
+	padding-block: 0.375rem 0.5rem;
 	font-weight: 600;
+	vertical-align: bottom;
 }

-.markdown-content :global(td) {
-	border: 1px solid var(--line-default);
-	padding: 0.5rem 0.75rem;
+/* GFM column alignment arrives as an align attribute, which any authored
+   text-align beats, so the three cases are restated rather than inherited */
+.markdown-content :global(:is(th, td)[align='left']) {
+	text-align: start;
+}
+
+.markdown-content :global(:is(th, td)[align='center']) {
+	text-align: center;
+}
+
+.markdown-content :global(:is(th, td)[align='right']) {
+	text-align: end;
+}
+
+/* A table this wide is scrolled either way, so its columns keep a width a word
+   can sit on instead of crumbling to three lines each */
+.markdown-content :global(.table-wrapper table:has(th:nth-child(6)) :is(th, td)) {
+	min-width: 7rem;
+}
+
+/* a flag or a path stays one token in its cell, and the wrapper scrolls */
+.markdown-content :global(:is(th, td) code:not(pre code)) {
+	white-space: nowrap;
+}
+
+/* a list restored into a cell keeps the row as tight as its neighbours */
+.markdown-content :global(:is(th, td) :is(ul, ol)) {
+	margin: 0;
+	padding-inline-start: 1.125rem;
 }

-.markdown-content :global(tr:nth-child(even)) {
-	background: hsl(var(--surface-muted) / 0.1);
+.markdown-content :global(:is(th, td) li) {
+	margin-bottom: 0.125rem;
+}
+
+/* A user bubble breaks at anywhere to fit its width, which pulls a table's
+   columns down to a few letters each; break-word keeps the min-content width */
+div.markdown-user-content :global(:is(th, td)) {
+	overflow-wrap: break-word;
+	word-break: normal;
 }

-/* User message markdown should keep table borders visible on light primary backgrounds */
-div.markdown-user-content :global(table),
-div.markdown-user-content :global(th),
-div.markdown-user-content :global(td),
-div.markdown-user-content :global(.table-wrapper) {
-	border-color: currentColor;
+/* ...and its hairlines stay visible on the tinted bubble background */
+div.markdown-user-content :global(table) {
+	--table-line: color-mix(in oklch, currentColor 25%, transparent);
 }

 /* Horizontal rules */
@@ -387,21 +440,10 @@ div.markdown-user-content :global(.table-wrapper) {
 	}
 }

-/* Advanced table enhancements */
-.markdown-content :global(table) {
-	transition: all 0.2s ease;
-}
-
+/* A row lights up under the pointer, to follow a value across a wide table */
 @media (hover: hover) and (pointer: fine) {
-	.markdown-content :global(table:hover) {
-		box-shadow:
-			0 4px 6px -1px rgb(0 0 0 / 0.1),
-			0 2px 4px -2px rgb(0 0 0 / 0.1);
-	}
-
-	.markdown-content :global(th:hover),
-	.markdown-content :global(td:hover) {
-		background: var(--surface-muted);
+	.markdown-content :global(tbody tr:hover td) {
+		background: color-mix(in oklch, var(--surface-muted) 45%, transparent);
 	}
 }

@@ -411,13 +453,8 @@ div.markdown-user-content :global(.table-wrapper) {
 	color: inherit;
 }

-.markdown-user-content :global(table:hover) {
-	box-shadow: none;
-}
-
-.markdown-user-content :global(th:hover),
-.markdown-user-content :global(td:hover) {
-	background: inherit;
+.markdown-user-content :global(tbody tr:hover td) {
+	background: transparent;
 }

 /* Enhanced blockquotes */
@@ -505,19 +542,18 @@ div.markdown-user-content :global(.table-wrapper) {
 	border-radius: 50%;
 }

-/* Scrollable tables */
+/* Scrollable tables: the wrapper is only a scroll port. The hairlines belong to
+   the rows, so a table that fits shows no box around it */
 .markdown-content :global(.table-wrapper) {
 	overflow-x: auto;
-	margin: 1.5rem 0;
-	border-radius: 0.5rem;
-	border: 1px solid var(--line-default);
+	margin: 1rem 0;
 	/* a wide table scrolls here, it does not widen the column */
 	max-width: 100%;
+	overscroll-behavior-x: contain;
 }

 .markdown-content :global(.table-wrapper table) {
 	margin: 0;
-	border: none;
 }

 /* Responsive adjustments */
@@ -534,18 +570,10 @@ div.markdown-user-content :global(.table-wrapper) {
 		font-size: 1.125rem;
 	}

-	.markdown-content :global(table) {
-		font-size: 0.875rem;
-	}
-
+	/* a narrower gutter, and no full-bleed: it hid the outer columns */
 	.markdown-content :global(th),
 	.markdown-content :global(td) {
-		padding: 0.375rem 0.5rem;
-	}
-
-	/* no full-bleed: it hid the outer columns */
-	.markdown-content :global(.table-wrapper) {
-		margin: 1rem 0;
+		padding-inline: 0.875rem;
 	}
 }

diff --git a/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte b/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte
index 5cbd5697c..2e43fa196 100644
--- a/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte
+++ b/ui/apps/chat/tests/stories/content/MarkdownContent.stories.svelte
@@ -1,5 +1,6 @@
 <script lang="ts" module>
 	import { AI_TUTORIAL_MD } from '../fixtures/ai-tutorial.js';
+	import { MARKDOWN_TABLES_MD } from '../fixtures/markdown-tables.js';
 	import { MERMAID_DIAGRAMS_MD } from '../fixtures/mermaid-diagrams.js';
 	import { defineMeta } from '@storybook/addon-svelte-csf';
 	import { MarkdownContent } from '#lib/components/app/index.ts';
@@ -19,6 +20,48 @@
 	name="Default"
 />

+<Story
+	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: MARKDOWN_TABLES_MD }}
+	name="Tables"
+	play={async ({ canvasElement }) => {
+		const tables = await waitFor(() => {
+			const found = [...canvasElement.querySelectorAll('table')];
+
+			expect(found).toHaveLength(5);
+
+			return found;
+		});
+		const numbers = tables[1];
+		const sizeCell = numbers.querySelectorAll('td')[2];
+		const sizeHeader = numbers.querySelectorAll('th')[2];
+		const wrapper = numbers.closest('.table-wrapper') as HTMLElement;
+
+		// the lean look: no frame, no filled header, one hairline under each row
+		await expect(getComputedStyle(wrapper).borderTopWidth).toBe('0px');
+		await expect(getComputedStyle(sizeHeader).backgroundColor).toBe('rgba(0, 0, 0, 0)');
+		await expect(getComputedStyle(sizeHeader).borderBottomWidth).toBe('1px');
+		await expect(getComputedStyle(sizeCell).borderLeftWidth).toBe('0px');
+
+		// a right-aligned column stays aligned in the header and in the cells
+		await expect(getComputedStyle(sizeHeader).textAlign).toBe('end');
+		await expect(getComputedStyle(sizeCell).textAlign).toBe('end');
+
+		// markup models put in cells still renders: a list, and a wrapped line
+		await expect(canvasElement.querySelector('td ul li')).not.toBeNull();
+		await expect(canvasElement.querySelector('td br')).not.toBeNull();
+
+		// too many columns for the column: the wrapper scrolls, the page does not
+		const wide = (tables[4] as HTMLElement).closest('.table-wrapper') as HTMLElement;
+
+		await expect(wide.scrollWidth).toBeGreaterThan(wide.clientWidth);
+		await expect(document.documentElement.scrollWidth).toBeLessThanOrEqual(window.innerWidth);
+		// and it scrolls on a width a model name sits on, rather than crumbling
+		await expect(wide.querySelector('td')!.getBoundingClientRect().width).toBeGreaterThanOrEqual(
+			100
+		);
+	}}
+/>
+
 <Story
 	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: MERMAID_DIAGRAMS_MD }}
 	name="Diagrams"
diff --git a/ui/apps/chat/tests/stories/fixtures/markdown-tables.ts b/ui/apps/chat/tests/stories/fixtures/markdown-tables.ts
new file mode 100644
index 000000000..ac286fc05
--- /dev/null
+++ b/ui/apps/chat/tests/stories/fixtures/markdown-tables.ts
@@ -0,0 +1,48 @@
+// Tables the way models write them: mixed column alignment, code and links in
+// cells, numbers meant to line up, a cell that wraps, escaped pipes and empty
+// cells, and one table too wide for the chat column.
+const tick = '`';
+
+export const MARKDOWN_TABLES_MD = `Here are a few tables with different alignments and content:
+
+## Server flags
+
+| Flag | Default | Description |
+| :--- | :---: | --- |
+| ${tick}--ctx-size${tick} | 4096 | Context size in tokens |
+| ${tick}--parallel${tick} | 1 | Slots that serve requests at once |
+| ${tick}--jinja${tick} | on | Use the model's own chat template |
+
+## Quantization types
+
+| Type | Bits per weight | Size (7B) | Notes |
+| :--- | ---: | ---: | :--- |
+| ${tick}Q4_K_M${tick} | 4.85 | 4.07 GB | A good default for most models |
+| ${tick}Q5_K_M${tick} | 5.69 | 4.78 GB | A little more quality for a little more memory |
+| ${tick}Q8_0${tick} | 8.50 | 7.16 GB | Close to the original weights, see [the docs](https://github.com/ggml-org/llama.cpp) |
+| ${tick}F16${tick} | 16.00 | 13.50 GB | **Full** half precision |
+
+## Build status
+
+| Package | Status | Version | Notes |
+| :--- | :--- | ---: | :--- |
+| ${tick}@ggml-org/llama-ui${tick} | ✅ Passing | 0.4.2 | See [ui/lib/ui](https://github.com/ggml-org/llama.cpp/tree/master/ui/lib/ui) |
+| ${tick}llama-storybook${tick} | ⚠️ Flaky | 0.3.0 | **Needs** a rerun on CI |
+| ${tick}llama-brand${tick} | ❌ Failing | 0.1.9 | Missing ${tick}BRAND.md${tick} |
+
+## Cells that hold more than a word
+
+| Input | Output | Escaped pipe |
+| :--- | :--- | :--- |
+| ${tick}a \\| b${tick} | ${tick}a or b${tick} | ✔ |
+| | (empty input) | ✘ |
+| A list | <ul><li>first</li><li>second</li></ul> | — |
+| Two lines | first<br>second | — |
+
+## A wide table
+
+| Model | Family | Parameters | Context | Quantization | Prompt t/s | Generation t/s | Memory | Backend | Notes |
+| :--- | :--- | ---: | ---: | :--- | ---: | ---: | ---: | :--- | :--- |
+| gpt-oss-20b | GPT-OSS | 20.9B | 131072 | MXFP4 | 1890.4 | 74.2 | 12.1 GB | Metal | Reasoning effort low, medium and high |
+| Qwen3-8B | Qwen3 | 8.2B | 40960 | Q4_K_M | 1312.7 | 58.9 | 5.0 GB | Metal | Thinking can be turned off per request |
+`;