ui: Fix markdown tables and lists being cut off on phones (#30687)

* ui : keep markdown tables inside the chat column on phones

The phone rule made the table wrapper full-bleed with -1rem margins, so the
first and the last column sat under the screen edge. Keep the wrapper inside the
chat column and cap it at its width, so a wide table scrolls in place instead.

Assisted-by: llama-ui (ggml-org/Qwen3.8-Flash-Next:IQ4_NL)

* test : show a table-only model answer in the chat message story

Adds a story with an answer that is mostly a table, so the table layout can be
checked at a phone width.

Assisted-by: llama-ui (ggml-org/Qwen3.8-Flash-Next:IQ4_NL)

* ui : indent markdown lists by 2rem

1.5rem put the marker too close to the item text.

Assisted-by: llama-ui (ggml-org/Qwen3.8-Flash-Next:IQ4_NL)
This commit is contained in:
Aleksander Grygier authored and GitHub committed 2026-10-19 09:28:16 +03:00
1 parent 8f97d82da3
commit 2b57148b08
3 files changed
+59 -6

No files matched your search

@@ -139,13 +139,13 @@
/* Lists */
.markdown-content :global(ul) {
list-style-type: disc;
margin-inline-start: 1.5rem;
margin-inline-start: 2rem;
margin-bottom: 1rem;
}
.markdown-content :global(ol) {
list-style-type: decimal;
margin-inline-start: 1.5rem;
margin-inline-start: 2rem;
margin-bottom: 1rem;
}
@@ -500,6 +500,8 @@ div.markdown-user-content :global(.table-wrapper) {
margin: 1.5rem 0;
border-radius: 0.5rem;
border: 1px solid var(--border);
/* a wide table scrolls here, it does not widen the column */
max-width: 100%;
}
.markdown-content :global(.table-wrapper table) {
@@ -530,11 +532,9 @@ div.markdown-user-content :global(.table-wrapper) {
padding: 0.375rem 0.5rem;
}
/* no full-bleed: it hid the outer columns */
.markdown-content :global(.table-wrapper) {
margin: 0.5rem -1rem;
border-radius: 0;
border-left: none;
border-right: none;
margin: 1rem 0;
}
}
@@ -1,4 +1,5 @@
<script lang="ts" module>
import { JOKES_TABLE_MD, WIDE_CELL_TABLE_MD } from './fixtures/mobile-tables.js';
import { defineMeta } from '@storybook/addon-svelte-csf';
import ChatMessage from '$lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte';
import type { ChatMessageActions } from '$lib/types';
@@ -49,6 +50,18 @@
type: 'message'
};
const assistantWithTable: DatabaseMessage = {
children: [],
content: `${JOKES_TABLE_MD}\n\n${WIDE_CELL_TABLE_MD}`,
convId: 'conv-1',
id: '7',
parent: '1',
role: 'assistant',
thinking: '',
timestamp: Date.now() - 1000 * 60 * 3,
type: 'message'
};
const assistantWithReasoning: DatabaseMessage = {
children: [],
content: "Here's the concise answer, now that I've thought it through carefully for you.",
@@ -124,6 +137,19 @@
}}
/>
<Story
args={{
class: 'max-w-[56rem] w-[calc(100vw-2rem)]',
message: assistantWithTable
}}
name="AssistantWithTable"
play={async () => {
const { settingsStore } = await import('$lib/stores/settings/index.svelte');
settingsStore.updateConfig('showRawOutputSwitch', false);
}}
/>
<Story
args={{
class: 'max-w-[56rem] w-[calc(100vw-2rem)]',
@@ -0,0 +1,27 @@
// Table-heavy answers, to check the table layout at a phone width.
export const JOKES_TABLE_MD = String.raw`
Sure! Here are the jokes in a table:
| No. | Joke |
|-----|------|
| 1 | Why don't scientists trust atoms? Because they make up everything. |
| 2 | I told my wife she was drawing her eyebrows too high. She looked surprised. |
| 3 | Why did the scarecrow win an award? Because he was outstanding in his field. |
| 4 | I'm reading a book about anti-gravity. It's impossible to put down. |
| 5 | Why don't skeletons fight each other? They don't have the guts. |
| 6 | I used to hate clowns, but they all have their fat-sies. |
| 7 | What do you call a fake noodle? An impasta. |
| 8 | Why did the bicycle fall over? Because it was two-tired. |
| 9 | I would tell you a chemistry joke, but I know I wouldn't get a reaction. |
| 10 | Why did the golfer bring two pairs of pants? In case he got a hole in one. |
`;
export const WIDE_CELL_TABLE_MD = String.raw`
Some endpoints, in a table, for reference:
| Name | Endpoint | Description |
|------|----------|-------------|
| Completions | https://huggingface.co/api/models/ggml-org/gpt-oss-20b-GGUF/summary | Long endpoint description |
| Models | ./v1/models | Lists the models loaded in the server slot |
| Props | ./props | Server capabilities and default sampling |
`;