Line data Source code
1 : <template>
2 2009 : <Transition
3 : enter-active-class="transition-all duration-300 ease-out"
4 : enter-from-class="-translate-y-3 opacity-0"
5 : enter-to-class="translate-y-0 opacity-100"
6 : >
7 : <div v-if="isVisible" class="pointer-events-none flex w-full justify-end">
8 : <div
9 : role="status"
10 : data-testid="error-overlay"
11 : :class="
12 : cn(
13 : 'pointer-events-auto relative flex w-fit max-w-120 min-w-80 flex-col gap-2 overflow-hidden rounded-lg border border-l-4 bg-background p-3 shadow-md transition-colors duration-200 ease-in-out',
14 : hasError ? 'border-l-destructive' : 'border-l-warning'
15 : )
16 : "
17 : >
18 : <div class="flex w-full items-start gap-2 pr-8">
19 : <i
20 : aria-hidden="true"
21 : :class="
22 : cn(
23 : 'mt-0.5 size-5',
24 : hasError
25 : ? 'icon-[lucide--circle-x] text-destructive'
26 : : 'icon-[lucide--triangle-alert] text-warning'
27 : )
28 : "
29 : />
30 : <span class="sr-only">{{
31 : t(hasError ? 'g.error' : 'g.warning')
32 : }}</span>
33 : <span class="min-w-0 flex-1 truncate text-sm">
34 : {{ overlayTitle }}
35 : </span>
36 : </div>
37 :
38 : <div
39 : class="flex w-full items-start gap-2 pr-8"
40 : data-testid="error-overlay-messages"
41 : >
42 : <span class="size-5 shrink-0" aria-hidden="true" />
43 : <p
44 : class="m-0 line-clamp-3 min-w-0 flex-1 text-sm/snug wrap-break-word whitespace-pre-wrap text-muted-foreground"
45 : >
46 : {{ overlayMessage }}
47 : </p>
48 : </div>
49 :
50 : <ErrorOverlayDeploymentOffer v-if="hasMissingNodes" />
51 :
52 : <div class="flex w-full items-center justify-end gap-2 pt-2">
53 : <Button
54 : variant="textonly"
55 : size="sm"
56 : data-testid="error-overlay-see-errors"
57 : @click="emit('viewErrors', overlayGroupKeys)"
58 : >
59 : {{
60 : appMode
61 : ? t('linearMode.error.goto')
62 : : t('errorOverlay.viewDetails')
63 : }}
64 : </Button>
65 : <ErrorOverlayDownloadAllModels
66 : :missing-model-groups="downloadableMissingModelGroups"
67 : @downloaded="emit('viewErrors', overlayGroupKeys)"
68 : />
69 : <Button
70 : v-if="canAskAgent && askAgentContext"
71 : variant="secondary"
72 : size="sm"
73 : data-testid="error-overlay-ask-agent"
74 : @click="askAgent"
75 : >
76 : {{ t('errorOverlay.askAgent') }}
77 : </Button>
78 : </div>
79 :
80 : <Button
81 : variant="muted-textonly"
82 : size="icon-sm"
83 : class="absolute top-2 right-2 size-6 rounded-sm"
84 : data-testid="error-overlay-dismiss"
85 : :aria-label="t('g.close')"
86 : @click="dismiss"
87 : >
88 : <i class="icon-[lucide--x] block leading-none" />
89 : </Button>
90 : </div>
91 : </div>
92 : </Transition>
93 : </template>
94 :
95 : <script setup lang="ts">
96 : import { useI18n } from 'vue-i18n'
97 : import { cn } from '@comfyorg/tailwind-utils'
98 :
99 : import Button from '@comfyorg/design-system/button/Button'
100 : import { useExecutionErrorStore } from '@/stores/executionErrorStore'
101 : import { useErrorOverlayState } from '@/platform/workflowErrors/overlay/useErrorOverlayState'
102 : import ErrorOverlayDeploymentOffer from '@/platform/workspace/components/ErrorOverlayDeploymentOffer.vue'
103 : import { useAskAgentPort } from '@/platform/workflowErrors/askAgentPort'
104 : import ErrorOverlayDownloadAllModels from '@/platform/workflowErrors/overlay/ErrorOverlayDownloadAllModels.vue'
105 :
106 : const { appMode = false } = defineProps<{ appMode?: boolean }>()
107 :
108 2009 : const emit = defineEmits<{ viewErrors: [groupKeys: readonly string[]] }>()
109 :
110 2009 : const { t } = useI18n()
111 2009 : const executionErrorStore = useExecutionErrorStore()
112 2009 : const { canAskAgent, askAgentAboutIssues } = useAskAgentPort()
113 :
114 2009 : const {
115 : hasError,
116 : hasMissingNodes,
117 : downloadableMissingModelGroups,
118 : isVisible,
119 : overlayMessage,
120 : overlayTitle,
121 : overlayGroupKeys,
122 : askAgentContext
123 : } = useErrorOverlayState()
124 :
125 19 : function dismiss() {
126 19 : executionErrorStore.dismissErrorOverlay()
127 : }
128 :
129 0 : function askAgent() {
130 0 : const context = askAgentContext.value
131 0 : if (!context) return
132 0 : askAgentAboutIssues(context)
133 0 : executionErrorStore.dismissErrorOverlay()
134 : }
135 : </script>
|