From fdf4c6460477e2761faac4527fc6266e48a893f0 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Tue, 18 Aug 2026 16:37:26 +0200 Subject: [PATCH] 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. --- .../ChatFormActionsAdd.svelte | 4 +- .../ChatFormActionModels.svelte | 10 +- .../ChatFormContextGauge.svelte | 7 +- .../ContextGaugeDetails.svelte | 2 +- .../ContextGaugePopup.svelte | 7 +- .../gauge-popup.svelte.ts} | 0 .../ChatFormInput/ChatFormInputBasic.svelte | 4 +- .../ChatFormInput/ChatFormInputRich.svelte | 6 +- .../ChatFormPickerMention.svelte | 4 +- .../ChatMessage/ChatMessage.svelte | 4 +- .../app/chat/ChatScreen/ChatScreen.svelte | 30 ++--- .../app/chat/ChatScreen/ChatScreenForm.svelte | 6 +- .../SidebarNavigation.svelte | 22 ++-- .../SidebarNavigationActions.svelte | 8 +- tools/ui/src/lib/hooks/use-pwa.svelte.ts | 2 +- tools/ui/src/lib/stores/build-info.svelte.ts | 45 -------- tools/ui/src/lib/stores/chat.svelte.ts | 3 - .../ui/src/lib/stores/conversations.svelte.ts | 25 ---- tools/ui/src/lib/stores/device.svelte.ts | 107 +++++++++++------- tools/ui/src/lib/stores/index.ts | 22 +--- tools/ui/src/lib/stores/persisted.svelte.ts | 51 --------- tools/ui/src/lib/stores/settings.svelte.ts | 4 +- tools/ui/src/lib/stores/theme.svelte.ts | 14 --- tools/ui/src/lib/stores/version.svelte.ts | 67 +++++++---- tools/ui/src/lib/stores/viewport.svelte.ts | 9 -- tools/ui/src/routes/(chat)/+page.svelte | 2 +- tools/ui/src/routes/+layout.svelte | 15 ++- tools/ui/src/routes/search/+page.svelte | 4 +- 28 files changed, 181 insertions(+), 303 deletions(-) rename tools/ui/src/lib/{stores/context-gauge-popup.svelte.ts => components/app/chat/ChatForm/ChatFormContextGauge/gauge-popup.svelte.ts} (100%) delete mode 100644 tools/ui/src/lib/stores/build-info.svelte.ts delete mode 100644 tools/ui/src/lib/stores/persisted.svelte.ts delete mode 100644 tools/ui/src/lib/stores/theme.svelte.ts delete mode 100644 tools/ui/src/lib/stores/viewport.svelte.ts diff --git a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionsAdd.svelte b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionsAdd.svelte index 47bdb47a4..b2581f11e 100644 --- a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionsAdd.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionsAdd.svelte @@ -2,10 +2,10 @@ import ChatFormActionAddButton from './ChatFormActionAddButton.svelte'; import ChatFormActionAddDropdown from './ChatFormActionAddDropdown.svelte'; import ChatFormActionAddSheet from './ChatFormActionAddSheet.svelte'; - import { isMobile } from '$lib/stores'; + import { deviceStore } from '$lib/stores'; -{#if isMobile.current} +{#if deviceStore.isMobile} {#snippet trigger({ disabled, onclick })} diff --git a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionModels.svelte b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionModels.svelte index fad223a98..689ef8c3a 100644 --- a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionModels.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionModels.svelte @@ -1,6 +1,12 @@ -{#if isMobile.current} +{#if deviceStore.isMobile} import ContextGaugeDial from './ContextGaugeDial.svelte'; - import { useContextGauge } from '$lib/hooks/use-context-gauge.svelte'; import { - chatStore, - conversationsStore, gaugeTriggerClick, gaugeTriggerEnter, gaugeTriggerKeydown, gaugeTriggerLeave, gaugeTriggerPointerDown - } from '$lib/stores'; + } from './gauge-popup.svelte'; + import { useContextGauge } from '$lib/hooks/use-context-gauge.svelte'; + import { chatStore, conversationsStore } from '$lib/stores'; import { untrack } from 'svelte'; const gauge = useContextGauge(); diff --git a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormContextGauge/ContextGaugeDetails.svelte b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormContextGauge/ContextGaugeDetails.svelte index eaaba69de..1153c70fd 100644 --- a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormContextGauge/ContextGaugeDetails.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormContextGauge/ContextGaugeDetails.svelte @@ -1,9 +1,9 @@