Commit 4694eccda for llama.cpp

commit 4694eccda0616206bebfb77c0f64c5b182e459b3
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Fri Dec 4 14:12:57 2026 +0100

    ui: file a conversation away with Archive, from its menus and in bulk (#33328)

    * ui: file a conversation away with Archive, from its menus and in bulk

    The "more actions" dropdown and the right-click menu of a conversation gain
    Archive, next to Pin. A filed-away chat leaves the sidebar's sections -
    Pinned, the groups and Ungrouped - and rests out of them; the search dialog
    is where it is found, behind a "Show N archived" toggle under the chats a
    query matched, its own Archived group among the results. The bulk selection
    bar gains the same action for a whole selection: Archive over any selection
    with a chat left in it, Restore once every selected chat rests in the
    archive.

    Archiving keeps a chat's pin and group, so restoring puts it back where it
    was, and a move that gives it a home elsewhere - a pin, a group, a drop on
    Pinned or on Recent - brings it back too, so such an action on a filed-away
    chat never reads as doing nothing.

    Assisted-by: Claude

    * ui: fix archive selection, restore path and fork families

    Select all, the selection count and shift or marquee ranges only take
    the chats the sidebar shows, and archiving drops what left the sidebar
    from the selection, so a bulk delete never reaches a hidden chat.

    Writing in an archived chat brings it back, which gives it a way back
    when conversation tabs are off, the default and the only option on a
    phone. The bulk Restore path, which no selection could reach, is gone.

    Archiving and restoring take the whole fork family, like moving into a
    group, and an archived chat no longer shows twice in search.

    * ui: count the whole fork family in the archive toast

    The bulk write takes the family, so the toast reports the family's size
    rather than the clicked selection, which a single chat with forks would
    otherwise report as one conversation while several leave the sidebar.

    Assisted-by: Claude

    ---------

    Co-authored-by: Pascal <admin@serveurperso.com>

diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogConversationArchive.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogConversationArchive.svelte
new file mode 100644
index 000000000..6400a716f
--- /dev/null
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogConversationArchive.svelte
@@ -0,0 +1,23 @@
+<script lang="ts">
+	import { Archive } from '@lucide/svelte';
+	import { DialogConfirmation } from '#lib/components/app/index.ts';
+
+	interface Props {
+		open: boolean;
+		onConfirm: () => void;
+		onCancel: () => void;
+	}
+
+	let { onCancel, onConfirm, open = $bindable() }: Props = $props();
+</script>
+
+<DialogConfirmation
+	bind:open
+	cancelText="Cancel"
+	confirmText="Archive"
+	description="The conversation and its forks leave the sidebar until you restore them or write in one again. Their messages, pin and group are kept, and restoring puts them back where they were."
+	icon={Archive}
+	{onCancel}
+	{onConfirm}
+	title="Archive Conversation"
+/>
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
index a952faeb5..3dd874373 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
@@ -1,6 +1,7 @@
 <script lang="ts">
 	import * as Dialog from '@ggml-org/llama-ui/ui/dialog';
 	import {
+		Archive,
 		ArrowDown,
 		ArrowUp,
 		CornerDownLeft,
@@ -45,6 +46,7 @@
 	import { formatRelativeTime, isIMEComposing, orgOf } from '#lib/utils/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
 	import { type Component, untrack } from 'svelte';
+	import { SvelteMap } from 'svelte/reactivity';

 	interface Props {
 		open: boolean;
@@ -70,12 +72,16 @@

 	interface SearchSection {
 		entries: SearchEntry[];
+		/** Renders a toggle under the entries, revealing the chats filed away in the archive. */
+		archivedToggle?: boolean;
 		/** Results still on their way; the section shows while they load. */
 		loading?: boolean;
 		title: string;
 	}

 	let query = $state('');
+	/** Whether the chats filed away in the archive join the results. */
+	let showArchived = $state(false);
 	let highlighted = $state(0);
 	let inputRef = $state<HTMLInputElement | null>(null);
 	/** The Hub repo picked from the results, shown in place of them. */
@@ -95,7 +101,7 @@
 		snippet?: ConversationSearchSnippet
 	): SearchEntry {
 		return {
-			icon: MessageSquare,
+			icon: conversation.archived ? Archive : MessageSquare,
 			id: `chat-${conversation.id}`,
 			label: conversation.name,
 			meta: formatRelativeTime(conversation.lastModified),
@@ -109,12 +115,49 @@
 		[...conversationsStore.conversations].sort((a, b) => b.lastModified - a.lastModified)
 	);

+	// a filed-away chat rests out of the results, reachable only through the archive toggle
 	const titleMatches = $derived(
 		recentConversations.filter((conversation) => matches(conversation.name))
 	);

+	// a filed-away chat counts toward the toggle whether the query met its title or its
+	// messages, so a chat matched only by what was said in it is still uncoverable
+	const archivedMatchConversations = $derived.by((): DatabaseConversation[] => {
+		if (!needle) return [];
+
+		const byId = new SvelteMap<string, DatabaseConversation>();
+
+		for (const conversation of titleMatches) {
+			if (conversation.archived) byId.set(conversation.id, conversation);
+		}
+
+		for (const { conversation } of contentMatches) {
+			if (conversation.archived && !byId.has(conversation.id)) {
+				byId.set(conversation.id, conversation);
+			}
+		}
+
+		return [...byId.values()];
+	});
+
+	const hasArchivedMatches = $derived(archivedMatchConversations.length > 0);
+
+	// the archive folds itself away once its chats stop matching, and with the query
+	$effect(() => {
+		if (!hasArchivedMatches) showArchived = false;
+	});
+
 	const chatEntries = $derived(
-		titleMatches.slice(0, limit).map((conversation) => chatEntry(conversation))
+		titleMatches
+			.filter((conversation) => !conversation.archived)
+			.slice(0, limit)
+			.map((conversation) => chatEntry(conversation))
+	);
+
+	const archivedEntries = $derived(
+		showArchived
+			? archivedMatchConversations.slice(0, limit).map((conversation) => chatEntry(conversation))
+			: []
 	);

 	// chats found by what was said in them, not by their title; scanned once typing settles
@@ -144,10 +187,13 @@

 	const contentEntries = $derived(
 		needle
-			? contentMatches.map(({ conversation, snippet }) => ({
-					...chatEntry(conversation, snippet),
-					id: `message-${conversation.id}`
-				}))
+			? contentMatches
+					// a filed-away chat does not slip in through its messages: it shows in Archived
+					.filter(({ conversation }) => !conversation.archived)
+					.map(({ conversation, snippet }) => ({
+						...chatEntry(conversation, snippet),
+						id: `message-${conversation.id}`
+					}))
 			: []
 	);

@@ -279,7 +325,12 @@
 	// your own chats first; the Hub answers last, so it comes last and never moves a row above it
 	const sections = $derived<SearchSection[]>(
 		[
-			{ entries: chatEntries, title: needle ? 'Chats' : 'Recents' },
+			{
+				archivedToggle: hasArchivedMatches,
+				entries: chatEntries,
+				title: needle ? 'Chats' : 'Recents'
+			},
+			...(archivedEntries.length > 0 ? [{ entries: archivedEntries, title: 'Archived' }] : []),
 			{
 				entries: contentEntries,
 				loading: contentSearch.isSearching && !!needle,
@@ -292,7 +343,8 @@
 				loading: hubSearch.isSearching && !!needle,
 				title: 'On Hugging Face'
 			}
-		].filter((section) => section.entries.length > 0 || section.loading)
+			// the Chats section stays for its archive toggle even with no chat of its own to show
+		].filter((section) => section.entries.length > 0 || section.loading || section.archivedToggle)
 	);

 	const entries = $derived(sections.flatMap((section) => section.entries));
@@ -337,6 +389,7 @@
 			query = '';
 			highlighted = 0;
 			selectedModel = null;
+			showArchived = false;
 		}

 		open = nextOpen;
@@ -490,6 +543,28 @@
 						<!-- a phone has no keyboard to move a highlight with: no row is lit there -->
 						{@render row(entry, index, isActive)}
 					{/each}
+
+					{#if section.archivedToggle}
+						<!-- the filed-away chats a query matched, one click away -->
+						<button
+							class="text-muted-foreground hover:text-foreground flex w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-body-sm transition-colors max-md:rounded-xl max-md:py-3"
+							onclick={() => {
+								showArchived = !showArchived;
+								highlighted = 0;
+							}}
+							type="button"
+						>
+							<Archive class="{ICON_CLASS_DEFAULT} shrink-0" />
+
+							<span class="min-w-0 flex-1 truncate">
+								{#if showArchived}
+									Hide archived
+								{:else}
+									Show {archivedMatchConversations.length} archived
+								{/if}
+							</span>
+						</button>
+					{/if}
 				</div>
 			{:else}
 				<p class="px-3 py-12 text-center text-body-sm text-muted-foreground">{emptyMessage}</p>
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/index.ts b/ui/apps/chat/src/lib/components/app/dialogs/index.ts
index 09bdd1a9c..39d54ba57 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/index.ts
+++ b/ui/apps/chat/src/lib/components/app/dialogs/index.ts
@@ -96,6 +96,23 @@ export { default as DialogSearch } from './DialogSearch.svelte';
  */
 export { default as DialogConfirmDownload } from './DialogConfirmDownload.svelte';

+/**
+ * **DialogConversationArchive** - Confirm filing a conversation away
+ *
+ * Non-destructive confirmation shared by every conversation archive entry
+ * point: filing a chat away takes it out of the sidebar until it is restored.
+ *
+ * @example
+ * ```svelte
+ * <DialogConversationArchive
+ *   bind:open={showArchive}
+ *   onConfirm={handleArchive}
+ *   onCancel={() => (showArchive = false)}
+ * />
+ * ```
+ */
+export { default as DialogConversationArchive } from './DialogConversationArchive.svelte';
+
 /**
  * **DialogConversationDelete** - Confirm deleting a conversation
  *
diff --git a/ui/apps/chat/src/lib/components/app/navigation/ConversationActions.svelte b/ui/apps/chat/src/lib/components/app/navigation/ConversationActions.svelte
index 11f70042b..ff0646398 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/ConversationActions.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/ConversationActions.svelte
@@ -1,6 +1,8 @@
 <script lang="ts">
 	import SidebarNavigationGroupSubmenu from './SidebarNavigation/SidebarNavigationGroupSubmenu.svelte';
 	import {
+		Archive,
+		ArchiveRestore,
 		Download,
 		FolderInput,
 		ListChecks,
@@ -89,6 +91,22 @@
 			onclick: run(() => void conversationsStore.toggleConversationPin(conversation.id)),
 			separator: canOpenInNewTab
 		},
+		// a filed-away chat rests out of the sidebar's sections; its menu, and the
+		// search dialog that finds it, are how it comes back
+		{
+			icon: conversation.archived ? ArchiveRestore : Archive,
+			label: conversation.archived ? 'Restore' : 'Archive',
+			// filing away leaves the sidebar, so it asks first; restoring does not
+			onclick: run(() => {
+				if (conversation.archived) {
+					void conversationsStore.setConversationArchived(conversation.id, false);
+
+					return;
+				}
+
+				uiStore.openConversationArchive(conversation.id);
+			})
+		},
 		{
 			icon: Pencil,
 			label: 'Edit',
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
index 36f0ffe51..6db82046f 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
@@ -3,6 +3,7 @@
 	import { PanelLeftClose, PanelLeftOpen, Search, Settings, SquarePen } from '@lucide/svelte';
 	import {
 		ActionIcon,
+		DialogConversationArchive,
 		DialogConversationDelete,
 		DialogConversationRename,
 		DialogConversationShare,
@@ -180,8 +181,13 @@
 	let renameDraft = $state('');
 	let renameOriginalTitle = $state('');

+	// a filed-away chat shows in no section, so a selection never reaches it
+	const sidebarConversations = $derived(
+		conversationsStore.conversations.filter((c) => !c.archived)
+	);
+
 	const renderedOrderIds = $derived(
-		buildConversationTree(conversationsStore.conversations).map((t) => t.conversation.id)
+		buildConversationTree(sidebarConversations).map((t) => t.conversation.id)
 	);

 	const allSelectedArePinned = $derived.by(() => {
@@ -221,7 +227,7 @@
 	});

 	const visibleSelectionStats = $derived.by(() => {
-		const visibleIds = conversationsStore.conversations.map((c) => c.id);
+		const visibleIds = sidebarConversations.map((c) => c.id);

 		let selectedVisible = 0;

@@ -257,7 +263,7 @@
 	}

 	function toggleSelectAllVisible() {
-		const visibleIds = conversationsStore.conversations.map((c) => c.id);
+		const visibleIds = sidebarConversations.map((c) => c.id);
 		const allSelected = visibleIds.length > 0 && visibleIds.every((id) => selectedIds.has(id));

 		if (allSelected) {
@@ -284,6 +290,24 @@
 		await conversationsStore.bulkToggleConversationPin(ids);
 	}

+	/** A chat filed away, with its fork family, leaves the sidebar and so the selection. */
+	function dropArchivedFromSelection() {
+		const shown = new Set(sidebarConversations.map((c) => c.id));
+
+		for (const id of [...selectedIds]) {
+			if (!shown.has(id)) selectedIds.delete(id);
+		}
+	}
+
+	async function handleBulkArchive() {
+		const ids = Array.from(selectedIds);
+
+		if (ids.length === 0) return;
+
+		await conversationsStore.bulkSetConversationsArchived(ids, true);
+		dropArchivedFromSelection();
+	}
+
 	async function handleBulkExport() {
 		const ids = Array.from(selectedIds);

@@ -365,6 +389,21 @@
 		uiStore.conversationDeleteId = null;
 	}

+	async function handleArchiveConfirm() {
+		const id = uiStore.conversationArchiveId;
+
+		uiStore.conversationArchiveId = null;
+
+		if (!id) return;
+
+		await conversationsStore.setConversationArchived(id, true);
+		dropArchivedFromSelection();
+	}
+
+	function handleArchiveCancel() {
+		uiStore.conversationArchiveId = null;
+	}
+
 	function handleStopGeneration(id: string) {
 		chatStore.stopGenerationForChat(id);
 	}
@@ -676,6 +715,7 @@
 						conversations={conversationsStore.conversations}
 						{currentChatId}
 						{isSelectionMode}
+						onBulkArchive={handleBulkArchive}
 						onBulkDelete={handleBulkDelete}
 						onBulkExport={handleBulkExport}
 						onBulkPinToggle={handleBulkPinToggle}
@@ -768,6 +808,12 @@
 	onConfirm={handleRenameConfirm}
 />

+<DialogConversationArchive
+	bind:open={() => uiStore.conversationArchiveId !== null, (open) => !open && handleArchiveCancel()}
+	onCancel={handleArchiveCancel}
+	onConfirm={handleArchiveConfirm}
+/>
+
 <DialogConversationDelete
 	bind:open={() => uiStore.conversationDeleteId !== null, (open) => !open && handleDeleteCancel()}
 	onCancel={handleDeleteCancel}
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 79a52302c..3311080b4 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
@@ -45,6 +45,7 @@
 		allSelectedArePinned: boolean;
 		pinStateIsMixed: boolean;
 		onSelectAllToggle: () => void;
+		onBulkArchive: () => void;
 		onBulkPinToggle: () => void;
 		onBulkExport: () => void;
 		onBulkDelete: () => void;
@@ -58,6 +59,7 @@
 		conversations,
 		currentChatId,
 		isSelectionMode = false,
+		onBulkArchive,
 		onBulkDelete,
 		onBulkExport,
 		onBulkPinToggle,
@@ -92,30 +94,33 @@

 	// Every group is a section of its own, between Pinned and Recent. A pinned
 	// chat stays in Pinned; any other chat in a group shows in its section only,
-	// with its forks nested under it as in Recent.
+	// with its forks nested under it as in Recent. None of them show a filed-away
+	// chat: the search dialog is where those are found.
 	let groupSections = $derived(
 		groupsStore.groups.map((group) => ({
 			group,
 			items: conversationTree.filter(
-				({ conversation }) => conversation.groupId === group.id && !conversation.pinned
+				({ conversation }) =>
+					conversation.groupId === group.id && !conversation.pinned && !conversation.archived
 			)
 		}))
 	);

 	let pinnedConversations = $derived(
-		conversationTree.filter(({ conversation }) => conversation.pinned)
+		conversationTree.filter(({ conversation }) => conversation.pinned && !conversation.archived)
 	);

 	let unpinnedConversations = $derived(
 		conversationTree.filter(
-			({ conversation }) => !conversation.pinned && !groupsStore.groupIdOf(conversation)
+			({ conversation }) =>
+				!conversation.pinned && !conversation.archived && !groupsStore.groupIdOf(conversation)
 		)
 	);

 	/** How long the other sections take to slide aside for a moved one. */
 	const SECTION_MOVE_MS = 200;

-	// Pinned, the groups, then Recent by default; dragging a heading reorders them
+	// Pinned, the groups, then Recent; dragging a heading reorders them
 	let savedSections = $derived(
 		uiStore.orderSidebarSections([
 			...(pinnedConversations.length > 0
@@ -156,26 +161,37 @@
 		return conversationsStore.conversations.find((item) => item.id === convId);
 	}

+	// a chat pinned but filed away is not in Pinned, so Pinned can still take it back
 	function isPinned(convId: string): boolean {
-		return Boolean(findConversation(convId)?.pinned);
+		const conversation = findConversation(convId);
+
+		return Boolean(conversation?.pinned && !conversation.archived);
 	}

-	// the chats Ungrouped shows: neither pinned nor in a group that is still there
+	// the chats Ungrouped shows: not pinned, not archived, not in a group that is still there
 	function isUngrouped(convId: string): boolean {
 		const conversation = findConversation(convId);

-		return Boolean(conversation && !conversation.pinned && !groupsStore.groupIdOf(conversation));
+		return Boolean(
+			conversation &&
+			!conversation.pinned &&
+			!conversation.archived &&
+			!groupsStore.groupIdOf(conversation)
+		);
 	}

-	/** Dropping on Pinned pins the chat, wherever it came from. */
+	/** Dropping on Pinned brings the chat back and pins it, wherever it came from. */
 	async function handleDropPinned(convId: string) {
 		const conversation = conversationsStore.conversations.find((item) => item.id === convId);

-		if (conversation && !conversation.pinned)
-			await conversationsStore.toggleConversationPin(convId);
+		if (!conversation) return;
+
+		if (conversation.archived) await conversationsStore.setConversationArchived(convId, false);
+
+		if (!conversation.pinned) await conversationsStore.toggleConversationPin(convId);
 	}

-	/** Dropping on Recent unpins the chat and takes it out of its group. */
+	/** Dropping on Recent unpins the chat, takes it out of its group and back from the archive. */
 	async function handleDropRecent(convId: string) {
 		const conversation = conversationsStore.conversations.find((item) => item.id === convId);

@@ -184,6 +200,8 @@
 		if (conversation.pinned) await conversationsStore.toggleConversationPin(convId);

 		if (conversation.groupId) await conversationsStore.setConversationGroup(convId, null);
+
+		if (conversation.archived) await conversationsStore.setConversationArchived(convId, false);
 	}
 </script>

@@ -228,6 +246,7 @@
 			<SidebarNavigationSelectionBar
 				{allVisibleSelected}
 				class="sticky top-0 z-10 m-2 mt-0"
+				{onBulkArchive}
 				{onBulkDelete}
 				{onBulkExport}
 				{onBulkPinToggle}
@@ -258,6 +277,7 @@
 {#snippet conversationItem(conversation: DatabaseConversation, depth = 0)}
 	<SidebarNavigationConversationItem
 		conversation={{
+			archived: conversation.archived,
 			currNode: conversation.currNode,
 			forkedFromConversationId: conversation.forkedFromConversationId,
 			groupId: conversation.groupId,
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationSelectionBar.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationSelectionBar.svelte
index 9325a065b..d583cd38d 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationSelectionBar.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationSelectionBar.svelte
@@ -1,7 +1,11 @@
 <script lang="ts">
 	import { Checkbox } from '@ggml-org/llama-ui/ui/checkbox';
-	import { Download, Pin, PinOff, Trash2, X } from '@lucide/svelte';
-	import { ActionIcon, DialogConfirmation } from '#lib/components/app/index.ts';
+	import { Archive, Download, Pin, PinOff, Trash2, X } from '@lucide/svelte';
+	import {
+		ActionIcon,
+		DialogConfirmation,
+		DialogConversationArchive
+	} from '#lib/components/app/index.ts';
 	import { TooltipSide } from '#lib/enums/index.ts';

 	interface Props {
@@ -13,6 +17,7 @@
 		someSelectedPinned: boolean;
 		pinStateIsMixed: boolean;
 		onSelectAllToggle: () => void;
+		onBulkArchive: () => void;
 		onBulkPinToggle: () => void;
 		onBulkExport: () => void;
 		onBulkDelete: () => void;
@@ -22,6 +27,7 @@
 	let {
 		allVisibleSelected,
 		class: className = '',
+		onBulkArchive,
 		onBulkDelete,
 		onBulkExport,
 		onBulkPinToggle,
@@ -35,11 +41,17 @@
 	}: Props = $props();

 	let showDeleteDialog = $state(false);
+	let showArchiveDialog = $state(false);

 	function handleDeleteClick() {
 		showDeleteDialog = true;
 	}

+	// filing a selection away takes it out of the sidebar, so it asks first
+	function handleArchiveClick() {
+		showArchiveDialog = true;
+	}
+
 	function handleDeleteConfirm() {
 		showDeleteDialog = false;
 		onBulkDelete();
@@ -68,6 +80,8 @@
 	);

 	const pinDisabled = $derived(!hasSelection || pinStateIsMixed);
+
+	const archiveTooltip = $derived(selectedCount > 1 ? 'Archive all' : 'Archive');
 </script>

 <div
@@ -103,6 +117,20 @@
 			tooltipSide={TooltipSide.TOP}
 		/>

+		<ActionIcon
+			ariaLabel={archiveTooltip}
+			class="size-7 rounded-md bg-transparent backdrop-blur-none hover:bg-accent! {hasSelection
+				? 'opacity-100'
+				: 'opacity-40'}"
+			disabled={!hasSelection}
+			icon={Archive}
+			iconSize="size-icon-sm"
+			onclick={handleArchiveClick}
+			size="sm"
+			tooltip={archiveTooltip}
+			tooltipSide={TooltipSide.TOP}
+		/>
+
 		<ActionIcon
 			ariaLabel="Export selected"
 			class="size-7 rounded-md bg-transparent backdrop-blur-none hover:bg-accent! {hasSelection
@@ -146,6 +174,15 @@
 	</div>
 </div>

+<DialogConversationArchive
+	bind:open={showArchiveDialog}
+	onCancel={() => (showArchiveDialog = false)}
+	onConfirm={() => {
+		showArchiveDialog = false;
+		onBulkArchive();
+	}}
+/>
+
 <DialogConfirmation
 	bind:open={showDeleteDialog}
 	cancelText="Cancel"
diff --git a/ui/apps/chat/src/lib/components/app/navigation/index.ts b/ui/apps/chat/src/lib/components/app/navigation/index.ts
index 230bfb70d..c21afa564 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/index.ts
+++ b/ui/apps/chat/src/lib/components/app/navigation/index.ts
@@ -164,7 +164,9 @@ export { default as SidebarNavigationSelectionBar } from './SidebarNavigation/Si
  * **SidebarNavigationConversationList** - Grouped conversation list
  *
  * Pure-presentational list of conversations. Splits items into a Pinned
- * section and a Recent Conversations section with the unpinned items. Item selection, edit, delete,
+ * section, one section per group, and a Recent Conversations section with what
+ * is in neither; the chats filed away from their menus show in none of them,
+ * and the search dialog is where those are found. Item selection, edit, delete,
  * and stop-generation are delegated to the caller via callbacks.
  *
  * @example
@@ -187,8 +189,9 @@ export { default as SidebarNavigationFooter } from './SidebarNavigation/SidebarN
  * **ConversationActions** - The actions a conversation's menus offer
  *
  * Owns which actions a conversation has and what they do: open in a new tab,
- * pin, rename, move to a group, export, share to Hugging Face, select and
- * delete. It draws no menu itself: it hands the actions to its `children`,
+ * pin, archive, rename, move to a group, export, share to Hugging Face, select
+ * and delete. A filed-away chat leaves the sidebar's sections and rests out of
+ * them until restored; the search dialog is where it is found. It draws no menu itself: it hands the actions to its `children`,
  * so the sidebar row's dropdown and right-click menu and a tab's right-click
  * menu all show the same list. Rename, delete and share open the dialogs the
  * sidebar hosts through `uiStore`.
diff --git a/ui/apps/chat/src/lib/services/database.service.ts b/ui/apps/chat/src/lib/services/database.service.ts
index e77b97a96..17bb66f3a 100644
--- a/ui/apps/chat/src/lib/services/database.service.ts
+++ b/ui/apps/chat/src/lib/services/database.service.ts
@@ -94,6 +94,31 @@ export class DatabaseService {
 		);
 	}

+	/**
+	 * Sets the archived state of each conversation in `ids` inside a single
+	 * transaction, filing them away or bringing them back. A chat's pin and
+	 * group are kept as they are, so restoring one puts it back where it was.
+	 *
+	 * @param ids - Conversation IDs to set
+	 * @param archived - True to file them away, false to bring them back
+	 */
+	static async bulkSetConversationsArchived(ids: string[], archived: boolean): Promise<void> {
+		const cleanIds = ids.filter((id): id is string => typeof id === 'string' && id.length > 0);
+
+		if (cleanIds.length === 0) return;
+
+		await db.transaction('rw', db[IDXDB_TABLES.conversations], async () => {
+			const convs = await db[IDXDB_TABLES.conversations].bulkGet(cleanIds);
+			const updates = convs
+				.filter((conv): conv is DatabaseConversation => !!conv)
+				.map((conv) => ({ ...conv, archived }));
+
+			if (updates.length === 0) return;
+
+			await db[IDXDB_TABLES.conversations].bulkPut(updates);
+		});
+	}
+
 	/**
 	 * Toggles the pinned status of each conversation in `ids` inside a single
 	 * transaction. Treats `pinned === undefined` as `false`, matching the
@@ -120,8 +145,12 @@ export class DatabaseService {
 				if (!conv) continue;

 				const newPinned = !conv.pinned;
+				const updated: DatabaseConversation = { ...conv, pinned: newPinned };

-				updates.push({ ...conv, pinned: newPinned });
+				// a pinned chat shows under Pinned, which files no archived chat away
+				if (newPinned) delete updated.archived;
+
+				updates.push(updated);
 				result.set(cleanIds[i], newPinned);
 			}

@@ -639,7 +668,8 @@ export class DatabaseService {

 	/**
 	 * Puts conversations into a group, or out of any group when `groupId` is null.
-	 * A conversation that joins a group is unpinned.
+	 * A conversation that joins a group is unpinned and no longer archived, since a
+	 * group section shows neither.
 	 *
 	 * @param ids - Conversation IDs
 	 * @param groupId - Target group, null to take them out of their group
@@ -653,6 +683,8 @@ export class DatabaseService {
 					conversation.groupId = groupId;

 					if (conversation.pinned) conversation.pinned = false;
+
+					if (conversation.archived) conversation.archived = false;
 				} else {
 					delete conversation.groupId;
 				}
diff --git a/ui/apps/chat/src/lib/stores/chat/index.svelte.ts b/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
index dfbdadd06..9cbf91372 100644
--- a/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
@@ -783,6 +783,10 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost {

 		const activeConv = conversationsStore.activeConversation;

+		// writing in a filed-away chat brings it back to the sidebar, with or without its tab
+		if (activeConv?.archived)
+			await conversationsStore.setConversationArchived(activeConv.id, false);
+
 		// If agentic loop is running, inject as a steering message instead of starting a new flow
 		if (activeConv && agenticStore.isRunning(activeConv.id)) {
 			agenticStore.injectSteeringMessage(activeConv.id, content, extras);
diff --git a/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts b/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts
index 18636bab8..e66913584 100644
--- a/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts
@@ -227,7 +227,42 @@ class ConversationsStore implements ConversationsPreferencesHost {
 	}

 	/**
-	 * Toggles the pinned state of each conversation individually.
+	 * Sets the archived state of each conversation, filing them away out of the
+	 * sidebar's sections or bringing them back. A chat's pin and group are kept
+	 * as they are, so restoring one puts it back where it was.
+	 *
+	 * @param convIds - Conversation IDs to set
+	 * @param archived - True to file them away, false to bring them back
+	 */
+	async bulkSetConversationsArchived(convIds: string[], archived: boolean): Promise<void> {
+		if (convIds.length === 0) return;
+
+		const ids = [...new Set(convIds.flatMap((id) => collectForkFamily(this.conversations, id)))];
+
+		try {
+			await DatabaseService.bulkSetConversationsArchived(ids, archived);
+
+			for (const id of ids) this.applyConversationUpdate(id, { archived });
+
+			// the toast counts the whole family the write took, not just the clicked chats
+			if (ids.length === 1) {
+				toast.success(archived ? 'Conversation archived' : 'Conversation restored');
+
+				return;
+			}
+
+			toast.success(
+				archived ? `Archived ${ids.length} conversations` : `Restored ${ids.length} conversations`
+			);
+		} catch (error) {
+			console.error('Failed to bulk set archived state:', error);
+			toast.error(archived ? 'Failed to archive conversations' : 'Failed to restore conversations');
+		}
+	}
+
+	/**
+	 * Toggles the pinned state of each conversation individually. A chat that
+	 * becomes pinned is brought back from the archive, as Pinned shows none.
 	 * Mixed-pin selections are intentionally not normalised here; the bulk
 	 * action UI surfaces them as a disabled mixed-state instead.
 	 * @param convIds - Conversation IDs to toggle
@@ -237,16 +272,13 @@ class ConversationsStore implements ConversationsPreferencesHost {

 		try {
 			const updates = await DatabaseService.bulkToggleConversationPins(convIds);
-			const activeId = this.activeConversation?.id;
-
-			if (this.activeConversation && activeId && updates.has(activeId)) {
-				this.activeConversation.pinned = updates.get(activeId)!;
-			}
-
-			for (let i = 0; i < this.conversations.length; i++) {
-				const newPinned = updates.get(this.conversations[i].id);

-				if (newPinned !== undefined) this.conversations[i].pinned = newPinned;
+			for (const [convId, newPinned] of updates) {
+				// a pinned chat shows under Pinned, which files no archived chat away
+				this.applyConversationUpdate(
+					convId,
+					newPinned ? { archived: false, pinned: true } : { pinned: false }
+				);
 			}

 			toast.success(
@@ -704,10 +736,32 @@ class ConversationsStore implements ConversationsPreferencesHost {
 		return undefined;
 	}

+	/**
+	 * Files a conversation away out of the sidebar's sections, or brings it back, with its
+	 * whole fork family so a family never splits across the archive. Archiving keeps the
+	 * chats' pin and group, so restoring puts them back where they were; a chat's menu, or
+	 * writing in it again, is what restores it.
+	 *
+	 * @param convId - The conversation to file away or bring back
+	 * @param archived - True to archive, false to restore
+	 */
+	async setConversationArchived(convId: string, archived: boolean): Promise<void> {
+		const ids = collectForkFamily(this.conversations, convId);
+
+		try {
+			await DatabaseService.bulkSetConversationsArchived(ids, archived);
+
+			for (const id of ids) this.applyConversationUpdate(id, { archived });
+		} catch (error) {
+			console.error('Failed to archive conversation:', error);
+		}
+	}
+
 	/**
 	 * Moves a conversation with its whole fork family into a group, or out of one
 	 * when `groupId` is null: a family never splits across sections. A pinned chat
-	 * that joins a group leaves Pinned, since group sections do not show pinned chats.
+	 * that joins a group leaves Pinned, since group sections do not show pinned chats,
+	 * and an archived one comes back, since they do not show archived chats either.
 	 *
 	 * @param convId - Conversation to move
 	 * @param groupId - Target group, null to take the conversations out of their group
@@ -723,7 +777,8 @@ class ConversationsStore implements ConversationsPreferencesHost {

 				this.applyConversationUpdate(conversation.id, {
 					groupId: groupId ?? undefined,
-					...(groupId && conversation.pinned ? { pinned: false } : {})
+					...(groupId && conversation.pinned ? { pinned: false } : {}),
+					...(groupId && conversation.archived ? { archived: false } : {})
 				});
 			}
 		} catch (error) {
@@ -739,7 +794,9 @@ class ConversationsStore implements ConversationsPreferencesHost {
 	}

 	/**
-	 * Toggles the pinned status of a conversation.
+	 * Toggles the pinned status of a conversation. Pinning one that is archived
+	 * brings it back, since the Pinned section is where a pinned chat shows.
+	 *
 	 * @param convId - The conversation ID to toggle
 	 * @returns The new pinned status
 	 */
@@ -747,6 +804,9 @@ class ConversationsStore implements ConversationsPreferencesHost {
 		try {
 			const newPinnedState = await DatabaseService.toggleConversationPin(convId);

+			if (newPinnedState && this.conversations.find((c) => c.id === convId)?.archived)
+				await this.setConversationArchived(convId, false);
+
 			this.applyConversationUpdate(convId, { pinned: newPinnedState });

 			return newPinnedState;
diff --git a/ui/apps/chat/src/lib/stores/ui.svelte.ts b/ui/apps/chat/src/lib/stores/ui.svelte.ts
index 23b1e36bf..6e92d856b 100644
--- a/ui/apps/chat/src/lib/stores/ui.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/ui.svelte.ts
@@ -81,6 +81,9 @@ class UiStore {
 	/** Set when a flow outside the chat wants the composer focused once it can take it. */
 	composerFocusRequested = $state(false);

+	/** Conversation the archive dialog asks about, `null` while closed. */
+	conversationArchiveId = $state<string | null>(null);
+
 	/** Conversation the delete dialog asks about, `null` while closed. */
 	conversationDeleteId = $state<string | null>(null);

@@ -208,6 +211,11 @@ class UiStore {
 		return !this.collapsedSidebarSections.has(id);
 	}

+	/** Ask to file a conversation away, from any of its menus. */
+	openConversationArchive(conversationId: string): void {
+		this.conversationArchiveId = conversationId;
+	}
+
 	/** Ask to delete a conversation, from any of its menus. */
 	openConversationDelete(conversationId: string): void {
 		this.conversationDeleteId = conversationId;
diff --git a/ui/apps/chat/src/lib/types/database.d.ts b/ui/apps/chat/src/lib/types/database.d.ts
index e47d60fff..827c3897e 100644
--- a/ui/apps/chat/src/lib/types/database.d.ts
+++ b/ui/apps/chat/src/lib/types/database.d.ts
@@ -27,6 +27,8 @@ export interface DatabaseConversation {
 	/** Tool categories disabled for this conversation */
 	disabledToolCategories?: ToolSource[];
 	forkedFromConversationId?: string;
+	/** Out of every sidebar section, found through the search dialog, its pin and group kept. */
+	archived?: boolean;
 	/** Sidebar group the conversation is sorted into. */
 	groupId?: string;
 	pinned?: boolean;
diff --git a/ui/apps/chat/src/routes/search/+page.svelte b/ui/apps/chat/src/routes/search/+page.svelte
index c442b2f14..98ca2816a 100644
--- a/ui/apps/chat/src/routes/search/+page.svelte
+++ b/ui/apps/chat/src/routes/search/+page.svelte
@@ -21,7 +21,10 @@

 		if (query.length === 0) return [];

-		return conversationsStore.conversations.filter((c) => c.name.toLowerCase().includes(query));
+		// a filed-away chat rests out of the results; the search dialog is where it is found
+		return conversationsStore.conversations.filter(
+			(c) => !c.archived && c.name.toLowerCase().includes(query)
+		);
 	});

 	// Search page is intended for mobile; on desktop the sidebar already exposes
diff --git a/ui/apps/chat/tests/client/sidebar-conversation-archive.svelte.test.ts b/ui/apps/chat/tests/client/sidebar-conversation-archive.svelte.test.ts
new file mode 100644
index 000000000..35c504f43
--- /dev/null
+++ b/ui/apps/chat/tests/client/sidebar-conversation-archive.svelte.test.ts
@@ -0,0 +1,162 @@
+// A conversation filed away from its menu leaves the sidebar's sections entirely: it
+// shows in no section, pinned or otherwise, and the search dialog is where it is found
+// and brought back. Its menu reads "Restore" on any row that still shows it.
+
+import '../../src/app.css';
+import SidebarNavigationHarness from './components/SidebarNavigationHarness.svelte';
+import { SIDEBAR_SECTION_IDS, UI_DATA_ATTRS } from '#lib/constants/index.ts';
+import { conversationsStore, uiStore } from '#lib/stores/index.ts';
+import { beforeEach, describe, expect, it } from 'vitest';
+import { page } from 'vitest/browser';
+import { render } from 'vitest-browser-svelte';
+
+const DESKTOP = { height: 900, width: 1280 };
+const TRIGGER_NAME = 'More actions';
+const LOOSE = 'loose';
+const AWAY = 'archived';
+const AWAY_PINNED = 'pinned-away';
+
+/** A loose chat, one filed away, and one that is both filed away and pinned. */
+function conversations(): DatabaseConversation[] {
+	return [
+		{ currNode: null, id: LOOSE, lastModified: 3000, name: 'A chat left in the list' },
+		{ archived: true, currNode: null, id: AWAY, lastModified: 2000, name: 'A chat filed away' },
+		{
+			archived: true,
+			currNode: null,
+			id: AWAY_PINNED,
+			lastModified: 1000,
+			name: 'A pinned chat filed away',
+			pinned: true
+		}
+	];
+}
+
+/** The sidebar rows of one chat; a row mid-slide belongs to two sections at once. */
+function rowsOf(convId: string): HTMLElement[] {
+	return [
+		...document.querySelectorAll<HTMLElement>(`[${UI_DATA_ATTRS.CONVERSATION_ROW}="${convId}"]`)
+	];
+}
+
+/** Whether the sidebar shows that chat inside that section. */
+function holds(sectionId: string, convId: string): boolean {
+	const rows = rowsOf(convId);
+	const [row] = rows;
+
+	return rows.length === 1 && Boolean(row?.closest(`[data-sidebar-section="${sectionId}"]`));
+}
+
+/** The one row the sidebar shows for that chat. */
+async function rowOf(convId: string): Promise<HTMLElement> {
+	await expect.poll(() => rowsOf(convId).length).toBe(1);
+
+	const [row] = rowsOf(convId);
+
+	if (!row) throw new Error(`the sidebar shows no row for ${convId}`);
+
+	return row;
+}
+
+/**
+ * Open a row's "more actions" dropdown. Its trigger renders with the hover, and the pointer
+ * never lands on a sidebar row in the tester's frame, so the hover is dispatched by hand -
+ * as is the click, since a menu opened this way is not under the pointer.
+ */
+async function openRowDropdown(convId: string): Promise<void> {
+	const row = await rowOf(convId);
+	const trigger = () => row.querySelector<HTMLElement>('.actions button');
+
+	row.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
+
+	await expect.poll(() => trigger()?.textContent?.trim()).toBe(TRIGGER_NAME);
+
+	trigger()?.click();
+}
+
+/** The named action of the menu that is open. */
+async function clickMenuItem(label: string): Promise<void> {
+	const item = page.getByRole('menuitem', { name: label });
+
+	await expect.element(item).toBeVisible();
+
+	const element = item.element();
+
+	if (!(element instanceof HTMLElement)) throw new Error(`${label} is not a menu item`);
+
+	element.click();
+}
+
+describe('archived conversation in the sidebar', () => {
+	beforeEach(async () => {
+		await page.viewport(DESKTOP.width, DESKTOP.height);
+
+		uiStore.isSidebarExpanded = true;
+		conversationsStore.activeConversation = null;
+		conversationsStore.conversations = conversations();
+	});
+
+	it('shows no row for the chats filed away, in any section', async () => {
+		render(SidebarNavigationHarness);
+
+		await expect.poll(() => holds(SIDEBAR_SECTION_IDS.RECENT, LOOSE)).toBe(true);
+
+		// the filed-away chats rest out of the list entirely, pinned one included
+		expect(rowsOf(AWAY)).toHaveLength(0);
+		expect(rowsOf(AWAY_PINNED)).toHaveLength(0);
+
+		// Pinned shows no filed-away chat, so with only those it is not a section at all
+		const pinned = document.querySelector(`[data-sidebar-section="${SIDEBAR_SECTION_IDS.PINNED}"]`);
+
+		expect(pinned).toBeNull();
+	});
+
+	it('files a chat away from its dropdown, out of every section', async () => {
+		render(SidebarNavigationHarness);
+
+		await expect.poll(() => holds(SIDEBAR_SECTION_IDS.RECENT, LOOSE)).toBe(true);
+
+		await openRowDropdown(LOOSE);
+		await clickMenuItem('Archive');
+
+		// filing away asks first: the confirmation is what takes the chat out
+		const confirm = page.getByRole('button', { name: 'Archive' });
+
+		await expect.element(confirm).toBeVisible();
+
+		const element = confirm.element();
+
+		if (!(element instanceof HTMLElement)) throw new Error('Archive is not a button');
+
+		element.click();
+
+		await expect.poll(() => rowsOf(LOOSE)).toHaveLength(0);
+		expect(conversationsStore.conversations.find((c) => c.id === LOOSE)?.archived).toBe(true);
+	});
+
+	it('leaves the chats filed away out of the selection', async () => {
+		render(SidebarNavigationHarness);
+
+		const row = await rowOf(LOOSE);
+
+		row.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true }));
+
+		await clickMenuItem('Select');
+
+		// the one chat the sidebar shows is the whole selection, so Select all has nothing to add
+		await expect
+			.element(page.getByRole('toolbar', { name: 'Bulk actions for selected conversations' }))
+			.toHaveTextContent('1 / 1 selected');
+		await expect.element(page.getByRole('checkbox', { name: 'Deselect all' })).toBeVisible();
+	});
+
+	it('offers the same action in the row context menu', async () => {
+		render(SidebarNavigationHarness);
+
+		const row = await rowOf(LOOSE);
+
+		row.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true }));
+
+		await expect.element(page.getByRole('menuitem', { name: 'Archive' })).toBeVisible();
+	});
+});
diff --git a/ui/apps/chat/tests/stories/navigation/SidebarNavigation.stories.svelte b/ui/apps/chat/tests/stories/navigation/SidebarNavigation.stories.svelte
index 8c4f05ca8..ad06bf7be 100644
--- a/ui/apps/chat/tests/stories/navigation/SidebarNavigation.stories.svelte
+++ b/ui/apps/chat/tests/stories/navigation/SidebarNavigation.stories.svelte
@@ -46,6 +46,15 @@
 			name: 'Math Problem Solving'
 		}
 	];
+
+	// the same chats, the two oldest filed away: they leave the sidebar entirely,
+	// and the search dialog is the one place that still finds them
+	const mockArchivedConversations: DatabaseConversation[] = mockConversations.map(
+		(conversation, index) => ({
+			...conversation,
+			...(index >= 3 ? { archived: true } : {})
+		})
+	);
 </script>

 <Story
@@ -65,3 +74,21 @@
 		<SidebarNavigation />
 	</div>
 </Story>
+
+<Story
+	asChild
+	name="With filed-away chats, out of the list"
+	play={async () => {
+		const { conversationsStore } = await import('#lib/stores/conversations/index.svelte.ts');
+
+		waitFor(() =>
+			setTimeout(() => {
+				conversationsStore.conversations = mockArchivedConversations;
+			}, 0)
+		);
+	}}
+>
+	<div class="flex-column h-screen w-72 bg-background">
+		<SidebarNavigation />
+	</div>
+</Story>
diff --git a/ui/apps/chat/tests/unit/conversation-archive.test.ts b/ui/apps/chat/tests/unit/conversation-archive.test.ts
new file mode 100644
index 000000000..1b2a82b01
--- /dev/null
+++ b/ui/apps/chat/tests/unit/conversation-archive.test.ts
@@ -0,0 +1,207 @@
+// Archiving files a conversation away with its fork family, out of the Pinned, group
+// and Ungrouped sections, and keeps its pin and group so a restore puts
+// it back where it was. A chat given a home elsewhere instead - pinned, or moved into a
+// group - comes back on its own, so such an action on a filed-away chat never reads as
+// doing nothing.
+
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+vi.mock('#lib/services/database.service.ts', () => ({
+	DatabaseService: {
+		bulkSetConversationsArchived: vi.fn(),
+		bulkToggleConversationPins: vi.fn(),
+		setConversationsGroup: vi.fn(),
+		toggleConversationPin: vi.fn()
+	}
+}));
+
+import { DatabaseService } from '#lib/services/database.service.ts';
+import { conversationsStore } from '#lib/stores/conversations/index.svelte.ts';
+import type { DatabaseConversation } from '#lib/types/database.js';
+
+const bulkSetConversationsArchivedMock = vi.mocked(DatabaseService.bulkSetConversationsArchived);
+const bulkToggleConversationPinsMock = vi.mocked(DatabaseService.bulkToggleConversationPins);
+const setConversationsGroupMock = vi.mocked(DatabaseService.setConversationsGroup);
+const toggleConversationPinMock = vi.mocked(DatabaseService.toggleConversationPin);
+
+function makeConversation(overrides: Partial<DatabaseConversation> = {}): DatabaseConversation {
+	return {
+		currNode: null,
+		id: 'conv-1',
+		lastModified: 1000,
+		name: 'conversation',
+		...overrides
+	};
+}
+
+/** One row in the list, and the same object as the active conversation. */
+function showConversation(overrides: Partial<DatabaseConversation> = {}) {
+	const conversation = makeConversation(overrides);
+
+	conversationsStore.conversations = [conversation];
+	conversationsStore.activeConversation = conversation;
+
+	return conversation;
+}
+
+beforeEach(() => {
+	bulkSetConversationsArchivedMock.mockReset();
+	bulkSetConversationsArchivedMock.mockResolvedValue(undefined);
+
+	bulkToggleConversationPinsMock.mockReset();
+	bulkToggleConversationPinsMock.mockResolvedValue(new Map());
+
+	setConversationsGroupMock.mockReset();
+	setConversationsGroupMock.mockResolvedValue(undefined);
+
+	toggleConversationPinMock.mockReset();
+	toggleConversationPinMock.mockResolvedValue(false);
+
+	conversationsStore.conversations = [];
+	conversationsStore.activeConversation = null;
+});
+
+describe('setConversationArchived', () => {
+	it('writes the flag through and mirrors it into the row', async () => {
+		showConversation();
+
+		await conversationsStore.setConversationArchived('conv-1', true);
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1'], true);
+		expect(conversationsStore.conversations[0]?.archived).toBe(true);
+	});
+
+	it('mirrors the flag into the active conversation as well', async () => {
+		showConversation();
+
+		await conversationsStore.setConversationArchived('conv-1', true);
+
+		expect(conversationsStore.activeConversation?.archived).toBe(true);
+	});
+
+	it('brings the chat back with false', async () => {
+		showConversation({ archived: true });
+
+		await conversationsStore.setConversationArchived('conv-1', false);
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1'], false);
+		expect(conversationsStore.conversations[0]?.archived).toBe(false);
+	});
+
+	it('files the whole fork family away together', async () => {
+		conversationsStore.conversations = [
+			makeConversation(),
+			makeConversation({ forkedFromConversationId: 'conv-1', id: 'conv-2' })
+		];
+
+		await conversationsStore.setConversationArchived('conv-2', true);
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1', 'conv-2'], true);
+		expect(conversationsStore.conversations.every((c) => c.archived)).toBe(true);
+	});
+
+	it('keeps the row as it is when the write fails', async () => {
+		showConversation();
+		bulkSetConversationsArchivedMock.mockRejectedValue(new Error('IndexedDB is closed'));
+
+		await conversationsStore.setConversationArchived('conv-1', true);
+
+		expect(conversationsStore.conversations[0]?.archived).toBeUndefined();
+	});
+});
+
+describe('bulkSetConversationsArchived', () => {
+	it('writes the flag through for the whole selection and mirrors it into the rows', async () => {
+		const first = makeConversation({ id: 'conv-1' });
+		const second = makeConversation({ archived: true, id: 'conv-2' });
+
+		conversationsStore.conversations = [first, second];
+		conversationsStore.activeConversation = first;
+
+		await conversationsStore.bulkSetConversationsArchived(['conv-1', 'conv-2'], true);
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1', 'conv-2'], true);
+		expect(first.archived).toBe(true);
+		expect(second.archived).toBe(true);
+		expect(conversationsStore.activeConversation?.archived).toBe(true);
+	});
+
+	it('brings the selection back with false', async () => {
+		showConversation({ archived: true });
+
+		await conversationsStore.bulkSetConversationsArchived(['conv-1'], false);
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1'], false);
+		expect(conversationsStore.conversations[0]?.archived).toBe(false);
+	});
+
+	it('does nothing for an empty selection', async () => {
+		showConversation();
+
+		await conversationsStore.bulkSetConversationsArchived([], true);
+
+		expect(bulkSetConversationsArchivedMock).not.toHaveBeenCalled();
+		expect(conversationsStore.conversations[0]?.archived).toBeUndefined();
+	});
+
+	it('keeps the rows as they are when the write fails', async () => {
+		showConversation();
+		bulkSetConversationsArchivedMock.mockRejectedValue(new Error('IndexedDB is closed'));
+
+		await conversationsStore.bulkSetConversationsArchived(['conv-1'], true);
+
+		expect(conversationsStore.conversations[0]?.archived).toBeUndefined();
+	});
+});
+
+describe('a filed-away chat given a home elsewhere', () => {
+	it('comes back when it is pinned, which files it under Pinned', async () => {
+		showConversation({ archived: true });
+		toggleConversationPinMock.mockResolvedValue(true);
+
+		await conversationsStore.toggleConversationPin('conv-1');
+
+		expect(bulkSetConversationsArchivedMock).toHaveBeenCalledWith(['conv-1'], false);
+		expect(conversationsStore.conversations[0]?.archived).toBe(false);
+		expect(conversationsStore.conversations[0]?.pinned).toBe(true);
+	});
+
+	it('stays filed away when its pin is taken off it', async () => {
+		showConversation({ archived: true, pinned: true });
+		toggleConversationPinMock.mockResolvedValue(false);
+
+		await conversationsStore.toggleConversationPin('conv-1');
+
+		expect(bulkSetConversationsArchivedMock).not.toHaveBeenCalled();
+		expect(conversationsStore.conversations[0]?.archived).toBe(true);
+	});
+
+	it('comes back when a selection pins it too', async () => {
+		showConversation({ archived: true });
+		bulkToggleConversationPinsMock.mockResolvedValue(new Map([['conv-1', true]]));
+
+		await conversationsStore.bulkToggleConversationPin(['conv-1']);
+
+		expect(conversationsStore.conversations[0]?.archived).toBe(false);
+		expect(conversationsStore.conversations[0]?.pinned).toBe(true);
+		expect(conversationsStore.activeConversation?.archived).toBe(false);
+	});
+
+	it('comes back when it joins a group, which shows no archived chat either', async () => {
+		showConversation({ archived: true });
+
+		await conversationsStore.setConversationGroup('conv-1', 'group-1');
+
+		expect(setConversationsGroupMock).toHaveBeenCalledWith(['conv-1'], 'group-1');
+		expect(conversationsStore.conversations[0]?.archived).toBe(false);
+	});
+
+	it('stays filed away when it only leaves its group', async () => {
+		showConversation({ archived: true, groupId: 'group-1' });
+
+		await conversationsStore.setConversationGroup('conv-1', null);
+
+		expect(conversationsStore.conversations[0]?.archived).toBe(true);
+		expect(conversationsStore.conversations[0]?.groupId).toBeUndefined();
+	});
+});