LCOV - code coverage report
Current view: top level - src/components/bottomPanel/tabs/terminal - CommandTerminal.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 4.5 % 22 1
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2            0 :   <BaseTerminal @created="terminalCreated" />
       3              : </template>
       4              : 
       5              : <script setup lang="ts">
       6              : import type { IDisposable } from '@xterm/xterm'
       7              : import type { Ref } from 'vue'
       8              : import { onMounted, onUnmounted } from 'vue'
       9              : 
      10              : import type { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
      11              : import { electronAPI } from '@/utils/envUtil'
      12              : 
      13              : import BaseTerminal from './BaseTerminal.vue'
      14              : 
      15            0 : const terminalCreated = (
      16              :   { terminal, useAutoSize }: ReturnType<typeof useTerminal>,
      17              :   root: Ref<HTMLElement | undefined>
      18              : ) => {
      19            0 :   const terminalApi = electronAPI().Terminal
      20              : 
      21            0 :   let offData: IDisposable
      22            0 :   let offOutput: () => void
      23              : 
      24            0 :   useAutoSize({
      25              :     root,
      26              :     autoRows: true,
      27              :     autoCols: true,
      28              :     onResize: async () => {
      29              :       // If we aren't visible, don't resize
      30            0 :       if (!terminal.element?.offsetParent) return
      31              : 
      32            0 :       await terminalApi.resize(terminal.cols, terminal.rows)
      33              :     }
      34              :   })
      35              : 
      36            0 :   onMounted(async () => {
      37            0 :     offData = terminal.onData(async (message: string) => {
      38            0 :       await terminalApi.write(message)
      39              :     })
      40              : 
      41            0 :     offOutput = terminalApi.onOutput((message) => {
      42            0 :       terminal.write(message)
      43              :     })
      44              : 
      45            0 :     const restore = await terminalApi.restore()
      46            0 :     setTimeout(() => {
      47            0 :       if (restore.buffer.length) {
      48            0 :         terminal.resize(restore.size.cols, restore.size.rows)
      49            0 :         terminal.write(restore.buffer.join(''))
      50              :       }
      51              :     }, 500)
      52              :   })
      53              : 
      54            0 :   onUnmounted(() => {
      55            0 :     offData?.dispose()
      56            0 :     offOutput?.()
      57              :   })
      58              : }
      59              : </script>
        

Generated by: LCOV version 2.0-1