LCOV - code coverage report
Current view: top level - src/constants - serverConfig.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 3.8 % 26 1
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { FormItem, ServerConfigValue } from '@comfyorg/settings-core/types'
       2              : import {
       3              :   CrossAttentionMethod,
       4              :   CudaMalloc,
       5              :   FloatingPointPrecision,
       6              :   HashFunction,
       7              :   LatentPreviewMethod,
       8              :   LogLevel,
       9              :   VramManagement
      10              : } from '@/types/serverArgs'
      11              : 
      12              : export interface ServerConfig<T> extends FormItem {
      13              :   id: string
      14              :   defaultValue: T
      15              :   category?: string[]
      16              :   // Override the default value getter with a custom function.
      17              :   getValue?: (value: T) => Record<string, ServerConfigValue>
      18              : }
      19              : 
      20         2355 : export const SERVER_CONFIG_ITEMS = [
      21              :   // Network settings
      22              :   {
      23              :     id: 'listen',
      24              :     name: 'Host: The IP address to listen on',
      25              :     category: ['Network'],
      26              :     type: 'text',
      27              :     defaultValue: '127.0.0.1'
      28              :   },
      29              :   {
      30              :     id: 'port',
      31              :     name: 'Port: The port to listen on',
      32              :     category: ['Network'],
      33              :     type: 'number',
      34              :     // The default launch port for desktop app is 8000 instead of 8188.
      35              :     defaultValue: 8000
      36              :   },
      37              :   {
      38              :     id: 'tls-keyfile',
      39              :     name: 'TLS Key File: Path to TLS key file for HTTPS',
      40              :     category: ['Network'],
      41              :     type: 'text',
      42              :     defaultValue: ''
      43              :   },
      44              :   {
      45              :     id: 'tls-certfile',
      46              :     name: 'TLS Certificate File: Path to TLS certificate file for HTTPS',
      47              :     category: ['Network'],
      48              :     type: 'text',
      49              :     defaultValue: ''
      50              :   },
      51              :   {
      52              :     id: 'enable-cors-header',
      53              :     name: 'Enable CORS header: Use "*" for all origins or specify domain',
      54              :     category: ['Network'],
      55              :     type: 'text',
      56              :     defaultValue: ''
      57              :   },
      58              :   {
      59              :     id: 'max-upload-size',
      60              :     name: 'Maximum upload size (MB)',
      61              :     category: ['Network'],
      62              :     type: 'number',
      63              :     defaultValue: 100
      64              :   },
      65              : 
      66              :   // CUDA settings
      67              :   {
      68              :     id: 'cuda-device',
      69              :     name: 'CUDA device index to use',
      70              :     category: ['CUDA'],
      71              :     type: 'number',
      72              :     defaultValue: null
      73              :   },
      74              :   {
      75              :     id: 'cuda-malloc',
      76              :     name: 'Use CUDA malloc for memory allocation',
      77              :     category: ['CUDA'],
      78              :     type: 'combo',
      79              :     options: Object.values(CudaMalloc),
      80              :     defaultValue: CudaMalloc.Auto,
      81              :     getValue: (value: CudaMalloc) => {
      82            0 :       switch (value) {
      83              :         case CudaMalloc.Auto:
      84            0 :           return {}
      85              :         case CudaMalloc.Enable:
      86            0 :           return {
      87              :             ['cuda-malloc']: true
      88              :           }
      89              :         case CudaMalloc.Disable:
      90            0 :           return {
      91              :             ['disable-cuda-malloc']: true
      92              :           }
      93              :       }
      94              :     }
      95              :   },
      96              : 
      97              :   // Precision settings
      98              :   {
      99              :     id: 'global-precision',
     100              :     name: 'Global floating point precision',
     101              :     category: ['Inference'],
     102              :     type: 'combo',
     103              :     options: [
     104              :       FloatingPointPrecision.AUTO,
     105              :       FloatingPointPrecision.FP32,
     106              :       FloatingPointPrecision.FP16
     107              :     ],
     108              :     defaultValue: FloatingPointPrecision.AUTO,
     109              :     tooltip: 'Global floating point precision',
     110              :     getValue: (value: FloatingPointPrecision) => {
     111            0 :       switch (value) {
     112              :         case FloatingPointPrecision.AUTO:
     113            0 :           return {}
     114              :         case FloatingPointPrecision.FP32:
     115            0 :           return {
     116              :             ['force-fp32']: true
     117              :           }
     118              :         case FloatingPointPrecision.FP16:
     119            0 :           return {
     120              :             ['force-fp16']: true
     121              :           }
     122              :         default:
     123            0 :           return {}
     124              :       }
     125              :     }
     126              :   },
     127              : 
     128              :   // UNET precision
     129              :   {
     130              :     id: 'unet-precision',
     131              :     name: 'UNET precision',
     132              :     category: ['Inference'],
     133              :     type: 'combo',
     134              :     options: [
     135              :       FloatingPointPrecision.AUTO,
     136              :       FloatingPointPrecision.FP64,
     137              :       FloatingPointPrecision.FP32,
     138              :       FloatingPointPrecision.FP16,
     139              :       FloatingPointPrecision.BF16,
     140              :       FloatingPointPrecision.FP8E4M3FN,
     141              :       FloatingPointPrecision.FP8E5M2
     142              :     ],
     143              :     defaultValue: FloatingPointPrecision.AUTO,
     144              :     tooltip: 'UNET precision',
     145              :     getValue: (value: FloatingPointPrecision) => {
     146            0 :       switch (value) {
     147              :         case FloatingPointPrecision.AUTO:
     148            0 :           return {}
     149              :         default:
     150            0 :           return {
     151              :             [`${value.toLowerCase()}-unet`]: true
     152              :           }
     153              :       }
     154              :     }
     155              :   },
     156              : 
     157              :   // VAE settings
     158              :   {
     159              :     id: 'vae-precision',
     160              :     name: 'VAE precision',
     161              :     category: ['Inference'],
     162              :     type: 'combo',
     163              :     options: [
     164              :       FloatingPointPrecision.AUTO,
     165              :       FloatingPointPrecision.FP16,
     166              :       FloatingPointPrecision.FP32,
     167              :       FloatingPointPrecision.BF16
     168              :     ],
     169              :     defaultValue: FloatingPointPrecision.AUTO,
     170              :     tooltip: 'VAE precision',
     171              :     getValue: (value: FloatingPointPrecision) => {
     172            0 :       switch (value) {
     173              :         case FloatingPointPrecision.AUTO:
     174            0 :           return {}
     175              :         default:
     176            0 :           return {
     177              :             [`${value.toLowerCase()}-vae`]: true
     178              :           }
     179              :       }
     180              :     }
     181              :   },
     182              :   {
     183              :     id: 'cpu-vae',
     184              :     name: 'Run VAE on CPU',
     185              :     category: ['Inference'],
     186              :     type: 'boolean',
     187              :     defaultValue: false
     188              :   },
     189              : 
     190              :   // Text Encoder settings
     191              :   {
     192              :     id: 'text-encoder-precision',
     193              :     name: 'Text Encoder precision',
     194              :     category: ['Inference'],
     195              :     type: 'combo',
     196              :     options: [
     197              :       FloatingPointPrecision.AUTO,
     198              :       FloatingPointPrecision.FP8E4M3FN,
     199              :       FloatingPointPrecision.FP8E5M2,
     200              :       FloatingPointPrecision.FP16,
     201              :       FloatingPointPrecision.FP32
     202              :     ],
     203              :     defaultValue: FloatingPointPrecision.AUTO,
     204              :     tooltip: 'Text Encoder precision',
     205              :     getValue: (value: FloatingPointPrecision) => {
     206            0 :       switch (value) {
     207              :         case FloatingPointPrecision.AUTO:
     208            0 :           return {}
     209              :         default:
     210            0 :           return {
     211              :             [`${value.toLowerCase()}-text-enc`]: true
     212              :           }
     213              :       }
     214              :     }
     215              :   },
     216              : 
     217              :   // Memory and performance settings
     218              :   {
     219              :     id: 'force-channels-last',
     220              :     name: 'Force channels-last memory format',
     221              :     category: ['Memory'],
     222              :     type: 'boolean',
     223              :     defaultValue: false
     224              :   },
     225              :   {
     226              :     id: 'directml',
     227              :     name: 'DirectML device index',
     228              :     category: ['Memory'],
     229              :     type: 'number',
     230              :     defaultValue: null
     231              :   },
     232              :   {
     233              :     id: 'disable-ipex-optimize',
     234              :     name: 'Disable IPEX optimization',
     235              :     category: ['Memory'],
     236              :     type: 'boolean',
     237              :     defaultValue: false
     238              :   },
     239              : 
     240              :   // Preview settings
     241              :   {
     242              :     id: 'preview-method',
     243              :     name: 'Method used for latent previews',
     244              :     category: ['Preview'],
     245              :     type: 'combo',
     246              :     options: Object.values(LatentPreviewMethod),
     247              :     defaultValue: LatentPreviewMethod.NoPreviews
     248              :   },
     249              :   {
     250              :     id: 'preview-size',
     251              :     name: 'Size of preview images',
     252              :     category: ['Preview'],
     253              :     type: 'slider',
     254              :     defaultValue: 512,
     255              :     attrs: {
     256              :       min: 128,
     257              :       max: 2048,
     258              :       step: 128
     259              :     }
     260              :   },
     261              : 
     262              :   // Cache settings
     263              :   {
     264              :     id: 'cache-classic',
     265              :     name: 'Use classic cache system',
     266              :     category: ['Cache'],
     267              :     type: 'boolean',
     268              :     defaultValue: false
     269              :   },
     270              :   {
     271              :     id: 'cache-lru',
     272              :     name: 'Use LRU caching with a maximum of N node results cached.',
     273              :     category: ['Cache'],
     274              :     type: 'number',
     275              :     defaultValue: null,
     276              :     tooltip: 'May use more RAM/VRAM.'
     277              :   },
     278              : 
     279              :   // Attention settings
     280              :   {
     281              :     id: 'cross-attention-method',
     282              :     name: 'Cross attention method',
     283              :     category: ['Attention'],
     284              :     type: 'combo',
     285              :     options: Object.values(CrossAttentionMethod),
     286              :     defaultValue: CrossAttentionMethod.Auto,
     287              :     getValue: (value: CrossAttentionMethod) => {
     288            0 :       switch (value) {
     289              :         case CrossAttentionMethod.Auto:
     290            0 :           return {}
     291              :         default:
     292            0 :           return {
     293              :             [`use-${value.toLowerCase()}-cross-attention`]: true
     294              :           }
     295              :       }
     296              :     }
     297              :   },
     298              :   {
     299              :     id: 'disable-xformers',
     300              :     name: 'Disable xFormers optimization',
     301              :     type: 'boolean',
     302              :     defaultValue: false
     303              :   },
     304              :   {
     305              :     id: 'force-upcast-attention',
     306              :     name: 'Force attention upcast',
     307              :     category: ['Attention'],
     308              :     type: 'boolean',
     309              :     defaultValue: false
     310              :   },
     311              :   {
     312              :     id: 'dont-upcast-attention',
     313              :     name: 'Prevent attention upcast',
     314              :     category: ['Attention'],
     315              :     type: 'boolean',
     316              :     defaultValue: false
     317              :   },
     318              : 
     319              :   // VRAM management
     320              :   {
     321              :     id: 'vram-management',
     322              :     name: 'VRAM management mode',
     323              :     category: ['Memory'],
     324              :     type: 'combo',
     325              :     options: Object.values(VramManagement),
     326              :     defaultValue: VramManagement.Auto,
     327              :     getValue: (value: VramManagement) => {
     328            0 :       switch (value) {
     329              :         case VramManagement.Auto:
     330            0 :           return {}
     331              :         default:
     332            0 :           return {
     333              :             [value]: true
     334              :           }
     335              :       }
     336              :     }
     337              :   },
     338              :   {
     339              :     id: 'reserve-vram',
     340              :     name: 'Reserved VRAM (GB)',
     341              :     category: ['Memory'],
     342              :     type: 'number',
     343              :     defaultValue: null,
     344              :     tooltip:
     345              :       'Set the amount of vram in GB you want to reserve for use by your OS/other software. By default some amount is reserved depending on your OS.'
     346              :   },
     347              : 
     348              :   // Misc settings
     349              :   {
     350              :     id: 'default-hashing-function',
     351              :     name: 'Default hashing function for model files',
     352              :     type: 'combo',
     353              :     options: Object.values(HashFunction),
     354              :     defaultValue: HashFunction.SHA256
     355              :   },
     356              :   {
     357              :     id: 'disable-smart-memory',
     358              :     name: 'Disable smart memory management',
     359              :     tooltip:
     360              :       'Force ComfyUI to aggressively offload to regular ram instead of keeping models in vram when it can.',
     361              :     category: ['Memory'],
     362              :     type: 'boolean',
     363              :     defaultValue: false
     364              :   },
     365              :   {
     366              :     id: 'deterministic',
     367              :     name: 'Make pytorch use slower deterministic algorithms when it can.',
     368              :     type: 'boolean',
     369              :     defaultValue: false,
     370              :     tooltip: 'Note that this might not make images deterministic in all cases.'
     371              :   },
     372              :   {
     373              :     id: 'fast',
     374              :     name: 'Enable some untested and potentially quality deteriorating optimizations.',
     375              :     type: 'boolean',
     376              :     defaultValue: false
     377              :   },
     378              :   {
     379              :     id: 'dont-print-server',
     380              :     name: "Don't print server output to console.",
     381              :     type: 'boolean',
     382              :     defaultValue: false
     383              :   },
     384              :   {
     385              :     id: 'disable-metadata',
     386              :     name: 'Disable saving prompt metadata in files.',
     387              :     type: 'boolean',
     388              :     defaultValue: false
     389              :   },
     390              :   {
     391              :     id: 'enable-manager-legacy-ui',
     392              :     name: 'Use legacy Manager UI',
     393              :     tooltip: 'Uses the legacy ComfyUI-Manager UI instead of the new UI.',
     394              :     type: 'boolean',
     395              :     defaultValue: false
     396              :   },
     397              :   {
     398              :     id: 'disable-all-custom-nodes',
     399              :     name: 'Disable loading all custom nodes.',
     400              :     type: 'boolean',
     401              :     defaultValue: false
     402              :   },
     403              :   {
     404              :     id: 'log-level',
     405              :     name: 'Logging verbosity level',
     406              :     type: 'combo',
     407              :     options: Object.values(LogLevel),
     408              :     defaultValue: LogLevel.INFO,
     409              :     getValue: (value: LogLevel) => {
     410            0 :       return {
     411              :         verbose: value
     412              :       }
     413              :     }
     414              :   },
     415              :   // Directories
     416              :   {
     417              :     id: 'input-directory',
     418              :     name: 'Input directory',
     419              :     category: ['Directories'],
     420              :     type: 'text',
     421              :     defaultValue: ''
     422              :   },
     423              :   {
     424              :     id: 'output-directory',
     425              :     name: 'Output directory',
     426              :     category: ['Directories'],
     427              :     type: 'text',
     428              :     defaultValue: ''
     429              :   }
     430              : ]
        

Generated by: LCOV version 2.0-1