Files
llama.cpp/tools/ui/tests/stories/SidebarNavigation.stories.svelte
T
Aleksander Grygier 6886628cb1 ui : Search dialog (#31173)
* ui : replace the sidebar search mode with a search dialog

Search opens a spotlight dialog (Cmd+K or the Search entry under New chat in the sidebar) with keyboard navigation over recent chats and sidebar actions. Phones keep the search page.

Sidebar actions show their shortcuts, with new ones for Settings (Cmd+,) and Models (Shift+Cmd+M).

Assisted-by: Claude (Opus 5.5 Medium)

* ui : ignore search dialog keys while an IME is composing

Enter confirms an IME candidate and the arrow keys move through the candidates, so the search field leaves them to the IME instead of opening the highlighted result or moving the highlight.

Assisted-by: Claude (Opus 5.5 Medium)
2026-10-28 08:53:41 +02:00

113 lines
2.8 KiB
Svelte

<script lang="ts" module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import SidebarNavigation from '$lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte';
import { expect } from 'storybook/test';
import { waitFor } from 'storybook/test';
import { screen } from 'storybook/test';
const { Story } = defineMeta({
component: SidebarNavigation,
parameters: {
layout: 'centered'
},
title: 'Components/SidebarNavigation'
});
</script>
<script lang="ts">
// Mock conversations for the sidebar
const mockConversations: DatabaseConversation[] = [
{
currNode: 'msg-1',
id: 'conv-1',
lastModified: Date.now() - 1000 * 60 * 5, // 5 minutes ago
name: 'Getting Started with AI'
},
{
currNode: 'msg-2',
id: 'conv-2',
lastModified: Date.now() - 1000 * 60 * 60 * 2, // 2 hours ago
name: 'Python Programming Help'
},
{
currNode: 'msg-3',
id: 'conv-3',
lastModified: Date.now() - 1000 * 60 * 60 * 24, // 1 day ago
name: 'Creative Writing Ideas'
},
{
currNode: 'msg-4',
id: 'conv-4',
lastModified: Date.now() - 1000 * 60 * 60 * 24 * 3, // 3 days ago
name: 'This is a very long conversation title that should be truncated properly when displayed'
},
{
currNode: 'msg-5',
id: 'conv-5',
lastModified: Date.now() - 1000 * 60 * 60 * 24 * 7, // 1 week ago
name: 'Math Problem Solving'
}
];
</script>
<Story
asChild
name="Default"
play={async () => {
const { conversationsStore } = await import('$lib/stores/conversations/index.svelte');
waitFor(() =>
setTimeout(() => {
conversationsStore.conversations = mockConversations;
}, 0)
);
}}
>
<div class="flex-column h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Story>
<Story
asChild
name="SearchActive"
play={async ({ userEvent }) => {
const { conversationsStore } = await import('$lib/stores/conversations/index.svelte');
waitFor(() =>
setTimeout(() => {
conversationsStore.conversations = mockConversations;
}, 0)
);
// Expand sidebar first, then click Search in the expanded button list
const logoTrigger = screen.getByRole('button', { name: /expand navigation/i });
await userEvent.click(logoTrigger);
const searchTrigger = screen.getByText('Search');
await userEvent.click(searchTrigger);
await expect(await screen.findByRole('combobox')).toHaveFocus();
}}
>
<div class="flex-column h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Story>
<Story
asChild
name="Empty"
play={async () => {
// Mock empty conversations store
const { conversationsStore } = await import('$lib/stores/conversations/index.svelte');
conversationsStore.conversations = [];
}}
>
<div class="flex-column h-screen w-72 bg-background">
<SidebarNavigation />
</div>
</Story>