Line data Source code
1 16 : <template>
2 45 : <div class="relative size-full">
3 : <p
4 : v-if="errorMessage"
5 : data-testid="terminal-error-message"
6 : class="p-4 text-center"
7 : >
8 : {{ errorMessage }}
9 : </p>
10 : <AppSpinner
11 : v-else-if="loading"
12 : data-testid="terminal-loading-spinner"
13 : class="absolute inset-0 z-10 m-auto size-8"
14 : />
15 : <BaseTerminal
16 : v-show="!loading && !errorMessage"
17 : @created="terminalCreated"
18 : />
19 : </div>
20 : </template>
21 :
22 : <script setup lang="ts">
23 : import type { Terminal } from '@xterm/xterm'
24 : import type { Ref } from 'vue'
25 : import { shallowRef } from 'vue'
26 :
27 : import AppSpinner from '@/components/common/AppSpinner.vue'
28 : import { useLogsTerminal } from '@/composables/bottomPanelTabs/useLogsTerminal'
29 : import type { useTerminal } from '@/composables/bottomPanelTabs/useTerminal'
30 :
31 : import BaseTerminal from './BaseTerminal.vue'
32 :
33 24 : const terminal = shallowRef<Terminal>()
34 24 : const { errorMessage, loading } = useLogsTerminal(terminal)
35 :
36 24 : const terminalCreated = (
37 : { terminal: instance, useAutoSize }: ReturnType<typeof useTerminal>,
38 : root: Ref<HTMLElement | undefined>
39 : ) => {
40 : // Auto-size terminal to fill container width.
41 : // minCols: 80 ensures minimum width for colab environments.
42 : // See https://github.com/comfyanonymous/ComfyUI/issues/6396
43 24 : useAutoSize({ root, autoRows: true, autoCols: true, minCols: 80 })
44 24 : terminal.value = instance
45 : }
46 : </script>
|