mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 15:40:10 +00:00
## Summary - Fix auth related race conditions with a new WorkspaceAuthGate in App.vue - De dup initialization calls - Add state machine to track state of refreshRemoteConfig - Fix websocket not using new workspace jwt - Misc improvments ## Changes - **What**: Mainly WorkspaceAuthGate.vue - **Breaking**: <!-- Any breaking changes (if none, remove this line) --> - **Dependencies**: <!-- New dependencies (if none, remove this line) --> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8350-Feat-workspaces-5-auth-gate-check-2f66d73d365081b1a49afcd418fab3e7) by [Unito](https://www.unito.io)
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/**
|
|
* Remote configuration service
|
|
*
|
|
* Fetches configuration from the server at runtime, enabling:
|
|
* - Feature flags without rebuilding
|
|
* - Server-side feature discovery
|
|
* - Version compatibility management
|
|
* - Avoiding vendor lock-in for native apps
|
|
*
|
|
* This module is tree-shaken in OSS builds.
|
|
*/
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
import type { RemoteConfig } from './types'
|
|
|
|
/**
|
|
* Load state for remote configuration.
|
|
* - 'unloaded': No config loaded yet
|
|
* - 'anonymous': Config loaded without auth (bootstrap)
|
|
* - 'authenticated': Config loaded with auth (user-specific flags available)
|
|
* - 'error': Failed to load config
|
|
*/
|
|
type RemoteConfigState = 'unloaded' | 'anonymous' | 'authenticated' | 'error'
|
|
|
|
/**
|
|
* Current load state of remote configuration
|
|
*/
|
|
export const remoteConfigState = ref<RemoteConfigState>('unloaded')
|
|
|
|
/**
|
|
* Whether the authenticated config has been loaded.
|
|
* Use this to gate access to user-specific feature flags like teamWorkspacesEnabled.
|
|
*/
|
|
export const isAuthenticatedConfigLoaded = computed(
|
|
() => remoteConfigState.value === 'authenticated'
|
|
)
|
|
|
|
/**
|
|
* Reactive remote configuration
|
|
* Updated whenever config is loaded from the server
|
|
*/
|
|
export const remoteConfig = ref<RemoteConfig>({})
|
|
|
|
export function configValueOrDefault<K extends keyof RemoteConfig>(
|
|
remoteConfig: RemoteConfig,
|
|
key: K,
|
|
defaultValue: NonNullable<RemoteConfig[K]>
|
|
): NonNullable<RemoteConfig[K]> {
|
|
const configValue = remoteConfig[key]
|
|
return configValue || defaultValue
|
|
}
|