ui: Stores consolidation refactor (#27238)

* ui: Remove dead code from stores

- persisted() helper was exported but never used
- messageUpdateCallback / registerMessageUpdateCallback were never wired up
- conversationsStore.initialize() alias, single caller moved to init()

* ui: Merge device, theme and viewport into a single deviceStore

All three are reactive browser-environment signals, now exposed as one
class store: deviceStore.isMobile, deviceStore.isIOSDevice / isIOSSafari
/ isWKWebView / isStandalone and deviceStore.systemTheme.isDark. The
systemTheme name disambiguates the OS preference from the user theme
preference in settingsStore. Drops the unused viewport export (only
isMobile was consumed).

* ui: Merge build info into version store

One VersionStore class with build (llama.cpp build number from
build.json) and frontend (PWA version from _app/version.json),
matching the class pattern of the other stores.

* ui: Colocate context gauge popup state with its components

The gauge popup state is local UI state shared only by the
ChatFormContextGauge subtree, so it lives next to its consumers
instead of the app-scope stores barrel.
This commit is contained in:
Aleksander Grygier
2026-08-18 16:37:26 +02:00
committed by GitHub
parent 04b569142d
commit fdf4c64604
28 changed files with 181 additions and 303 deletions
+42 -25
View File
@@ -1,44 +1,61 @@
/**
* versionStore - Frontend build version
* versionStore - Build version information
*
* Reads from SvelteKit's `_app/version.json` — generated by the @vite-pwa/sveltekit
* plugin. The version string changes on every build, so comparing it against
* localStorage reliably detects server upgrades.
* - `build`: llama.cpp build number from `build.json`, embedded at llama.cpp
* build time (LLAMA_BUILD_NUMBER). Shown in the UI when `showBuildVersion`
* is enabled.
* - `frontend`: frontend build version from SvelteKit's `_app/version.json`,
* generated by the @vite-pwa/sveltekit plugin. Changes on every build, so
* comparing it against localStorage reliably detects server upgrades.
*
* In dev mode, falls back to `'dev'`.
* In dev mode both fall back to `'dev'`.
*/
import { browser } from '$app/environment';
import { base } from '$app/paths';
let version = $state<string>('');
class VersionStore {
build = $state<string>('');
frontend = $state<string>('');
async function loadVersion() {
if (!browser) return;
constructor() {
if (!browser) return;
if (import.meta.env.DEV) {
version = 'dev';
if (import.meta.env.DEV) {
this.build = 'dev';
this.frontend = 'dev';
return;
return;
}
void this.load();
}
try {
const res = await fetch(`${base}/_app/version.json`, { cache: 'no-store' });
private async load(): Promise<void> {
try {
const res = await fetch(`${base}/build.json`, { cache: 'no-store' });
if (res.ok) {
const data = await res.json();
if (res.ok) {
const data = await res.json();
version = data.version ?? '';
this.build = data.version ?? '';
}
} catch {
// build.json missing or unreachable - leave as empty string
}
try {
const res = await fetch(`${base}/_app/version.json`, { cache: 'no-store' });
if (res.ok) {
const data = await res.json();
this.frontend = data.version ?? '';
}
} catch {
// version.json missing or unreachable - leave as empty string
}
} catch {
// _app/version.json missing or unreachable - leave as empty string
}
}
loadVersion();
export const versionStore = {
get value(): string {
return version;
}
};
export const versionStore = new VersionStore();