LCOV - code coverage report
Current view: top level - src/renderer/extensions/propertiesPanel - propertiesPanelStore.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 81.5 % 27 22
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { defineStore } from 'pinia'
       2              : import { computed, ref, watch } from 'vue'
       3              : 
       4              : import { useSettingStore } from '@/platform/settings/settingStore'
       5              : import { useErrorsTabRequestStore } from '@/platform/workflowErrors/panel/errorsTabRequestStore'
       6              : 
       7              : export type PropertiesPanelTab =
       8              :   | 'parameters'
       9              :   | 'nodes'
      10              :   | 'settings'
      11              :   | 'info'
      12              :   | 'subgraph'
      13              :   | 'errors'
      14              : 
      15              : type PropertiesPanelSection = 'advanced-inputs'
      16              : 
      17              : /**
      18              :  * Store for managing the properties panel state.
      19              :  * This panel displays properties and settings for selected nodes.
      20              :  */
      21         2356 : export const usePropertiesPanelStore = defineStore('propertiesPanel', () => {
      22         2355 :   const settingStore = useSettingStore()
      23         2355 :   const errorsTabRequestStore = useErrorsTabRequestStore()
      24              : 
      25         2355 :   const isAvailable = computed(
      26              :     () => settingStore.get('Comfy.UseNewMenu') !== 'Disabled'
      27              :   )
      28              : 
      29         2355 :   const isOpen = computed({
      30              :     get: () =>
      31              :       isAvailable.value && settingStore.get('Comfy.RightSidePanel.IsOpen'),
      32              :     set: (value: boolean) =>
      33              :       settingStore.set('Comfy.RightSidePanel.IsOpen', value)
      34              :   })
      35         2355 :   const activeTab = ref<PropertiesPanelTab>('parameters')
      36         2355 :   const isEditingSubgraph = computed(() => activeTab.value === 'subgraph')
      37         2355 :   const focusedSection = ref<PropertiesPanelSection | null>(null)
      38              : 
      39         2355 :   watch(isAvailable, (available) => {
      40            5 :     if (!available) void settingStore.set('Comfy.RightSidePanel.IsOpen', false)
      41              :   })
      42              : 
      43         2355 :   watch([isOpen, activeTab], ([open, tab]) => {
      44          291 :     if (!open || tab !== 'errors') errorsTabRequestStore.clearRequests()
      45              :   })
      46              : 
      47              :   /** Opens the panel, optionally on a tab; returns false when it cannot open. */
      48          183 :   function openPanel(tab?: PropertiesPanelTab): boolean {
      49          183 :     if (!isAvailable.value) return false
      50          183 :     isOpen.value = true
      51          183 :     if (tab) activeTab.value = tab
      52          183 :     return true
      53              :   }
      54              : 
      55            6 :   function closePanel() {
      56            6 :     isOpen.value = false
      57              :   }
      58              : 
      59          103 :   function togglePanel() {
      60          103 :     isOpen.value = !isOpen.value
      61              :   }
      62              : 
      63              :   /**
      64              :    * Focus on a specific section in the properties panel.
      65              :    * This will open the panel, switch to the parameters tab, and signal
      66              :    * the component to expand and scroll to the section.
      67              :    */
      68            0 :   function focusSection(section: PropertiesPanelSection) {
      69            0 :     openPanel('parameters')
      70            0 :     focusedSection.value = section
      71              :   }
      72              : 
      73              :   /**
      74              :    * Clear the focused section after it has been handled.
      75              :    */
      76            0 :   function clearFocusedSection() {
      77            0 :     focusedSection.value = null
      78              :   }
      79              : 
      80         2355 :   return {
      81              :     isAvailable,
      82              :     isOpen,
      83              :     activeTab,
      84              :     isEditingSubgraph,
      85              :     focusedSection,
      86              :     openPanel,
      87              :     closePanel,
      88              :     togglePanel,
      89              :     focusSection,
      90              :     clearFocusedSection
      91              :   }
      92              : })
        

Generated by: LCOV version 2.0-1