Skip to content

Commit 5c1eb33

Browse files
skirkrunekomeowww
andauthored
feat: Refactor Font Configuration for Consistency and Correctness (#409)
* feat(unocss): centralize font configuration and fix cyrillic font handling (#389) This commit refactors the UnoCSS font configuration to establish a single source of truth and resolve issues with Cyrillic character rendering. - Centralizes all font definitions within the root uno.config.ts. - Updates the theme.fontFamily to use a correct fallback chain, ensuring "Comfortaa" is used for Cyrillic characters. - Restricts the "Kiwi Maru" font to Latin and Japanese character subsets to prevent incorrect application. - Simplifies application-specific uno.config.ts files by removing redundant local font overrides. * fix(ui): ensure provider models reload reactively (#407) This commit resolves a persistent reactivity issue where the model list would not update automatically after changing provider credentials. This was a recurring problem reported by users on Discord. Previously, the model list was only fetched when the consciousness settings page was first mounted. This meant that if a user updated an API key and navigated back, the page would still display the old, stale model list until the application was fully restarted. The fix introduces two key changes: 1. A `watch` effect has been added to the `providers.ts` store. It now monitors `providerCredentials` and automatically refetches the model list for a specific provider whenever its credentials change. 2. The `consciousness.vue` component now uses the `onActivated` lifecycle hook in addition to `onMounted`. This ensures that the model list is refreshed every time the component becomes active, such as when navigating back to it. A `watch` on the `activeProvider` was also added to handle provider switching within the page. These changes ensure that the model list is always synchronized with the current provider configuration, providing a much smoother and more intuitive user experience. Closes #407 --------- Co-authored-by: Neko <neko@ayaka.moe>
1 parent 31daae1 commit 5c1eb33

File tree

5 files changed

+32
-69
lines changed

5 files changed

+32
-69
lines changed

apps/realtime-audio/uno.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export default defineConfig({
1717
presetAttributify(),
1818
presetTypography(),
1919
presetWebFonts({
20-
fonts: {
21-
...presetWebFontsFonts('fontsource'),
22-
},
20+
fonts: presetWebFontsFonts('fontsource'),
2321
timeouts: {
2422
warning: 5000,
2523
failure: 10000,

apps/stage-tamagotchi/src/pages/settings/modules/consciousness.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Alert, ErrorContainer, RadioCardManySelect, RadioCardSimple } from '@pr
33
import { useConsciousnessStore } from '@proj-airi/stage-ui/stores/modules/consciousness'
44
import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers'
55
import { storeToRefs } from 'pinia'
6-
import { onMounted } from 'vue'
6+
import { onMounted, watch } from 'vue'
77
import { useI18n } from 'vue-i18n'
88
import { RouterLink } from 'vue-router'
99
@@ -23,9 +23,15 @@ const {
2323
2424
const { t } = useI18n()
2525
26-
onMounted(async () => {
27-
await consciousnessStore.loadModelsForProvider(activeProvider.value)
28-
})
26+
async function loadModelsForProvider() {
27+
if (activeProvider.value) {
28+
await consciousnessStore.loadModelsForProvider(activeProvider.value)
29+
}
30+
}
31+
32+
onMounted(loadModelsForProvider)
33+
34+
watch(activeProvider, loadModelsForProvider)
2935
3036
function updateCustomModelName(value: string) {
3137
customModelName.value = value

packages/stage-ui/src/stores/providers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,20 @@ export const useProvidersStore = defineStore('providers', () => {
23722372
}
23732373
}
23742374
}
2375+
// Watch for credential changes and refetch models accordingly
2376+
watch(providerCredentials, (newCreds, oldCreds) => {
2377+
// Determine which providers have changed credentials
2378+
const changedProviders = Object.keys(newCreds).filter(providerId =>
2379+
JSON.stringify(newCreds[providerId]) !== JSON.stringify(oldCreds?.[providerId]),
2380+
)
2381+
2382+
for (const providerId of changedProviders) {
2383+
// If the provider is configured and has the capability, refetch its models
2384+
if (configuredProviders.value[providerId] && providerMetadata[providerId]?.capabilities.listModels) {
2385+
fetchModelsForProvider(providerId)
2386+
}
2387+
}
2388+
}, { deep: true })
23752389

23762390
// Function to get localized provider metadata
23772391
function getProviderMetadata(providerId: string) {

packages/stage-ui/uno.config.ts

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,11 @@
1-
import { defineConfig, mergeConfigs, presetWebFonts } from 'unocss'
1+
import { defineConfig, mergeConfigs } from 'unocss'
22

33
import { histoireUnoConfig, sharedUnoConfig } from '../../uno.config'
44

55
export default mergeConfigs([
66
sharedUnoConfig(),
77
histoireUnoConfig(),
88
defineConfig({
9-
presets: [
10-
presetWebFonts({
11-
fonts: {
12-
'sans': {
13-
name: 'DM Sans Variable',
14-
provider: 'none',
15-
},
16-
'serif': {
17-
name: 'DM Serif Display',
18-
provider: 'none',
19-
},
20-
'mono': {
21-
name: 'DM Mono',
22-
provider: 'none',
23-
},
24-
'cute': {
25-
name: 'Kiwi Maru',
26-
provider: 'none',
27-
},
28-
'cuteen': {
29-
name: 'Sniglet',
30-
provider: 'none',
31-
},
32-
'jura': {
33-
name: 'Jura Variable',
34-
provider: 'none',
35-
},
36-
'gugi': {
37-
name: 'Gugi',
38-
provider: 'none',
39-
},
40-
'quicksand': {
41-
name: 'Quicksand Variable',
42-
provider: 'none',
43-
},
44-
'quanlai': {
45-
name: 'cjkfonts AllSeto',
46-
provider: 'none',
47-
},
48-
'xiaolai': {
49-
name: 'Xiaolai SC',
50-
provider: 'none',
51-
},
52-
'urbanist': {
53-
name: 'Urbanist Variable',
54-
provider: 'none',
55-
},
56-
'm-plus-rounded': {
57-
name: 'M PLUS Rounded 1c',
58-
provider: 'none',
59-
},
60-
},
61-
timeouts: {
62-
warning: 5000,
63-
failure: 10000,
64-
},
65-
}),
66-
],
9+
// All font configurations are now inherited from the root uno.config.ts
6710
}),
6811
])

uno.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function presetWebFontsFonts(provider: 'fontsource' | 'none'): Record<str
8585
'cutejp': {
8686
name: 'Kiwi Maru',
8787
provider,
88+
subsets: ['latin', 'japanese'],
8889
},
8990
'cuteen': {
9091
name: 'Sniglet',
@@ -109,6 +110,7 @@ export function presetWebFontsFonts(provider: 'fontsource' | 'none'): Record<str
109110
'comfortaa': {
110111
name: provider === 'fontsource' ? 'Comfortaa' : 'Comfortaa Variable',
111112
provider,
113+
subsets: ['cyrillic'],
112114
},
113115
'm-plus-rounded': {
114116
name: 'M PLUS Rounded 1c',
@@ -193,9 +195,9 @@ export function sharedUnoConfig() {
193195
fontFamily: {
194196
'sans': `"DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
195197
'sans-rounded': `"Comfortaa Variable", "Comfortaa", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
196-
'cute': `"Sniglet", "Kiwi Maru", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
197-
'cuteen': `"Sniglet", "Kiwi Maru", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
198-
'cutejp': `"Sniglet", "Kiwi Maru", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
198+
'cute': `"Sniglet", "Kiwi Maru", "Comfortaa", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
199+
'cuteen': `"Sniglet", "Kiwi Maru", "Comfortaa", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
200+
'cutejp': `"Sniglet", "Kiwi Maru", "Comfortaa", "xiaolai", "DM Sans Variant", "DM Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";`,
199201
},
200202
/**
201203
* https://github.com/unocss/unocss/blob/1031312057a3bea1082b7d938eb2ad640f57613a/packages-presets/preset-wind4/src/theme/animate.ts

0 commit comments

Comments
 (0)