Line data Source code
1 : <template>
2 6 : <div class="flex min-h-0 flex-1 flex-col gap-2 overflow-hidden">
3 : <div v-if="card.nodeId" class="flex min-h-8 flex-wrap items-center gap-2">
4 : <span class="flex min-w-0 flex-1 text-xs font-normal">
5 : <button
6 : v-if="hasRuntimeError && (card.nodeTitle || card.title)"
7 : type="button"
8 : class="m-0 max-w-full min-w-0 cursor-pointer appearance-none truncate rounded-sm border-0 bg-transparent p-0 text-left outline-none focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
9 : @click="handleLocateNode"
10 : >
11 : {{ card.nodeTitle || card.title }}
12 : </button>
13 : <span
14 : v-else-if="card.nodeTitle || card.title"
15 : class="max-w-full min-w-0 truncate"
16 : >
17 : {{ card.nodeTitle || card.title }}
18 : </span>
19 : </span>
20 : <div class="flex shrink-0 items-center">
21 : <Button
22 : v-if="hasRuntimeError"
23 : variant="muted-textonly"
24 : size="icon-sm"
25 : :class="
26 : cn(
27 : 'size-8 shrink-0 hover:text-foreground focus-visible:ring-inset',
28 : runtimeDetailsExpanded &&
29 : 'bg-muted text-foreground hover:bg-muted'
30 : )
31 : "
32 : :aria-label="t('g.details')"
33 : :aria-controls="runtimeDetailsControlIds || undefined"
34 : :aria-expanded="runtimeDetailsExpanded"
35 : @click.stop="toggleRuntimeDetails"
36 : >
37 : <i class="icon-[lucide--monitor-x]" />
38 : </Button>
39 : <LocateNodeButton :label="locateLabel" @locate="handleLocateNode" />
40 : </div>
41 : </div>
42 :
43 : <div
44 : class="flex min-h-0 flex-1 flex-col space-y-2 divide-y divide-border/20"
45 : >
46 6 : <div
47 : v-for="(error, idx) in card.errors"
48 : :key="idx"
49 : class="flex min-h-0 flex-col gap-1"
50 : >
51 : <p
52 : v-if="getInlineMessage(error)"
53 : class="m-0 max-h-[4lh] overflow-y-auto px-0.5 text-xs/relaxed wrap-break-word whitespace-pre-wrap"
54 : >
55 : {{ getInlineMessage(error) }}
56 : </p>
57 :
58 : <ul
59 : v-if="getInlineItemLabel(error)"
60 : class="m-0 list-disc space-y-1 pl-5 text-xs/relaxed text-muted-foreground marker:text-muted-foreground"
61 : >
62 : <li class="min-w-0 wrap-break-word">
63 : <button
64 : v-if="card.nodeId"
65 : type="button"
66 : class="m-0 inline max-w-full cursor-pointer appearance-none rounded-sm border-0 bg-transparent p-0 text-left text-sm/relaxed font-normal wrap-break-word outline-none hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
67 : @click="handleLocateNode"
68 : >
69 : {{ getInlineItemLabel(error) }}
70 : </button>
71 : <span v-else>
72 : {{ getInlineItemLabel(error) }}
73 : </span>
74 : </li>
75 : </ul>
76 :
77 : <div
78 : v-if="!error.isRuntimeError && getInlineDetails(error, idx)"
79 : :class="
80 : cn('overflow-y-auto rounded-lg bg-foreground/5 p-3', 'max-h-[6lh]')
81 : "
82 : >
83 : <p
84 : class="m-0 text-xs/normal wrap-break-word whitespace-pre-wrap text-foreground/50"
85 : >
86 : {{ getInlineDetails(error, idx) }}
87 : </p>
88 : </div>
89 :
90 : <TransitionCollapse>
91 : <div
92 : v-if="error.isRuntimeError && runtimeDetailsExpanded"
93 : :id="getRuntimeDetailsId(idx)"
94 : role="region"
95 : data-testid="runtime-error-panel"
96 : :aria-label="t('rightSidePanel.errorLog')"
97 : class="flex min-h-0 flex-col gap-1"
98 : >
99 : <div
100 : v-if="getInlineDetails(error, idx)"
101 : class="flex flex-col gap-3 rounded-lg bg-foreground/5 p-3"
102 : >
103 : <div class="flex flex-col gap-2">
104 : <div class="flex items-center justify-between gap-1 py-1">
105 : <span class="text-xs font-semibold uppercase">
106 : {{ t('rightSidePanel.errorLog') }}
107 : </span>
108 : <Button
109 : variant="muted-textonly"
110 : size="icon-sm"
111 : class="size-7 shrink-0 hover:text-foreground focus-visible:ring-inset"
112 : :aria-label="t('g.copy')"
113 : data-testid="error-card-copy"
114 : @click="handleCopyError(idx)"
115 : >
116 : <i class="icon-[lucide--copy]" />
117 : </Button>
118 : </div>
119 : <div class="max-h-[15lh] overflow-y-auto">
120 : <p
121 : class="m-0 text-xs/normal wrap-break-word whitespace-pre-wrap text-foreground/50"
122 : >
123 : {{ getInlineDetails(error, idx) }}
124 : </p>
125 : </div>
126 : </div>
127 :
128 : <div aria-hidden="true" class="h-px w-full bg-border" />
129 :
130 : <div class="flex items-center justify-between gap-2">
131 : <Button
132 : :tooltip="t('rightSidePanel.getHelpTooltip')"
133 : variant="textonly"
134 : size="sm"
135 : class="justify-start gap-1 px-0 hover:bg-transparent hover:text-foreground focus-visible:ring-inset"
136 : @click="handleGetHelp"
137 : >
138 : <i class="icon-[lucide--external-link]" />
139 : {{ t('g.getHelpAction') }}
140 : </Button>
141 : <Button
142 : :tooltip="t('rightSidePanel.findOnGithubTooltip')"
143 : variant="textonly"
144 : size="sm"
145 : class="justify-end gap-1 px-0 hover:bg-transparent hover:text-foreground focus-visible:ring-inset"
146 : data-testid="error-card-find-on-github"
147 : @click="handleCheckGithub(error)"
148 : >
149 : <i class="icon-[lucide--github]" />
150 : {{ t('g.findOnGithub') }}
151 : </Button>
152 : </div>
153 : </div>
154 : </div>
155 : </TransitionCollapse>
156 : </div>
157 : </div>
158 : </div>
159 : </template>
160 :
161 : <script setup lang="ts">
162 : import { computed, ref, watch } from 'vue'
163 : import { useI18n } from 'vue-i18n'
164 :
165 : import Button from '@comfyorg/design-system/button/Button'
166 : import { useTelemetry } from '@comfyorg/telemetry'
167 : import { cn } from '@comfyorg/tailwind-utils'
168 : import LocateNodeButton from './LocateNodeButton.vue'
169 : import TransitionCollapse from '@comfyorg/design-system/transition/TransitionCollapse'
170 :
171 : import type { ErrorCardData, ErrorItem } from './types'
172 : import { useErrorActions } from './useErrorActions'
173 : import { useErrorReport } from './useErrorReport'
174 :
175 : const { card, expandDetailsToken = 0 } = defineProps<{
176 : card: ErrorCardData
177 : expandDetailsToken?: number
178 : }>()
179 :
180 6 : const emit = defineEmits<{
181 : locateNode: [nodeId: string]
182 : copyToClipboard: [text: string]
183 : }>()
184 :
185 6 : const { t } = useI18n()
186 6 : const { displayedDetailsMap } = useErrorReport(() => card)
187 6 : const { findOnGitHub, contactSupport: handleGetHelp } = useErrorActions()
188 6 : const runtimeDetailsExpanded = ref(true)
189 :
190 6 : watch(
191 : () => expandDetailsToken,
192 : (token) => {
193 6 : if (token > 0) runtimeDetailsExpanded.value = true
194 : },
195 : { immediate: true }
196 : )
197 6 : const hasRuntimeError = computed(() =>
198 : card.errors.some((error) => error.isRuntimeError)
199 : )
200 6 : const locateLabel = computed(() => {
201 6 : const item = card.nodeTitle || card.title
202 6 : return item
203 : ? t('rightSidePanel.locateNodeFor', { item }, { escapeParameter: false })
204 : : t('rightSidePanel.locateNode')
205 : })
206 6 : const runtimeDetailsControlIds = computed(() =>
207 : card.errors
208 : .map((error, idx) => (error.isRuntimeError ? getRuntimeDetailsId(idx) : ''))
209 : .filter(Boolean)
210 : .join(' ')
211 : )
212 :
213 0 : function toggleRuntimeDetails() {
214 0 : runtimeDetailsExpanded.value = !runtimeDetailsExpanded.value
215 : }
216 :
217 0 : function handleLocateNode() {
218 0 : if (card.nodeId) {
219 0 : emit('locateNode', card.nodeId)
220 : }
221 : }
222 :
223 0 : function handleCopyError(idx: number) {
224 0 : useTelemetry()?.trackUiButtonClicked({
225 : button_id: 'error_tab_copy_error_clicked',
226 : element_group: 'errors_panel'
227 : })
228 0 : const details = displayedDetailsMap.value[idx]
229 0 : const message = getCopyMessage(card.errors[idx])
230 0 : emit('copyToClipboard', [message, details].filter(Boolean).join('\n\n'))
231 : }
232 :
233 0 : function handleCheckGithub(error: ErrorItem) {
234 0 : findOnGitHub(error.message)
235 : }
236 :
237 0 : function getCopyMessage(error: ErrorItem | undefined) {
238 0 : return error?.displayMessage ?? error?.message
239 : }
240 :
241 6 : function getInlineMessage(error: ErrorItem | undefined) {
242 6 : if (!error || error.displayMessage) return undefined
243 0 : return error.message
244 : }
245 :
246 30 : function getInlineItemLabel(error: ErrorItem | undefined) {
247 30 : if (!error || error.isRuntimeError) return undefined
248 0 : return error.displayItemLabel
249 : }
250 :
251 24 : function getInlineDetails(error: ErrorItem | undefined, idx: number) {
252 24 : if (getInlineItemLabel(error)) return undefined
253 24 : return displayedDetailsMap.value[idx]
254 : }
255 :
256 18 : function getRuntimeDetailsId(idx: number) {
257 18 : return `${card.id}-runtime-details-${idx}`
258 : }
259 : </script>
|