mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 07:50:15 +00:00
change cloud feature flags to be loaded dynamically at runtime rather than set in build (#6246)
## Summary Implements server-side remote configuration to decouple runtime behavior from build artifacts, enabling dynamic configuration updates without redeployment. ## Technical Changes - **Replaced** build-time constants (`__MIXPANEL_TOKEN__`, `__BUILD_FLAGS__`) with runtime configuration loaded from `/api/features` - Configuration now sourced from `window.__CONFIG__` (hydrated from `/api/features` endpoint) - **Added** `src/platform/remoteConfig/` service that polls server configuration every 30 seconds - **Modified** application bootstrap sequence in `main.ts` to load remote config before module initialization (required for cloud builds) - **Removed** global constants: `__BUILD_FLAGS__`, `__MIXPANEL_TOKEN__`. Runtime subscription enforcement toggle via `subscription_required` flag - Server health alerts with variant-based severity rendering (info/warning/error) via topbar badges ## Rationale - **Build-once-deploy-anywhere**: Single immutable artifact promoted through environments (staging → production) - **Zero-downtime configuration**: Update behavior without rebuilding or redeploying the application - **Incident response**: Disable features or display alerts dynamically in response to outages or degraded service - **Instant rollback**: Revert configuration changes server-side without artifact redeployment - **Progressive delivery**: Enable A/B testing, canary releases, and user/region-based configuration - **Environment parity**: Eliminate configuration drift between staging and production builds - Decouples deployment cadence from configuration changes - Enables GitOps workflows for configuration management separate from code deployments - Supports real-time operational control of client behavior - Reduces build matrix complexity (no per-environment builds) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6246-change-cloud-feature-flags-to-be-loaded-dynamically-at-runtime-rather-than-set-in-build-2966d73d3650811cbb41c9093961037a) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import { t } from '@/i18n'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.CloudBadge',
|
||||
topbarBadges: [
|
||||
{
|
||||
label: t('g.beta'),
|
||||
text: 'Comfy Cloud'
|
||||
}
|
||||
]
|
||||
})
|
||||
36
src/extensions/core/cloudBadges.ts
Normal file
36
src/extensions/core/cloudBadges.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { remoteConfig } from '@/platform/remoteConfig/remoteConfig'
|
||||
import { t } from '@/i18n'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
import type { TopbarBadge } from '@/types/comfy'
|
||||
|
||||
const badges = computed<TopbarBadge[]>(() => {
|
||||
const result: TopbarBadge[] = []
|
||||
|
||||
// Add server health alert first (if present)
|
||||
const alert = remoteConfig.value.server_health_alert
|
||||
if (alert) {
|
||||
result.push({
|
||||
text: alert.message,
|
||||
label: alert.badge,
|
||||
variant: alert.severity ?? 'error',
|
||||
tooltip: alert.tooltip
|
||||
})
|
||||
}
|
||||
|
||||
// Always add cloud badge last (furthest right)
|
||||
result.push({
|
||||
label: t('g.beta'),
|
||||
text: 'Comfy Cloud'
|
||||
})
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.Cloud.Badges',
|
||||
get topbarBadges() {
|
||||
return badges.value
|
||||
}
|
||||
})
|
||||
15
src/extensions/core/cloudRemoteConfig.ts
Normal file
15
src/extensions/core/cloudRemoteConfig.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { loadRemoteConfig } from '@/platform/remoteConfig/remoteConfig'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
|
||||
/**
|
||||
* Cloud-only extension that polls for remote config updates
|
||||
* Initial config load happens in main.ts before any other imports
|
||||
*/
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.Cloud.RemoteConfig',
|
||||
|
||||
setup: async () => {
|
||||
// Poll for config updates every 30 seconds
|
||||
setInterval(() => void loadRemoteConfig(), 30000)
|
||||
}
|
||||
})
|
||||
@@ -4,8 +4,11 @@ import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
||||
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
|
||||
/**
|
||||
* Cloud-only extension that enforces active subscription requirement
|
||||
*/
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.CloudSubscription',
|
||||
name: 'Comfy.Cloud.Subscription',
|
||||
|
||||
setup: async () => {
|
||||
const { isLoggedIn } = useCurrentUser()
|
||||
@@ -13,7 +16,6 @@ useExtensionService().registerExtension({
|
||||
|
||||
const checkSubscriptionStatus = () => {
|
||||
if (!isLoggedIn.value) return
|
||||
|
||||
void requireActiveSubscription()
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,12 @@ import './uploadImage'
|
||||
import './webcamCapture'
|
||||
import './widgetInputs'
|
||||
|
||||
// Cloud-only extensions - tree-shaken in OSS builds
|
||||
if (isCloud) {
|
||||
import('./cloudBadge')
|
||||
await import('./cloudRemoteConfig')
|
||||
await import('./cloudBadges')
|
||||
|
||||
if (__BUILD_FLAGS__.REQUIRE_SUBSCRIPTION) {
|
||||
import('./cloudSubscription')
|
||||
if (window.__CONFIG__?.subscription_required) {
|
||||
await import('./cloudSubscription')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user