mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 19:49:58 +00:00
Feature flags for model upload button and asset update options now check remote config from `/api/features` first, falling back to websocket feature flags. - **What**: Added `model_upload_button_enabled` and `asset_update_options_enabled` to `RemoteConfig` type - **What**: Updated feature flag getters to prioritize remote config over websocket flags - **Why**: Enables dynamic feature control without requiring websocket connection, consistent with other feature flags pattern - Pattern consistency with other remote config feature flags - Proper fallback behavior when remote config is unavailable ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7143-feat-Add-remote-config-support-for-model-upload-and-asset-update-feature-flags-2bf6d73d3650819cb364f0ab69d77dd0) by [Unito](https://www.unito.io) Co-authored-by: Claude <noreply@anthropic.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { computed, reactive, readonly } from 'vue'
|
|
|
|
import { remoteConfig } from '@/platform/remoteConfig/remoteConfig'
|
|
import { api } from '@/scripts/api'
|
|
|
|
/**
|
|
* Known server feature flags (top-level, not extensions)
|
|
*/
|
|
export enum ServerFeatureFlag {
|
|
SUPPORTS_PREVIEW_METADATA = 'supports_preview_metadata',
|
|
MAX_UPLOAD_SIZE = 'max_upload_size',
|
|
MANAGER_SUPPORTS_V4 = 'extension.manager.supports_v4',
|
|
MODEL_UPLOAD_BUTTON_ENABLED = 'model_upload_button_enabled',
|
|
ASSET_UPDATE_OPTIONS_ENABLED = 'asset_update_options_enabled'
|
|
}
|
|
|
|
/**
|
|
* Composable for reactive access to server-side feature flags
|
|
*/
|
|
export function useFeatureFlags() {
|
|
const flags = reactive({
|
|
get supportsPreviewMetadata() {
|
|
return api.getServerFeature(ServerFeatureFlag.SUPPORTS_PREVIEW_METADATA)
|
|
},
|
|
get maxUploadSize() {
|
|
return api.getServerFeature(ServerFeatureFlag.MAX_UPLOAD_SIZE)
|
|
},
|
|
get supportsManagerV4() {
|
|
return api.getServerFeature(ServerFeatureFlag.MANAGER_SUPPORTS_V4)
|
|
},
|
|
get modelUploadButtonEnabled() {
|
|
// Check remote config first (from /api/features), fall back to websocket feature flags
|
|
return (
|
|
remoteConfig.value.model_upload_button_enabled ??
|
|
api.getServerFeature(
|
|
ServerFeatureFlag.MODEL_UPLOAD_BUTTON_ENABLED,
|
|
false
|
|
)
|
|
)
|
|
},
|
|
get assetUpdateOptionsEnabled() {
|
|
// Check remote config first (from /api/features), fall back to websocket feature flags
|
|
return (
|
|
remoteConfig.value.asset_update_options_enabled ??
|
|
api.getServerFeature(
|
|
ServerFeatureFlag.ASSET_UPDATE_OPTIONS_ENABLED,
|
|
false
|
|
)
|
|
)
|
|
}
|
|
})
|
|
|
|
const featureFlag = <T = unknown>(featurePath: string, defaultValue?: T) =>
|
|
computed(() => api.getServerFeature(featurePath, defaultValue))
|
|
|
|
return {
|
|
flags: readonly(flags),
|
|
featureFlag
|
|
}
|
|
}
|