Commit 4663f9ca8 for llama.cpp

commit 4663f9ca8a97c525ba3d248711fa2b52050920ec
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Mon Nov 23 14:12:41 2026 +0100

    ui: smooth height transition for every collapsible (#32873)

    * ui: give every collapsible the smooth height transition

    Llama UI's Collapsible.Content now force-mounts the bits-ui content and
    renders the animated region the chat used to keep as CollapsibleRegion:
    height eases open and shut, and the body unmounts once the collapse is
    over. The chat's standalone regions use Collapsible.Root/Content, so the
    tool groups in settings, the tools menu and drawer and the terminal block
    animate like the rest.

    Assisted-by: Claude (Opus 5.5 Medium)

    * ui: keep collapsible spacing inside the content

    Collapsible.Content now stays in the layout while closed, so a margin on
    it left a gap under a closed MCP tools list, connection log or server
    info. The margin moves onto the content inside, as does the story's
    spacing.

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/ui/apps/chat/src/lib/components/app/content/CollapsibleContentBlock.svelte b/ui/apps/chat/src/lib/components/app/content/CollapsibleContentBlock.svelte
index 89a0b3621..797a4f2fe 100644
--- a/ui/apps/chat/src/lib/components/app/content/CollapsibleContentBlock.svelte
+++ b/ui/apps/chat/src/lib/components/app/content/CollapsibleContentBlock.svelte
@@ -2,7 +2,6 @@
 	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import { cn } from '@ggml-org/llama-ui/utils';
 	import ChevronDown from '@lucide/svelte/icons/chevron-down';
-	import CollapsibleRegion from '#lib/components/app/misc/CollapsibleRegion.svelte';
 	import { ICON_CLASS_DEFAULT } from '#lib/constants/index.ts';
 	import type { Snippet } from 'svelte';
 	import type { Component } from 'svelte';
@@ -157,23 +156,16 @@
 	{/if}

 	{#if collapsible}
-		<!-- Content is force-mounted so the trigger keeps a real `aria-controls` target;
-		     the region owns opening and closing. It animates the height instead of
-		     snapping it, and unmounts the body once the collapse is over - a closed
-		     block still costs nothing, which matters while tokens stream past it. -->
-		<Collapsible.Content forceMount>
-			<CollapsibleRegion {open}>
-				<div class="pl-1.5 grid min-w-0" style="min-height: var(--min-message-height);">
-					<div
-						class={cn(
-							'min-w-0 pb-2 my-2',
-							!flushBody && 'border-l border-muted-foreground/20 pl-4'
-						)}
-					>
-						{@render children()}
-					</div>
+		<!-- The body unmounts once the collapse is over, so a closed block costs
+		     nothing while tokens stream past it. -->
+		<Collapsible.Content>
+			<div class="pl-1.5 grid min-w-0" style="min-height: var(--min-message-height);">
+				<div
+					class={cn('min-w-0 pb-2 my-2', !flushBody && 'border-l border-muted-foreground/20 pl-4')}
+				>
+					{@render children()}
 				</div>
-			</CollapsibleRegion>
+			</div>
 		</Collapsible.Content>
 	{/if}
 </Collapsible.Root>
diff --git a/ui/apps/chat/src/lib/components/app/content/CollapsibleTerminalBlock.svelte b/ui/apps/chat/src/lib/components/app/content/CollapsibleTerminalBlock.svelte
index 798a0ed20..ebfcb7c2f 100644
--- a/ui/apps/chat/src/lib/components/app/content/CollapsibleTerminalBlock.svelte
+++ b/ui/apps/chat/src/lib/components/app/content/CollapsibleTerminalBlock.svelte
@@ -95,13 +95,9 @@
 	</Collapsible.Trigger>

 	<Collapsible.Content>
-		<!-- See CollapsibleContentBlock: bits-ui keeps closed content mounted, which
-		     makes a collapsed tool result re-render on every streamed token. -->
-		{#if open}
-			<div class="terminal-body p-3 pt-1">
-				{@render children()}
-			</div>
-		{/if}
+		<div class="terminal-body p-3 pt-1">
+			{@render children()}
+		</div>
 	</Collapsible.Content>
 </Collapsible.Root>

diff --git a/ui/apps/chat/src/lib/components/app/mcp/McpConnectionLogs.svelte b/ui/apps/chat/src/lib/components/app/mcp/McpConnectionLogs.svelte
index 87efebf7a..cff6fa0db 100644
--- a/ui/apps/chat/src/lib/components/app/mcp/McpConnectionLogs.svelte
+++ b/ui/apps/chat/src/lib/components/app/mcp/McpConnectionLogs.svelte
@@ -48,9 +48,9 @@
 			</Collapsible.Trigger>
 		</div>

-		<Collapsible.Content class="mt-2">
+		<Collapsible.Content>
 			<div
-				class="max-h-64 space-y-0.5 overflow-y-auto rounded bg-muted/50 p-2 font-mono text-caption-sm"
+				class="mt-2 max-h-64 space-y-0.5 overflow-y-auto rounded bg-muted/50 p-2 font-mono text-caption-sm"
 			>
 				{#each logs as log (log.timestamp.getTime() + log.message)}
 					{@const IconComponent = getMcpLogLevelIcon(log.level)}
diff --git a/ui/apps/chat/src/lib/components/app/mcp/McpServerCard/McpServerCardToolsList.svelte b/ui/apps/chat/src/lib/components/app/mcp/McpServerCard/McpServerCardToolsList.svelte
index bc3631ddf..48846d336 100644
--- a/ui/apps/chat/src/lib/components/app/mcp/McpServerCard/McpServerCardToolsList.svelte
+++ b/ui/apps/chat/src/lib/components/app/mcp/McpServerCard/McpServerCardToolsList.svelte
@@ -31,8 +31,8 @@
 		<span>{toolsCount} tools available · Show details</span>
 	</Collapsible.Trigger>

-	<Collapsible.Content class="mt-2">
-		<div class="max-h-64 space-y-3 overflow-y-auto">
+	<Collapsible.Content>
+		<div class="mt-2 max-h-64 space-y-3 overflow-y-auto">
 			{#each tools as tool (tool.name)}
 				<div>
 					<Badge variant="secondary">{tool.name}</Badge>
diff --git a/ui/apps/chat/src/lib/components/app/mcp/McpServerInfo.svelte b/ui/apps/chat/src/lib/components/app/mcp/McpServerInfo.svelte
index 220e6c6d9..e895d8ce0 100644
--- a/ui/apps/chat/src/lib/components/app/mcp/McpServerInfo.svelte
+++ b/ui/apps/chat/src/lib/components/app/mcp/McpServerInfo.svelte
@@ -26,8 +26,8 @@
 			<span>Server instructions</span>
 		</Collapsible.Trigger>

-		<Collapsible.Content class="mt-2">
-			<p class="rounded bg-muted/50 p-2 text-caption text-muted-foreground">
+		<Collapsible.Content>
+			<p class="mt-2 rounded bg-muted/50 p-2 text-caption text-muted-foreground">
 				{instructions}
 			</p>
 		</Collapsible.Content>
diff --git a/ui/apps/chat/src/lib/components/app/misc/CollapsibleSection.svelte b/ui/apps/chat/src/lib/components/app/misc/CollapsibleSection.svelte
index 86d6cc2c2..5963a36f7 100644
--- a/ui/apps/chat/src/lib/components/app/misc/CollapsibleSection.svelte
+++ b/ui/apps/chat/src/lib/components/app/misc/CollapsibleSection.svelte
@@ -1,5 +1,5 @@
 <script lang="ts">
-	import CollapsibleRegion from './CollapsibleRegion.svelte';
+	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import * as DropdownMenu from '@ggml-org/llama-ui/ui/dropdown-menu';
 	import { ChevronDown, ChevronUp } from '@lucide/svelte';
 	import { ICON_CLASS_DEFAULT } from '#lib/constants/index.ts';
@@ -95,9 +95,11 @@
 {/snippet}

 {#snippet region()}
-	<!-- Custom expand region instead of bits-ui Collapsible (whose conditional
-	     rendering kills the transition). -->
-	<CollapsibleRegion {open}>{@render children()}</CollapsibleRegion>
+	<Collapsible.Root {open}>
+		<Collapsible.Content>
+			{@render children()}
+		</Collapsible.Content>
+	</Collapsible.Root>
 {/snippet}

 {#if triggerPosition === 'top'}
diff --git a/ui/apps/chat/src/lib/components/app/misc/GroupedList.svelte b/ui/apps/chat/src/lib/components/app/misc/GroupedList.svelte
index e249918c5..d7ecd763d 100644
--- a/ui/apps/chat/src/lib/components/app/misc/GroupedList.svelte
+++ b/ui/apps/chat/src/lib/components/app/misc/GroupedList.svelte
@@ -16,7 +16,7 @@
 </script>

 <script generics="G, E" lang="ts">
-	import CollapsibleRegion from './CollapsibleRegion.svelte';
+	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import type { Snippet } from 'svelte';
 	import { SvelteMap, SvelteSet } from 'svelte/reactivity';

@@ -151,19 +151,21 @@
 			</div>
 		{/if}

-		<CollapsibleRegion open={expanded}>
-			{#each entry.rows as row (keyOf(row))}
-				{@render item({ depth: 1, entry: row })}
-			{/each}
-
-			{#if entry.hidden > 0 && more}
-				{@render more({
-					count: Math.min(groupWindow, entry.hidden),
-					onMore: () => growGroup(entry.key),
-					unit: GroupedListUnit.ENTRIES
-				})}
-			{/if}
-		</CollapsibleRegion>
+		<Collapsible.Root open={expanded}
+			><Collapsible.Content>
+				{#each entry.rows as row (keyOf(row))}
+					{@render item({ depth: 1, entry: row })}
+				{/each}
+
+				{#if entry.hidden > 0 && more}
+					{@render more({
+						count: Math.min(groupWindow, entry.hidden),
+						onMore: () => growGroup(entry.key),
+						unit: GroupedListUnit.ENTRIES
+					})}
+				{/if}
+			</Collapsible.Content></Collapsible.Root
+		>
 	{/each}

 	{#if windowed.length < (groups?.length ?? 0) && more}
diff --git a/ui/apps/chat/src/lib/components/app/misc/index.ts b/ui/apps/chat/src/lib/components/app/misc/index.ts
index 8bb162917..a85fa0840 100644
--- a/ui/apps/chat/src/lib/components/app/misc/index.ts
+++ b/ui/apps/chat/src/lib/components/app/misc/index.ts
@@ -70,4 +70,3 @@ export {
 	type GroupedListGroup,
 	GroupedListUnit
 } from './GroupedList.svelte';
-export { default as CollapsibleRegion } from './CollapsibleRegion.svelte';
diff --git a/ui/apps/chat/src/lib/components/app/models/ModelsManager/ModelsManagerModelsTable.svelte b/ui/apps/chat/src/lib/components/app/models/ModelsManager/ModelsManagerModelsTable.svelte
index b29212136..15577a9df 100644
--- a/ui/apps/chat/src/lib/components/app/models/ModelsManager/ModelsManagerModelsTable.svelte
+++ b/ui/apps/chat/src/lib/components/app/models/ModelsManager/ModelsManagerModelsTable.svelte
@@ -9,6 +9,7 @@
 		type ModelQuantGroup,
 		type ModelsTableGroup
 	} from './utils';
+	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import * as Empty from '@ggml-org/llama-ui/ui/empty';
 	import {
 		ArrowDown,
@@ -22,7 +23,6 @@
 	} from '@lucide/svelte';
 	import { DialogConfirmDownload } from '#lib/components/app/dialogs/index.ts';
 	import {
-		CollapsibleRegion,
 		GroupedList,
 		type GroupedListGroup,
 		GroupedListUnit,
@@ -235,18 +235,20 @@
 			onToggle={() => toggleQuants(entry.key)}
 		/>

-		<CollapsibleRegion open={!collapsedQuants.has(entry.key)}>
-			{#each entry.quants as quant (quant.id)}
-				<ModelsManagerQuantRow
-					indent={indent + 24}
-					{isFavorite}
-					onDelete={requestDelete}
-					{onSelect}
-					option={quant}
-					selected={selectedId === quant.id}
-				/>
-			{/each}
-		</CollapsibleRegion>
+		<Collapsible.Root open={!collapsedQuants.has(entry.key)}
+			><Collapsible.Content>
+				{#each entry.quants as quant (quant.id)}
+					<ModelsManagerQuantRow
+						indent={indent + 24}
+						{isFavorite}
+						onDelete={requestDelete}
+						{onSelect}
+						option={quant}
+						selected={selectedId === quant.id}
+					/>
+				{/each}
+			</Collapsible.Content></Collapsible.Root
+		>
 	{:else}
 		<ModelsManagerModelRow
 			{indent}
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationList.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationList.svelte
index 5893c81c9..b4acae529 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationList.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationList.svelte
@@ -5,12 +5,9 @@
 	import SidebarNavigationSectionHeading from './SidebarNavigationSectionHeading.svelte';
 	import SidebarNavigationSelectionBar from './SidebarNavigationSelectionBar.svelte';
 	import SidebarNavigationShowMore from './SidebarNavigationShowMore.svelte';
+	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import { FolderPlus, MoreHorizontal, Pin } from '@lucide/svelte';
-	import {
-		CollapsibleRegion,
-		ContextMenuActions,
-		DropdownMenuActions
-	} from '#lib/components/app/index.ts';
+	import { ContextMenuActions, DropdownMenuActions } from '#lib/components/app/index.ts';
 	import {
 		SIDEBAR_ROW_SLIDE_MS,
 		SIDEBAR_SECTION_IDS,
@@ -307,17 +304,22 @@
 			</div>
 		{/snippet}

-		<CollapsibleRegion open={uiStore.isSidebarSectionOpen(SIDEBAR_SECTION_IDS.PINNED)}>
-			<ul class="flex w-full min-w-0 flex-col md:gap-0.5 {className}">
-				{#each previewOf(SIDEBAR_SECTION_IDS.PINNED, pinnedConversations) as { conversation, depth } (conversation.id)}
-					<li transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }} class="group/item relative p-0">
-						{@render conversationItem(conversation, depth)}
-					</li>
-				{/each}
-
-				{@render showMore(SIDEBAR_SECTION_IDS.PINNED, pinnedConversations.length)}
-			</ul>
-		</CollapsibleRegion>
+		<Collapsible.Root open={uiStore.isSidebarSectionOpen(SIDEBAR_SECTION_IDS.PINNED)}
+			><Collapsible.Content>
+				<ul class="flex w-full min-w-0 flex-col md:gap-0.5 {className}">
+					{#each previewOf(SIDEBAR_SECTION_IDS.PINNED, pinnedConversations) as { conversation, depth } (conversation.id)}
+						<li
+							transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }}
+							class="group/item relative p-0"
+						>
+							{@render conversationItem(conversation, depth)}
+						</li>
+					{/each}
+
+					{@render showMore(SIDEBAR_SECTION_IDS.PINNED, pinnedConversations.length)}
+				</ul>
+			</Collapsible.Content></Collapsible.Root
+		>
 	</SidebarNavigationDropZone>
 {/snippet}

@@ -358,22 +360,27 @@
 			</ContextMenuActions>
 		{/snippet}

-		<CollapsibleRegion open={uiStore.isSidebarSectionOpen(SIDEBAR_SECTION_IDS.RECENT)}>
-			<ul class="flex w-full min-w-0 flex-col md:gap-0.5">
-				{#each previewOf(SIDEBAR_SECTION_IDS.RECENT, unpinnedConversations) as { conversation, depth } (conversation.id)}
-					<li transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }} class="group/item relative p-0">
-						{@render conversationItem(conversation, depth)}
-					</li>
-				{/each}
-
-				{#if conversations.length === 0}
-					<li class="px-2 py-4 text-center">
-						<p class="mb-4 p-4 text-body-sm text-muted-foreground">No conversations yet</p>
-					</li>
-				{/if}
-
-				{@render showMore(SIDEBAR_SECTION_IDS.RECENT, unpinnedConversations.length)}
-			</ul>
-		</CollapsibleRegion>
+		<Collapsible.Root open={uiStore.isSidebarSectionOpen(SIDEBAR_SECTION_IDS.RECENT)}
+			><Collapsible.Content>
+				<ul class="flex w-full min-w-0 flex-col md:gap-0.5">
+					{#each previewOf(SIDEBAR_SECTION_IDS.RECENT, unpinnedConversations) as { conversation, depth } (conversation.id)}
+						<li
+							transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }}
+							class="group/item relative p-0"
+						>
+							{@render conversationItem(conversation, depth)}
+						</li>
+					{/each}
+
+					{#if conversations.length === 0}
+						<li class="px-2 py-4 text-center">
+							<p class="mb-4 p-4 text-body-sm text-muted-foreground">No conversations yet</p>
+						</li>
+					{/if}
+
+					{@render showMore(SIDEBAR_SECTION_IDS.RECENT, unpinnedConversations.length)}
+				</ul>
+			</Collapsible.Content></Collapsible.Root
+		>
 	</SidebarNavigationDropZone>
 {/snippet}
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationGroupSection.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationGroupSection.svelte
index 4a9ab73ed..8bbb55fed 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationGroupSection.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationGroupSection.svelte
@@ -2,10 +2,10 @@
 	import SidebarNavigationDropZone from './SidebarNavigationDropZone.svelte';
 	import SidebarNavigationSectionHeading from './SidebarNavigationSectionHeading.svelte';
 	import SidebarNavigationShowMore from './SidebarNavigationShowMore.svelte';
+	import * as Collapsible from '@ggml-org/llama-ui/ui/collapsible';
 	import { MoreHorizontal, Pencil, Plus, SquarePen, Trash2 } from '@lucide/svelte';
 	import {
 		ActionIcon,
-		CollapsibleRegion,
 		ContextMenuActions,
 		DialogConfirmation,
 		DropdownMenuActions
@@ -134,35 +134,37 @@
 		</ContextMenuActions>
 	{/snippet}

-	<CollapsibleRegion {open}>
-		<ul class="flex w-full min-w-0 flex-col md:gap-0.5 {className}">
-			{#each shownItems as { conversation, depth } (conversation.id)}
-				<li transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }} class="group/item relative p-0">
-					{@render conversationRow(conversation, depth)}
-				</li>
-			{:else}
-				<li>
-					<button
-						class="w-full rounded-lg px-2 py-1.5 text-left text-caption text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground"
-						onclick={() => void startChat()}
-						type="button"
-					>
-						Start a chat in this group
-					</button>
-				</li>
-			{/each}
+	<Collapsible.Root {open}
+		><Collapsible.Content>
+			<ul class="flex w-full min-w-0 flex-col md:gap-0.5 {className}">
+				{#each shownItems as { conversation, depth } (conversation.id)}
+					<li transition:slide={{ duration: SIDEBAR_ROW_SLIDE_MS }} class="group/item relative p-0">
+						{@render conversationRow(conversation, depth)}
+					</li>
+				{:else}
+					<li>
+						<button
+							class="w-full rounded-lg px-2 py-1.5 text-left text-caption text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground"
+							onclick={() => void startChat()}
+							type="button"
+						>
+							Start a chat in this group
+						</button>
+					</li>
+				{/each}

-			{#if items.length > SIDEBAR_SECTION_PREVIEW_COUNT}
-				<!-- only an opened section is long enough for its row to need to stick -->
-				<li class={expanded ? SIDEBAR_SHOW_MORE_ROW_CLASS : 'p-0'}>
-					<SidebarNavigationShowMore
-						{expanded}
-						onToggle={() => uiStore.toggleSidebarSectionExpanded(sectionId)}
-					/>
-				</li>
-			{/if}
-		</ul>
-	</CollapsibleRegion>
+				{#if items.length > SIDEBAR_SECTION_PREVIEW_COUNT}
+					<!-- only an opened section is long enough for its row to need to stick -->
+					<li class={expanded ? SIDEBAR_SHOW_MORE_ROW_CLASS : 'p-0'}>
+						<SidebarNavigationShowMore
+							{expanded}
+							onToggle={() => uiStore.toggleSidebarSectionExpanded(sectionId)}
+						/>
+					</li>
+				{/if}
+			</ul>
+		</Collapsible.Content></Collapsible.Root
+	>
 </SidebarNavigationDropZone>

 <DialogConfirmation
diff --git a/ui/apps/chat/src/lib/constants/ui.constants.ts b/ui/apps/chat/src/lib/constants/ui.constants.ts
index 5ac2adfbb..05198a344 100644
--- a/ui/apps/chat/src/lib/constants/ui.constants.ts
+++ b/ui/apps/chat/src/lib/constants/ui.constants.ts
@@ -13,12 +13,11 @@ import McpLogo from '#lib/components/app/mcp/McpLogo.svelte';
 import { SidebarAction, ToolSource } from '#lib/enums/index.ts';
 import type { DesktopIconStripItem } from '#lib/types/index.ts';

+export { COLLAPSIBLE_TRANSITION_MS } from '@ggml-org/llama-ui/constants';
+
 /** Delay before a copied affordance resets from its check to the copy icon. */
 export const COPY_FEEDBACK_RESET_MS = 1500;

-/** How long a collapsible block's body takes to expand or collapse. */
-export const COLLAPSIBLE_TRANSITION_MS = 200;
-
 /**
  * Parts of a message where right-click keeps the browser's own menu (open or
  * copy a link, save an image, copy code or a field), not the message actions.
diff --git a/ui/apps/chat/tests/client/collapsible-lazy-body.svelte.test.ts b/ui/apps/chat/tests/client/collapsible-lazy-body.svelte.test.ts
index 3a9d019a4..8f17d752e 100644
--- a/ui/apps/chat/tests/client/collapsible-lazy-body.svelte.test.ts
+++ b/ui/apps/chat/tests/client/collapsible-lazy-body.svelte.test.ts
@@ -1,11 +1,11 @@
-// Guards the lazy-body behaviour of the shared collapsible wrappers.
+// Guards the lazy-body behaviour of Llama UI's Collapsible.Content, through the
+// chat's collapsible blocks.
 //
-// bits-ui's Collapsible.Content renders its children unconditionally and only
-// sets `hidden`, so before this was gated a collapsed tool result kept its whole
-// body in the DOM and re-rendered it on every streamed token (measured at
-// ~41ms/section/token for a 200KB result). These tests pin the fix: closed means
-// not rendered, and opening still mounts the body. The collapse is animated, so
-// "not rendered" happens when the transition ends rather than when it starts.
+// A collapsed tool result that kept its body in the DOM re-rendered it on every
+// streamed token (measured at ~41ms/section/token for a 200KB result). These
+// tests pin the fix: closed means not rendered, and opening still mounts the
+// body. The collapse is animated, so "not rendered" happens when the transition
+// ends rather than when it starts.

 import CollapsibleLazyBodyHarness from './components/CollapsibleLazyBodyHarness.svelte';
 import { tick } from 'svelte';
diff --git a/ui/lib/ui/package-lock.json b/ui/lib/ui/package-lock.json
index 1de52e057..d59032738 100644
--- a/ui/lib/ui/package-lock.json
+++ b/ui/lib/ui/package-lock.json
@@ -1,12 +1,12 @@
 {
 	"name": "@ggml-org/llama-ui",
-	"version": "0.5.0",
+	"version": "0.6.0",
 	"lockfileVersion": 3,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "@ggml-org/llama-ui",
-			"version": "0.5.0",
+			"version": "0.6.0",
 			"license": "MIT",
 			"dependencies": {
 				"@ggml-org/llama-brand": "0.1.0",
diff --git a/ui/lib/ui/package.json b/ui/lib/ui/package.json
index 1def1aae4..e61db7cff 100644
--- a/ui/lib/ui/package.json
+++ b/ui/lib/ui/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@ggml-org/llama-ui",
-	"version": "0.5.0",
+	"version": "0.6.0",
 	"description": "Shared UI library for llama.cpp frontend apps.",
 	"license": "MIT",
 	"repository": {
diff --git a/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-content.svelte b/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-content.svelte
index 59b068c5f..6d984863c 100644
--- a/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-content.svelte
+++ b/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-content.svelte
@@ -1,7 +1,19 @@
 <script lang="ts">
+	import CollapsibleRegion from './collapsible-region.svelte';
 	import { Collapsible as CollapsiblePrimitive } from 'bits-ui';

-	let { ref = $bindable(null), ...restProps }: CollapsiblePrimitive.ContentProps = $props();
+	type Props = Omit<CollapsiblePrimitive.ContentProps, 'child' | 'forceMount' | 'hiddenUntilFound'>;
+
+	let { children, ref = $bindable(null), ...restProps }: Props = $props();
 </script>

-<CollapsiblePrimitive.Content bind:ref data-slot="collapsible-content" {...restProps} />
+<!-- Force-mounted so the trigger keeps a real `aria-controls` target and the region
+     can animate the height both ways; bits-ui's own conditional rendering would
+     snap it open and shut. -->
+<CollapsiblePrimitive.Content bind:ref data-slot="collapsible-content" forceMount {...restProps}>
+	{#snippet child({ open, props })}
+		<CollapsibleRegion {...props} {open}>
+			{@render children?.()}
+		</CollapsibleRegion>
+	{/snippet}
+</CollapsiblePrimitive.Content>
diff --git a/ui/apps/chat/src/lib/components/app/misc/CollapsibleRegion.svelte b/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-region.svelte
similarity index 69%
rename from ui/apps/chat/src/lib/components/app/misc/CollapsibleRegion.svelte
rename to ui/lib/ui/src/lib/components/ui/collapsible/collapsible-region.svelte
index 40809de45..991075339 100644
--- a/ui/apps/chat/src/lib/components/app/misc/CollapsibleRegion.svelte
+++ b/ui/lib/ui/src/lib/components/ui/collapsible/collapsible-region.svelte
@@ -1,16 +1,20 @@
 <script lang="ts">
-	import { COLLAPSIBLE_TRANSITION_MS } from '#lib/constants/index.ts';
+	import { cn } from '../utils';
+	import { COLLAPSIBLE_TRANSITION_MS } from '../../../constants';
 	import type { Snippet } from 'svelte';
+	import type { HTMLAttributes } from 'svelte/elements';

-	interface Props {
-		children: Snippet;
+	interface Props extends HTMLAttributes<HTMLDivElement> {
+		children?: Snippet;
 		open: boolean;
 	}

-	let { children, open }: Props = $props();
+	let { children, class: className, open, ...restProps }: Props = $props();

-	// rows stay mounted through the collapse transition so it can play; this is
-	// only the initial state, the effect below owns it afterwards
+	// The body stays mounted through the collapse so it can play, and unmounts once
+	// it is over: a closed collapsible costs nothing, even while its content would
+	// re-render on every streamed token. This is only the initial state, the effect
+	// below owns it afterwards.
 	// svelte-ignore state_referenced_locally
 	let contentMounted = $state(open);

@@ -27,10 +31,10 @@
 	});
 </script>

-<div class="collapsible-region" data-expanded={open}>
+<div {...restProps} class={cn('collapsible-region', className)} data-expanded={open}>
 	{#if contentMounted}
 		<div class="collapsible-region-content">
-			{@render children()}
+			{@render children?.()}
 		</div>
 	{/if}
 </div>
@@ -80,4 +84,10 @@
 			overflow: clip;
 		}
 	}
+
+	@media (prefers-reduced-motion: reduce) {
+		.collapsible-region {
+			transition: none;
+		}
+	}
 </style>
diff --git a/ui/lib/ui/src/lib/constants/ui.constants.ts b/ui/lib/ui/src/lib/constants/ui.constants.ts
index ff1bde2c9..9f5382141 100644
--- a/ui/lib/ui/src/lib/constants/ui.constants.ts
+++ b/ui/lib/ui/src/lib/constants/ui.constants.ts
@@ -7,3 +7,6 @@ export const UI_DATA_ATTRS = {

 /** How close to the bottom (px) a streaming code block counts as at the bottom. */
 export const SYNTAX_CODE_SCROLL_AT_BOTTOM_THRESHOLD_PX = 32;
+
+/** How long a collapsible's body takes to expand or collapse; matches the region's CSS transition. */
+export const COLLAPSIBLE_TRANSITION_MS = 200;
diff --git a/ui/lib/ui/tests/stories/components/display/Collapsible.stories.svelte b/ui/lib/ui/tests/stories/components/display/Collapsible.stories.svelte
index 2690a1f80..0291f9414 100644
--- a/ui/lib/ui/tests/stories/components/display/Collapsible.stories.svelte
+++ b/ui/lib/ui/tests/stories/components/display/Collapsible.stories.svelte
@@ -16,7 +16,7 @@
 </script>

 {#snippet section(open: boolean)}
-	<Collapsible.Root class="w-72 space-y-2" {open}>
+	<Collapsible.Root class="w-72" {open}>
 		<div class="flex items-center justify-between">
 			<span class="text-label">Advanced sampling</span>

@@ -29,12 +29,15 @@
 			</Collapsible.Trigger>
 		</div>

-		<div class="rounded-md border px-4 py-2 font-mono text-body-sm">temperature 0.8</div>
+		<div class="mt-2 rounded-md border px-4 py-2 font-mono text-body-sm">temperature 0.8</div>

-		<Collapsible.Content class="space-y-2">
-			<div class="rounded-md border px-4 py-2 font-mono text-body-sm">top_p 0.95</div>
+		<!-- spacing goes inside the content: the closed region stays in the layout -->
+		<Collapsible.Content>
+			<div class="space-y-2 pt-2">
+				<div class="rounded-md border px-4 py-2 font-mono text-body-sm">top_p 0.95</div>

-			<div class="rounded-md border px-4 py-2 font-mono text-body-sm">min_p 0.05</div>
+				<div class="rounded-md border px-4 py-2 font-mono text-body-sm">min_p 0.05</div>
+			</div>
 		</Collapsible.Content>
 	</Collapsible.Root>
 {/snippet}