new chat shortcut

This commit is contained in:
Aidan Bleser 2025-06-17 13:16:03 -05:00
parent e4bb379d77
commit f80d8f6ef7
2 changed files with 31 additions and 6 deletions

View file

@ -5,6 +5,8 @@
import { PUBLIC_CONVEX_URL } from '$env/static/public'; import { PUBLIC_CONVEX_URL } from '$env/static/public';
import { models } from '$lib/state/models.svelte'; import { models } from '$lib/state/models.svelte';
import GlobalModal from '$lib/components/ui/modal/global-modal.svelte'; import GlobalModal from '$lib/components/ui/modal/global-modal.svelte';
import { shortcut } from '$lib/actions/shortcut.svelte';
import { goto } from '$app/navigation';
let { children } = $props(); let { children } = $props();
@ -12,6 +14,10 @@
models.init(); models.init();
</script> </script>
<svelte:window
use:shortcut={{ ctrl: true, shift: true, key: 'o', callback: () => goto('/chat') }}
/>
<ModeWatcher /> <ModeWatcher />
{@render children()} {@render children()}

View file

@ -30,6 +30,22 @@
}, },
]; ];
type Shortcut = {
name: string;
keys: string[];
};
const shortcuts: Shortcut[] = [
{
name: 'Toggle Sidebar',
keys: [cmdOrCtrl, 'B'],
},
{
name: 'New Chat',
keys: [cmdOrCtrl, 'Shift', 'O'],
},
];
async function signOut() { async function signOut() {
await authClient.signOut(); await authClient.signOut();
@ -69,14 +85,17 @@
<div class="mt-4 flex w-full flex-col gap-2"> <div class="mt-4 flex w-full flex-col gap-2">
<span class="text-sm font-medium">Keyboard Shortcuts</span> <span class="text-sm font-medium">Keyboard Shortcuts</span>
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<div class="flex place-items-center justify-between"> {#each shortcuts as { name, keys } (name)}
<span class="text-muted-foreground text-sm">Toggle Sidebar </span> <div class="flex place-items-center justify-between">
<span class="text-muted-foreground text-sm">{name}</span>
<div> <div class="flex place-items-center gap-1">
<Kbd>{cmdOrCtrl}</Kbd> {#each keys as key (key)}
<Kbd>B</Kbd> <Kbd>{key}</Kbd>
{/each}
</div>
</div> </div>
</div> {/each}
</div> </div>
</div> </div>
</div> </div>