mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 17:30:07 +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:
@@ -15,7 +15,7 @@ describe('useTelemetry', () => {
|
||||
|
||||
// Should return null for OSS builds
|
||||
expect(provider).toBeNull()
|
||||
})
|
||||
}, 10000)
|
||||
|
||||
it('should return null consistently for OSS builds', async () => {
|
||||
const { useTelemetry } = await import('@/platform/telemetry')
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useExecutionStore } from '@/stores/executionStore'
|
||||
|
||||
// Create mock functions that will be shared
|
||||
const mockNodeExecutionIdToNodeLocatorId = vi.fn()
|
||||
const mockNodeIdToNodeLocatorId = vi.fn()
|
||||
const mockNodeLocatorIdToNodeExecutionId = vi.fn()
|
||||
|
||||
// Mock the workflowStore
|
||||
vi.mock('@/platform/workflow/management/stores/workflowStore', () => ({
|
||||
useWorkflowStore: vi.fn(() => ({
|
||||
nodeExecutionIdToNodeLocatorId: vi.fn(),
|
||||
nodeIdToNodeLocatorId: vi.fn(),
|
||||
nodeLocatorIdToNodeExecutionId: vi.fn()
|
||||
}))
|
||||
}))
|
||||
vi.mock('@/platform/workflow/management/stores/workflowStore', async () => {
|
||||
const { ComfyWorkflow } = await vi.importActual<
|
||||
typeof import('@/platform/workflow/management/stores/workflowStore')
|
||||
>('@/platform/workflow/management/stores/workflowStore')
|
||||
return {
|
||||
ComfyWorkflow,
|
||||
useWorkflowStore: vi.fn(() => ({
|
||||
nodeExecutionIdToNodeLocatorId: mockNodeExecutionIdToNodeLocatorId,
|
||||
nodeIdToNodeLocatorId: mockNodeIdToNodeLocatorId,
|
||||
nodeLocatorIdToNodeExecutionId: mockNodeLocatorIdToNodeExecutionId
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
// Remove any previous global types
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
interface Window {}
|
||||
}
|
||||
|
||||
@@ -37,7 +46,8 @@ vi.mock('@/composables/node/useNodeProgressText', () => ({
|
||||
vi.mock('@/scripts/app', () => ({
|
||||
app: {
|
||||
graph: {
|
||||
getNodeById: vi.fn()
|
||||
getNodeById: vi.fn(),
|
||||
_nodes: [] // Add _nodes array for workflowStore iteration
|
||||
},
|
||||
revokePreviews: vi.fn(),
|
||||
nodePreviewImages: {}
|
||||
@@ -98,24 +108,16 @@ describe('executionStore - display_component handling', () => {
|
||||
|
||||
describe('useExecutionStore - NodeLocatorId conversions', () => {
|
||||
let store: ReturnType<typeof useExecutionStore>
|
||||
let workflowStore: ReturnType<typeof useWorkflowStore>
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
|
||||
// Create the mock workflowStore instance
|
||||
const mockWorkflowStore = {
|
||||
nodeExecutionIdToNodeLocatorId: vi.fn(),
|
||||
nodeIdToNodeLocatorId: vi.fn(),
|
||||
nodeLocatorIdToNodeExecutionId: vi.fn()
|
||||
}
|
||||
|
||||
// Mock the useWorkflowStore function to return our mock
|
||||
vi.mocked(useWorkflowStore).mockReturnValue(mockWorkflowStore as any)
|
||||
|
||||
workflowStore = mockWorkflowStore as any
|
||||
store = useExecutionStore()
|
||||
vi.clearAllMocks()
|
||||
// Reset mock implementations
|
||||
mockNodeExecutionIdToNodeLocatorId.mockReset()
|
||||
mockNodeIdToNodeLocatorId.mockReset()
|
||||
mockNodeLocatorIdToNodeExecutionId.mockReset()
|
||||
|
||||
setActivePinia(createPinia())
|
||||
store = useExecutionStore()
|
||||
})
|
||||
|
||||
describe('executionIdToNodeLocatorId', () => {
|
||||
@@ -168,24 +170,20 @@ describe('useExecutionStore - NodeLocatorId conversions', () => {
|
||||
describe('nodeLocatorIdToExecutionId', () => {
|
||||
it('should convert NodeLocatorId to execution ID', () => {
|
||||
const mockExecutionId = '123:456'
|
||||
vi.spyOn(workflowStore, 'nodeLocatorIdToNodeExecutionId').mockReturnValue(
|
||||
mockExecutionId as any
|
||||
)
|
||||
mockNodeLocatorIdToNodeExecutionId.mockReturnValue(mockExecutionId)
|
||||
|
||||
const result = store.nodeLocatorIdToExecutionId(
|
||||
'a1b2c3d4-e5f6-7890-abcd-ef1234567890:456'
|
||||
)
|
||||
|
||||
expect(workflowStore.nodeLocatorIdToNodeExecutionId).toHaveBeenCalledWith(
|
||||
expect(mockNodeLocatorIdToNodeExecutionId).toHaveBeenCalledWith(
|
||||
'a1b2c3d4-e5f6-7890-abcd-ef1234567890:456'
|
||||
)
|
||||
expect(result).toBe(mockExecutionId)
|
||||
})
|
||||
|
||||
it('should return null when conversion fails', () => {
|
||||
vi.spyOn(workflowStore, 'nodeLocatorIdToNodeExecutionId').mockReturnValue(
|
||||
null
|
||||
)
|
||||
mockNodeLocatorIdToNodeExecutionId.mockReturnValue(null)
|
||||
|
||||
const result = store.nodeLocatorIdToExecutionId('invalid:format')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user