Commit 2359d27a3 for llama.cpp

commit 2359d27a3694f220b190e5947684fcd4b3b2340f
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Mon Nov 23 15:45:44 2026 +0100

    ui: name the PWA from the build env and default it to Llama Chat (#32890)

    The manifest is built in Node by its Vite plugin, where import.meta.env is not set, so it was
    always named llama-ui whatever VITE_PUBLIC_APP_NAME said. The plugin now names it from the env
    Vite loaded (.env files included), and the default name is Llama Chat.

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/ui/apps/chat/.env.example b/ui/apps/chat/.env.example
index ed46f9ade..9760b0dd4 100644
--- a/ui/apps/chat/.env.example
+++ b/ui/apps/chat/.env.example
@@ -1,4 +1,4 @@
-VITE_PUBLIC_APP_NAME='llama-ui'
+VITE_PUBLIC_APP_NAME='Llama Chat'
 VITE_DEBUG='true'
 VITE_PUBLIC_SERVER_ORIGIN='http://localhost:8033'

diff --git a/ui/apps/chat/scripts/vite-plugin-pwa-manifest.ts b/ui/apps/chat/scripts/vite-plugin-pwa-manifest.ts
index d6ba3d2aa..a82eac906 100644
--- a/ui/apps/chat/scripts/vite-plugin-pwa-manifest.ts
+++ b/ui/apps/chat/scripts/vite-plugin-pwa-manifest.ts
@@ -1,12 +1,11 @@
 import { HEADERS } from '../src/lib/constants/headers.constants';
 import {
 	PWA_FILE_PATHS,
-	PWA_MANIFEST,
-	PWA_MANIFEST_PLUGIN
+	PWA_MANIFEST_PLUGIN,
+	pwaManifest
 } from '../src/lib/constants/pwa.constants';
 import type { Plugin } from 'vite';

-const MANIFEST_SOURCE = JSON.stringify(PWA_MANIFEST);
 // the build writes files relative to its output directory: the path without its leading slash
 const MANIFEST_FILE = PWA_FILE_PATHS.MANIFEST.slice(1);

@@ -15,17 +14,24 @@ const MANIFEST_FILE = PWA_FILE_PATHS.MANIFEST.slice(1);
  * The adapter copies the client output, so the file lands at the root of the build.
  */
 export function pwaManifestPlugin(): Plugin {
+	let manifestSource = '';
+
 	return {
+		// named from the env Vite loaded (.env files too): this module runs in Node, where
+		// import.meta.env is not set and APP_NAME would fall back to its default
+		configResolved(config) {
+			manifestSource = JSON.stringify(pwaManifest(config.env));
+		},
 		configureServer(server) {
 			server.middlewares.use(PWA_FILE_PATHS.MANIFEST, (_req, res) => {
 				res.setHeader(HEADERS.CONTENT_TYPE, PWA_MANIFEST_PLUGIN.CONTENT_TYPE);
-				res.end(MANIFEST_SOURCE);
+				res.end(manifestSource);
 			});
 		},
 		generateBundle() {
 			if (this.environment.name !== PWA_MANIFEST_PLUGIN.ENVIRONMENT) return;

-			this.emitFile({ fileName: MANIFEST_FILE, source: MANIFEST_SOURCE, type: 'asset' });
+			this.emitFile({ fileName: MANIFEST_FILE, source: manifestSource, type: 'asset' });
 		},
 		name: PWA_MANIFEST_PLUGIN.NAME
 	};
diff --git a/ui/apps/chat/src/lib/constants/app.constants.ts b/ui/apps/chat/src/lib/constants/app.constants.ts
index c598f480f..8e87264c3 100644
--- a/ui/apps/chat/src/lib/constants/app.constants.ts
+++ b/ui/apps/chat/src/lib/constants/app.constants.ts
@@ -1 +1 @@
-export const APP_NAME = import.meta.env?.VITE_PUBLIC_APP_NAME || 'llama-ui';
+export const APP_NAME = import.meta.env?.VITE_PUBLIC_APP_NAME || 'Llama Chat';
diff --git a/ui/apps/chat/src/lib/constants/pwa.constants.ts b/ui/apps/chat/src/lib/constants/pwa.constants.ts
index 734356fb7..71e9cbfeb 100644
--- a/ui/apps/chat/src/lib/constants/pwa.constants.ts
+++ b/ui/apps/chat/src/lib/constants/pwa.constants.ts
@@ -45,6 +45,10 @@ export const APPLE_ASSETS = {
 	TOUCH_ICON: 'apple-touch-icon-180x180.png'
 } as const;

+/**
+ * The web app manifest. In the browser APP_NAME follows the env; the manifest plugin runs in
+ * Node, where import.meta.env is not set, so it names the manifest with pwaManifest().
+ */
 export const PWA_MANIFEST = {
 	background_color: THEME_COLORS.BACKGROUND_LIGHT,
 	description: 'Local AI chat interface powered by llama.cpp',
@@ -68,6 +72,13 @@ export const PWA_MANIFEST = {
 	theme_color: THEME_COLORS.BACKGROUND_LIGHT
 };

+/** PWA_MANIFEST with the name a build sets (VITE_PUBLIC_APP_NAME) */
+export function pwaManifest(env: Record<string, string | undefined>) {
+	const name = env.VITE_PUBLIC_APP_NAME || PWA_MANIFEST.name;
+
+	return { ...PWA_MANIFEST, name, short_name: name };
+}
+
 export const PWA_ICON_PATHS = {
 	MASKABLE_512: '/maskable-icon-512x512.png',
 	PWA_64: '/pwa-64x64.png',