LCOV - code coverage report
Current view: top level - src/platform/keybindings/components/shortcuts - ShortcutsList.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 14 14
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2           22 :   <div class="shortcuts-list flex justify-center">
       3              :     <div
       4              :       data-testid="shortcuts-columns"
       5              :       class="grid h-full w-[90%] grid-cols-1 gap-4 md:grid-cols-3 md:gap-24"
       6              :     >
       7           62 :       <div
       8              :         v-for="(subcategoryCommands, subcategory) in filteredSubcategories"
       9              :         :key="subcategory"
      10              :         class="flex flex-col"
      11              :       >
      12              :         <h3
      13              :           class="subcategory-title mb-4 text-xs font-bold tracking-wide text-muted-foreground uppercase"
      14              :         >
      15              :           {{ getSubcategoryTitle(subcategory) }}
      16              :         </h3>
      17              : 
      18              :         <div class="flex flex-col gap-1">
      19          224 :           <div
      20              :             v-for="command in subcategoryCommands"
      21              :             :key="command.id"
      22              :             class="shortcut-item flex items-center justify-between rounded-sm py-2 transition-colors duration-200"
      23              :           >
      24              :             <div class="shortcut-info grow pr-4">
      25              :               <div class="shortcut-name text-sm font-medium">
      26              :                 {{ t(`commands.${normalizeI18nKey(command.id)}.label`) }}
      27              :               </div>
      28              :             </div>
      29              : 
      30              :             <div class="keybinding-display shrink-0">
      31              :               <div
      32              :                 class="keybinding-combo flex gap-1"
      33              :                 :aria-label="`Keyboard shortcut: ${command.keybinding!.combo.getKeySequences().join(' + ')}`"
      34              :               >
      35          464 :                 <span
      36              :                   v-for="key in command.keybinding!.combo.getKeySequences()"
      37              :                   :key="key"
      38              :                   class="key-badge min-w-6 rounded-sm bg-muted px-2 py-1 text-center font-mono text-xs"
      39              :                 >
      40              :                   {{ formatKey(key) }}
      41              :                 </span>
      42              :               </div>
      43              :             </div>
      44              :           </div>
      45              :         </div>
      46              :       </div>
      47              :     </div>
      48              :   </div>
      49              : </template>
      50              : 
      51              : <script setup lang="ts">
      52              : import { computed } from 'vue'
      53              : import { useI18n } from 'vue-i18n'
      54              : 
      55              : import type { ComfyCommandImpl } from '@comfyorg/keybindings/commandStore'
      56              : import { normalizeI18nKey } from '@/utils/formatUtil'
      57              : 
      58           22 : const { t } = useI18n()
      59              : 
      60              : const { subcategories } = defineProps<{
      61              :   subcategories: Record<string, ComfyCommandImpl[]>
      62              : }>()
      63              : 
      64           22 : const filteredSubcategories = computed(() => {
      65           22 :   const result: Record<string, ComfyCommandImpl[]> = {}
      66              : 
      67           22 :   for (const [subcategory, commands] of Object.entries(subcategories)) {
      68           62 :     result[subcategory] = commands.filter((cmd) => !!cmd.keybinding)
      69              :   }
      70              : 
      71           22 :   return result
      72              : })
      73              : 
      74           22 : const getSubcategoryTitle = (subcategory: string): string => {
      75              :   const titleMap: Record<string, string> = {
      76              :     workflow: t('shortcuts.subcategories.workflow'),
      77              :     node: t('shortcuts.subcategories.node'),
      78              :     queue: t('shortcuts.subcategories.queue'),
      79              :     view: t('shortcuts.subcategories.view'),
      80              :     'panel-controls': t('shortcuts.subcategories.panelControls')
      81              :   }
      82              : 
      83           62 :   return titleMap[subcategory] || subcategory
      84              : }
      85              : 
      86           22 : const formatKey = (key: string): string => {
      87              :   const keyMap: Record<string, string> = {
      88              :     Control: 'Ctrl',
      89              :     Meta: 'Cmd',
      90              :     ArrowUp: '↑',
      91              :     ArrowDown: '↓',
      92              :     ArrowLeft: '←',
      93              :     ArrowRight: '→',
      94              :     Backspace: '⌫',
      95              :     Delete: '⌦',
      96              :     Enter: '↵',
      97              :     Escape: 'Esc',
      98              :     Tab: '⇥',
      99              :     ' ': 'Space'
     100              :   }
     101              : 
     102          464 :   return keyMap[key] || key
     103              : }
     104              : </script>
        

Generated by: LCOV version 2.0-1