Line data Source code
1 : <template>
2 129 : <div class="flex min-w-0 flex-col">
3 : <!-- Search bar + collapse toggle -->
4 : <div class="flex min-w-0 shrink-0 items-center border-b px-4 pt-1 pb-4">
5 : <AsyncSearchInput
6 : v-model="searchQuery"
7 : :clear-label="$t('g.clear')"
8 : :placeholder="$t('g.searchPlaceholder', { subject: '' })"
9 : :accessible-label="$t('g.search')"
10 : />
11 : <CollapseToggleButton
12 : v-model="isAllCollapsed"
13 : :expand-label="$t('g.expandAll')"
14 : :collapse-label="$t('g.collapseAll')"
15 : :show="!isSearching && allErrorGroups.length > 1"
16 : />
17 : </div>
18 :
19 : <div class="min-w-0 flex-1 overflow-y-auto bg-background p-3">
20 : <div
21 : v-if="filteredGroups.length === 0"
22 : role="status"
23 : class="px-1 pt-5 pb-15 text-center text-sm text-muted-foreground"
24 : >
25 : {{
26 : searchQuery.trim()
27 : ? t('rightSidePanel.noneSearchDesc')
28 : : t('rightSidePanel.noErrors')
29 : }}
30 : </div>
31 :
32 : <div v-else class="overflow-hidden rounded-lg border border-secondary">
33 : <!-- Errors summary hero -->
34 : <div data-testid="errors-summary-hero" class="bg-foreground/5">
35 : <div role="status" class="flex items-center gap-2 p-2">
36 : <span v-if="hasMixedSeverityTotals" class="sr-only">
37 : {{
38 : t('rightSidePanel.severityCountsStatus', {
39 : errors: errorCount,
40 : setup: missingCount
41 : })
42 : }}
43 : </span>
44 : <span
45 : :class="
46 : cn(
47 : 'flex h-12 min-w-9 shrink-0 items-center justify-center px-1 text-[2rem]/none font-extrabold tabular-nums',
48 : hero.countClass
49 : )
50 : "
51 : >
52 : {{ hero.count }}
53 : </span>
54 : <span aria-hidden="true" class="h-9 w-px shrink-0 bg-border" />
55 : <div class="flex min-w-0 flex-1 flex-col gap-1 px-2 text-xs/tight">
56 : <span class="font-semibold">
57 : {{ hero.title }}
58 : </span>
59 : <span class="text-muted-foreground">
60 : {{ hero.description }}
61 : </span>
62 : </div>
63 : <Button
64 : v-if="canAskAgent"
65 : variant="outline"
66 : size="sm"
67 : class="shrink-0"
68 : data-testid="error-card-ask-agent"
69 : :aria-label="askAgentLabel"
70 : @click="handleAskAgent"
71 : >
72 : {{ t('rightSidePanel.askAgent') }}
73 : </Button>
74 : </div>
75 : <DeploymentBuildActions
76 : v-if="buildDeployment"
77 : :deployment="buildDeployment"
78 : :missing-pack-groups="missingPackGroups"
79 : :missing-model-groups="missingModelGroups"
80 : />
81 : <div
82 : v-if="hasMixedSeverityTotals"
83 : data-testid="errors-summary-filters"
84 : class="flex flex-wrap items-center gap-2 px-2 pb-2"
85 : >
86 0 : <Button
87 : v-for="chip in severityChips"
88 : :key="chip.severity"
89 : type="button"
90 : variant="outline"
91 : size="sm"
92 : :data-testid="'errors-summary-filter-' + chip.severity"
93 : :aria-pressed="chip.active"
94 : :class="
95 : cn(
96 : 'h-7 shrink-0 gap-1 rounded-lg px-3 font-semibold hover:bg-transparent',
97 : chip.active && 'gap-2 pr-2',
98 : SEVERITY_CHIP_CLASS[chip.severity][
99 : chip.active ? 'active' : 'idle'
100 : ]
101 : )
102 : "
103 : @click="toggleSeverityFilter(chip.severity)"
104 : >
105 : {{ chip.label }}
106 : <i
107 : v-if="chip.active"
108 : aria-hidden="true"
109 : class="icon-[lucide--x] size-3.5"
110 : />
111 : </Button>
112 : </div>
113 : </div>
114 :
115 : <!-- Context strip: workflow summary, or the selection's errors -->
116 : <div
117 : data-testid="selection-context-strip"
118 : role="status"
119 : class="flex items-center border-t border-secondary px-3 pt-3.5 pb-1.5"
120 : >
121 : <i18n-t
122 : :keypath="strip.keypath"
123 : :plural="strip.count"
124 : tag="span"
125 : :class="
126 : cn(
127 : 'min-w-0 flex-1 truncate text-xs font-semibold transition-colors duration-200',
128 : hasSelectionEmphasis ? 'text-primary' : 'text-muted-foreground'
129 : )
130 : "
131 : >
132 : <template #node>{{ selectionStripNodeLabel }}</template>
133 : <template #nodes>{{ strip.nodes }}</template>
134 : <template #count>{{ strip.count }}</template>
135 : </i18n-t>
136 : </div>
137 :
138 : <!-- In-block so the chips stay mounted as the release control -->
139 : <div
140 : v-if="visibleGroups.length === 0"
141 : role="status"
142 : class="border-t border-secondary px-1 pt-5 pb-15 text-center text-sm text-muted-foreground"
143 : >
144 : {{ t('rightSidePanel.noneSearchDesc') }}
145 : </div>
146 :
147 : <!-- Group by Class Type -->
148 : <TransitionGroup tag="div" name="list-scale" class="relative">
149 127 : <ErrorCardSection
150 : v-for="group in visibleGroups"
151 : :key="group.groupKey"
152 : :data-testid="'error-group-' + group.type.replaceAll('_', '-')"
153 : :data-group-key="group.groupKey"
154 : :title="group.displayTitle"
155 : :count="group.count"
156 : :severity="group.severity"
157 : :collapse="isSectionCollapsed(group.groupKey) && !isSearching"
158 : class="border-t border-secondary first:border-t-0"
159 : @update:collapse="setSectionCollapsed(group.groupKey, $event)"
160 : >
161 : <template #title-badge>
162 : <Badge
163 : v-if="group.blockedLastRun"
164 : data-testid="blocked-last-run-indicator"
165 : variant="pill"
166 : severity="warning"
167 : >
168 : {{ t('rightSidePanel.blockedLastRun') }}
169 : </Badge>
170 : </template>
171 : <template #actions>
172 : <Button
173 : v-if="
174 : group.type === 'missing_node' &&
175 : missingNodePacks.length > 0 &&
176 : shouldShowInstallButton
177 : "
178 : variant="secondary"
179 : size="sm"
180 : class="shrink-0"
181 : :disabled="isInstallingAll"
182 : @click.stop="installAll"
183 : >
184 : <DotSpinner v-if="isInstallingAll" duration="1s" :size="12" />
185 : {{
186 : isInstallingAll
187 : ? t('rightSidePanel.missingNodePacks.installing')
188 : : t('rightSidePanel.missingNodePacks.installAll')
189 : }}
190 : </Button>
191 : <Button
192 : v-else-if="group.type === 'swap_nodes'"
193 : :tooltip="
194 : t(
195 : 'nodeReplacement.replaceAllWarning',
196 : 'Replaces all available nodes in this group.'
197 : )
198 : "
199 : variant="secondary"
200 : size="sm"
201 : class="shrink-0"
202 : @click.stop="handleReplaceAll()"
203 : >
204 : {{ t('nodeReplacement.replaceAll', 'Replace All') }}
205 : </Button>
206 : <Button
207 : v-else-if="
208 : group.type === 'missing_model' &&
209 : showMissingModelHeaderRefresh
210 : "
211 : data-testid="missing-model-header-refresh"
212 : variant="muted-textonly"
213 : size="icon"
214 : class="shrink-0 hover:bg-transparent hover:text-foreground"
215 : :aria-label="t('rightSidePanel.missingModels.refresh')"
216 : :aria-busy="missingModelStore.isRefreshingMissingModels"
217 : :aria-disabled="missingModelStore.isRefreshingMissingModels"
218 : @click.stop="handleMissingModelRefresh"
219 : >
220 : <DotSpinner
221 : v-if="missingModelStore.isRefreshingMissingModels"
222 : aria-hidden="true"
223 : duration="1s"
224 : :size="12"
225 : />
226 : <i
227 : v-else
228 : aria-hidden="true"
229 : class="icon-[lucide--refresh-cw]"
230 : />
231 : </Button>
232 : <span
233 : v-if="
234 : group.type === 'missing_model' &&
235 : showMissingModelHeaderRefresh
236 : "
237 : role="status"
238 : aria-live="polite"
239 : class="sr-only"
240 : >
241 : {{
242 : missingModelStore.isRefreshingMissingModels
243 : ? t('rightSidePanel.missingModels.refreshing')
244 : : ''
245 : }}
246 : </span>
247 : </template>
248 :
249 : <div
250 : v-if="group.displayMessage"
251 : data-testid="error-group-display-message"
252 : class="px-3 py-1"
253 : >
254 : <p
255 : class="m-0 text-xs/normal wrap-break-word whitespace-pre-wrap text-foreground/50"
256 : >
257 : {{ group.displayMessage }}
258 : </p>
259 : <CloudErrorAction :catalog-id="group.catalogId" />
260 : </div>
261 :
262 : <!-- Missing Node Packs -->
263 : <MissingNodeCard
264 : v-if="group.type === 'missing_node'"
265 : :show-info-button="shouldShowManagerButtons"
266 : :missing-pack-groups="missingPackGroups"
267 : :highlighted-node-ids="selectionMatchedAssetNodeIds"
268 : @locate-node="handleLocateMissingNode"
269 : @open-manager-info="handleOpenManagerInfo"
270 : />
271 :
272 : <!-- Swap Nodes -->
273 : <SwapNodesCard
274 : v-if="group.type === 'swap_nodes'"
275 : :swap-node-groups="swapNodeGroups"
276 : :highlighted-node-ids="selectionMatchedAssetNodeIds"
277 : @locate-node="handleLocateMissingNode"
278 : @replace="handleReplaceGroup"
279 : />
280 :
281 : <!-- Execution Errors -->
282 : <div v-if="isExecutionItemListGroup(group)" class="px-3">
283 : <ul class="m-0 list-none space-y-1 p-0">
284 1 : <li
285 : v-for="item in getExecutionItemList(group)"
286 : :key="item.key"
287 : :aria-current="
288 : isCardInSelection(item.cardId) ? 'true' : undefined
289 : "
290 : :class="
291 : cn(
292 : 'min-w-0',
293 : selectionEmphasisClass(isCardInSelection(item.cardId))
294 : )
295 : "
296 : >
297 : <div class="flex min-w-0 items-center gap-2">
298 : <span class="flex min-w-0 flex-1 items-center gap-1">
299 : <Tooltip :disabled="!item.displayDetails">
300 : <TooltipTrigger as-child>
301 : <button
302 : type="button"
303 : class="m-0 inline max-w-full cursor-pointer appearance-none rounded-sm border-0 bg-transparent p-0 text-left text-xs/relaxed font-normal wrap-break-word text-muted-foreground outline-none hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset"
304 : @click="handleLocateNode(item.nodeId)"
305 : >
306 : {{ item.label }}
307 : </button>
308 : </TooltipTrigger>
309 : <TooltipContent>{{
310 : item.displayDetails
311 : }}</TooltipContent>
312 : </Tooltip>
313 : <Button
314 : v-if="item.displayDetails"
315 : variant="muted-textonly"
316 : size="icon-sm"
317 : :class="
318 : cn(
319 : 'size-6 shrink-0 hover:text-foreground focus-visible:ring-inset',
320 : isExecutionItemDetailExpanded(item.key) &&
321 : 'bg-muted text-foreground hover:bg-muted'
322 : )
323 : "
324 : :aria-label="
325 : t(
326 : 'rightSidePanel.infoFor',
327 : { item: item.label },
328 : { escapeParameter: false }
329 : )
330 : "
331 : :aria-controls="getExecutionItemDetailId(item.key)"
332 : :aria-expanded="isExecutionItemDetailExpanded(item.key)"
333 : @click.stop="toggleExecutionItemDetail(item.key)"
334 : >
335 : <i class="icon-[lucide--info] size-3.5" />
336 : </Button>
337 : </span>
338 : <LocateNodeButton
339 : :label="
340 : t(
341 : 'rightSidePanel.locateNodeFor',
342 : {
343 : item: item.label
344 : },
345 : { escapeParameter: false }
346 : )
347 : "
348 : @locate="handleLocateNode(item.nodeId)"
349 : />
350 : </div>
351 : <TransitionCollapse>
352 : <p
353 : v-if="
354 : item.displayDetails &&
355 : isExecutionItemDetailExpanded(item.key)
356 : "
357 : :id="getExecutionItemDetailId(item.key)"
358 : class="m-0 mt-0.5 pr-10 text-2xs/relaxed wrap-break-word whitespace-pre-wrap text-muted-foreground"
359 : >
360 : {{ item.displayDetails }}
361 : </p>
362 : </TransitionCollapse>
363 : </li>
364 : </ul>
365 : </div>
366 : <div v-else-if="group.type === 'execution'" class="space-y-3 px-3">
367 7 : <ErrorNodeCard
368 : v-for="card in group.cards"
369 : :key="card.id"
370 : :card="card"
371 : :expand-details-token="
372 : detailGroupKeys.includes(group.groupKey)
373 : ? expandDetailsToken
374 : : 0
375 : "
376 : :aria-current="isCardInSelection(card.id) ? 'true' : undefined"
377 : :class="
378 : cn(
379 : selectionEmphasisClass(isCardInSelection(card.id)),
380 : isCardInSelection(card.id) && '-my-1 py-1'
381 : )
382 : "
383 : @locate-node="handleLocateNode"
384 : @copy-to-clipboard="copyToClipboard"
385 : />
386 : </div>
387 :
388 : <!-- Missing Models -->
389 : <MissingModelCard
390 : v-if="group.type === 'missing_model'"
391 : :missing-model-groups="missingModelGroups"
392 : :highlighted-node-ids="selectionMatchedAssetNodeIds"
393 : :on-deployment="runsOnDeployment"
394 : @locate-model="handleLocateAssetNode"
395 : />
396 :
397 : <!-- Missing Media -->
398 : <MissingMediaCard
399 : v-if="group.type === 'missing_media'"
400 : :missing-media-groups="missingMediaGroups"
401 : :highlighted-node-ids="selectionMatchedAssetNodeIds"
402 : @locate-node="handleLocateAssetNode"
403 : />
404 : </ErrorCardSection>
405 : </TransitionGroup>
406 : </div>
407 : </div>
408 : </div>
409 : </template>
410 :
411 : <script setup lang="ts">
412 : import Badge from '@comfyorg/design-system/badge/Badge'
413 : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
414 : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
415 : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
416 :
417 : import { storeToRefs } from 'pinia'
418 : import { computed, ref, watch } from 'vue'
419 : import { useI18n } from 'vue-i18n'
420 : import { cn } from '@comfyorg/tailwind-utils'
421 : import type { Positionable } from '@comfyorg/graph-model/interfaces'
422 :
423 : import { useCopyToClipboard } from '@/composables/useCopyToClipboard'
424 : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
425 : import { useTelemetry } from '@comfyorg/telemetry'
426 : import { useErrorsTabRequestStore } from './errorsTabRequestStore'
427 : import { useWorkflowErrorManager } from '@/platform/workflowErrors/workflowErrorManager'
428 :
429 : import CollapseToggleButton from '@comfyorg/design-system/accordion/CollapseToggleButton'
430 : import TransitionCollapse from '@comfyorg/design-system/transition/TransitionCollapse'
431 : import AsyncSearchInput from '@comfyorg/design-system/search-input/AsyncSearchInput'
432 : import ErrorCardSection from './ErrorCardSection.vue'
433 : import ErrorNodeCard from './ErrorNodeCard.vue'
434 : import LocateNodeButton from './LocateNodeButton.vue'
435 : import MissingNodeCard from './MissingNodeCard.vue'
436 : import SwapNodesCard from '@/platform/workflowErrors/nodeReplacement/components/SwapNodesCard.vue'
437 : import MissingModelCard from '@/platform/workflowErrors/missingModel/components/MissingModelCard.vue'
438 : import MissingMediaCard from '@/platform/workflowErrors/missingMedia/components/MissingMediaCard.vue'
439 : import { isCloud } from '@/platform/distribution/types'
440 : import Button from '@comfyorg/design-system/button/Button'
441 : import CloudErrorAction from '@/platform/openOnCloud/components/CloudErrorAction.vue'
442 : import DotSpinner from '@comfyorg/design-system/common/DotSpinner'
443 : import { useMissingModelStore } from '@/platform/workflowErrors/missingModel/missingModelStore'
444 : import DeploymentBuildActions from './DeploymentBuildActions.vue'
445 : import { useBootDeploymentLabel } from '@/platform/workspace/composables/useDeploymentLabels'
446 : import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore'
447 : import {
448 : buildAllErrorContext,
449 : buildGroupErrorContext
450 : } from './buildAgentErrorContext'
451 : import { useErrorGroups } from './useErrorGroups'
452 : import type { SwapNodeGroup } from './useErrorGroups'
453 : import type { ErrorGroup, ErrorGroupSeverity } from './types'
454 : import { isExecutionItemListGroup } from './executionItemList'
455 : import { selectionEmphasisClass } from './selectionEmphasis'
456 : import { useNodeReplacement } from '@/platform/workflowErrors/nodeReplacement/useNodeReplacement'
457 : import { useAskAgentPort } from '@/platform/workflowErrors/askAgentPort'
458 :
459 : interface ExecutionItemListEntry {
460 : key: string
461 : cardId: string
462 : nodeId: string
463 : label: string
464 : displayDetails?: string
465 : }
466 :
467 : interface ContextStrip {
468 : keypath: string
469 : count: number
470 : nodes: number
471 : }
472 :
473 : const { selectedItems = [] } = defineProps<{
474 : selectedItems?: readonly Positionable[]
475 : }>()
476 :
477 89 : const emit = defineEmits<{
478 : locateNode: [nodeId: string, executionIdMap?: Map<string, LGraphNode>]
479 : issueCount: [count: number]
480 : }>()
481 :
482 : /** Count-only `none` keys keep node-less errors from reading as "0 nodes". */
483 89 : const SUMMARY_KEYPATHS = {
484 : error: {
485 : none: 'rightSidePanel.errorsSummary',
486 : single: 'rightSidePanel.errorNodeSummary',
487 : multiple: 'rightSidePanel.errorNodesSummary'
488 : },
489 : setup: {
490 : none: 'rightSidePanel.setupSummary',
491 : single: 'rightSidePanel.setupNodeSummary',
492 : multiple: 'rightSidePanel.setupNodesSummary'
493 : }
494 : } as const
495 :
496 89 : const HIDDEN_BY_FILTER = { error: 'missing', missing: 'error' } as const
497 :
498 89 : const SEVERITY_CHIP_CLASS = {
499 : error: {
500 : idle: 'border-border text-destructive',
501 : active: 'border-destructive/45 text-destructive'
502 : },
503 : missing: {
504 : idle: 'border-border text-warning',
505 : active: 'border-warning/50 text-warning'
506 : }
507 : } as const
508 :
509 89 : const { t } = useI18n()
510 89 : const { copyToClipboard } = useCopyToClipboard()
511 89 : const errorsTabRequestStore = useErrorsTabRequestStore()
512 89 : const missingModelStore = useMissingModelStore()
513 89 : const manager = useWorkflowErrorManager()
514 89 : const { shouldShowManagerButtons, shouldShowInstallButton } =
515 : manager.useManagerState()
516 89 : const { openManager } = manager
517 89 : const { missingNodePacks } = manager.useMissingNodes()
518 89 : const { isInstalling: isInstallingAll, installAllPacks: installAll } =
519 : manager.usePackInstall(() => missingNodePacks.value)
520 89 : const { replaceGroup, replaceAllGroups } = useNodeReplacement()
521 89 : const { canAskAgent, askAgentAboutIssues } = useAskAgentPort()
522 :
523 89 : const searchQuery = ref('')
524 89 : const expandDetailsToken = ref(0)
525 89 : const detailGroupKeys = ref<string[]>([])
526 89 : const expandedExecutionItemDetailKeys = ref(new Set<string>())
527 89 : const isSearching = computed(() => searchQuery.value.trim() !== '')
528 :
529 75 : function getExecutionItemList(group: ErrorGroup): ExecutionItemListEntry[] {
530 75 : if (group.type !== 'execution') return []
531 :
532 7 : const items: ExecutionItemListEntry[] = []
533 7 : for (const card of group.cards) {
534 7 : if (!card.nodeId) continue
535 7 : for (let idx = 0; idx < card.errors.length; idx++) {
536 7 : const error = card.errors[idx]
537 7 : const label = error.displayItemLabel
538 7 : if (!label) continue
539 7 : items.push({
540 : key: `${card.id}:${idx}`,
541 : cardId: card.id,
542 : nodeId: card.nodeId,
543 : label,
544 : displayDetails: error.displayDetails
545 : })
546 : }
547 : }
548 7 : return items.sort(compareExecutionItemListEntry)
549 : }
550 :
551 0 : function compareExecutionItemListEntry(
552 : a: ExecutionItemListEntry,
553 : b: ExecutionItemListEntry
554 : ) {
555 0 : return (
556 : a.nodeId.localeCompare(b.nodeId, undefined, { numeric: true }) ||
557 : a.label.localeCompare(b.label)
558 : )
559 : }
560 :
561 3 : function isExecutionItemDetailExpanded(key: string) {
562 3 : return expandedExecutionItemDetailKeys.value.has(key)
563 : }
564 :
565 0 : function toggleExecutionItemDetail(key: string) {
566 0 : const nextKeys = new Set(expandedExecutionItemDetailKeys.value)
567 0 : if (nextKeys.has(key)) {
568 0 : nextKeys.delete(key)
569 : } else {
570 0 : nextKeys.add(key)
571 0 : useTelemetry()?.trackUiButtonClicked({
572 : button_id: 'error_tab_info_opened',
573 : element_group: 'errors_panel'
574 : })
575 : }
576 0 : expandedExecutionItemDetailKeys.value = nextKeys
577 : }
578 :
579 2 : function getExecutionItemDetailId(key: string) {
580 2 : return `execution-item-detail-${key}`
581 : }
582 :
583 89 : const {
584 : allErrorGroups,
585 : filteredGroups,
586 : collapseState,
587 : errorNodeCache,
588 : missingNodeCache,
589 : missingPackGroups,
590 : missingModelGroups,
591 : missingMediaGroups,
592 : swapNodeGroups,
593 : hasSelection,
594 : selectedNodeCount,
595 : selectedNodeTitle,
596 : selectionMatchedGroupKeys,
597 : selectionMatchedCardIds,
598 : selectionMatchedAssetNodeIds,
599 : selectionErrorCount,
600 : errorNodeCount
601 : } = useErrorGroups(searchQuery, () => selectedItems)
602 :
603 89 : const errorCount = computed(() =>
604 : filteredGroups.value
605 : .filter((group) => group.severity === 'error')
606 : .reduce((sum, group) => sum + group.count, 0)
607 : )
608 89 : const missingCount = computed(() =>
609 : filteredGroups.value
610 : .filter((group) => group.severity === 'missing')
611 : .reduce((sum, group) => sum + group.count, 0)
612 : )
613 89 : const hasMixedSeverity = computed(
614 : () => errorCount.value > 0 && missingCount.value > 0
615 : )
616 :
617 89 : const BUILD_FIXABLE_TYPES: ReadonlySet<ErrorGroup['type']> = new Set([
618 : 'missing_node',
619 : 'missing_model'
620 : ])
621 89 : const { bootDeployment, changeSinceBoot } = storeToRefs(
622 : useDeploymentPickStore()
623 : )
624 89 : const bootDeploymentLabel = useBootDeploymentLabel()
625 89 : const runsOnDeployment = computed(() => isCloud && !!bootDeployment.value)
626 89 : const buildDeployment = computed(() => {
627 89 : if (!runsOnDeployment.value || !bootDeployment.value) return undefined
628 : const buildFixes = filteredGroups.value.some((group) =>
629 : BUILD_FIXABLE_TYPES.has(group.type)
630 : )
631 89 : return buildFixes ? bootDeployment.value : undefined
632 : })
633 89 : const buildFixesAllSetup = computed(
634 : () =>
635 : buildDeployment.value !== undefined &&
636 : changeSinceBoot.value === null &&
637 : filteredGroups.value.every(
638 : (group) =>
639 : group.severity !== 'missing' || BUILD_FIXABLE_TYPES.has(group.type)
640 : )
641 : )
642 :
643 89 : const severityTotals = computed(() => {
644 106 : const totals: Record<ErrorGroupSeverity, number> = { error: 0, missing: 0 }
645 106 : for (const group of allErrorGroups.value) {
646 108 : totals[group.severity] += group.count
647 : }
648 106 : return totals
649 : })
650 :
651 89 : const severityFilter = ref<ErrorGroupSeverity | null>(null)
652 : // Workflow-wide, not search-scoped: a search emptying one severity must not
653 : // disable an engaged filter.
654 89 : const hasMixedSeverityTotals = computed(
655 : () => severityTotals.value.error > 0 && severityTotals.value.missing > 0
656 : )
657 89 : const activeSeverityFilter = computed(() =>
658 : hasMixedSeverityTotals.value ? severityFilter.value : null
659 : )
660 89 : const visibleGroups = computed(() => {
661 107 : const severity = activeSeverityFilter.value
662 107 : if (!severity) return filteredGroups.value
663 0 : return filteredGroups.value.filter((group) => group.severity === severity)
664 : })
665 :
666 0 : function toggleSeverityFilter(severity: ErrorGroupSeverity) {
667 0 : severityFilter.value = severityFilter.value === severity ? null : severity
668 : }
669 :
670 : /**
671 : * Dedupes the Set-valued computed (fresh reference per recompute) so the
672 : * watchers below only fire when the matched membership changes.
673 : */
674 89 : const selectionEmphasisSignature = computed(() =>
675 : hasSelection.value
676 : ? [
677 : ...selectionMatchedGroupKeys.value,
678 : ...selectionMatchedCardIds.value,
679 : ...selectionMatchedAssetNodeIds.value
680 : ]
681 : .sort()
682 : .join('\n')
683 : : ''
684 : )
685 :
686 : /** Issue identity per severity — membership, so same-count replacements are visible. */
687 89 : const severityIssueKeys = computed<Record<ErrorGroupSeverity, Set<string>>>(
688 : () => ({
689 : error: new Set(
690 : allErrorGroups.value
691 : .filter((group) => group.type === 'execution')
692 : .flatMap((group) =>
693 : group.cards.flatMap((card) =>
694 : card.errors.map(
695 : (error, index) =>
696 : `${group.groupKey}|${card.id}|${error.message}#${index}`
697 : )
698 : )
699 : )
700 : ),
701 : missing: new Set([
702 : ...missingPackGroups.value.flatMap((pack) =>
703 : pack.nodeTypes.map(
704 : (nodeType) =>
705 : `pack|${pack.packId}|${typeof nodeType === 'string' ? nodeType : `${nodeType.type}|${nodeType.nodeId}`}`
706 : )
707 : ),
708 : ...swapNodeGroups.value.flatMap((swap) =>
709 : swap.nodeTypes.map(
710 : (nodeType) =>
711 : `swap|${swap.type}|${typeof nodeType === 'string' ? nodeType : nodeType.nodeId}`
712 : )
713 : ),
714 : ...missingModelGroups.value.flatMap((group) =>
715 : group.models.flatMap((model) =>
716 : model.referencingNodes.map(
717 : (ref) =>
718 : `model|${group.directory}|${model.name}|${ref.nodeId}|${ref.widgetName}`
719 : )
720 : )
721 : ),
722 : ...missingMediaGroups.value.flatMap((group) =>
723 : group.items.flatMap((item) =>
724 : item.referencingNodes.map(
725 : (ref) =>
726 : `media|${group.mediaType}|${item.name}|${ref.nodeId}|${ref.widgetName}`
727 : )
728 : )
729 : )
730 : ])
731 : })
732 : )
733 :
734 : // Release-only, never auto-select; an unchanged selection does not release,
735 : // since engaging the filter against it is the user's explicit call.
736 89 : watch(severityIssueKeys, (next, prev) => {
737 18 : const active = severityFilter.value
738 18 : if (!active) return
739 0 : const hidden = HIDDEN_BY_FILTER[active]
740 : const hiddenGainedMember = [...next[hidden]].some(
741 : (key) => !prev[hidden].has(key)
742 : )
743 18 : if (hiddenGainedMember || next[active].size === 0) {
744 0 : severityFilter.value = null
745 : }
746 : })
747 :
748 89 : watch(selectionEmphasisSignature, () => {
749 22 : const active = severityFilter.value
750 22 : if (!active) return
751 0 : const matchedKeys = selectionMatchedGroupKeys.value
752 0 : if (matchedKeys.size === 0) return
753 0 : const hidden = HIDDEN_BY_FILTER[active]
754 : const selectionHasHiddenSeverity = allErrorGroups.value.some(
755 : (group) => matchedKeys.has(group.groupKey) && group.severity === hidden
756 : )
757 0 : if (selectionHasHiddenSeverity) severityFilter.value = null
758 : })
759 :
760 89 : const hero = computed(() => {
761 89 : if (hasMixedSeverity.value) {
762 0 : const total = errorCount.value + missingCount.value
763 0 : return {
764 : count: total,
765 : countClass: 'text-foreground',
766 : title: t('rightSidePanel.issuesDetected', total),
767 : description: t('rightSidePanel.resolveBeforeRun')
768 : }
769 : }
770 89 : if (missingCount.value > 0) {
771 82 : return {
772 : count: missingCount.value,
773 : countClass: 'text-warning',
774 : title: t('rightSidePanel.setupRequired'),
775 : description: buildFixesAllSetup.value
776 : ? t(
777 : 'rightSidePanel.addToDeploymentBuild',
778 : { deployment: bootDeploymentLabel.value },
779 : { escapeParameter: false }
780 : )
781 : : t('rightSidePanel.finishSetupBeforeRun')
782 : }
783 : }
784 7 : return {
785 : count: errorCount.value,
786 : countClass: 'text-destructive',
787 : title: t('rightSidePanel.errorsDetected', errorCount.value),
788 : description: t('rightSidePanel.resolveErrorsBeforeRun')
789 : }
790 : })
791 :
792 89 : const severityChips = computed(() => [
793 : {
794 : severity: 'error' as const,
795 : active: activeSeverityFilter.value === 'error',
796 : label:
797 : activeSeverityFilter.value === 'error'
798 : ? t('rightSidePanel.errorsFilterActive', errorCount.value)
799 : : t('rightSidePanel.errorsFilter', errorCount.value)
800 : },
801 : {
802 : severity: 'missing' as const,
803 : active: activeSeverityFilter.value === 'missing',
804 : label: t('rightSidePanel.setupFilter', missingCount.value)
805 : }
806 : ])
807 :
808 89 : const hasSelectionEmphasis = computed(
809 : () => hasSelection.value && selectionErrorCount.value > 0
810 : )
811 89 : const selectionStripNodeLabel = computed(
812 : () => selectedNodeTitle.value ?? t('g.untitled')
813 : )
814 :
815 : // The strip is a status line, not a view of the current filter — summary
816 : // numbers are workflow-wide, never search-filtered.
817 89 : const workflowErrorCount = computed(
818 : () => severityTotals.value.error + severityTotals.value.missing
819 : )
820 89 : const workflowBlockingErrorCount = computed(() => severityTotals.value.error)
821 89 : const hasErrorSeverity = computed(() => severityTotals.value.error > 0)
822 89 : const hasMissingSeverity = computed(() => severityTotals.value.missing > 0)
823 :
824 89 : const strip = computed<ContextStrip>(() => {
825 111 : if (hasSelectionEmphasis.value) {
826 21 : return {
827 : keypath:
828 : selectedNodeCount.value === 1
829 : ? 'rightSidePanel.selectedNodeErrors'
830 : : 'rightSidePanel.selectedNodesErrors',
831 : nodes: selectedNodeCount.value,
832 : count: selectionErrorCount.value
833 : }
834 : }
835 111 : if (hasErrorSeverity.value && hasMissingSeverity.value) {
836 0 : return {
837 : keypath:
838 : errorNodeCount.value === 0
839 : ? 'rightSidePanel.errorsSummary'
840 : : 'rightSidePanel.nodesAffected',
841 : nodes: errorNodeCount.value,
842 : count:
843 : errorNodeCount.value === 0
844 : ? workflowBlockingErrorCount.value
845 : : errorNodeCount.value
846 : }
847 : }
848 : const keypaths = hasErrorSeverity.value
849 : ? SUMMARY_KEYPATHS.error
850 : : SUMMARY_KEYPATHS.setup
851 : const nodeCountKey =
852 : errorNodeCount.value === 0
853 : ? 'none'
854 : : errorNodeCount.value === 1
855 : ? 'single'
856 : : 'multiple'
857 :
858 111 : return {
859 : keypath: keypaths[nodeCountKey],
860 : nodes: errorNodeCount.value,
861 : count: workflowErrorCount.value
862 : }
863 : })
864 :
865 23 : function isCardInSelection(cardId: string): boolean {
866 23 : return selectionMatchedCardIds.value.has(cardId)
867 : }
868 :
869 : /**
870 : * Selection acts as emphasis, not a filter: expand the groups containing
871 : * the selected nodes' errors and collapse the rest. When the emphasis ends
872 : * (selection cleared or moved to a node without errors), re-expand all
873 : * groups so the tab reads as the workflow overview again.
874 : */
875 89 : watch(
876 : selectionEmphasisSignature,
877 : (signature, previousSignature) => {
878 111 : if (!signature) {
879 89 : if (!previousSignature) return
880 12 : for (const groupKey of Object.keys(collapseState)) {
881 6 : setSectionCollapsed(groupKey, false)
882 : }
883 5 : return
884 : }
885 22 : const matchedKeys = selectionMatchedGroupKeys.value
886 24 : for (const group of allErrorGroups.value) {
887 23 : setSectionCollapsed(group.groupKey, !matchedKeys.has(group.groupKey))
888 : }
889 : },
890 : { immediate: true }
891 : )
892 :
893 89 : const showMissingModelHeaderRefresh = computed(
894 : () => !isCloud && missingModelGroups.value.length > 0
895 : )
896 :
897 2 : function handleMissingModelRefresh() {
898 2 : if (missingModelStore.isRefreshingMissingModels) return
899 :
900 2 : void missingModelStore.refreshMissingModels()
901 : }
902 :
903 89 : const isAllCollapsed = computed({
904 : get() {
905 123 : return filteredGroups.value.every((g) => isSectionCollapsed(g.groupKey))
906 : },
907 : set(collapse: boolean) {
908 0 : for (const group of allErrorGroups.value) {
909 0 : setSectionCollapsed(group.groupKey, collapse)
910 : }
911 : }
912 : })
913 :
914 325 : function isSectionCollapsed(groupKey: string): boolean {
915 : // Defaults to expanded when not explicitly set by the user
916 325 : return collapseState[groupKey] ?? false
917 : }
918 :
919 29 : function setSectionCollapsed(groupKey: string, collapsed: boolean) {
920 29 : collapseState[groupKey] = collapsed
921 : }
922 :
923 89 : watch(
924 : () => errorsTabRequestStore.focusedNodeId,
925 : (graphNodeId) => {
926 89 : if (!graphNodeId) return
927 0 : const prefix = `${graphNodeId}:`
928 0 : for (const group of allErrorGroups.value) {
929 0 : if (group.type !== 'execution') continue
930 :
931 0 : const hasMatch = group.cards.some(
932 : (card) =>
933 : card.graphNodeId === graphNodeId ||
934 : (card.nodeId?.startsWith(prefix) ?? false)
935 : )
936 0 : setSectionCollapsed(group.groupKey, !hasMatch)
937 : }
938 0 : errorsTabRequestStore.clearFocusedNode()
939 : },
940 : { immediate: true }
941 : )
942 :
943 73 : function openClosedErrorDetails(groupKeys: readonly string[]) {
944 73 : searchQuery.value = ''
945 73 : severityFilter.value = null
946 73 : const keys = new Set(groupKeys)
947 73 : const nextKeys = new Set(expandedExecutionItemDetailKeys.value)
948 73 : for (const group of allErrorGroups.value) {
949 74 : if (!keys.has(group.groupKey)) continue
950 74 : if (isSectionCollapsed(group.groupKey)) {
951 0 : setSectionCollapsed(group.groupKey, false)
952 : }
953 74 : for (const item of getExecutionItemList(group)) {
954 6 : if (item.displayDetails) nextKeys.add(item.key)
955 : }
956 : }
957 73 : expandedExecutionItemDetailKeys.value = nextKeys
958 73 : detailGroupKeys.value = [...keys]
959 73 : expandDetailsToken.value += 1
960 : }
961 :
962 89 : watch(
963 : () => errorsTabRequestStore.detailsRequest,
964 : (request) => {
965 163 : if (!request) return
966 73 : openClosedErrorDetails(request)
967 73 : errorsTabRequestStore.clearDetailsRequest()
968 : },
969 : { immediate: true }
970 : )
971 :
972 0 : function handleLocateNode(nodeId: string) {
973 0 : emit('locateNode', nodeId, errorNodeCache.value)
974 : }
975 :
976 3 : function handleLocateMissingNode(nodeId: string) {
977 3 : emit('locateNode', nodeId, missingNodeCache.value)
978 : }
979 :
980 2 : function handleLocateAssetNode(nodeId: string) {
981 2 : emit('locateNode', nodeId)
982 : }
983 :
984 0 : function handleOpenManagerInfo(packId: string) {
985 : const isKnownToRegistry = missingNodePacks.value.some((p) => p.id === packId)
986 0 : if (isKnownToRegistry) {
987 0 : openManager({ initialTab: 'missing', initialPackId: packId })
988 : } else {
989 0 : openManager({ initialTab: 'all', initialPackId: packId })
990 : }
991 : }
992 :
993 8 : function handleReplaceGroup(group: SwapNodeGroup) {
994 8 : replaceGroup(group)
995 : }
996 :
997 5 : function handleReplaceAll() {
998 5 : replaceAllGroups(swapNodeGroups.value)
999 : }
1000 :
1001 89 : const missingGroupContext = computed(() => ({
1002 : missingPackGroups: missingPackGroups.value,
1003 : swapNodeGroups: swapNodeGroups.value,
1004 : missingModelGroups: missingModelGroups.value,
1005 : missingMediaGroups: missingMediaGroups.value
1006 : }))
1007 :
1008 89 : const askAgentLabel = computed(() => {
1009 1 : const groups = filteredGroups.value
1010 1 : const title = groups.length === 1 ? groups[0].displayTitle : hero.value.title
1011 1 : return t('rightSidePanel.askAgentAbout', { title })
1012 : })
1013 :
1014 89 : const allIssuesContext = computed(() =>
1015 : buildAllErrorContext(allErrorGroups.value, missingGroupContext.value, {
1016 : label: t('agent.errorContext.allLabel')
1017 : })
1018 : )
1019 :
1020 89 : watch(
1021 : () => allIssuesContext.value.count,
1022 : (count) => emit('issueCount', count),
1023 : { immediate: true }
1024 : )
1025 :
1026 0 : function handleAskAgent() {
1027 0 : const groups = filteredGroups.value
1028 0 : if (groups.length === 0) return
1029 0 : if (groups.length === 1) {
1030 0 : askAgentAboutIssues(
1031 : buildGroupErrorContext(groups[0], missingGroupContext.value)
1032 : )
1033 0 : return
1034 : }
1035 0 : askAgentAboutIssues(
1036 : buildAllErrorContext(groups, missingGroupContext.value, {
1037 : label: hero.value.title,
1038 : scope: 'card'
1039 : })
1040 : )
1041 : }
1042 :
1043 0 : function askAboutAllIssues() {
1044 0 : if (allIssuesContext.value.count === 0) return
1045 0 : askAgentAboutIssues(allIssuesContext.value)
1046 : }
1047 :
1048 89 : defineExpose({ askAboutAllIssues })
1049 : </script>
|