Spaces:
Sleeping
Sleeping
Andrew
commited on
Commit
·
9a5b276
1
Parent(s):
1d2459b
refactor(ui): update layout to handle persona state initialization
Browse files- src/routes/+layout.svelte +14 -6
src/routes/+layout.svelte
CHANGED
|
@@ -24,6 +24,7 @@
|
|
| 24 |
import IconShare from "$lib/components/icons/IconShare.svelte";
|
| 25 |
import { shareModal } from "$lib/stores/shareModal";
|
| 26 |
import BackgroundGenerationPoller from "$lib/components/BackgroundGenerationPoller.svelte";
|
|
|
|
| 27 |
|
| 28 |
let { data = $bindable(), children } = $props();
|
| 29 |
|
|
@@ -150,7 +151,7 @@
|
|
| 150 |
}
|
| 151 |
|
| 152 |
// Global keyboard shortcut: New Chat (Ctrl/Cmd + Shift + O)
|
| 153 |
-
const onKeydown = (e: KeyboardEvent) => {
|
| 154 |
// Ignore when a modal has focus (app is inert)
|
| 155 |
const appEl = document.getElementById("app");
|
| 156 |
if (appEl?.hasAttribute("inert")) return;
|
|
@@ -159,6 +160,12 @@
|
|
| 159 |
const metaOrCtrl = e.metaKey || e.ctrlKey;
|
| 160 |
if (oPressed && e.shiftKey && metaOrCtrl) {
|
| 161 |
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
isAborted.set(true);
|
| 163 |
goto(`${base}/`, { invalidateAll: true });
|
| 164 |
}
|
|
@@ -242,14 +249,14 @@
|
|
| 242 |
|
| 243 |
<div
|
| 244 |
class="fixed grid h-full w-screen grid-cols-1 grid-rows-[auto,1fr] overflow-hidden text-smd {!isNavCollapsed
|
| 245 |
-
? 'md:grid-cols-[290px,1fr]'
|
| 246 |
-
: 'md:grid-cols-[0px,1fr]'} transition-[
|
| 247 |
>
|
| 248 |
<ExpandNavigation
|
| 249 |
isCollapsed={isNavCollapsed}
|
| 250 |
onClick={() => (isNavCollapsed = !isNavCollapsed)}
|
| 251 |
-
classNames="absolute inset-y-0 z-10 my-auto {!isNavCollapsed
|
| 252 |
-
? 'left-[290px]'
|
| 253 |
: 'left-0'} *:transition-transform"
|
| 254 |
/>
|
| 255 |
|
|
@@ -274,7 +281,8 @@
|
|
| 274 |
/>
|
| 275 |
</MobileNav>
|
| 276 |
<nav
|
| 277 |
-
class="grid max-h-screen grid-cols-1 grid-rows-[auto,1fr,auto] overflow-hidden
|
|
|
|
| 278 |
>
|
| 279 |
<NavMenu
|
| 280 |
{conversations}
|
|
|
|
| 24 |
import IconShare from "$lib/components/icons/IconShare.svelte";
|
| 25 |
import { shareModal } from "$lib/stores/shareModal";
|
| 26 |
import BackgroundGenerationPoller from "$lib/components/BackgroundGenerationPoller.svelte";
|
| 27 |
+
import { resetActivePersonasToDefaults } from "$lib/utils/personaDefaults";
|
| 28 |
|
| 29 |
let { data = $bindable(), children } = $props();
|
| 30 |
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
// Global keyboard shortcut: New Chat (Ctrl/Cmd + Shift + O)
|
| 154 |
+
const onKeydown = async (e: KeyboardEvent) => {
|
| 155 |
// Ignore when a modal has focus (app is inert)
|
| 156 |
const appEl = document.getElementById("app");
|
| 157 |
if (appEl?.hasAttribute("inert")) return;
|
|
|
|
| 160 |
const metaOrCtrl = e.metaKey || e.ctrlKey;
|
| 161 |
if (oPressed && e.shiftKey && metaOrCtrl) {
|
| 162 |
e.preventDefault();
|
| 163 |
+
|
| 164 |
+
await resetActivePersonasToDefaults(
|
| 165 |
+
settings,
|
| 166 |
+
$settings.personas,
|
| 167 |
+
$settings.activePersonas
|
| 168 |
+
);
|
| 169 |
isAborted.set(true);
|
| 170 |
goto(`${base}/`, { invalidateAll: true });
|
| 171 |
}
|
|
|
|
| 249 |
|
| 250 |
<div
|
| 251 |
class="fixed grid h-full w-screen grid-cols-1 grid-rows-[auto,1fr] overflow-hidden text-smd {!isNavCollapsed
|
| 252 |
+
? 'md:grid-cols-[var(--sidebar-width,290px),1fr]'
|
| 253 |
+
: 'md:grid-cols-[0px,1fr]'} transition-[grid-template-columns] duration-300 dark:text-gray-300 md:grid-rows-[1fr]"
|
| 254 |
>
|
| 255 |
<ExpandNavigation
|
| 256 |
isCollapsed={isNavCollapsed}
|
| 257 |
onClick={() => (isNavCollapsed = !isNavCollapsed)}
|
| 258 |
+
classNames="absolute inset-y-0 z-10 my-auto transition-[left] duration-300 {!isNavCollapsed
|
| 259 |
+
? 'left-[var(--sidebar-width,290px)]'
|
| 260 |
: 'left-0'} *:transition-transform"
|
| 261 |
/>
|
| 262 |
|
|
|
|
| 281 |
/>
|
| 282 |
</MobileNav>
|
| 283 |
<nav
|
| 284 |
+
class="grid max-h-screen grid-cols-1 grid-rows-[auto,1fr,auto] overflow-hidden transition-[width,opacity] duration-300 max-md:hidden {isNavCollapsed ? 'opacity-0' : 'opacity-100'}"
|
| 285 |
+
style={!isNavCollapsed ? "width: var(--sidebar-width, 290px);" : "width: 0;"}
|
| 286 |
>
|
| 287 |
<NavMenu
|
| 288 |
{conversations}
|