diff --git a/apps/stage-pocket/src/App.vue b/apps/stage-pocket/src/App.vue index 0b26667f5..825cf9e05 100644 --- a/apps/stage-pocket/src/App.vue +++ b/apps/stage-pocket/src/App.vue @@ -10,7 +10,7 @@ import { useContextBridgeStore } from '@proj-airi/stage-ui/stores/mods/api/conte import { useAiriCardStore } from '@proj-airi/stage-ui/stores/modules/airi-card' import { useArtistryStore } from '@proj-airi/stage-ui/stores/modules/artistry' import { useConsciousnessStore } from '@proj-airi/stage-ui/stores/modules/consciousness' -import { configureAsDefaultsIfEmpty } from '@proj-airi/stage-ui/stores/modules/default' +import { configureAsDefaultsIfEmpty, unconfigureAuthenticationProviders } from '@proj-airi/stage-ui/stores/modules/default' import { useHearingStore } from '@proj-airi/stage-ui/stores/modules/hearing' import { useSpeechStore } from '@proj-airi/stage-ui/stores/modules/speech' import { useVisionStore } from '@proj-airi/stage-ui/stores/modules/vision' @@ -51,6 +51,16 @@ useSettingsStageModel() useVisionStore() let stopAuthenticatedSetup: (() => void) | undefined +let stopLoggedOutSetup: (() => void) | undefined + +async function removeAuthenticationProviderConfiguration() { + if (!syncedPinia.isLeader()) + return + + if (await unconfigureAuthenticationProviders()) + await cardStore.persistActiveCardModuleSelections() +} + function registerAuthenticatedSetup() { stopAuthenticatedSetup ??= authStore.onAuthenticated(async () => { if (!syncedPinia.isLeader()) @@ -60,6 +70,7 @@ function registerAuthenticatedSetup() { await cardStore.persistActiveCardModuleSelections() await onboardingStore.closeAfterAuthentication() }) + stopLoggedOutSetup ??= authStore.onLogout(removeAuthenticationProviderConfiguration) } const primaryColor = computed(() => { @@ -103,6 +114,8 @@ onMounted(async () => { await displayModelsStore.initialize() await cardStore.initialize() registerAuthenticatedSetup() + if (!authStore.isAuthenticated) + await removeAuthenticationProviderConfiguration() if (onboardingStore.needsOnboarding) { onboardingStore.showingSetup = true @@ -122,6 +135,7 @@ onMounted(async () => { onUnmounted(() => { stopAuthenticatedSetup?.() + stopLoggedOutSetup?.() contextBridgeStore.dispose() }) diff --git a/apps/stage-tamagotchi/src/renderer/App.vue b/apps/stage-tamagotchi/src/renderer/App.vue index 1745977f5..2585fb38f 100644 --- a/apps/stage-tamagotchi/src/renderer/App.vue +++ b/apps/stage-tamagotchi/src/renderer/App.vue @@ -20,7 +20,7 @@ import { useContextBridgeStore } from '@proj-airi/stage-ui/stores/mods/api/conte import { useAiriCardStore } from '@proj-airi/stage-ui/stores/modules/airi-card' import { useArtistryStore } from '@proj-airi/stage-ui/stores/modules/artistry' import { useConsciousnessStore } from '@proj-airi/stage-ui/stores/modules/consciousness' -import { configureAsDefaultsIfEmpty } from '@proj-airi/stage-ui/stores/modules/default' +import { configureAsDefaultsIfEmpty, unconfigureAuthenticationProviders } from '@proj-airi/stage-ui/stores/modules/default' import { useHearingStore } from '@proj-airi/stage-ui/stores/modules/hearing' import { useSpeechStore } from '@proj-airi/stage-ui/stores/modules/speech' import { useVisionStore } from '@proj-airi/stage-ui/stores/modules/vision' @@ -140,6 +140,16 @@ function createFullStageRuntime() { useVisionStore() let stopAuthenticatedSetup: (() => void) | undefined + let stopLoggedOutSetup: (() => void) | undefined + + async function removeAuthenticationProviderConfiguration() { + if (!syncedPinia.isLeader()) + return + + if (await unconfigureAuthenticationProviders()) + await cardStore.persistActiveCardModuleSelections() + } + function registerAuthenticatedSetup() { stopAuthenticatedSetup ??= authStore.onAuthenticated(async () => { if (!syncedPinia.isLeader()) @@ -149,6 +159,7 @@ function createFullStageRuntime() { await cardStore.persistActiveCardModuleSelections() await onboardingStore.closeAfterAuthentication() }) + stopLoggedOutSetup ??= authStore.onLogout(removeAuthenticationProviderConfiguration) } const { activeProvider, artistryGlobals, activeModel, defaultPromptPrefix, providerOptions } = storeToRefs(artistryStore) @@ -254,6 +265,8 @@ function createFullStageRuntime() { await displayModelsStore.initialize() await cardStore.initialize() registerAuthenticatedSetup() + if (!authStore.isAuthenticated) + await removeAuthenticationProviderConfiguration() await displayModelsStore.loadDisplayModelsFromIndexedDB() await settingsStore.initializeStageModel() @@ -299,6 +312,7 @@ function createFullStageRuntime() { }, dispose() { stopAuthenticatedSetup?.() + stopLoggedOutSetup?.() contextBridgeStore.dispose() }, } diff --git a/apps/stage-web/src/App.vue b/apps/stage-web/src/App.vue index c19fcd92f..75d4a652e 100644 --- a/apps/stage-web/src/App.vue +++ b/apps/stage-web/src/App.vue @@ -12,7 +12,7 @@ import { useContextBridgeStore } from '@proj-airi/stage-ui/stores/mods/api/conte import { useAiriCardStore } from '@proj-airi/stage-ui/stores/modules/airi-card' import { useArtistryStore } from '@proj-airi/stage-ui/stores/modules/artistry' import { useConsciousnessStore } from '@proj-airi/stage-ui/stores/modules/consciousness' -import { configureAsDefaultsIfEmpty } from '@proj-airi/stage-ui/stores/modules/default' +import { configureAsDefaultsIfEmpty, unconfigureAuthenticationProviders } from '@proj-airi/stage-ui/stores/modules/default' import { useHearingStore } from '@proj-airi/stage-ui/stores/modules/hearing' import { useSpeechStore } from '@proj-airi/stage-ui/stores/modules/speech' import { useVisionStore } from '@proj-airi/stage-ui/stores/modules/vision' @@ -58,6 +58,16 @@ useSettingsStageModel() useVisionStore() let stopAuthenticatedSetup: (() => void) | undefined +let stopLoggedOutSetup: (() => void) | undefined + +async function removeAuthenticationProviderConfiguration() { + if (!syncedPinia.isLeader()) + return + + if (await unconfigureAuthenticationProviders()) + await cardStore.persistActiveCardModuleSelections() +} + function registerAuthenticatedSetup() { stopAuthenticatedSetup ??= authStore.onAuthenticated(async () => { if (!syncedPinia.isLeader()) @@ -67,6 +77,7 @@ function registerAuthenticatedSetup() { await cardStore.persistActiveCardModuleSelections() await onboardingStore.closeAfterAuthentication() }) + stopLoggedOutSetup ??= authStore.onLogout(removeAuthenticationProviderConfiguration) } const inferencePreload = useInferencePreload() @@ -118,6 +129,8 @@ onMounted(async () => { await displayModelsStore.initialize() await cardStore.initialize() registerAuthenticatedSetup() + if (!authStore.isAuthenticated) + await removeAuthenticationProviderConfiguration() if (onboardingStore.needsOnboarding) { onboardingStore.showingSetup = true @@ -138,6 +151,7 @@ onMounted(async () => { onUnmounted(() => { stopAuthenticatedSetup?.() + stopLoggedOutSetup?.() stopLeadershipListener() contextBridgeStore.dispose() }) diff --git a/packages/stage-pages/src/pages/settings/modules/consciousness.vue b/packages/stage-pages/src/pages/settings/modules/consciousness.vue index 03c32f10a..959395502 100644 --- a/packages/stage-pages/src/pages/settings/modules/consciousness.vue +++ b/packages/stage-pages/src/pages/settings/modules/consciousness.vue @@ -18,7 +18,7 @@ const airiCardStore = useAiriCardStore() const consciousnessStore = useConsciousnessStore() const consciousnessSettingsStore = useConsciousnessSettingsStore() const { configuredProviders } = storeToRefs(providerStore) -const { persistedChatProvidersMetadata } = storeToRefs(providersStore) +const { moduleChatProvidersMetadata } = storeToRefs(providersStore) const { reasoning } = storeToRefs(consciousnessSettingsStore) const { activeProvider, @@ -88,13 +88,13 @@ async function updateReasoning(value: boolean) { See also: https://stackoverflow.com/a/33737340 -->