Commit 08cd108a1 for llama.cpp

commit 08cd108a147f67bef9c04018d02ba8fd3047a263
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Wed Dec 2 16:30:02 2026 +0100

    ui: navigate through typed routes, and let the dev proxy reach llama-server (#33539)

    * ui: let the dev proxy pass llama-server's cross-origin check

    llama-server refuses browser requests whose Origin does not match its own
    host unless --cors-origins allows it, and the Vite proxy forwarded the
    page's Origin (localhost:5173, or a LAN or Tailscale address). Loading a
    model, saving tools and /v1 calls failed with 403 under `vite dev`.

    The proxy now calls the server with its own Host and no Origin, WebSocket
    upgrades included. Sec-Fetch-Site still passes through, so requests from
    other sites stay refused.

    Assisted-by: Claude (Opus 5.5 Medium)

    * ui: navigate through resolve() with typed route ids

    ROUTES holds the app's route ids, as page.route.id reports them, in
    place of hash strings and the separate *_ROUTE_ID constants. Every link
    and goto() goes through resolve() from $app/paths, which checks the
    route exists and returns its URL (#/models with the hash router).
    RouterService resolves the route that takes a param, a chat's. Tab
    links and sidebar items carry the resolved URL's type, and checks for
    the current page compare page.route.id instead of the hash.

    svelte/no-navigation-without-resolve is on again, with type information
    for the app's modules so a URL typed as ResolvedPathname passes. The
    goto wrapper that keeps an installed app to one history entry is its
    one exception: it passes on a URL its callers resolved.

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/ui/apps/chat/eslint.config.js b/ui/apps/chat/eslint.config.js
index c34d898c1..f4786f8ae 100644
--- a/ui/apps/chat/eslint.config.js
+++ b/ui/apps/chat/eslint.config.js
@@ -289,7 +289,6 @@ export default ts.config(
 			'simple-import-sort/imports': ['error', { groups: [['.*']] }],
 			'svelte/no-at-html-tags': 'off',
 			// This app uses hash-based routing (#/) where resolve() from $app/paths does not apply
-			'svelte/no-navigation-without-resolve': 'off',

 			// Sort HTML attributes alphabetically in the markup. The Svelte directives
 			// (bind:/use:/animate:/style:/in:/out:/transition:/class:) sort first,
@@ -345,9 +344,20 @@ export default ts.config(
 		}
 	},
 	{
-		// the one place that wraps SvelteKit's goto, and its test
+		// the one place that wraps SvelteKit's goto, and its test: the wrapper passes on a URL its
+		// callers resolved
 		files: ['src/lib/utils/navigation.ts', 'tests/client/navigation.svelte.test.ts'],
-		rules: { 'no-restricted-imports': 'off', 'no-restricted-syntax': 'off' }
+		rules: {
+			'no-restricted-imports': 'off',
+			'no-restricted-syntax': 'off',
+			'svelte/no-navigation-without-resolve': 'off'
+		}
+	},
+	{
+		// type information for the app's own modules too, so svelte/no-navigation-without-resolve
+		// accepts a URL typed as ResolvedPathname, such as RouterService.chat(id)
+		files: ['src/**/*.ts'],
+		languageOptions: { parserOptions: { projectService: true } }
 	},
 	{
 		// Exclude generated build output and Storybook files from ESLint
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte
index 3720c3dfd..b5d7c1083 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte
@@ -31,6 +31,7 @@
 	import { parseFilesToMessageExtras } from '#lib/utils/browser-only.ts';
 	import { deriveAgenticSections } from '#lib/utils/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
+	import { resolve } from '$app/paths';

 	interface Props {
 		class?: string;
@@ -243,7 +244,7 @@
 			const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id);

 			if (conversationDeleted) {
-				goto(ROUTES.START);
+				goto(resolve(ROUTES.START));
 			}

 			return;
@@ -284,7 +285,7 @@
 			const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id);

 			if (conversationDeleted) {
-				goto(ROUTES.START);
+				goto(resolve(ROUTES.START));
 			}
 		} else {
 			chatActions.delete(message);
@@ -372,7 +373,7 @@
 				isEditing = false;

 				if (conversationDeleted) {
-					goto(ROUTES.START);
+					goto(resolve(ROUTES.START));
 				} else {
 					focusMainChatForm();
 				}
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte
index 97e65b432..dc7d16c3b 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte
@@ -83,7 +83,7 @@
 			<HoverCard.Trigger
 				class="hover:bg-muted/80 focus-visible:ring-ring inline-flex max-w-full items-center gap-1.5 rounded-full border bg-muted px-2.5 py-1 text-caption transition-colors outline-none focus-visible:ring-2"
 				href={safeUrl}
-				rel="noopener noreferrer"
+				rel="external noopener noreferrer"
 				target="_blank"
 			>
 				{#if faviconUrl}
@@ -108,7 +108,7 @@
 						<a
 							class="line-clamp-3 text-label leading-snug hover:underline"
 							href={safeUrl}
-							rel="noopener noreferrer"
+							rel="external noopener noreferrer"
 							target="_blank">{result.title}</a
 						>

diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte
index 259e99617..cf761ab61 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte
@@ -369,7 +369,7 @@
 			{/if}

 			<div class="pointer-events-none flex flex-col gap-6 items-center w-full">
-				{#if stick.farFromBottom && page.url.hash.includes(ROUTES.CHAT) && page.params.id}
+				{#if stick.farFromBottom && page.route.id === ROUTES.CHAT && page.params.id}
 					<ChatScreenActionScrollDown onclick={() => stick.scrollToBottom('smooth')} />
 				{/if}
 			</div>
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte
index c01af20d6..d5c550956 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte
@@ -10,10 +10,11 @@
 		TAB_SURFACE_IDLE_CLASS,
 		UI_DATA_ATTRS
 	} from '#lib/constants/index.ts';
+	import type { ResolvedPathname } from '$app/types';
 	import type { Component } from 'svelte';

 	interface Tab {
-		href: string;
+		href: ResolvedPathname;
 		/** Marks the new-chat tab. */
 		icon?: Component;
 		id: string;
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte
index 9c8720c68..ffae3557c 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte
@@ -26,6 +26,7 @@
 		url.searchParams.set(URL_PARAMS.MODEL, model);

 		handleOpenChange(false);
+
 		goto(url.toString());
 	}
 </script>
diff --git a/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte b/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte
index c716652b0..256baa2dd 100644
--- a/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte
+++ b/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte
@@ -54,7 +54,7 @@
 			class="shrink-0 text-muted-foreground hover:text-foreground"
 			href={safeWebsiteUrl}
 			onclick={(e) => e.stopPropagation()}
-			rel="noopener noreferrer"
+			rel="external noopener noreferrer"
 			target="_blank"
 		>
 			<ExternalLink class="size-icon-xs" />
diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte
index 79de8a3fa..75d1b1de9 100644
--- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte
+++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte
@@ -76,7 +76,7 @@
 							aria-label="View base model on HuggingFace"
 							class="shrink-0 text-muted-foreground transition-colors hover:text-foreground"
 							href={HuggingFaceService.getModelUrl(baseModels[0])}
-							rel="noopener noreferrer"
+							rel="external noopener noreferrer"
 							target="_blank"
 						>
 							<ExternalLink class="size-icon-xs" />
@@ -90,7 +90,7 @@
 			<Button
 				class="h-auto gap-1.5 px-2.5 py-1.5 text-caption"
 				href={HuggingFaceService.getModelUrl(modelId)}
-				rel="noopener noreferrer"
+				rel="external noopener noreferrer"
 				size="sm"
 				target="_blank"
 				variant="secondary"
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 cb1bf33fb..36f0ffe51 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
@@ -45,6 +45,7 @@
 	} from '#lib/stores/index.ts';
 	import { buildConversationTree, hapticTap, remToPx } from '#lib/utils/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
+	import { resolve } from '$app/paths';
 	import { page } from '$app/state';
 	import { tick, untrack } from 'svelte';
 	import { SvelteSet } from 'svelte/reactivity';
@@ -157,7 +158,7 @@
 	});

 	$effect(() => {
-		if (deviceStore.isMobile && page.url.hash.includes(ROUTES.SEARCH)) {
+		if (deviceStore.isMobile && page.route.id === ROUTES.SEARCH) {
 			uiStore.isSidebarExpanded = false;
 		}
 	});
@@ -548,7 +549,7 @@

 <svelte:window bind:innerWidth onkeydown={handleKeydown} />

-{#if innerWidth > 768 || !page.url.hash.includes(ROUTES.SEARCH)}
+{#if innerWidth > 768 || page.route.id !== ROUTES.SEARCH}
 	<!-- svelte-ignore a11y_no_static_element_interactions -->
 	<aside
 		bind:this={asideEl}
@@ -611,7 +612,7 @@
 						class="pointer-events-auto size-10 rounded-full! md:size-9 {isStripHidden
 							? 'bg-transparent! hover:bg-transparent!'
 							: 'matte-key bg-card! hover:bg-card! dark:bg-muted-foreground/15! dark:hover:bg-muted-foreground/15!'}"
-						href={uiStore.isSidebarExpanded && !isLogoToggle ? ROUTES.START : undefined}
+						href={uiStore.isSidebarExpanded && !isLogoToggle ? resolve(ROUTES.START) : undefined}
 						icon={isLogoToggle && logoHovered
 							? uiStore.isSidebarExpanded
 								? PanelLeftClose
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte
index 6463e0acf..103345eb9 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte
@@ -66,11 +66,7 @@
 		return undefined;
 	}

-	function isItemActive(item: {
-		activeRouteId?: string;
-		activeRoutePrefix?: string;
-		activeUrlIncludes?: string;
-	}): boolean {
+	function isItemActive(item: DesktopIconStripItem): boolean {
 		if (item.activeRouteId) {
 			return page.route.id === item.activeRouteId;
 		}
diff --git a/ui/apps/chat/src/lib/components/app/servers/ServerErrorSplash.svelte b/ui/apps/chat/src/lib/components/app/servers/ServerErrorSplash.svelte
index 1c458a426..3daa74716 100644
--- a/ui/apps/chat/src/lib/components/app/servers/ServerErrorSplash.svelte
+++ b/ui/apps/chat/src/lib/components/app/servers/ServerErrorSplash.svelte
@@ -8,6 +8,7 @@
 	import { serverStore, settingsStore } from '#lib/stores/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
 	import { serverUrl } from '#lib/utils/server-config.ts';
+	import { resolve } from '$app/paths';
 	import { fade, fly, scale } from 'svelte/transition';

 	interface Props {
@@ -80,7 +81,7 @@

 				// Show success state briefly, then navigate to home
 				setTimeout(() => {
-					goto(ROUTES.START);
+					goto(resolve(ROUTES.START));
 				}, 1000);
 			} else {
 				// API key is invalid - User Story A
diff --git a/ui/apps/chat/src/lib/constants/routes.constants.ts b/ui/apps/chat/src/lib/constants/routes.constants.ts
index 851f11018..0dfb7ae48 100644
--- a/ui/apps/chat/src/lib/constants/routes.constants.ts
+++ b/ui/apps/chat/src/lib/constants/routes.constants.ts
@@ -1,3 +1,5 @@
+import type { RouteId } from '$app/types';
+
 /** Query params the chat routes read from the URL. */
 export const URL_PARAMS = {
 	/** Load the selected model instead of waiting for the first message. */
@@ -8,21 +10,20 @@ export const URL_PARAMS = {
 	QUERY: 'q'
 } as const;

+/**
+ * Route ids of the app's pages, as `page.route.id` reports them. Navigate with
+ * `resolve(ROUTES.MODELS)` from `$app/paths`, which checks the route exists and returns its URL
+ * (`#/models` with the hash router); URLs with ids come from RouterService.
+ */
 export const ROUTES = {
-	/** Chat base — for dynamic chat URLs use RouterService. */
-	CHAT: '#/chat',
+	/** A conversation. */
+	CHAT: '/(chat)/chat/[id]',
 	/** Models manager. */
-	MODELS: '#/models',
+	MODELS: '/models',
 	/** Search — mobile-only full-page conversation search. */
-	SEARCH: '#/search',
+	SEARCH: '/search',
 	/** Settings - a page on a phone, a dialog elsewhere. */
-	SETTINGS: '#/settings',
+	SETTINGS: '/settings',
 	/** Root — start of the app. */
-	START: '#/'
-} as const;
-
-/** SvelteKit route id of the models manager, as `page.route.id` reports it. */
-export const MODELS_ROUTE_ID = '/models';
-
-/** SvelteKit route id of the settings page, as `page.route.id` reports it. */
-export const SETTINGS_ROUTE_ID = '/settings';
+	START: '/(chat)'
+} as const satisfies Record<string, RouteId>;
diff --git a/ui/apps/chat/src/lib/constants/ui.constants.ts b/ui/apps/chat/src/lib/constants/ui.constants.ts
index fb6815773..60afa36e2 100644
--- a/ui/apps/chat/src/lib/constants/ui.constants.ts
+++ b/ui/apps/chat/src/lib/constants/ui.constants.ts
@@ -5,7 +5,7 @@ import {
 	SHORTCUT_SEARCH,
 	SHORTCUT_SETTINGS
 } from './keyboard-shortcuts.constants';
-import { MODELS_ROUTE_ID, SETTINGS_ROUTE_ID } from './routes.constants';
+import { ROUTES } from './routes.constants';
 import Search from '@lucide/svelte/icons/search';
 import Settings from '@lucide/svelte/icons/settings';
 import SquarePen from '@lucide/svelte/icons/square-pen';
@@ -182,14 +182,14 @@ export const SIDEBAR_ACTIONS_ITEMS: DesktopIconStripItem[] = [
 export const SIDEBAR_FOOTER_ITEMS: DesktopIconStripItem[] = [
 	{
 		action: SidebarAction.MANAGE_MODELS,
-		activeRouteId: MODELS_ROUTE_ID,
+		activeRouteId: ROUTES.MODELS,
 		icon: MODEL_ICON,
 		keys: SHORTCUT_MODELS,
 		tooltip: 'Models'
 	},
 	{
 		action: SidebarAction.SETTINGS,
-		activeRouteId: SETTINGS_ROUTE_ID,
+		activeRouteId: ROUTES.SETTINGS,
 		icon: Settings,
 		keys: SHORTCUT_SETTINGS,
 		tooltip: 'Settings'
diff --git a/ui/apps/chat/src/lib/services/index.ts b/ui/apps/chat/src/lib/services/index.ts
index 243d77a83..c4fa963d5 100644
--- a/ui/apps/chat/src/lib/services/index.ts
+++ b/ui/apps/chat/src/lib/services/index.ts
@@ -328,7 +328,7 @@ export {
  * - **All components/stores**: Call RouterService for dynamic route URLs
  *
  * **Key Responsibilities:**
- * - Build chat URLs for specific conversations: `RouterService.chat(id)` → `#/chat/:id`
+ * - Build chat URLs for specific conversations: `RouterService.chat(id)` → `#/chat/<id>`, via `resolve()`
  *
  * @see ROUTES in constants/routes.ts — static route base paths
  */
diff --git a/ui/apps/chat/src/lib/services/router.service.ts b/ui/apps/chat/src/lib/services/router.service.ts
index 314619249..13e8fccf6 100644
--- a/ui/apps/chat/src/lib/services/router.service.ts
+++ b/ui/apps/chat/src/lib/services/router.service.ts
@@ -1,13 +1,16 @@
 /**
- * RouterService - Builds app route paths
+ * RouterService - Builds app URLs
  *
- * Returns chat route strings from a single source of truth (ROUTES). No state.
+ * Resolves the route ids in ROUTES with their params into typed URLs (`#/…` with the hash
+ * router). No state.
  */

 import { ROUTES } from '#lib/constants/index.ts';
+import { resolve } from '$app/paths';
+import type { ResolvedPathname } from '$app/types';

 export class RouterService {
-	static chat(id: string): string {
-		return `${ROUTES.CHAT}/${id}`;
+	static chat(id: string): ResolvedPathname {
+		return resolve(ROUTES.CHAT, { id });
 	}
 }
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 6162caf5f..18636bab8 100644
--- a/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/conversations/index.svelte.ts
@@ -6,7 +6,6 @@
  * overrides, reasoning effort, cwd) live in ConversationPreferences,
  * composed as {@link ConversationsStore.preferences}.
  */
-
 import { NEW_CHAT_TAB_ID, ROUTES } from '#lib/constants/index.ts';
 import { MessageRole } from '#lib/enums/index.ts';
 import { ConversationTransferService } from '#lib/services/conversation-transfer.service.ts';
@@ -30,6 +29,7 @@ import {
 import { goto } from '#lib/utils/navigation.ts';
 import { withSearchChatsDisabled } from '#lib/utils/search-chats.ts';
 import { browser } from '$app/env';
+import { resolve } from '$app/paths';
 import { SvelteSet } from 'svelte/reactivity';
 import { toast } from 'svelte-sonner';

@@ -342,7 +342,7 @@ class ConversationsStore implements ConversationsPreferencesHost {

 			toast.success('All conversations deleted');

-			await goto(ROUTES.START);
+			await goto(resolve(ROUTES.START));
 		} catch (error) {
 			console.error('Failed to delete all conversations:', error);
 			toast.error('Failed to delete conversations');
@@ -668,7 +668,7 @@ class ConversationsStore implements ConversationsPreferencesHost {

 		this.clearActiveConversation();
 		this.preferences.pendingGroupId = null;
-		await goto(ROUTES.START);
+		await goto(resolve(ROUTES.START));
 	}

 	/**
diff --git a/ui/apps/chat/src/lib/stores/tabs.svelte.ts b/ui/apps/chat/src/lib/stores/tabs.svelte.ts
index 25ab1400e..2209a15d4 100644
--- a/ui/apps/chat/src/lib/stores/tabs.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/tabs.svelte.ts
@@ -16,7 +16,6 @@
  * - Tab order persists to localStorage and is pruned against the loaded
  *   conversation list on init. The new-chat tab is kept across reloads.
  */
-
 import {
 	CONVERSATION_TABS_LOCALSTORAGE_KEY,
 	NEW_CHAT_TAB_ID,
@@ -26,6 +25,8 @@ import { RouterService } from '#lib/services/router.service.ts';
 import type { TabView } from '#lib/utils/chat-tabs.ts';
 import { goto } from '#lib/utils/navigation.ts';
 import { browser } from '$app/env';
+import { resolve } from '$app/paths';
+import type { ResolvedPathname } from '$app/types';
 import { untrack } from 'svelte';

 export class TabsStore {
@@ -65,7 +66,7 @@ export class TabsStore {
 		id: string,
 		isActive: boolean,
 		view: Pick<TabView, 'fallbackHref' | 'hrefFor' | 'ids'> = {
-			fallbackHref: ROUTES.START,
+			fallbackHref: resolve(ROUTES.START),
 			hrefFor: (tabId) => this.hrefFor(tabId),
 			ids: this.openTabs
 		}
@@ -116,8 +117,8 @@ export class TabsStore {
 		if (activeId && ids.includes(activeId)) await goto(view.hrefFor(keepId));
 	}

-	hrefFor(id: string): string {
-		return id === NEW_CHAT_TAB_ID ? ROUTES.START : RouterService.chat(id);
+	hrefFor(id: string): ResolvedPathname {
+		return id === NEW_CHAT_TAB_ID ? resolve(ROUTES.START) : RouterService.chat(id);
 	}

 	/**
diff --git a/ui/apps/chat/src/lib/stores/ui.svelte.ts b/ui/apps/chat/src/lib/stores/ui.svelte.ts
index aaec13bca..23b1e36bf 100644
--- a/ui/apps/chat/src/lib/stores/ui.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/ui.svelte.ts
@@ -5,9 +5,7 @@
  * (e.g. the desktop sidebar's expanded/collapsed state, which the sidebar
  * controls and the chat tab bar reacts to).
  */
-
 import {
-	MODELS_ROUTE_ID,
 	ROUTES,
 	SETTINGS_KEYS,
 	SIDEBAR_COLLAPSED_SECTIONS_LOCALSTORAGE_KEY,
@@ -24,7 +22,9 @@ import type { Group } from '#lib/types/groups.js';
 import { remToPx } from '#lib/utils/css.ts';
 import { goto } from '#lib/utils/navigation.ts';
 import { browser } from '$app/env';
+import { resolve } from '$app/paths';
 import { page } from '$app/state';
+import type { ResolvedPathname } from '$app/types';
 import { SvelteSet } from 'svelte/reactivity';

 interface ConversationShareOptions {
@@ -117,7 +117,7 @@ class UiStore {
 	modelDetailsFocus = $state<string | null>(null);

 	/** Route the models page returns to: the last page visited before it. */
-	modelsReturnRoute: string = ROUTES.START;
+	modelsReturnRoute: ResolvedPathname = resolve(ROUTES.START);
 	/** Bumped to close every open models selector; a counter, so no selector has to reset it. */
 	modelsSelectorCloseSignal = $state(0);
 	/** Section ids in the order the user dragged them into, kept across reloads. */
@@ -148,7 +148,7 @@ class UiStore {

 	/** Whether the models manager route is the current page. */
 	get isModelsPageOpen(): boolean {
-		return page.route.id === MODELS_ROUTE_ID;
+		return page.route.id === ROUTES.MODELS;
 	}

 	/** Whether the desktop sidebar is expanded (open); remembered across reloads on desktop. */
@@ -255,7 +255,7 @@ class UiStore {
 	openModelsManager(): void {
 		if (!this.isModelsManagerShown || this.isModelsPageOpen) return;

-		void goto(ROUTES.MODELS);
+		void goto(resolve(ROUTES.MODELS));
 	}

 	/**
@@ -291,7 +291,8 @@ class UiStore {
 	rememberModelsReturnRoute(): void {
 		if (this.isModelsPageOpen) return;

-		this.modelsReturnRoute = page.url.hash || ROUTES.START;
+		// with the hash router, the page's hash is its resolved URL
+		this.modelsReturnRoute = (page.url.hash as ResolvedPathname) || resolve(ROUTES.START);
 	}
 	/** Ask the composer to take focus, e.g. after a dialog closes onto the chat. */
 	requestComposerFocus(): void {
diff --git a/ui/apps/chat/src/lib/types/navigation.d.ts b/ui/apps/chat/src/lib/types/navigation.d.ts
index 90012d8ba..4de568a17 100644
--- a/ui/apps/chat/src/lib/types/navigation.d.ts
+++ b/ui/apps/chat/src/lib/types/navigation.d.ts
@@ -1,4 +1,5 @@
 import type { MenuKind, SidebarAction } from '#lib/enums/index.ts';
+import type { ResolvedPathname } from '$app/types';
 import type { Component, Snippet } from 'svelte';

 /**
@@ -7,7 +8,8 @@ import type { Component, Snippet } from 'svelte';
 export interface DesktopIconStripItem {
 	icon: Component;
 	tooltip: string;
-	route?: string;
+	/** A page of the app, from `resolve()` */
+	route?: ResolvedPathname;
 	/** Custom action handled by the sidebar, e.g. opening a new-chat tab */
 	action?: SidebarAction;
 	activeRouteId?: string;
diff --git a/ui/apps/chat/src/lib/utils/chat-tabs.ts b/ui/apps/chat/src/lib/utils/chat-tabs.ts
index f080e42ed..07b05d33d 100644
--- a/ui/apps/chat/src/lib/utils/chat-tabs.ts
+++ b/ui/apps/chat/src/lib/utils/chat-tabs.ts
@@ -1,5 +1,7 @@
 import { NEW_CHAT_TAB_ID, ROUTES } from '#lib/constants/index.ts';
 import { RouterService } from '#lib/services/router.service.ts';
+import { resolve } from '$app/paths';
+import type { ResolvedPathname } from '$app/types';

 interface TabRoute {
 	params: Partial<Record<string, string>>;
@@ -11,8 +13,8 @@ export interface TabView {
 	/** Tab of the current route; null on a page without one. */
 	activeId: string | null;
 	/** Where to go when the last visible tab closes. */
-	fallbackHref: string;
-	hrefFor: (id: string) => string;
+	fallbackHref: ResolvedPathname;
+	hrefFor: (id: string) => ResolvedPathname;
 	/** Visible tab ids, in strip order. */
 	ids: string[];
 }
@@ -31,8 +33,8 @@ export function resolveTabTarget(page: TabRoute): string | null {
 export function resolveTabView(page: TabRoute, openTabs: string[]): TabView {
 	return {
 		activeId: resolveTabTarget(page),
-		fallbackHref: ROUTES.START,
-		hrefFor: (id) => (id === NEW_CHAT_TAB_ID ? ROUTES.START : RouterService.chat(id)),
+		fallbackHref: resolve(ROUTES.START),
+		hrefFor: (id) => (id === NEW_CHAT_TAB_ID ? resolve(ROUTES.START) : RouterService.chat(id)),
 		ids: openTabs
 	};
 }
diff --git a/ui/apps/chat/src/routes/(chat)/chat/[id]/+page.svelte b/ui/apps/chat/src/routes/(chat)/chat/[id]/+page.svelte
index bb588ce53..b3be488f3 100644
--- a/ui/apps/chat/src/routes/(chat)/chat/[id]/+page.svelte
+++ b/ui/apps/chat/src/routes/(chat)/chat/[id]/+page.svelte
@@ -4,6 +4,7 @@
 	import { chatStore, conversationsStore, modelsStore } from '#lib/stores/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
 	import { afterNavigate } from '$app/navigation';
+	import { resolve } from '$app/paths';
 	import { page } from '$app/state';

 	let chatId = $derived(page.params.id);
@@ -29,6 +30,7 @@

 		url.searchParams.delete(URL_PARAMS.QUERY);
 		url.searchParams.delete(URL_PARAMS.MODEL);
+
 		goto(url.toString(), { replace: true, shallow: true });
 	}

@@ -98,7 +100,7 @@
 				const success = await conversationsStore.loadConversation(chatId);

 				if (!success) {
-					await goto(ROUTES.START);
+					await goto(resolve(ROUTES.START));

 					return;
 				}
diff --git a/ui/apps/chat/src/routes/+error.svelte b/ui/apps/chat/src/routes/+error.svelte
index 2ed4bc20d..07faa4cbd 100644
--- a/ui/apps/chat/src/routes/+error.svelte
+++ b/ui/apps/chat/src/routes/+error.svelte
@@ -2,6 +2,7 @@
 	import { ServerErrorSplash } from '#lib/components/app/index.ts';
 	import { APP_NAME, ROUTES } from '#lib/constants/index.ts';
 	import { goto } from '#lib/utils/navigation.ts';
+	import { resolve } from '$app/paths';
 	import { page } from '$app/state';

 	let error = $derived(page.error);
@@ -18,7 +19,7 @@

 	function handleRetry() {
 		// Navigate back to home page after successful API key validation
-		goto(ROUTES.START);
+		goto(resolve(ROUTES.START));
 	}
 </script>

@@ -65,7 +66,7 @@

 			<button
 				class="rounded-md bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90"
-				onclick={() => goto(ROUTES.START)}
+				onclick={() => goto(resolve(ROUTES.START))}
 			>
 				Go Home
 			</button>
diff --git a/ui/apps/chat/src/routes/+layout.svelte b/ui/apps/chat/src/routes/+layout.svelte
index 3674b3eec..7ed35e037 100644
--- a/ui/apps/chat/src/routes/+layout.svelte
+++ b/ui/apps/chat/src/routes/+layout.svelte
@@ -19,7 +19,6 @@
 		FAVICON_PATHS,
 		FAVICON_SELECTORS,
 		HEADERS,
-		MODELS_ROUTE_ID,
 		NEW_CHAT_TAB_ID,
 		ROUTES,
 		SETTINGS_KEYS,
@@ -189,9 +188,9 @@

 		untrack(() => {
 			if (
-				(page.route.id === '/(chat)' ||
-					page.route.id === '/(chat)/chat/[id]' ||
-					page.route.id === MODELS_ROUTE_ID) &&
+				(page.route.id === ROUTES.START ||
+					page.route.id === ROUTES.CHAT ||
+					page.route.id === ROUTES.MODELS) &&
 				page.status !== 401 &&
 				page.status !== 403
 			) {
@@ -423,7 +422,7 @@

 			<!-- the phone sidebar sits under the page, so its toggle rides on the page; it steps
 			     aside while the expanded chat form covers the screen -->
-			{#if deviceStore.isMobile && !page.url.hash.includes(ROUTES.SEARCH) && !uiStore.isComposerExpanded}
+			{#if deviceStore.isMobile && page.route.id !== ROUTES.SEARCH && !uiStore.isComposerExpanded}
 				<div transition:fade={{ duration: CHAT_FORM_CHROME_FADE_MS }}>
 					<GlassKey
 						class="sidebar-reveal-pin-top fixed top-(--corner-control-top) left-4 z-30"
diff --git a/ui/apps/chat/src/routes/search/+page.svelte b/ui/apps/chat/src/routes/search/+page.svelte
index 6a180e07c..c442b2f14 100644
--- a/ui/apps/chat/src/routes/search/+page.svelte
+++ b/ui/apps/chat/src/routes/search/+page.svelte
@@ -6,6 +6,7 @@
 	import { goto, shouldReplaceHistory } from '#lib/utils/navigation.ts';
 	import { browser } from '$app/env';
 	import { afterNavigate } from '$app/navigation';
+	import { resolve } from '$app/paths';
 	import { page } from '$app/state';

 	let searchQuery = $state('');
@@ -27,7 +28,7 @@
 	// in-place search, so bounce back to a new-chat tab without a history entry.
 	$effect(() => {
 		if (browser && !deviceStore.isMobile) {
-			goto(ROUTES.START, { replace: true });
+			goto(resolve(ROUTES.START), { replace: true });
 		}
 	});

diff --git a/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts b/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts
index a1166c03b..88d66f5d1 100644
--- a/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts
+++ b/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts
@@ -2,7 +2,6 @@
 // group inset in the sidebar and a row in the group. This holds the rule app.css states for
 // them, on what the browser actually renders: a row's corners are concentric with its
 // group's, so its radius is the group's less the padding between their edges.
-
 import '../../src/app.css';
 import SidebarNavigationActions from '#lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte';
 import SidebarNavigationFooter from '#lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte';
diff --git a/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte b/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte
index c51ee56c3..95a5a5b36 100644
--- a/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte
+++ b/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte
@@ -2,7 +2,9 @@
 	import { SquarePen } from '@lucide/svelte';
 	import { defineMeta } from '@storybook/addon-svelte-csf';
 	import ChatTabsItem from '#lib/components/app/chat/ChatTabs/ChatTabsItem.svelte';
-	import { NEW_CHAT_LABEL, NEW_CHAT_TAB_ID } from '#lib/constants/index.ts';
+	import { NEW_CHAT_LABEL, NEW_CHAT_TAB_ID, ROUTES } from '#lib/constants/index.ts';
+	import { RouterService } from '#lib/services/router.service.ts';
+	import { resolve } from '$app/paths';
 	import StateGallery from '$llama-ui-stories/helpers/StateGallery.svelte';
 	import StateGalleryItem from '$llama-ui-stories/helpers/StateGalleryItem.svelte';

@@ -14,7 +16,7 @@
 		title: 'Llama Chat/Chat/ChatTabs/ChatTabsItem'
 	});

-	const tab = { href: '#/chat/conv-1', id: 'conv-1', name: 'Rust borrow checker' };
+	const tab = { href: RouterService.chat('conv-1'), id: 'conv-1', name: 'Rust borrow checker' };

 	const handlers = {
 		onActivate: (id: string) => console.log('activate', id),
@@ -37,7 +39,12 @@
 			<ChatTabsItem
 				{...handlers}
 				isActive
-				tab={{ href: '#/', icon: SquarePen, id: NEW_CHAT_TAB_ID, name: NEW_CHAT_LABEL }}
+				tab={{
+					href: resolve(ROUTES.START),
+					icon: SquarePen,
+					id: NEW_CHAT_TAB_ID,
+					name: NEW_CHAT_LABEL
+				}}
 			/>
 		</StateGalleryItem>

diff --git a/ui/apps/chat/vite.config.ts b/ui/apps/chat/vite.config.ts
index 80e60ef94..02df8737d 100644
--- a/ui/apps/chat/vite.config.ts
+++ b/ui/apps/chat/vite.config.ts
@@ -13,7 +13,7 @@ import { playwright } from '@vitest/browser-playwright';
 import { mdsvex } from 'mdsvex';
 import { dirname, resolve } from 'path';
 import { fileURLToPath } from 'url';
-import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite';
+import { defineConfig, loadEnv, type ProxyOptions, searchForWorkspaceRoot } from 'vite';

 const __dirname = dirname(fileURLToPath(import.meta.url));
 const LLAMA_VOICE_SOURCE = resolve(__dirname, '../../lib/voice/src');
@@ -58,6 +58,18 @@ export default defineConfig(({ command, mode }) => {
 	const huggingFace = env.VITE_PUBLIC_HUGGING_FACE
 		? env.VITE_PUBLIC_HUGGING_FACE === 'true'
 		: command === 'serve';
+	// llama-server takes cross-origin browser requests only from --cors-origins, so the proxy
+	// calls it as its own page: the Host of the server and no Origin. Sec-Fetch-Site still
+	// passes through, so the server keeps refusing requests from other sites.
+	const toServer = (ws = false): ProxyOptions => ({
+		changeOrigin: true,
+		configure: (proxy) => {
+			proxy.on('proxyReq', (req) => req.removeHeader('origin'));
+			proxy.on('proxyReqWs', (req) => req.removeHeader('origin'));
+		},
+		target: SERVER_ORIGIN,
+		ws
+	});

 	return {
 		build: {
@@ -149,13 +161,13 @@ export default defineConfig(({ command, mode }) => {
 				'Cross-Origin-Opener-Policy': 'same-origin'
 			},
 			proxy: {
-				'/cors-proxy': SERVER_ORIGIN,
-				'/models': SERVER_ORIGIN,
-				'/props': SERVER_ORIGIN,
-				'/slots': SERVER_ORIGIN,
-				'/tools': SERVER_ORIGIN,
+				'/cors-proxy': toServer(),
+				'/models': toServer(),
+				'/props': toServer(),
+				'/slots': toServer(),
+				'/tools': toServer(),
 				// ws: realtime transcription (/v1/realtime) is a WebSocket
-				'/v1': { target: SERVER_ORIGIN, ws: true }
+				'/v1': toServer(true)
 			}
 		},