mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-27 08:25:50 +00:00
## Summary Follow-up to the closed earlier attempt in #11646. This PR keeps the same user-facing goal, but changes the implementation to reuse the existing missing model pipeline for refresh instead of maintaining a separate candidate-only recheck path. Adds a missing model refresh action in the Errors tab by reusing the existing missing model pipeline, so users can re-check models after downloading or manually placing files without reloading the workflow. ## Changes - **What**: - Adds `app.refreshMissingModels()` as a reusable refresh entry point for the current root graph. - Splits node definition reloading into `app.reloadNodeDefs()` so missing-model refresh can pull fresh `object_info` without showing the generic combo refresh success flow. - Reuses the existing missing model pipeline instead of adding a separate candidate-only checker. The refresh path serializes the current graph, reuses active workflow model metadata when available, falls back to current missing-model metadata, and then reruns the same candidate discovery/enrichment/surfacing flow used during workflow load. - Adds missing model refresh state and error handling to `missingModelStore`. - Adds a Refresh button next to Download all in the missing model card action bar. - Moves Download all from the Errors tab header into the missing model card, so the Download all and Refresh actions render or hide together. - Changes Download all visibility from “more than one downloadable model” to “at least one downloadable model.” - Keeps the action bar hidden when there are no downloadable missing models; Cloud still does not render this action area. - Normalizes active workflow `pendingWarnings` updates so resolved missing model warnings do not get revived by stale empty warning objects. - Adds test IDs and coverage for the new action bar, refresh state, refresh delegation, pending warning sync, and E2E refresh behavior. - **Breaking**: None. - **Dependencies**: None. ## Review Focus The main design choice is intentionally reusing the missing model pipeline for refresh instead of implementing a smaller candidate-only recheck. The earlier candidate-only approach was cheaper, but it created a separate source of truth for missing-model resolution and made edge cases harder to reason about. In particular, it could diverge from the behavior used when a workflow is loaded, and it did not naturally handle the case where a model becomes missing after the workflow is already open. This version pays the cost of refreshing node definitions and rerunning the missing-model scan for the current graph, but keeps the refresh behavior aligned with workflow load semantics. Expected behavior by environment: - OSS browser: - The action bar appears when at least one missing model has a downloadable URL and directory. - Download all uses the existing browser download path. - Refresh reloads `object_info`, refreshes node definitions/combo values, reruns missing-model detection for the current graph, and clears the error if the selected model is now available. - OSS desktop: - The same action bar appears under the same downloadable-model condition. - Download all uses the existing Electron DownloadManager path. - Refresh uses the same missing-model pipeline as browser, so manually placed files or desktop-downloaded files can be rechecked without reloading the workflow. - Cloud: - The action bar remains hidden because model download/import is not supported in this section for Cloud. A few boundaries are intentional: - This PR does not add automatic filesystem watching. Browser OSS cannot reliably observe local model folder changes, so the user-triggered Refresh button remains the cross-environment mechanism. - This PR does not redesign the public `refreshComboInNodes` API beyond extracting `reloadNodeDefs()` for reuse. Further cleanup of toast behavior or a more explicit object-info reload API can be follow-up work. - This PR keeps refresh scoped to missing-model validation; missing media and missing nodes continue to use their existing flows. Linear: FE-417 ## Screenshots (if applicable) https://github.com/user-attachments/assets/2e02799f-1374-4377-b7b3-172241517772 ## Validation - `pnpm format` - `pnpm lint` (passes; existing unrelated warning remains in `src/platform/workspace/composables/useWorkspaceBilling.test.ts`) - `pnpm typecheck` - `pnpm test:unit` - `pnpm test:browser:local -- --project=chromium browser_tests/tests/propertiesPanel/errorsTabMissingModels.spec.ts` - `pnpm build` - `NX_SKIP_NX_CACHE=true DISTRIBUTION=desktop USE_PROD_CONFIG=true NODE_OPTIONS='--max-old-space-size=8192' pnpm exec nx build` - Manual desktop verification through `~/Projects/desktop` after copying the desktop build into `assets/ComfyUI/web_custom_versions/desktop_app`: - confirmed the FE bundle is built with `DISTRIBUTION = "desktop"` - confirmed missing model Download uses the desktop download path instead of browser download - confirmed Refresh can clear the missing model error after the model is available - Push hook: `pnpm knip --cache` ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11661-feat-refresh-missing-models-through-pipeline-34f6d73d3650811488defee54a7a6667) by [Unito](https://www.unito.io)
307 lines
9.2 KiB
TypeScript
307 lines
9.2 KiB
TypeScript
import { createTestingPinia } from '@pinia/testing'
|
|
import { render, screen } from '@testing-library/vue'
|
|
import userEvent from '@testing-library/user-event'
|
|
import PrimeVue from 'primevue/config'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { createI18n } from 'vue-i18n'
|
|
import TabErrors from './TabErrors.vue'
|
|
import { useMissingModelStore } from '@/platform/missingModel/missingModelStore'
|
|
import type { MissingModelCandidate } from '@/platform/missingModel/types'
|
|
|
|
vi.mock('@/scripts/app', () => ({
|
|
app: {
|
|
rootGraph: {
|
|
serialize: vi.fn(() => ({})),
|
|
getNodeById: vi.fn()
|
|
}
|
|
}
|
|
}))
|
|
|
|
vi.mock('@/utils/graphTraversalUtil', () => ({
|
|
getNodeByExecutionId: vi.fn(),
|
|
getRootParentNode: vi.fn(() => null),
|
|
forEachNode: vi.fn(),
|
|
mapAllNodes: vi.fn(() => [])
|
|
}))
|
|
|
|
vi.mock('@/composables/useCopyToClipboard', () => ({
|
|
useCopyToClipboard: vi.fn(() => ({
|
|
copyToClipboard: vi.fn()
|
|
}))
|
|
}))
|
|
|
|
vi.mock('@/services/litegraphService', () => ({
|
|
useLitegraphService: vi.fn(() => ({
|
|
fitView: vi.fn()
|
|
}))
|
|
}))
|
|
|
|
describe('TabErrors.vue', () => {
|
|
let i18n: ReturnType<typeof createI18n>
|
|
|
|
beforeEach(() => {
|
|
i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'en',
|
|
messages: {
|
|
en: {
|
|
g: {
|
|
workflow: 'Workflow',
|
|
copy: 'Copy'
|
|
},
|
|
rightSidePanel: {
|
|
noErrors: 'No errors',
|
|
noneSearchDesc: 'No results found',
|
|
missingModels: {
|
|
missingModelsTitle: 'Missing Models',
|
|
downloadAll: 'Download all',
|
|
refresh: 'Refresh',
|
|
refreshing: 'Refreshing missing models.'
|
|
},
|
|
promptErrors: {
|
|
prompt_no_outputs: {
|
|
desc: 'Prompt has no outputs'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
function renderComponent(initialState = {}) {
|
|
const user = userEvent.setup()
|
|
render(TabErrors, {
|
|
global: {
|
|
plugins: [
|
|
PrimeVue,
|
|
i18n,
|
|
createTestingPinia({
|
|
createSpy: vi.fn,
|
|
initialState
|
|
})
|
|
],
|
|
stubs: {
|
|
FormSearchInput: {
|
|
template:
|
|
'<input @input="$emit(\'update:modelValue\', $event.target.value)" />'
|
|
},
|
|
PropertiesAccordionItem: {
|
|
template: '<div><slot name="label" /><slot /></div>'
|
|
},
|
|
Button: {
|
|
template: '<button v-bind="$attrs"><slot /></button>'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
return { user }
|
|
}
|
|
|
|
it('renders "no errors" state when store is empty', () => {
|
|
renderComponent()
|
|
expect(screen.getByText('No errors')).toBeInTheDocument()
|
|
})
|
|
|
|
it('renders prompt-level errors (Group title = error message)', async () => {
|
|
renderComponent({
|
|
executionError: {
|
|
lastPromptError: {
|
|
type: 'prompt_no_outputs',
|
|
message: 'Server Error: No outputs',
|
|
details: 'Error details'
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(screen.getByText('Server Error: No outputs')).toBeInTheDocument()
|
|
expect(screen.getByText('Prompt has no outputs')).toBeInTheDocument()
|
|
expect(screen.queryByText('Error details')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('renders node validation errors grouped by class_type', async () => {
|
|
const { getNodeByExecutionId } = await import('@/utils/graphTraversalUtil')
|
|
vi.mocked(getNodeByExecutionId).mockReturnValue({
|
|
title: 'CLIP Text Encode'
|
|
} as ReturnType<typeof getNodeByExecutionId>)
|
|
|
|
renderComponent({
|
|
executionError: {
|
|
lastNodeErrors: {
|
|
'6': {
|
|
class_type: 'CLIPTextEncode',
|
|
errors: [
|
|
{ message: 'Required input is missing', details: 'Input: text' }
|
|
]
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(screen.getByText('CLIPTextEncode')).toBeInTheDocument()
|
|
expect(screen.getByText('#6')).toBeInTheDocument()
|
|
expect(screen.getByText('CLIP Text Encode')).toBeInTheDocument()
|
|
expect(screen.getByText('Required input is missing')).toBeInTheDocument()
|
|
})
|
|
|
|
it('renders runtime execution errors from WebSocket', async () => {
|
|
const { getNodeByExecutionId } = await import('@/utils/graphTraversalUtil')
|
|
vi.mocked(getNodeByExecutionId).mockReturnValue({
|
|
title: 'KSampler'
|
|
} as ReturnType<typeof getNodeByExecutionId>)
|
|
|
|
renderComponent({
|
|
executionError: {
|
|
lastExecutionError: {
|
|
prompt_id: 'abc',
|
|
node_id: '10',
|
|
node_type: 'KSampler',
|
|
exception_message: 'Out of memory',
|
|
exception_type: 'RuntimeError',
|
|
traceback: ['Line 1', 'Line 2'],
|
|
timestamp: Date.now()
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(screen.getAllByText('KSampler').length).toBeGreaterThanOrEqual(1)
|
|
expect(screen.getByText('#10')).toBeInTheDocument()
|
|
expect(screen.getByText('RuntimeError: Out of memory')).toBeInTheDocument()
|
|
expect(screen.getByText(/Line 1/)).toBeInTheDocument()
|
|
})
|
|
|
|
it('filters errors based on search query', async () => {
|
|
const { getNodeByExecutionId } = await import('@/utils/graphTraversalUtil')
|
|
vi.mocked(getNodeByExecutionId).mockReturnValue(null)
|
|
|
|
const { user } = renderComponent({
|
|
executionError: {
|
|
lastNodeErrors: {
|
|
'1': {
|
|
class_type: 'CLIPTextEncode',
|
|
errors: [{ message: 'Missing text input' }]
|
|
},
|
|
'2': {
|
|
class_type: 'KSampler',
|
|
errors: [{ message: 'Out of memory' }]
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(screen.getAllByText('CLIPTextEncode').length).toBeGreaterThanOrEqual(
|
|
1
|
|
)
|
|
expect(screen.getAllByText('KSampler').length).toBeGreaterThanOrEqual(1)
|
|
|
|
await user.type(screen.getByRole('textbox'), 'Missing text input')
|
|
|
|
expect(screen.getAllByText('CLIPTextEncode').length).toBeGreaterThanOrEqual(
|
|
1
|
|
)
|
|
expect(screen.queryByText('KSampler')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('calls copyToClipboard when copy button is clicked', async () => {
|
|
const { useCopyToClipboard } =
|
|
await import('@/composables/useCopyToClipboard')
|
|
const mockCopy = vi.fn()
|
|
vi.mocked(useCopyToClipboard).mockReturnValue({ copyToClipboard: mockCopy })
|
|
|
|
const { user } = renderComponent({
|
|
executionError: {
|
|
lastNodeErrors: {
|
|
'1': {
|
|
class_type: 'TestNode',
|
|
errors: [{ message: 'Test message', details: 'Test details' }]
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
await user.click(screen.getByTestId('error-card-copy'))
|
|
|
|
expect(mockCopy).toHaveBeenCalledWith('Test message\n\nTest details')
|
|
})
|
|
|
|
it('renders single runtime error outside accordion in full-height panel', async () => {
|
|
const { getNodeByExecutionId } = await import('@/utils/graphTraversalUtil')
|
|
vi.mocked(getNodeByExecutionId).mockReturnValue({
|
|
title: 'KSampler'
|
|
} as ReturnType<typeof getNodeByExecutionId>)
|
|
|
|
renderComponent({
|
|
executionError: {
|
|
lastExecutionError: {
|
|
prompt_id: 'abc',
|
|
node_id: '10',
|
|
node_type: 'KSampler',
|
|
exception_message: 'Out of memory',
|
|
exception_type: 'RuntimeError',
|
|
traceback: ['Line 1', 'Line 2'],
|
|
timestamp: Date.now()
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(screen.getAllByText('KSampler').length).toBeGreaterThanOrEqual(1)
|
|
expect(screen.getByText('RuntimeError: Out of memory')).toBeInTheDocument()
|
|
expect(screen.getByTestId('runtime-error-panel')).toBeInTheDocument()
|
|
expect(screen.getAllByText('RuntimeError: Out of memory')).toHaveLength(1)
|
|
})
|
|
|
|
it('shows missing model Refresh in the section header when no model is downloadable', async () => {
|
|
const missingModel = {
|
|
nodeId: '1',
|
|
nodeType: 'CheckpointLoaderSimple',
|
|
widgetName: 'ckpt_name',
|
|
name: 'local-only.safetensors',
|
|
directory: 'checkpoints',
|
|
isMissing: true,
|
|
isAssetSupported: true
|
|
} satisfies MissingModelCandidate
|
|
|
|
const { user } = renderComponent({
|
|
missingModel: {
|
|
missingModelCandidates: [missingModel]
|
|
}
|
|
})
|
|
const missingModelStore = useMissingModelStore()
|
|
|
|
expect(screen.getByText('Missing Models (1)')).toBeInTheDocument()
|
|
expect(
|
|
screen.queryByTestId('missing-model-actions')
|
|
).not.toBeInTheDocument()
|
|
|
|
await user.click(screen.getByTestId('missing-model-header-refresh'))
|
|
|
|
expect(missingModelStore.refreshMissingModels).toHaveBeenCalled()
|
|
})
|
|
|
|
it('keeps missing model Refresh in the card actions when models are downloadable', () => {
|
|
const missingModel = {
|
|
nodeId: '1',
|
|
nodeType: 'CheckpointLoaderSimple',
|
|
widgetName: 'ckpt_name',
|
|
name: 'downloadable.safetensors',
|
|
url: 'https://huggingface.co/comfy/test/resolve/main/downloadable.safetensors',
|
|
directory: 'checkpoints',
|
|
isMissing: true,
|
|
isAssetSupported: true
|
|
} satisfies MissingModelCandidate
|
|
|
|
renderComponent({
|
|
missingModel: {
|
|
missingModelCandidates: [missingModel]
|
|
}
|
|
})
|
|
|
|
expect(
|
|
screen.queryByTestId('missing-model-header-refresh')
|
|
).not.toBeInTheDocument()
|
|
expect(screen.getByTestId('missing-model-actions')).toBeInTheDocument()
|
|
expect(screen.getByRole('button', { name: /Download all/ })).toBeVisible()
|
|
expect(screen.getByRole('button', { name: 'Refresh' })).toBeVisible()
|
|
})
|
|
})
|