From 1a6d78a1cf8b08762aaeae80240580f025dcb4c6 Mon Sep 17 00:00:00 2001 From: Mariana Martinho Date: Wed, 11 Nov 2026 19:01:54 +0100 Subject: [PATCH 1/8] style(perf-test): filter-style setup row and one results card Same change as #2004, now based on main instead of the closed #1981. Co-Authored-By: Claude Opus 5.5 --- locales/en.json | 28 +- locales/zh.json | 28 +- .../src/components/BrandedPageHeader.vue | 19 +- src/renderer/src/panel/PanelApp.test.ts | 314 ++--- .../src/views/PerformanceTestView.vue | 1083 +++++++++-------- 5 files changed, 829 insertions(+), 643 deletions(-) diff --git a/locales/en.json b/locales/en.json index eb46da807..ed9fa2e26 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1548,14 +1548,16 @@ "performanceTest": { "title": "Performance Tests", "description": "Run performance tests against your ComfyUI builds.", - "selectInstance": "1. Select a build", - "workspaceLabel": "Workspace", + "selectInstance": "Build", "instanceLabel": "Build", "selectInstancePlaceholder": "Select a build", - "chooseWorkflow": "2. Choose a workflow", + "chooseWorkflow": "Workflow", "chooseExampleWorkflow": "Choose an example workflow", "loadingExampleWorkflows": "Loading example workflows...", - "orImportApiWorkflow": "or import an API workflow", + "importApiWorkflow": "Import API workflow", + "orDropJson": "or drop the .json", + "exampleTag": "Example", + "apiTag": "API", "exampleWorkflowPickerTitle": "Choose an example workflow", "exampleWorkflowPickerDescription": "Missing models will be downloaded automatically.", "useExampleWorkflow": "Use workflow", @@ -1567,7 +1569,6 @@ "exampleModelsFailed": "Could not download every model required by this workflow.", "exampleModelsNoSpace": "There is not enough disk space for this workflow's models.", "cancelExampleDownload": "Cancel download", - "dropWorkflowHint": "Drop a workflow .json file in API format here, or click to browse", "importingWorkflow": "Importing workflow...", "preparingExampleWorkflow": "Preparing workflow and downloading required models...", "importFailed": "Could not import the workflow.", @@ -1577,14 +1578,14 @@ "stop": "Stop", "stopping": "Stopping...", "stopFailed": "Could not stop the build.", - "measurementSettings": "3. Set measurement settings", + "measurementSettings": "Runs", "warmupRuns": "Warm-up runs", "warmupRunsHint": "Runs executed first to load models and warm up caches. They are not included in the results.", "measuredRuns": "Measured runs", "measuredRunsHint": "Runs timed after the warm-up runs. Their durations are used to calculate the results.", "logsPlaceholder": "Build logs will appear here.", "results": "Results", - "resultsPlaceholder": "Performance test results will appear here.", + "resultsPlaceholder": "Choose a workflow and press Run. Results stay here until the next run.", "workflowFileName": "Workflow file", "fastestRun": "Fastest run", "slowestRun": "Slowest run", @@ -1593,7 +1594,6 @@ "measuredRunCount": "Measured runs", "failedRunCount": "Failed runs", "runProgress": "Progress", - "runProgressCount": "{completed} of {total} runs completed", "runDurationChart": "Run duration aggregates", "device": "Compute device", "vram": "VRAM", @@ -1614,7 +1614,17 @@ "launchFailed": "Failed to start the build.", "submittingRuns": "Submitting {warmupCount} warm-up runs and {count} measured runs...", "completedRuns": "Finished {count} measured runs ({failed} failed). Final response saved to {path}", - "submitFailed": "Failed to submit the performance test workflow." + "submitFailed": "Failed to submit the performance test workflow.", + "chooseWorkflowPlaceholder": "Choose a workflow", + "resultContextOn": "on", + "runNumber": "Run {current} of {total}", + "resultsEmptyTitle": "No results yet", + "medianSummary": "Median run · {count} measured · {failed} failed", + "legendMedian": "Median", + "legendAverage": "Average", + "legendRange": "fastest to slowest", + "runPhaseWarmup": "warm-up run", + "runPhaseMeasured": "measured run {current} of {total}" }, "benchmarks": { "title": "Benchmarks", diff --git a/locales/zh.json b/locales/zh.json index f17ba0975..0d44dcb5b 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -1548,14 +1548,16 @@ "performanceTest": { "title": "性能测试", "description": "针对您的 ComfyUI 构建运行性能测量。", - "selectInstance": "1. 选择构建", - "workspaceLabel": "工作区", + "selectInstance": "构建", "instanceLabel": "构建", "selectInstancePlaceholder": "选择构建", - "chooseWorkflow": "2. 选择工作流", + "chooseWorkflow": "工作流", "chooseExampleWorkflow": "选择示例工作流", "loadingExampleWorkflows": "正在加载示例工作流...", - "orImportApiWorkflow": "或导入 API 工作流", + "importApiWorkflow": "导入 API 工作流", + "orDropJson": "或拖入 .json 文件", + "exampleTag": "示例", + "apiTag": "API", "exampleWorkflowPickerTitle": "选择示例工作流", "exampleWorkflowPickerDescription": "缺少的模型将自动下载。", "useExampleWorkflow": "使用工作流", @@ -1567,7 +1569,6 @@ "exampleModelsFailed": "无法下载此工作流所需的全部模型。", "exampleModelsNoSpace": "磁盘空间不足,无法下载此工作流的模型。", "cancelExampleDownload": "取消下载", - "dropWorkflowHint": "将 API 格式的工作流 .json 文件拖放到此处,或点击浏览", "importingWorkflow": "正在导入工作流...", "preparingExampleWorkflow": "正在准备工作流并下载所需模型...", "importFailed": "无法导入工作流。", @@ -1577,14 +1578,14 @@ "stop": "停止", "stopping": "正在停止...", "stopFailed": "无法停止构建。", - "measurementSettings": "3. 设置测量参数", + "measurementSettings": "运行次数", "warmupRuns": "预热运行次数", "warmupRunsHint": "预先执行的运行,用于加载模型并预热缓存。这些运行不计入结果。", "measuredRuns": "测量运行次数", "measuredRunsHint": "在预热运行之后计时的运行。其耗时将用于计算结果。", "logsPlaceholder": "构建日志将显示在此处。", "results": "结果", - "resultsPlaceholder": "性能测试结果将显示在此处。", + "resultsPlaceholder": "选择工作流并点击运行。结果会保留到下一次运行。", "workflowFileName": "工作流文件", "fastestRun": "最快运行", "slowestRun": "最慢运行", @@ -1593,7 +1594,6 @@ "measuredRunCount": "测量运行数", "failedRunCount": "失败运行数", "runProgress": "进度", - "runProgressCount": "已完成 {completed}/{total} 次运行", "runDurationChart": "运行时长汇总", "device": "计算设备", "vram": "显存", @@ -1614,7 +1614,17 @@ "launchFailed": "无法启动构建。", "submittingRuns": "正在提交 {warmupCount} 次预热运行和 {count} 次测量运行...", "completedRuns": "已完成 {count} 次测量运行({failed} 次失败)。最终响应已保存到 {path}", - "submitFailed": "无法提交基准工作流。" + "submitFailed": "无法提交基准工作流。", + "chooseWorkflowPlaceholder": "选择工作流", + "resultContextOn": "于", + "runNumber": "第 {current} / {total} 次运行", + "resultsEmptyTitle": "暂无结果", + "medianSummary": "中位运行 · {count} 次测量 · {failed} 次失败", + "legendMedian": "中位数", + "legendAverage": "平均值", + "legendRange": "最快到最慢", + "runPhaseWarmup": "预热运行", + "runPhaseMeasured": "第 {current} / {total} 次测量运行" }, "benchmarks": { "title": "性能比较", diff --git a/src/renderer/src/components/BrandedPageHeader.vue b/src/renderer/src/components/BrandedPageHeader.vue index 2a3fc7045..fa182cede 100644 --- a/src/renderer/src/components/BrandedPageHeader.vue +++ b/src/renderer/src/components/BrandedPageHeader.vue @@ -1,19 +1,28 @@ diff --git a/src/renderer/src/panel/PanelApp.test.ts b/src/renderer/src/panel/PanelApp.test.ts index 42ce7c79f..ecd69d36f 100644 --- a/src/renderer/src/panel/PanelApp.test.ts +++ b/src/renderer/src/panel/PanelApp.test.ts @@ -124,13 +124,14 @@ vi.mock('../views/MigrateConfirmTakeover.vue', () => ({ methods: { open: vi.fn() } } })) -import { mount, flushPromises, DOMWrapper } from '@vue/test-utils' +import { mount, flushPromises } from '@vue/test-utils' import { createPinia, setActivePinia } from 'pinia' import PanelApp from './PanelApp.vue' import { en } from '../lib/i18nMessages' import { __resetLauncherPrefsForTest } from '../composables/useLauncherPrefs' import { useOverlay } from '../composables/useOverlay' import { useDashboardScopeStore } from '../stores/dashboardScopeStore' +import { PERSONAL_WORKSPACE_ID } from '../../../shared/workspaces' import { TELEMETRY_ACTION_EVENT_NAME, type TelemetryActionEventDetail } from '../lib/telemetry' interface InstallationLike { @@ -486,6 +487,51 @@ function dataTransferWith(file: File): DataTransfer { return dataTransfer } +async function openWorkflowMenu(wrapper: ReturnType) { + const trigger = wrapper.get('.performance-test__workflow-trigger') + ;(trigger.element as HTMLButtonElement).focus() + await trigger.trigger('keydown', { key: 'ArrowDown' }) + await flushPromises() +} + +async function waitForBuildMenuFocusReturn() { + await vi.waitFor(() => + expect(document.activeElement).toBe( + document.querySelector('.performance-test__instance-select button') + ) + ) +} + +function workflowMenuItem(selector: string): HTMLElement | null { + return document.body.querySelector(`[role="menu"] ${selector}`) +} + +async function chooseWorkflowItem(wrapper: ReturnType, selector: string) { + await openWorkflowMenu(wrapper) + const item = workflowMenuItem(selector) + expect(item).not.toBeNull() + item!.click() + await flushPromises() + await settleWorkflowMenu(wrapper) +} + +async function settleWorkflowMenu(wrapper: ReturnType) { + const trigger = wrapper.get('.performance-test__workflow-trigger').element + await vi.waitFor(() => + expect( + document.activeElement === trigger || document.querySelector('[role="dialog"]') !== null + ).toBe(true) + ) +} + +async function closeWorkflowMenu(wrapper: ReturnType) { + document.activeElement?.dispatchEvent( + new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }) + ) + await flushPromises() + await settleWorkflowMenu(wrapper) +} + function mountPanel() { return mount(PanelApp, { attachTo: document.body, @@ -637,9 +683,12 @@ describe('PanelApp', () => { mockState.panelSwitchCallbacks.forEach((callback) => callback({ panel: 'performance-test' })) await flushPromises() - expect( - wrapper.get('.performance-test__workspace-select .workspace-selector__name').text() - ).toBe('Workspace Two') + expect(useDashboardScopeStore().selectedWorkspaceId).toBe('workspace-2') + await wrapper + .get('.performance-test__instance-select button') + .trigger('keydown', { key: 'ArrowDown' }) + await flushPromises() + expect(document.querySelectorAll('.ui-select-option')).toHaveLength(1) }) it('shows only installed Personal instances on Performance Test while signed out', async () => { @@ -671,10 +720,6 @@ describe('PanelApp', () => { await flushPromises() expect(wrapper.find('.performance-test__content').exists()).toBe(true) - expect( - wrapper.get('.performance-test__workspace-select .workspace-selector__name').text() - ).toBe('Personal') - await wrapper .get('.performance-test__instance-select button') .trigger('keydown', { key: 'ArrowDown' }) @@ -759,22 +804,14 @@ describe('PanelApp', () => { expect(wrapper.find('[data-testid="performance-test"]').exists()).toBe(true) expect(wrapper.get('.branded-page-header h1').text()).toBe('Performance Tests') expect(wrapper.find('[data-testid="app-sidebar"]').exists()).toBe(true) - expect(wrapper.findAll('.performance-test__selection-row')).toHaveLength(2) - expect( - wrapper.findAll('.performance-test__selection-label').map((label) => label.text()) - ).toEqual(['Workspace', 'Build']) - expect(wrapper.findAll('.performance-test__selection-control button')).toHaveLength(2) - expect(wrapper.find('.performance-test__workspace-select .ui-select-trigger').exists()).toBe( - false - ) - expect( - wrapper.get('.performance-test__workspace-select .workspace-selector__name').text() - ).toBe('Workspace One') - expect(wrapper.find('.performance-test__columns').exists()).toBe(true) - expect(wrapper.findAll('.performance-test__column')).toHaveLength(3) - expect( - wrapper.findAll('.performance-test__column h2').map((heading) => heading.text()) - ).toEqual(['1. Select a build', '2. Choose a workflow', '3. Set measurement settings']) + expect(wrapper.find('.performance-test__workspace-select').exists()).toBe(false) + expect(wrapper.find('.performance-test__setup').exists()).toBe(true) + expect(wrapper.findAll('.performance-test__step')).toHaveLength(3) + expect(wrapper.findAll('.performance-test__step h2').map((heading) => heading.text())).toEqual([ + 'Build', + 'Workflow', + 'Runs' + ]) const settings = wrapper.findAll('.performance-test__setting') expect(settings).toHaveLength(2) expect(settings.map((setting) => setting.find('label').text())).toEqual([ @@ -819,40 +856,34 @@ describe('PanelApp', () => { expect(measuredRunsInput.element).toHaveProperty('value', '5') const logsToggle = wrapper.get('.performance-test__logs-section button') expect(logsToggle.text()).toBe('Logs') - expect(logsToggle.attributes('aria-expanded')).toBe('true') - const resultsToggle = wrapper.get('.performance-test__results-section button') - expect(resultsToggle.text()).toBe('Results') - expect(resultsToggle.attributes('aria-expanded')).toBe('true') + expect(logsToggle.attributes('aria-expanded')).toBe('false') + expect(wrapper.get('.performance-test__logs-summary').text()).toBe( + 'Build logs will appear here.' + ) + expect(wrapper.get('.performance-test__results-section h2').text()).toBe('Results') expect( wrapper.findAll('.performance-test__content > section').map((section) => section.classes()[0]) ).toEqual(['performance-test__results-section', 'performance-test__logs-section']) - expect(wrapper.get('.performance-test__results').text()).toContain( - 'Performance test results will appear here.' - ) - await resultsToggle.trigger('click') - expect(resultsToggle.attributes('aria-expanded')).toBe('false') - expect(wrapper.get('.performance-test__results').attributes('style')).toContain('display: none') - await resultsToggle.trigger('click') - expect( - wrapper.get('.performance-test__column:nth-child(3) .performance-test__run').exists() - ).toBe(true) - expect(wrapper.find('.performance-test__drop-zone').text()).toBe( - 'Drop a workflow .json file in API format here, or click to browse' + expect(wrapper.find('.performance-test__system-section').exists()).toBe(false) + expect(wrapper.get('.performance-test__results').text()).toContain('No results yet') + expect(wrapper.get('.performance-test__setup .performance-test__run').exists()).toBe(true) + expect(wrapper.get('.performance-test__workflow-trigger').text()).toBe( + 'WorkflowChoose a workflow' ) expect(wrapper.find('.performance-test__run').text()).toBe('Run') + expect(wrapper.get('.performance-test__logs').attributes('style')).toContain('display: none') + await logsToggle.trigger('click') + expect(logsToggle.attributes('aria-expanded')).toBe('true') expect(wrapper.find('.performance-test__logs').text()).toBe('Build logs will appear here.') expect(wrapper.get('.performance-test__logs').classes()).toContain('scroll-visible') await logsToggle.trigger('click') - expect(logsToggle.attributes('aria-expanded')).toBe('false') - expect(wrapper.get('.performance-test__logs').attributes('style')).toContain('display: none') - await logsToggle.trigger('click') const instanceSelect = wrapper.get('.performance-test__instance-select button') expect(instanceSelect.attributes()).toMatchObject({ - role: 'combobox', + 'aria-haspopup': 'menu', 'aria-label': 'Select a build', 'aria-expanded': 'false' }) - expect(instanceSelect.text()).toBe('Select a build') + expect(instanceSelect.text()).toBe('BuildSelect a build') await instanceSelect.trigger('keydown', { key: 'ArrowDown' }) await flushPromises() expect( @@ -866,15 +897,14 @@ describe('PanelApp', () => { ) ).toEqual(['Standalone · 0.3.50', 'Standalone', 'Standalone']) expect(wrapper.text()).not.toContain('Other Workspace Install') - expect(wrapper.find('.branded-page-header__description').text()).toBe( - 'Run performance tests against your ComfyUI builds.' - ) + expect(wrapper.find('.branded-page-header__description').exists()).toBe(false) expect(wrapper.find('[data-testid="chooser-view"]').exists()).toBe(false) ;(document.querySelectorAll('.ui-select-option')[0] as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() - expect(instanceSelect.text()).toBe('Workspace Install') + await waitForBuildMenuFocusReturn() + expect(instanceSelect.text()).toBe('BuildWorkspace Install') const api = ( window as unknown as { @@ -894,15 +924,15 @@ describe('PanelApp', () => { } } ).api - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await flushPromises() expect(api.importPerformanceTestWorkflow).toHaveBeenCalledWith(undefined) expect(wrapper.get('.performance-test__workflow-file').text()).toContain('cat-workflow.json') - expect(wrapper.get('.performance-test__workflow-file').text()).toContain( + expect(wrapper.get('.performance-test__workflow-trigger').attributes('title')).toBe( 'C:\\ComfyUI\\performance-tests\\20260907225500\\cat-workflow.json' ) - expect(wrapper.get('.performance-test__drop-zone').text()).not.toContain( - 'Drop a workflow .json file in API format here, or click to browse' + expect(wrapper.get('.performance-test__workflow-trigger').text()).not.toContain( + 'Choose a workflow' ) api.importPerformanceTestWorkflow.mockResolvedValueOnce({ @@ -916,7 +946,7 @@ describe('PanelApp', () => { await flushPromises() expect(api.getPathForFile).toHaveBeenCalledWith(droppedFile) expect(api.importPerformanceTestWorkflow).toHaveBeenLastCalledWith('C:\\incoming\\dropped.json') - expect(wrapper.get('.performance-test__workflow-file').text()).toContain( + expect(wrapper.get('.performance-test__workflow-trigger').attributes('title')).toBe( 'C:\\ComfyUI\\performance-tests\\20260907225600\\cat-workflow.json' ) @@ -1005,7 +1035,9 @@ describe('PanelApp', () => { telemetryEvents.some((event) => event.actionName === 'comfy.desktop.performance_test.stopped') ).toBe(false) const results = wrapper.get('.performance-test__results').text() - expect(results).toContain('Workflow filecat-workflow.json') + expect(wrapper.get('.performance-test__run-label').text()).toBe( + 'cat-workflow.json on Workspace Install' + ) expect(results).toContain('Fastest run') expect(results).toContain('1.250 s') expect(results).toContain('Slowest run') @@ -1014,55 +1046,37 @@ describe('PanelApp', () => { expect(results).not.toContain('prompt-7') expect(results).toContain('Average run') expect(results).toContain('2.000 s') - expect(results).toContain('Median run') expect(results).toContain('1.875 s') - expect(results).toContain('Measured runs') - expect(results).toContain('5') - expect(results).toContain('Failed runs') - expect(results).toContain('0') + expect(results).toContain('Median run · 5 measured · 0 failed') expect(wrapper.get('.performance-test__summary').findAll(':scope > *')).toHaveLength(2) expect( wrapper .get('.performance-test__timing-list') .findAll('dt') .map((label) => label.text()) - ).toEqual([ - 'Measured runs', - 'Failed runs', - 'Fastest run', - 'Average run', - 'Slowest run', - 'Median run' - ]) + ).toEqual(['Fastest run', 'Average run', 'Slowest run']) expect(wrapper.get('.performance-test__aggregate-chart').attributes('aria-label')).toBe( 'Run duration aggregates' ) - expect(wrapper.findAll('.performance-test__aggregate-bar')).toHaveLength(4) - expect(wrapper.findAll('.performance-test__results h3')).toHaveLength(1) - expect(results).toContain('System information') - expect(results).toContain('NVIDIA GeForce RTX 4090') - expect(results).not.toContain('Top-level fallback should not be displayed') - expect(wrapper.find('.performance-test__result-list--compact').exists()).toBe(true) - expect(wrapper.findAll('.performance-test__system-group h4')).toHaveLength(0) - const systemGroups = wrapper.findAll('.performance-test__system-group') - expect(systemGroups[0]!.text()).toContain('NVIDIA GeForce RTX 4090') - expect(systemGroups[0]!.text()).toContain('VRAM24.0 GB') - expect(systemGroups[0]!.text()).toContain('RAM63.9 GB') - expect(systemGroups[0]!.text()).toContain('PyTorch version2.10.0+cu130') - expect(systemGroups[0]!.text()).toContain('xFormers version0.0.31') - expect(systemGroups[1]!.text()).toContain('CPUAMD Ryzen 9 7950X') - expect(systemGroups[1]!.text()).toContain('CPU cores32') - expect(systemGroups[1]!.text()).toContain('Architecturex64') - expect(systemGroups[1]!.text()).toContain('Operating systemMicrosoft Windows 11 Pro 10.0.26200') - expect(results).not.toContain('GPU driver') - expect(results).not.toContain('Device index') - expect(results).not.toContain('Backend') - expect(results).not.toContain('24576 MB') - expect(results).not.toContain('65461 MB') + const systemSection = wrapper.get('.performance-test__system-section') + expect(systemSection.get('h3').text()).toBe('System information') + const system = systemSection.get('.performance-test__system').text() + expect(system).toContain('NVIDIA GeForce RTX 4090') + expect(system).not.toContain('Top-level fallback should not be displayed') + expect(system).toContain('VRAM24.0 GB') + expect(system).toContain('RAM63.9 GB') + expect(system).toContain('PyTorch version2.10.0+cu130') + expect(system).toContain('xFormers version0.0.31') + expect(system).toContain('CPUAMD Ryzen 9 7950X') + expect(system).toContain('CPU cores32') + expect(system).toContain('Architecturex64') + expect(system).toContain('Operating systemMicrosoft Windows 11 Pro 10.0.26200') + for (const hidden of ['GPU driver', 'Device index', 'Backend', '24576 MB', '65461 MB']) { + expect(results).not.toContain(hidden) + expect(system).not.toContain(hidden) + } expect( - wrapper - .get('.performance-test__results') - .element.lastElementChild?.classList.contains('performance-test__results-actions') + wrapper.get('.performance-test__results-head .performance-test__results-actions').exists() ).toBe(true) const openResultsFolder = wrapper.get('.performance-test__open-results') expect(openResultsFolder.text()).toBe('Open folder') @@ -1119,7 +1133,7 @@ describe('PanelApp', () => { }) await flushPromises() expect(wrapper.get('.performance-test__logs').text()).toContain('ComfyUI is ready') - expect(wrapper.get('.performance-test__stop').attributes('disabled')).toBe('') + expect(wrapper.find('.performance-test__stop').exists()).toBe(false) expect(api.stopComfyUI).toHaveBeenCalledWith('performance-test:workspace-install') expect(api.cancelOperation).toHaveBeenCalledWith('performance-test:workspace-install') @@ -1131,7 +1145,7 @@ describe('PanelApp', () => { }) ) const runActionCalls = api.runAction.mock.calls.length - await wrapper.get('.performance-test__delete-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__delete-workflow') expect(wrapper.get('.performance-test__run').attributes('disabled')).toBe('') await wrapper.get('.performance-test__run').trigger('click') expect(api.runAction).toHaveBeenCalledTimes(runActionCalls) @@ -1145,21 +1159,15 @@ describe('PanelApp', () => { 'C:\\ComfyUI\\performance-tests\\20260907225600\\cat-workflow.json' ) expect(wrapper.find('.performance-test__workflow-file').exists()).toBe(false) - expect(wrapper.get('.performance-test__drop-zone').text()).toContain( - 'Drop a workflow .json file in API format here, or click to browse' - ) + expect(wrapper.get('.performance-test__workflow-trigger').text()).toContain('Choose a workflow') expect(wrapper.get('.performance-test__workflow-error').text()).toBe( 'This workflow belongs to a completed test and was kept with its results.' ) - await wrapper.get('.performance-test__workspace-select button').trigger('click') - await flushPromises() - await new DOMWrapper(document.body) - .get('[data-testid="devplatform-workspace-personal"]') - .trigger('click') + useDashboardScopeStore().selectWorkspace(PERSONAL_WORKSPACE_ID) await flushPromises() - expect(instanceSelect.text()).toBe('Select a build') + expect(instanceSelect.text()).toBe('BuildSelect a build') await instanceSelect.trigger('keydown', { key: 'ArrowDown' }) await flushPromises() expect( @@ -1171,6 +1179,7 @@ describe('PanelApp', () => { new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() + await waitForBuildMenuFocusReturn() }) it('opens the new-install takeover above the chooser body when show-new-install fires', async () => { @@ -1496,11 +1505,12 @@ describe('PanelApp', () => { new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() + await waitForBuildMenuFocusReturn() return { wrapper, api } } async function chooseExampleWorkflow(wrapper: ReturnType): Promise { - await wrapper.get('.performance-test__example-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__example-workflow') await flushPromises() ;( document.querySelector('[data-testid="performance-test-use-example"]') as HTMLButtonElement @@ -1555,7 +1565,7 @@ describe('PanelApp', () => { it('prepares an example workflow and blocks the run until its models are downloaded', async () => { const { wrapper, api } = await mountWithInstance() - await wrapper.get('.performance-test__example-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__example-workflow') await flushPromises() expect(api.getPerformanceTestExampleWorkflows).toHaveBeenCalledWith('workspace-install') expect(document.querySelector('[role="dialog"]')?.textContent).toContain('Z-Image Int8') @@ -1571,25 +1581,29 @@ describe('PanelApp', () => { 'workspace-install', 'image_z_image_int8' ) - const workflow = wrapper.get('.performance-test__workflow-file') - expect(workflow.text()).toContain('Z-Image Int8: Text to Image') - expect(workflow.text()).toContain(downloading.message) - expect(workflow.get('[role="progressbar"]').attributes('aria-valuenow')).toBe('40') - expect(wrapper.get('.performance-test__delete-workflow').attributes('aria-label')).toBe( + expect(wrapper.get('.performance-test__workflow-file').text()).toContain( + 'Z-Image Int8: Text to Image' + ) + const status = wrapper.get('.performance-test__status') + expect(status.text()).toContain(downloading.message) + expect(status.get('[role="progressbar"]').attributes('aria-valuenow')).toBe('40') + await openWorkflowMenu(wrapper) + expect(workflowMenuItem('.performance-test__delete-workflow')?.textContent).toContain( 'Cancel download' ) + await closeWorkflowMenu(wrapper) expect(wrapper.get('.performance-test__run').attributes('disabled')).toBeDefined() await emitExampleDownload({ ...downloading, percent: 80 }) expect( - wrapper - .get('.performance-test__workflow-file [role="progressbar"]') - .attributes('aria-valuenow') + wrapper.get('.performance-test__status [role="progressbar"]').attributes('aria-valuenow') ).toBe('80') await emitExampleDownload({ status: 'done', percent: 100, message: 'Template models ready' }) expect(wrapper.get('.performance-test__run').attributes('disabled')).toBeUndefined() - expect(wrapper.get('.performance-test__workflow-file').text()).toContain(EXAMPLE_PATH) + expect(wrapper.get('.performance-test__workflow-trigger').attributes('title')).toBe( + EXAMPLE_PATH + ) expect(wrapper.find('[role="progressbar"]').exists()).toBe(false) }) @@ -1620,7 +1634,7 @@ describe('PanelApp', () => { download: { status: 'done', percent: 100, message: 'Template models ready' } }) await chooseExampleWorkflow(wrapper) - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await flushPromises() expect(wrapper.get('.performance-test__workflow-file').text()).toContain('cat-workflow.json') const telemetryEvents = captureTelemetry() @@ -1643,7 +1657,7 @@ describe('PanelApp', () => { 'C:\\ComfyUI\\performance-tests\\20260907220000\\image_z_image_int8.json' ) - expect(wrapper.get('.performance-test__workflow-file').text()).toContain(downloading.message) + expect(wrapper.get('.performance-test__status').text()).toContain(downloading.message) expect(wrapper.get('.performance-test__run').attributes('disabled')).toBeDefined() }) @@ -1707,7 +1721,7 @@ describe('PanelApp', () => { } ]) const importedPath = 'C:\\ComfyUI\\performance-tests\\20260907225500\\cat-workflow.json' - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await flushPromises() let resolvePrepare!: (result: unknown) => void api.preparePerformanceTestExampleWorkflow.mockImplementationOnce( @@ -1725,13 +1739,16 @@ describe('PanelApp', () => { .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() + await waitForBuildMenuFocusReturn() resolvePrepare({ ok: true, filePath: EXAMPLE_PATH, download: downloading }) await flushPromises() expect(api.deletePerformanceTestWorkflow).toHaveBeenCalledWith(EXAMPLE_PATH) expect(api.deletePerformanceTestWorkflow).not.toHaveBeenCalledWith(importedPath) - expect(wrapper.get('.performance-test__workflow-file').text()).toContain(importedPath) + expect(wrapper.get('.performance-test__workflow-trigger').attributes('title')).toBe( + importedPath + ) }) it('removes an example prepared for another instance once a launching test releases it', async () => { @@ -1770,6 +1787,7 @@ describe('PanelApp', () => { .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() + await waitForBuildMenuFocusReturn() expect(api.deletePerformanceTestWorkflow).not.toHaveBeenCalled() resolveLaunch({ ok: false, message: 'Launch failed' }) @@ -1808,6 +1826,7 @@ describe('PanelApp', () => { .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() + await waitForBuildMenuFocusReturn() expect(api.deletePerformanceTestWorkflow).toHaveBeenCalledWith(EXAMPLE_PATH) expect(wrapper.get('.performance-test__workflow-file').exists()).toBe(true) @@ -1816,7 +1835,7 @@ describe('PanelApp', () => { it('explains that example workflows need an installed instance', async () => { const { wrapper, api } = await mountWithInstance('installing') - await wrapper.get('.performance-test__example-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__example-workflow') await flushPromises() expect(api.getPerformanceTestExampleWorkflows).not.toHaveBeenCalled() @@ -1845,7 +1864,7 @@ describe('PanelApp', () => { const { wrapper, api } = await mountWithInstance() await chooseExampleWorkflow(wrapper) - await wrapper.get('.performance-test__delete-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__delete-workflow') await flushPromises() expect(api.deletePerformanceTestWorkflow).toHaveBeenCalledWith(EXAMPLE_PATH) @@ -1885,7 +1904,7 @@ describe('PanelApp', () => { diskSpace: { free: 1_000_000_000, total: 1_000_000_000_000 } }) - await wrapper.get('.performance-test__example-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__example-workflow') await flushPromises() expect(document.querySelector('.performance-test__example-disk-error')).not.toBeNull() @@ -1901,7 +1920,7 @@ describe('PanelApp', () => { const onLine = vi.spyOn(navigator, 'onLine', 'get').mockReturnValue(false) try { - await wrapper.get('.performance-test__example-workflow').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__example-workflow') await flushPromises() expect(api.getPerformanceTestExampleWorkflows).not.toHaveBeenCalled() expect(wrapper.get('.performance-test__workflow-error').text()).toBe(offlineMessage) @@ -1970,7 +1989,7 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await wrapper .get('.performance-test__instance-select button') .trigger('keydown', { key: 'ArrowDown' }) @@ -1979,6 +1998,7 @@ describe('PanelApp', () => { new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() + await waitForBuildMenuFocusReturn() const runButton = wrapper.get('.performance-test__run') expect(runButton.attributes('disabled')).toBeUndefined() @@ -1989,7 +2009,7 @@ describe('PanelApp', () => { resolveImport = resolve }) ) - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') expect(runButton.attributes('disabled')).toBe('') await runButton.trigger('click') expect(api.runAction).not.toHaveBeenCalled() @@ -2004,15 +2024,15 @@ describe('PanelApp', () => { await flushPromises() const workflowImportCalls = api.importPerformanceTestWorkflow.mock.calls.length - expect(wrapper.get('.performance-test__drop-content').attributes('disabled')).toBe('') - await wrapper.get('.performance-test__drop-content').trigger('click') + expect(wrapper.get('.performance-test__workflow-trigger').attributes('disabled')).toBe('') + await openWorkflowMenu(wrapper) + expect(workflowMenuItem('.performance-test__drop-content')).toBeNull() await wrapper.get('.performance-test__drop-zone').trigger('drop', { dataTransfer: dataTransferWith( new File(['{}'], 'replacement.json', { type: 'application/json' }) ) }) expect(api.importPerformanceTestWorkflow).toHaveBeenCalledTimes(workflowImportCalls) - expect(wrapper.find('.performance-test__delete-workflow').exists()).toBe(false) expect(api.deletePerformanceTestWorkflow).not.toHaveBeenCalled() expect(api.stopComfyUI).not.toHaveBeenCalledWith('workspace-install') expect(api.runAction).toHaveBeenCalledWith('workspace-install', 'launch', { @@ -2024,8 +2044,7 @@ describe('PanelApp', () => { resolveLaunch({ ok: true }) await flushPromises() expect(api.runPerformanceTestWorkflow).toHaveBeenCalled() - expect(wrapper.get('.performance-test__drop-content').attributes('disabled')).toBe('') - expect(wrapper.find('.performance-test__delete-workflow').exists()).toBe(false) + expect(wrapper.get('.performance-test__workflow-trigger').attributes('disabled')).toBe('') resolveSubmission({ ok: true, @@ -2037,7 +2056,9 @@ describe('PanelApp', () => { resultPath: 'C:\\ComfyUI\\performance-tests\\20260907225600\\jobs.json' }) await flushPromises() - expect(wrapper.find('.performance-test__delete-workflow').exists()).toBe(true) + await openWorkflowMenu(wrapper) + expect(workflowMenuItem('.performance-test__delete-workflow')).not.toBeNull() + await closeWorkflowMenu(wrapper) }) it('restarts an already-running performance test session before running', async () => { @@ -2076,7 +2097,7 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await wrapper .get('.performance-test__instance-select button') .trigger('keydown', { key: 'ArrowDown' }) @@ -2085,6 +2106,7 @@ describe('PanelApp', () => { new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() + await waitForBuildMenuFocusReturn() const runButton = wrapper.get('.performance-test__run') expect(runButton.attributes('disabled')).toBeUndefined() @@ -2139,7 +2161,7 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await wrapper.get('.performance-test__drop-content').trigger('click') + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') await wrapper .get('.performance-test__instance-select button') .trigger('keydown', { key: 'ArrowDown' }) @@ -2148,10 +2170,12 @@ describe('PanelApp', () => { new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() + await waitForBuildMenuFocusReturn() const telemetryEvents = captureTelemetry() await wrapper.get('.performance-test__run').trigger('click') await flushPromises() - expect(wrapper.get('.performance-test__run').text()).toBe('Running...') + expect(wrapper.find('.performance-test__run').exists()).toBe(false) + expect(wrapper.get('.performance-test__setup .performance-test__stop').text()).toBe('Stop') mockState.performanceTestProgressCallbacks.forEach((callback) => callback({ sessionId: 'different-session', completedRuns: 5, totalRuns: 6 }) @@ -2164,12 +2188,12 @@ describe('PanelApp', () => { }) ) await flushPromises() - expect(wrapper.get('.performance-test__progress').text()).toContain('Progress') - expect(wrapper.get('.performance-test__progress').text()).toContain('2 of 6 runs completed') - const progressBar = wrapper.get('[role="progressbar"]') + expect(wrapper.get('.performance-test__progress').text()).toContain('Run 3 of 6') + expect(wrapper.get('.performance-test__progress').text()).toContain('measured run 2 of 5') + const progressBar = wrapper.get('.performance-test__progress-track') expect(progressBar.attributes('aria-valuenow')).toBe('2') expect(progressBar.attributes('aria-valuemax')).toBe('6') - expect(progressBar.get('i').attributes('style')).toContain('width: 33%') + expect(progressBar.findAll('i')).toHaveLength(6) const exitedCallback = api.onComfyExited.mock.calls[0]![0] as (data: { installationId: string @@ -2198,6 +2222,7 @@ describe('PanelApp', () => { await flushPromises() expect(api.stopComfyUI).toHaveBeenCalledWith('performance-test:workspace-install') expect(stopButton.attributes('disabled')).toBe('') + expect(stopButton.text()).toBe('Stopping...') expect( telemetryEvents.filter( (event) => event.actionName === 'comfy.desktop.performance_test.stopped' @@ -2225,13 +2250,18 @@ describe('PanelApp', () => { resultPath: 'C:\\ComfyUI\\performance-tests\\late-result\\jobs.json' }) await flushPromises() - expect(wrapper.get('.performance-test__drop-content').attributes('disabled')).toBe('') - expect(wrapper.find('.performance-test__delete-workflow').exists()).toBe(false) + expect(wrapper.get('.performance-test__workflow-trigger').attributes('disabled')).toBe('') resolveStop() await flushPromises() - expect(wrapper.get('.performance-test__drop-content').attributes('disabled')).toBeUndefined() - expect(wrapper.find('.performance-test__delete-workflow').exists()).toBe(true) + expect(wrapper.find('.performance-test__stop').exists()).toBe(false) + expect(wrapper.find('.performance-test__setup .performance-test__run').exists()).toBe(true) + expect( + wrapper.get('.performance-test__workflow-trigger').attributes('disabled') + ).toBeUndefined() + await openWorkflowMenu(wrapper) + expect(workflowMenuItem('.performance-test__delete-workflow')).not.toBeNull() + await closeWorkflowMenu(wrapper) expect( telemetryEvents.some( (event) => event.actionName === 'comfy.desktop.performance_test.completed' diff --git a/src/renderer/src/views/PerformanceTestView.vue b/src/renderer/src/views/PerformanceTestView.vue index 80114953b..a1ec0e71b 100644 --- a/src/renderer/src/views/PerformanceTestView.vue +++ b/src/renderer/src/views/PerformanceTestView.vue @@ -2,15 +2,30 @@ import Input from '@comfyorg/design-system/input/Input' import { computed, nextTick, onUnmounted, ref, toRef, useTemplateRef, watch } from 'vue' import { useI18n } from 'vue-i18n' -import { FolderOpen, ImageDown, Trash2 } from 'lucide-vue-next' +import { + Check, + ChevronDown, + CircleAlert, + FolderOpen, + ImageDown, + LayoutGrid, + Play, + Square, + Trash2, + Upload +} from 'lucide-vue-next' import Button from '@comfyorg/design-system/button/Button' +import Menu from '@comfyorg/design-system/menu/Menu' +import MenuItem from '@comfyorg/design-system/menu/MenuItem' +import MenuRadioItem from '@comfyorg/design-system/menu/MenuRadioItem' +import MenuSeparator from '@comfyorg/design-system/menu/MenuSeparator' +import { DropdownMenuRadioGroup } from 'reka-ui' import BrandBackground from '../components/BrandBackground.vue' import BrandedPageHeader from '../components/BrandedPageHeader.vue' import CollapsibleSectionToggle from '../components/CollapsibleSectionToggle.vue' import InfoTooltip from '../components/InfoTooltip.vue' import TemplatePickerStep from '../components/TemplatePickerStep.vue' import BaseModal from '../components/ui/BaseModal.vue' -import BaseSelect, { type BaseSelectOption } from '../components/ui/BaseSelect.vue' import { usePerformanceTestExampleWorkflow } from '../composables/usePerformanceTestExampleWorkflow' import { useWorkspaceInstallScope } from '../composables/useWorkspaceInstallScope' import { useAuthStore } from '../stores/authStore' @@ -28,12 +43,15 @@ import { } from '../lib/performanceTestResultsSvg' import { emitTelemetryAction } from '../lib/telemetry' import { performanceTestSessionKey } from '../../../shared/performanceTestSession' -import DevPlatformWorkspaceSelector from './devplatform/DevPlatformWorkspaceSelector.vue' -const resultListClass = - 'grid gap-x-6 m-0 [&>div]:min-w-0 [&_dt]:text-neutral-200 [&_dt]:[text-align:var(--perf-label-align,left)] [&_dd]:mt-[var(--perf-value-margin,4px)] [&_dd]:[overflow-wrap:anywhere] [&_dd]:[color:var(--perf-value-color,var(--text-primary))] [&_dd]:text-[length:var(--perf-value-size,24px)] [&_dd]:leading-[var(--perf-value-leading,1.25)] [&_dd]:[text-align:var(--perf-value-align,left)]' -const compactResultListClass = - 'grid-cols-1 gap-y-2 [--perf-value-margin:0px] [--perf-value-size:12px] [--perf-value-leading:1.3] [--perf-value-color:var(--text-muted)] [--perf-value-align:right] [--perf-label-align:left] [&>div]:flex [&>div]:items-baseline [&>div]:justify-between [&>div]:gap-2 [&>div]:pb-1 [&>div]:border-b [&>div]:border-solid [&>div]:border-[var(--chooser-surface-border)] [&_dt]:flex-none [&_dt]:text-[12px]' +const toggleClass = + 'self-center text-[11px] font-semibold tracking-[0.04em] text-subtle-foreground uppercase hover:text-foreground [&_.collapsible-section-toggle__chevron]:size-3.5' +const filterClass = 'gap-1.5 px-3 text-[13px]/5' +const numberInputClass = + 'w-9 flex-none [&_input]:h-6 [&_input]:w-full [&_input]:rounded-md [&_input]:border-0 [&_input]:bg-transparent [&_input]:p-0 [&_input]:text-center [&_input]:text-[13px] [&_input]:text-foreground [&_input]:tabular-nums [&_input]:shadow-none [&_input]:[appearance:textfield] [&_input]:focus-visible:ring-0 [&_input::-webkit-inner-spin-button]:appearance-none [&_input::-webkit-outer-spin-button]:appearance-none' +const runButtonClass = 'ml-auto min-w-20 gap-1.5 px-3 text-[13px]/5' +const actionClass = 'h-[30px] gap-1.5 rounded-lg px-2 text-[12.5px]/5 font-normal' +const summaryClass = 'ml-3 min-w-0 truncate text-[13px] font-normal tracking-normal normal-case' interface PerformanceTestRunTelemetry { readonly installationId: string @@ -61,7 +79,7 @@ const performanceTestInstallations = computed(() => (authStore.isSignedIn || installation.status === 'installed') ) ) -const instanceOptions = computed(() => +const instanceOptions = computed<{ value: string; label: string; description: string }[]>(() => performanceTestInstallations.value.map((installation) => ({ value: installation.id, label: installation.name, @@ -69,6 +87,9 @@ const instanceOptions = computed(() => })) ) const selectedInstallationId = ref(null) +const selectedInstance = computed(() => + instanceOptions.value.find((option) => option.value === selectedInstallationId.value) +) const workflowFilePath = ref(null) const workflowImportError = ref(null) const isWorkflowDragging = ref(false) @@ -109,8 +130,8 @@ const { }) const isExportingResults = ref(false) const exportResultsError = ref(null) -const logsExpanded = ref(true) -const resultsExpanded = ref(true) +const logsExpanded = ref(false) +const systemExpanded = ref(false) const warmupRuns = ref('1') const measuredRuns = ref('5') const logInstallationId = ref(null) @@ -141,35 +162,85 @@ const computeDeviceNames = computed(() => .flatMap((device) => (device.deviceName ? [device.deviceName] : [])) .join(', ') ) -const aggregateChart = computed(() => { +const numberLine = computed(() => { const statistics = performanceTestResult.value?.statistics - if (!statistics) return [] - - const aggregates = [ - { - label: t('performanceTest.fastestRun'), - value: statistics.fastest.durationSeconds - }, - { - label: t('performanceTest.slowestRun'), - value: statistics.slowest.durationSeconds - }, - { - label: t('performanceTest.averageRunDuration'), - value: statistics.averageDurationSeconds - }, - { - label: t('performanceTest.medianRunDuration'), - value: statistics.medianDurationSeconds - } + if (!statistics) return null + const fastest = statistics.fastest.durationSeconds + const slowest = statistics.slowest.durationSeconds + const span = slowest - fastest + const position = (value: number): number => (span > 0 ? ((value - fastest) / span) * 100 : 50) + const average = position(statistics.averageDurationSeconds) + return { + fastest: formatDuration(fastest), + slowest: formatDuration(slowest), + average: formatDuration(statistics.averageDurationSeconds), + median: formatDuration(statistics.medianDurationSeconds), + medianAt: `${position(statistics.medianDurationSeconds)}%`, + averageAt: `${average}%`, + averageLabelAt: `${Math.min(88, Math.max(12, average))}%` + } +}) +const systemSummary = computed(() => { + const hardware = performanceTestResult.value?.hardware + const systemInfo = performanceTestResult.value?.systemInfo + return [ + computeDeviceNames.value, + hardware?.vramMb != null ? `${formatMemory(hardware.vramMb)} ${t('performanceTest.vram')}` : '', + systemInfo ? formatOperatingSystem(systemInfo) : '', + hardware?.pytorchVersion ? `PyTorch ${hardware.pytorchVersion}` : '' ] - const maximum = Math.max(...aggregates.map(({ value }) => value), 0) - - return aggregates.map((aggregate) => ({ - ...aggregate, - width: maximum > 0 ? `${(aggregate.value / maximum) * 100}%` : '0%' - })) + .filter(Boolean) + .join(' · ') +}) +const lastLogLine = computed( + () => + performanceTestLogs.value + .split('\n') + .map((line) => line.trim()) + .filter(Boolean) + .pop() ?? '' +) +interface PerformanceTestRunLabel { + readonly workflow: string + readonly build: string + readonly warmups: number +} +const runLabel = ref(null) +const runSettings = computed(() => [ + { + id: 'performance-test-warmup-runs', + label: t('performanceTest.warmupRuns'), + hint: t('performanceTest.warmupRunsHint'), + min: '0', + max: '5', + value: warmupRuns.value, + update: (value: string | number | undefined) => (warmupRuns.value = String(value ?? '')), + commit: correctWarmupRuns + }, + { + id: 'performance-test-measured-runs', + label: t('performanceTest.measuredRuns'), + hint: t('performanceTest.measuredRunsHint'), + min: '1', + max: '100', + value: measuredRuns.value, + update: (value: string | number | undefined) => (measuredRuns.value = String(value ?? '')), + commit: correctMeasuredRuns + } +]) +const runPhase = computed(() => { + const warmups = runLabel.value?.warmups ?? 0 + const current = Math.min(completedProgressRuns.value + 1, totalProgressRuns.value) + return current <= warmups + ? t('performanceTest.runPhaseWarmup') + : t('performanceTest.runPhaseMeasured', { + current: current - warmups, + total: totalProgressRuns.value - warmups + }) }) +const hasWorkflow = computed(() => + Boolean(workflowFilePath.value || pendingExampleWorkflowLabel.value) +) const workflowLabel = computed( () => pendingExampleWorkflowLabel.value ?? @@ -343,6 +414,12 @@ async function runPerformanceTest(): Promise { }) isLaunching.value = true performanceTestResult.value = null + runLabel.value = { + workflow: workflowLabel.value, + build: selectedInstance.value?.label ?? '', + warmups + } + logsExpanded.value = true progressSessionId.value = sessionId completedProgressRuns.value = 0 totalProgressRuns.value = warmups + runs @@ -384,6 +461,7 @@ async function runPerformanceTest(): Promise { ) if (submission.ok) { performanceTestResult.value = submission + logsExpanded.value = false if (activeRunTelemetry === runTelemetry) { activeRunTelemetry = null const summary = submission.resultsSummary @@ -649,515 +727,560 @@ watch(performanceTestLogs, async () => { + - + + + + - -
-

{{ t('performanceTest.measurementSettings') }}

-
- - - - +
+

{{ t('performanceTest.measurementSettings') }}

+
- + + + + +
+ +
+
+ + +
+ + +
+ + +
+ +
+

{{ t('performanceTest.results') }}

+
+ + {{ runLabel.workflow }} + {{ t('performanceTest.resultContextOn') }} {{ runLabel.build }} +
- - - - -
- -
-
-
+ {{ exportResultsError }} +
-
- - -
- -
+
+
-
- {{ t('performanceTest.runProgress') }} - - {{ - t('performanceTest.runProgressCount', { - completed: completedProgressRuns, - total: totalProgressRuns - }) - }} - +
+ {{ + t('performanceTest.runNumber', { + current: Math.min(completedProgressRuns + 1, totalProgressRuns), + total: totalProgressRuns + }) + }} + {{ runPhase }}
- + + + +
- -

- {{ t('performanceTest.resultsPlaceholder') }} -

- - - -
- - {{ exportResultsError }} - - - +
+
+

+ {{ t('performanceTest.resultsEmptyTitle') }} +

+

+ {{ t('performanceTest.resultsPlaceholder') }} +

+
+
+

+ +

+ {{ + systemSummary + }} +
+
+
+
{{ t('performanceTest.device') }}
+
{{ computeDeviceNames }}
+
+
+
{{ t('performanceTest.vram') }}
+
{{ formatMemory(performanceTestResult.hardware.vramMb) }}
+
+
+
{{ t('performanceTest.ram') }}
+
{{ formatMemory(performanceTestResult.hardware.ramMb) }}
+
+
+
{{ t('performanceTest.pytorchVersion') }}
+
{{ performanceTestResult.hardware.pytorchVersion }}
+
+
+
{{ t('performanceTest.xformersVersion') }}
+
{{ performanceTestResult.hardware.xformersVersion }}
+
+ +
+
+
- +
+ + {{ lastLogLine || t('performanceTest.logsPlaceholder') }} +
- {{ performanceTestLogs || t('performanceTest.logsPlaceholder') }} + {{ performanceTestLogs.trimStart() || t('performanceTest.logsPlaceholder') }}
@@ -1168,13 +1291,17 @@ watch(performanceTestLogs, async () => { :open="isExamplePickerOpen" size="xl" :aria-label="t('performanceTest.exampleWorkflowPickerTitle')" - content-class="performance-test__example-modal [&_h2]:m-0 [&_h2+p]:mt-1.5 [&_h2+p]:mr-0 [&_h2+p]:mb-0 [&_h2+p]:ml-0 [&_h2+p]:text-[13px] [&_h2+p]:text-text-muted" + content-class="performance-test__example-modal" @close="isExamplePickerOpen = false" >

Date: Wed, 11 Nov 2026 19:11:00 +0100 Subject: [PATCH 2/8] style: page title matches the Builds title on main Co-Authored-By: Claude Opus 5.5 --- src/renderer/src/components/BrandedPageHeader.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/BrandedPageHeader.vue b/src/renderer/src/components/BrandedPageHeader.vue index fa182cede..a6627eded 100644 --- a/src/renderer/src/components/BrandedPageHeader.vue +++ b/src/renderer/src/components/BrandedPageHeader.vue @@ -10,7 +10,9 @@ defineProps<{ class="branded-page-header box-border flex w-full items-end justify-between gap-6 @max-[700px]:flex-col @max-[700px]:items-start @max-[700px]:gap-3" >

-

{{ title }}

+

+ {{ title }} +

Date: Wed, 11 Nov 2026 12:07:14 -0800 Subject: [PATCH 3/8] fix(perf-test): drag highlight, all-failed results, stopped-run card, status line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The drop-zone highlight now clears when a dragged file leaves the Workflow control. dragleave.self ignored leaves that started on the trigger button, which fills the zone, so the outline stayed on. - A test whose measured runs all failed has no statistics. The card now says "0 measured · 5 failed" instead of "Median run · ..." with no median. - A run that is stopped or fails before it has results drops its "x on build" header, so the card goes back to its plain empty state. - A workflow error no longer hides an example model download that is still running; both lines show. - Removed the unused BrandedPageHeader actions slot, the unused numberLine.averageLabelAt, four orphaned performanceTest strings, and the stale DevPlatformWorkspaceSelector test stub. Each new PanelApp test fails against the previous view and passes now. --- locales/en.json | 5 +- locales/zh.json | 5 +- .../src/components/BrandedPageHeader.vue | 6 -- src/renderer/src/panel/PanelApp.test.ts | 98 +++++++++++++++++++ .../src/views/PerformanceTestView.test.ts | 1 - .../src/views/PerformanceTestView.vue | 27 +++-- 6 files changed, 118 insertions(+), 24 deletions(-) diff --git a/locales/en.json b/locales/en.json index ed9fa2e26..3dffd87e3 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1547,9 +1547,7 @@ }, "performanceTest": { "title": "Performance Tests", - "description": "Run performance tests against your ComfyUI builds.", "selectInstance": "Build", - "instanceLabel": "Build", "selectInstancePlaceholder": "Select a build", "chooseWorkflow": "Workflow", "chooseExampleWorkflow": "Choose an example workflow", @@ -1586,7 +1584,6 @@ "logsPlaceholder": "Build logs will appear here.", "results": "Results", "resultsPlaceholder": "Choose a workflow and press Run. Results stay here until the next run.", - "workflowFileName": "Workflow file", "fastestRun": "Fastest run", "slowestRun": "Slowest run", "averageRunDuration": "Average run", @@ -1610,7 +1607,6 @@ "exportResultsImage": "Export results", "exportingImage": "Exporting image...", "exportImageFailed": "Could not export the results image.", - "running": "Running...", "launchFailed": "Failed to start the build.", "submittingRuns": "Submitting {warmupCount} warm-up runs and {count} measured runs...", "completedRuns": "Finished {count} measured runs ({failed} failed). Final response saved to {path}", @@ -1620,6 +1616,7 @@ "runNumber": "Run {current} of {total}", "resultsEmptyTitle": "No results yet", "medianSummary": "Median run · {count} measured · {failed} failed", + "runCounts": "{count} measured · {failed} failed", "legendMedian": "Median", "legendAverage": "Average", "legendRange": "fastest to slowest", diff --git a/locales/zh.json b/locales/zh.json index 0d44dcb5b..010cea065 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -1547,9 +1547,7 @@ }, "performanceTest": { "title": "性能测试", - "description": "针对您的 ComfyUI 构建运行性能测量。", "selectInstance": "构建", - "instanceLabel": "构建", "selectInstancePlaceholder": "选择构建", "chooseWorkflow": "工作流", "chooseExampleWorkflow": "选择示例工作流", @@ -1586,7 +1584,6 @@ "logsPlaceholder": "构建日志将显示在此处。", "results": "结果", "resultsPlaceholder": "选择工作流并点击运行。结果会保留到下一次运行。", - "workflowFileName": "工作流文件", "fastestRun": "最快运行", "slowestRun": "最慢运行", "averageRunDuration": "平均运行时长", @@ -1610,7 +1607,6 @@ "exportResultsImage": "导出结果", "exportingImage": "正在导出图像...", "exportImageFailed": "无法导出结果图像。", - "running": "正在运行...", "launchFailed": "无法启动构建。", "submittingRuns": "正在提交 {warmupCount} 次预热运行和 {count} 次测量运行...", "completedRuns": "已完成 {count} 次测量运行({failed} 次失败)。最终响应已保存到 {path}", @@ -1620,6 +1616,7 @@ "runNumber": "第 {current} / {total} 次运行", "resultsEmptyTitle": "暂无结果", "medianSummary": "中位运行 · {count} 次测量 · {failed} 次失败", + "runCounts": "{count} 次测量 · {failed} 次失败", "legendMedian": "中位数", "legendAverage": "平均值", "legendRange": "最快到最慢", diff --git a/src/renderer/src/components/BrandedPageHeader.vue b/src/renderer/src/components/BrandedPageHeader.vue index a6627eded..d3e3d6c27 100644 --- a/src/renderer/src/components/BrandedPageHeader.vue +++ b/src/renderer/src/components/BrandedPageHeader.vue @@ -20,11 +20,5 @@ defineProps<{ {{ description }}

-
- -
diff --git a/src/renderer/src/panel/PanelApp.test.ts b/src/renderer/src/panel/PanelApp.test.ts index ecd69d36f..f007c93b5 100644 --- a/src/renderer/src/panel/PanelApp.test.ts +++ b/src/renderer/src/panel/PanelApp.test.ts @@ -2269,6 +2269,104 @@ describe('PanelApp', () => { ).toBe(false) }) + it('reports a test whose measured runs all failed without showing a median', async () => { + const { wrapper } = await mountWithInstance() + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + const runApi = ( + window as unknown as { api: { runPerformanceTestWorkflow: ReturnType } } + ).api + const successfulRun = runApi.runPerformanceTestWorkflow.getMockImplementation()! + runApi.runPerformanceTestWorkflow.mockImplementationOnce(async (...args: unknown[]) => { + const result = (await successfulRun(...args)) as RunPerformanceTestWorkflowResult + return { + ...result, + failedRuns: 5, + statistics: null, + resultsSummary: { + ...result.resultsSummary!, + fastestJobDurationSeconds: null, + slowestJobDurationSeconds: null, + averageJobDurationSeconds: null, + medianJobDurationSeconds: null, + measuredJobCount: 0, + failedRunCount: 5 + } + } + }) + + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + + expect(wrapper.get('.performance-test__median-summary').text()).toBe('0 measured · 5 failed') + expect(wrapper.get('.performance-test__results').text()).not.toContain('Median run') + expect(wrapper.find('.performance-test__timing-list').exists()).toBe(false) + }) + + it('returns the results card to its empty state when a run is stopped before results', async () => { + const { wrapper } = await mountWithInstance() + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + const runApi = (window as unknown as { api: { runAction: ReturnType } }).api + let finishLaunch!: (result: { ok: boolean; cancelled: boolean }) => void + runApi.runAction.mockReturnValueOnce(new Promise((resolve) => (finishLaunch = resolve))) + + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + expect(wrapper.get('.performance-test__run-label').text()).toBe( + 'cat-workflow.json on Workspace Install' + ) + + await wrapper.get('.performance-test__stop').trigger('click') + finishLaunch({ ok: false, cancelled: true }) + await flushPromises() + + expect(wrapper.find('.performance-test__stop').exists()).toBe(false) + expect(wrapper.find('.performance-test__run-label').exists()).toBe(false) + expect(wrapper.get('.performance-test__results').text()).toContain('No results yet') + }) + + it('keeps the model download visible when importing another workflow fails', async () => { + const { wrapper, api } = await mountWithInstance() + await chooseExampleWorkflow(wrapper) + const importApi = ( + window as unknown as { api: { importPerformanceTestWorkflow: ReturnType } } + ).api + importApi.importPerformanceTestWorkflow.mockResolvedValueOnce({ + ok: false, + message: 'This file is not an API workflow.' + }) + + await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + + expect(api.preparePerformanceTestExampleWorkflow).toHaveBeenCalled() + expect(wrapper.get('.performance-test__workflow-error').text()).toBe( + 'This file is not an API workflow.' + ) + const download = wrapper.get('.performance-test__example-download-bar') + expect(download.attributes('aria-valuenow')).toBe('40') + expect(wrapper.text()).toContain(downloading.message) + }) + + it('clears the drop highlight once a dragged file leaves the workflow control', async () => { + window.history.replaceState({}, '', '/?panel=performance-test&firstUseCompleted=true') + const wrapper = mountPanel() + await flushPromises() + const zone = wrapper.get('.performance-test__drop-zone') + const trigger = wrapper.get('.performance-test__workflow-trigger').element + const drag = (type: string, relatedTarget?: EventTarget): Promise => { + trigger.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true, relatedTarget })) + return flushPromises() + } + + await drag('dragenter') + expect(zone.classes()).toContain('performance-test__drop-zone--dragging') + + await drag('dragleave', zone.element) + expect(zone.classes()).toContain('performance-test__drop-zone--dragging') + + await drag('dragleave', document.body) + expect(zone.classes()).not.toContain('performance-test__drop-zone--dragging') + }) + it('returns to the underlying body when a takeover emits close', async () => { window.history.replaceState({}, '', '/?panel=new-install&firstUseCompleted=true') const wrapper = mountPanel() diff --git a/src/renderer/src/views/PerformanceTestView.test.ts b/src/renderer/src/views/PerformanceTestView.test.ts index a2617f5e2..e0e41e36c 100644 --- a/src/renderer/src/views/PerformanceTestView.test.ts +++ b/src/renderer/src/views/PerformanceTestView.test.ts @@ -29,7 +29,6 @@ function mountView() { BrandBackground: { template: '
' }, BrandedPageHeader: true, DevPlatformAccountChip: true, - DevPlatformWorkspaceSelector: true, InfoTooltip: true, TemplatePickerStep: true, BaseModal: true diff --git a/src/renderer/src/views/PerformanceTestView.vue b/src/renderer/src/views/PerformanceTestView.vue index a1ec0e71b..f1b1b1801 100644 --- a/src/renderer/src/views/PerformanceTestView.vue +++ b/src/renderer/src/views/PerformanceTestView.vue @@ -176,8 +176,7 @@ const numberLine = computed(() => { average: formatDuration(statistics.averageDurationSeconds), median: formatDuration(statistics.medianDurationSeconds), medianAt: `${position(statistics.medianDurationSeconds)}%`, - averageAt: `${average}%`, - averageLabelAt: `${Math.min(88, Math.max(12, average))}%` + averageAt: `${average}%` } }) const systemSummary = computed(() => { @@ -368,6 +367,12 @@ async function deleteWorkflow(): Promise { } } +function leaveWorkflowDropZone(event: DragEvent): void { + const zone = event.currentTarget as HTMLElement + if (event.relatedTarget instanceof Node && zone.contains(event.relatedTarget)) return + isWorkflowDragging.value = false +} + async function dropWorkflow(event: DragEvent): Promise { isWorkflowDragging.value = false const file = event.dataTransfer?.files[0] @@ -543,6 +548,7 @@ async function runPerformanceTest(): Promise { } activeLaunchPromise = null if (activeRunTelemetry === runTelemetry) activeRunTelemetry = null + if (!performanceTestResult.value) runLabel.value = null progressSessionId.value = null isLaunching.value = false } @@ -810,7 +816,7 @@ watch(performanceTestLogs, async () => { :aria-busy="isWorkflowImporting || isWorkflowDeleting" @dragenter.prevent="isWorkflowDragging = !isWorkflowLocked" @dragover.prevent="isWorkflowDragging = !isWorkflowLocked" - @dragleave.self.prevent="isWorkflowDragging = false" + @dragleave.prevent="leaveWorkflowDropZone" @drop.prevent="dropWorkflow" >

{{ t('performanceTest.chooseWorkflow') }}

@@ -971,7 +977,7 @@ watch(performanceTestLogs, async () => { {{ workflowImportError }}

Date: Thu, 12 Nov 2026 09:48:08 -0800 Subject: [PATCH 8/8] refactor(perf-test): split the page into composables and components, fix run edge cases The Performance Tests view was one 1,300-line component. It is now a thin page over two composables and small components: - usePerformanceTestRun owns the launch, submit, stop and telemetry lifecycle with an explicit stage (starting, running, finishing, stopping). - usePerformanceTestWorkflow owns import, drop, delete and the example flow. - lib/performanceTestResults holds the pure helpers (run-count clamping, formatting, duration rows, system facts) that the page and the PNG export now share, so the two can no longer drift. - FilterButton is the shared "Label value v" trigger; the Build and Workflow menus, run-count fields, progress, summary, system facts, card and logs are components under views/performanceTest. Behaviour fixes: - A failed submission now stops the build and returns the page to Run, and the results card says why. Before, the build stayed up and only Stop showed. - While the build boots the card says "Starting the build..." instead of claiming run 1 is executing. - Results that arrive after the user pressed Stop are ignored. - Run needs the chosen build to still be in the list. - The page and the export read the saved results summary, and the export no longer needs a hardware snapshot. - The export sizes text by estimated width (CJK aware), shrinks a slow median so it stays clear of the chart, and fits the title. - "{workflow} on {build}" and the trigger names are single translated strings instead of concatenated fragments. - The drop highlight only shows for file drags; the example download can be cancelled from the status line. - Unused measuredRunCount, failedRunCount and resultContextOn strings removed. --- locales/en.json | 9 +- locales/zh.json | 9 +- .../src/components/ui/FilterButton.vue | 27 + .../src/composables/usePerformanceTestRun.ts | 300 ++++ .../composables/usePerformanceTestWorkflow.ts | 122 ++ .../src/lib/performanceTestResults.ts | 122 ++ .../src/lib/performanceTestResultsSvg.test.ts | 25 +- .../src/lib/performanceTestResultsSvg.ts | 53 +- src/renderer/src/panel/PanelApp.test.ts | 289 +++- .../src/views/PerformanceTestView.vue | 1316 +++-------------- .../PerformanceTestBuildMenu.vue | 71 + .../performanceTest/PerformanceTestCard.vue | 23 + .../performanceTest/PerformanceTestLogs.vue | 76 + .../PerformanceTestProgress.vue | 79 + .../PerformanceTestResultSummary.vue | 67 + .../PerformanceTestRunCountField.vue | 44 + .../PerformanceTestSystemFacts.vue | 32 + .../PerformanceTestWorkflowMenu.vue | 153 ++ .../src/views/performanceTest/labels.ts | 26 + 19 files changed, 1677 insertions(+), 1166 deletions(-) create mode 100644 src/renderer/src/components/ui/FilterButton.vue create mode 100644 src/renderer/src/composables/usePerformanceTestRun.ts create mode 100644 src/renderer/src/composables/usePerformanceTestWorkflow.ts create mode 100644 src/renderer/src/lib/performanceTestResults.ts create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestBuildMenu.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestCard.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestLogs.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestProgress.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestResultSummary.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestRunCountField.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestSystemFacts.vue create mode 100644 src/renderer/src/views/performanceTest/PerformanceTestWorkflowMenu.vue create mode 100644 src/renderer/src/views/performanceTest/labels.ts diff --git a/locales/en.json b/locales/en.json index f2ac2ab1e..570a0ac4b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1586,8 +1586,6 @@ "slowestRun": "Slowest run", "averageRunDuration": "Average run", "medianRunDuration": "Median run", - "measuredRunCount": "Measured runs", - "failedRunCount": "Failed runs", "runProgress": "Progress", "runDurationChart": "Run duration", "device": "Compute device", @@ -1610,7 +1608,12 @@ "completedRuns": "Finished {count} measured runs ({failed} failed). Final response saved to {path}", "submitFailed": "Failed to submit the performance test workflow.", "chooseWorkflowPlaceholder": "Choose a workflow", - "resultContextOn": "on", + "buildTriggerLabel": "Build: {build}", + "workflowTriggerLabel": "Workflow: {workflow}", + "resultContext": "{workflow} on {build}", + "startingBuild": "Starting the build...", + "runFailedTitle": "The test didn't finish", + "runFailedHint": "See the logs below for details.", "runNumber": "Run {current} of {total}", "resultsEmptyTitle": "No results yet", "medianSummary": "Median run · {count} measured · {failed} failed", diff --git a/locales/zh.json b/locales/zh.json index 836d6e9e7..9d244cded 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -1586,8 +1586,6 @@ "slowestRun": "最慢运行", "averageRunDuration": "平均运行时长", "medianRunDuration": "运行时长中位数", - "measuredRunCount": "测量运行数", - "failedRunCount": "失败运行数", "runProgress": "进度", "runDurationChart": "运行时长", "device": "计算设备", @@ -1610,7 +1608,12 @@ "completedRuns": "已完成 {count} 次测量运行({failed} 次失败)。最终响应已保存到 {path}", "submitFailed": "无法提交基准工作流。", "chooseWorkflowPlaceholder": "选择工作流", - "resultContextOn": "于", + "buildTriggerLabel": "构建:{build}", + "workflowTriggerLabel": "工作流:{workflow}", + "resultContext": "在 {build} 上运行 {workflow}", + "startingBuild": "正在启动构建...", + "runFailedTitle": "测试未完成", + "runFailedHint": "详情请查看下方日志。", "runNumber": "第 {current} / {total} 次运行", "resultsEmptyTitle": "暂无结果", "medianSummary": "中位运行 · {count} 次测量 · {failed} 次失败", diff --git a/src/renderer/src/components/ui/FilterButton.vue b/src/renderer/src/components/ui/FilterButton.vue new file mode 100644 index 000000000..873b908a7 --- /dev/null +++ b/src/renderer/src/components/ui/FilterButton.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/renderer/src/composables/usePerformanceTestRun.ts b/src/renderer/src/composables/usePerformanceTestRun.ts new file mode 100644 index 000000000..35a5fb82b --- /dev/null +++ b/src/renderer/src/composables/usePerformanceTestRun.ts @@ -0,0 +1,300 @@ +import { computed, onUnmounted, ref, shallowRef } from 'vue' +import { useSessionStore } from '../stores/sessionStore' +import { emitTelemetryAction } from '../lib/telemetry' +import type { ActionResult, RunPerformanceTestWorkflowResult } from '../types/ipc' +import { performanceTestSessionKey } from '../../../shared/performanceTestSession' + +export interface PerformanceTestRunRequest { + readonly installationId: string + readonly buildName: string + readonly workflowPath: string + readonly workflowName: string + readonly telemetryWorkflowName: string + readonly warmupRuns: number + readonly measuredRuns: number +} + +export type PerformanceTestStage = 'idle' | 'starting' | 'running' | 'finishing' | 'stopping' + +interface RunTelemetry { + readonly installationId: string + readonly workflowName: string + readonly warmupRuns: number + readonly measuredRuns: number + readonly startedAtMs: number +} + +type Translate = (key: string, values?: Record) => string + +function secondsToMilliseconds(seconds: number | null | undefined): number | null { + return seconds == null ? null : seconds * 1000 +} + +function errorMessage(error: unknown, fallback: string): string { + return (error as Error | undefined)?.message || fallback +} + +function emitCompleted( + telemetry: RunTelemetry, + submission: RunPerformanceTestWorkflowResult +): void { + const summary = submission.resultsSummary + const statistics = submission.statistics + const hardware = submission.hardware + emitTelemetryAction('comfy.desktop.performance_test.completed', { + installation_id: telemetry.installationId, + workflow_name: telemetry.workflowName, + warmup_runs: telemetry.warmupRuns, + measured_runs: telemetry.measuredRuns, + successful_runs: + summary?.measuredJobCount ?? + statistics?.measuredJobCount ?? + Math.max(0, submission.submitted - (submission.failedRuns ?? 0)), + failed_runs: summary?.failedRunCount ?? submission.failedRuns ?? 0, + duration_ms: performance.now() - telemetry.startedAtMs, + fastest_run_duration_ms: secondsToMilliseconds( + summary?.fastestJobDurationSeconds ?? statistics?.fastest.durationSeconds + ), + average_run_duration_ms: secondsToMilliseconds( + summary?.averageJobDurationSeconds ?? statistics?.averageDurationSeconds + ), + median_run_duration_ms: secondsToMilliseconds( + summary?.medianJobDurationSeconds ?? statistics?.medianDurationSeconds + ), + slowest_run_duration_ms: secondsToMilliseconds( + summary?.slowestJobDurationSeconds ?? statistics?.slowest.durationSeconds + ), + deviceType: hardware?.deviceType ?? null, + deviceIndex: hardware?.deviceIndex ?? null, + deviceName: hardware?.deviceName ?? null, + backend: hardware?.backend ?? null, + devicesDeviceType: hardware?.devices.map((device) => device.deviceType) ?? [], + devicesDeviceIndex: hardware?.devices.map((device) => device.deviceIndex) ?? [], + devicesDeviceName: hardware?.devices.map((device) => device.deviceName) ?? [], + devicesBackend: hardware?.devices.map((device) => device.backend) ?? [], + vramMb: hardware?.vramMb ?? null, + ramMb: hardware?.ramMb ?? null, + pytorchVersion: hardware?.pytorchVersion ?? null, + xformersVersion: hardware?.xformersVersion ?? null, + cudaDeviceSet: hardware?.cudaDeviceSet ?? null + }) +} + +export function usePerformanceTestRun(t: Translate) { + const sessionStore = useSessionStore() + const isActive = ref(false) + const phase = ref<'starting' | 'running' | 'finishing'>('starting') + const isStopping = ref(false) + const buildInstallationId = ref(null) + const request = shallowRef(null) + const result = shallowRef(null) + const failure = ref(null) + const logSessionId = ref(null) + const progressSessionId = ref(null) + const completedRuns = ref(0) + const totalRuns = ref(0) + let activeLaunch: Promise | null = null + let activeTelemetry: RunTelemetry | null = null + let runToken = 0 + + const stage = computed(() => { + if (isStopping.value) return 'stopping' + return isActive.value ? phase.value : 'idle' + }) + const isBusy = computed(() => stage.value !== 'idle') + const ownsBuild = computed(() => isBusy.value || buildInstallationId.value !== null) + const canStop = computed(() => Boolean(buildInstallationId.value && !isStopping.value)) + const logs = computed(() => + logSessionId.value ? (sessionStore.getSession(logSessionId.value)?.output ?? '') : '' + ) + + const unsubscribeProgress = window.api.onPerformanceTestProgress((progress) => { + if (progress.sessionId !== progressSessionId.value) return + completedRuns.value = progress.completedRuns + totalRuns.value = progress.totalRuns + }) + onUnmounted(unsubscribeProgress) + + function canStart(installationId: string): boolean { + return !isBusy.value && !sessionStore.isLaunching(performanceTestSessionKey(installationId)) + } + + async function submit( + run: PerformanceTestRunRequest, + sessionId: string, + token: number, + telemetry: RunTelemetry + ): Promise { + sessionStore.appendOutput( + sessionId, + `\n${t('performanceTest.submittingRuns', { + count: run.measuredRuns, + warmupCount: run.warmupRuns + })}\n` + ) + let submission: RunPerformanceTestWorkflowResult | null = null + let outcome: string + try { + submission = await window.api.runPerformanceTestWorkflow( + sessionId, + run.workflowPath, + run.measuredRuns, + run.warmupRuns + ) + outcome = submission.ok + ? t('performanceTest.completedRuns', { + count: submission.submitted, + failed: submission.failedRuns, + path: submission.resultPath + }) + : submission.message || t('performanceTest.submitFailed') + } catch (error) { + outcome = errorMessage(error, t('performanceTest.submitFailed')) + } + if (token === runToken) { + if (submission?.ok) { + result.value = submission + if (activeTelemetry === telemetry) { + activeTelemetry = null + emitCompleted(telemetry, submission) + } + } else { + failure.value = outcome + } + } + sessionStore.appendOutput(sessionId, `${outcome}\n`) + } + + async function saveLogs(sessionId: string, workflowPath: string): Promise { + const logs = sessionStore.getSession(sessionId)?.output + if (logs === undefined) return + try { + const saved = await window.api.savePerformanceTestLogs(workflowPath, logs) + if (!saved.ok) console.error('Failed to save performance test logs:', saved.message) + } catch (error) { + console.error('Failed to save performance test logs:', error) + } + } + + async function start(run: PerformanceTestRunRequest): Promise { + if (!canStart(run.installationId)) return + const sessionId = performanceTestSessionKey(run.installationId) + const token = ++runToken + const telemetry: RunTelemetry = { + installationId: run.installationId, + workflowName: run.telemetryWorkflowName, + warmupRuns: run.warmupRuns, + measuredRuns: run.measuredRuns, + startedAtMs: performance.now() + } + activeTelemetry = telemetry + emitTelemetryAction('comfy.desktop.performance_test.started', { + installation_id: run.installationId, + workflow_name: telemetry.workflowName, + warmup_runs: run.warmupRuns, + measured_runs: run.measuredRuns, + total_runs: run.warmupRuns + run.measuredRuns + }) + isActive.value = true + phase.value = 'starting' + request.value = run + result.value = null + failure.value = null + progressSessionId.value = sessionId + completedRuns.value = 0 + totalRuns.value = run.warmupRuns + run.measuredRuns + try { + if (sessionStore.isRunning(sessionId)) await window.api.stopComfyUI(sessionId) + logSessionId.value = sessionId + buildInstallationId.value = run.installationId + sessionStore.startSession(sessionId) + activeLaunch = window.api.runAction(run.installationId, 'launch', { + launchModeOverride: 'console', + autoPortOnConflict: true, + sessionIdOverride: sessionId + }) + const launched = await activeLaunch + activeLaunch = null + if (token !== runToken) return + if (!launched.ok) { + buildInstallationId.value = null + if (!launched.cancelled) { + failure.value = launched.message || t('performanceTest.launchFailed') + sessionStore.appendOutput(sessionId, failure.value) + } + return + } + phase.value = 'running' + await submit(run, sessionId, token, telemetry) + if (token !== runToken) return + phase.value = 'finishing' + await stop() + } catch (error) { + const message = errorMessage(error, t('performanceTest.launchFailed')) + sessionStore.appendOutput(sessionId, message) + if (token === runToken) failure.value = message + buildInstallationId.value = null + } finally { + await saveLogs(sessionId, run.workflowPath) + activeLaunch = null + if (activeTelemetry === telemetry) activeTelemetry = null + if (!result.value && !failure.value) request.value = null + progressSessionId.value = null + isActive.value = false + } + } + + async function stop(): Promise { + const installationId = buildInstallationId.value + if (!installationId || !canStop.value) return + const sessionId = performanceTestSessionKey(installationId) + runToken += 1 + isStopping.value = true + try { + await window.api.cancelOperation(sessionId) + if (activeLaunch) await activeLaunch.catch(() => undefined) + await window.api.stopComfyUI(sessionId) + if (buildInstallationId.value === installationId) buildInstallationId.value = null + } catch (error) { + sessionStore.appendOutput( + sessionId, + `\n${errorMessage(error, t('performanceTest.stopFailed'))}\n` + ) + } finally { + isStopping.value = false + } + } + + async function stopFromUser(): Promise { + const telemetry = activeTelemetry + if (telemetry) { + activeTelemetry = null + emitTelemetryAction('comfy.desktop.performance_test.stopped', { + installation_id: telemetry.installationId, + workflow_name: telemetry.workflowName, + warmup_runs: telemetry.warmupRuns, + measured_runs: telemetry.measuredRuns, + completed_runs: completedRuns.value, + total_runs: telemetry.warmupRuns + telemetry.measuredRuns, + duration_ms: performance.now() - telemetry.startedAtMs + }) + } + await stop() + } + + return { + stage, + isBusy, + ownsBuild, + canStop, + request, + result, + failure, + logs, + completedRuns, + totalRuns, + canStart, + start, + stopFromUser + } +} diff --git a/src/renderer/src/composables/usePerformanceTestWorkflow.ts b/src/renderer/src/composables/usePerformanceTestWorkflow.ts new file mode 100644 index 000000000..e26a9763d --- /dev/null +++ b/src/renderer/src/composables/usePerformanceTestWorkflow.ts @@ -0,0 +1,122 @@ +import { computed, ref, type Ref, type ShallowRef } from 'vue' +import type TemplatePickerStep from '../components/TemplatePickerStep.vue' +import { fileName } from '../lib/performanceTestResults' +import { usePerformanceTestExampleWorkflow } from './usePerformanceTestExampleWorkflow' + +export type PerformanceTestWorkflowSource = 'example' | 'api' + +interface PerformanceTestWorkflowContext { + picker: Readonly | null>> + selectedInstallationId: Ref + isSelectedInstallationInstalled: Readonly> + isLocked: Readonly> + t: (key: string) => string +} + +export function usePerformanceTestWorkflow(context: PerformanceTestWorkflowContext) { + const { isLocked, t } = context + const filePath = ref(null) + const error = ref(null) + const isImporting = ref(false) + const isDeleting = ref(false) + + const example = usePerformanceTestExampleWorkflow({ + picker: context.picker, + selectedInstallationId: context.selectedInstallationId, + isSelectedInstallationInstalled: context.isSelectedInstallationInstalled, + workflowFilePath: filePath, + workflowError: error, + isWorkflowImporting: isImporting, + isWorkflowLocked: isLocked, + deleteWorkflow: remove, + t + }) + + const source = computed(() => { + if (example.pendingLabel.value) return 'example' + if (!filePath.value) return null + return example.displayName.value === null ? 'api' : 'example' + }) + const label = computed( + () => + example.pendingLabel.value ?? + example.displayName.value ?? + (filePath.value ? fileName(filePath.value) : '') + ) + const telemetryName = computed(() => + example.displayName.value === null || !filePath.value ? 'custom' : fileName(filePath.value) + ) + const isReady = computed(() => + Boolean( + filePath.value && + !isImporting.value && + !isDeleting.value && + !example.download.value && + !example.isForOtherInstallation.value + ) + ) + + async function importFrom(sourcePath?: string): Promise { + if (isImporting.value || isDeleting.value || isLocked.value) return + isImporting.value = true + error.value = null + try { + const result = await window.api.importPerformanceTestWorkflow(sourcePath) + if (result.ok && result.filePath) { + example.release() + filePath.value = result.filePath + } else if (!result.canceled) { + error.value = result.message || t('performanceTest.importFailed') + } + } catch (cause) { + error.value = (cause as Error)?.message || t('performanceTest.importFailed') + } finally { + isImporting.value = false + } + } + + async function importFile(file: File): Promise { + const sourcePath = window.api.getPathForFile(file) + if (sourcePath) await importFrom(sourcePath) + } + + async function remove(): Promise { + const removing = filePath.value + if (!removing || isDeleting.value || isLocked.value) return + isDeleting.value = true + error.value = null + try { + const result = await window.api.deletePerformanceTestWorkflow(removing) + if (result.ok) { + if (filePath.value === removing) { + filePath.value = null + example.clearState() + } + if (result.status === 'preserved') { + error.value = result.message || t('performanceTest.deleteFailed') + } + } else { + error.value = result.message || t('performanceTest.deleteFailed') + } + } catch (cause) { + error.value = (cause as Error)?.message || t('performanceTest.deleteFailed') + } finally { + isDeleting.value = false + } + } + + return { + filePath, + error, + isImporting, + isDeleting, + source, + label, + telemetryName, + isReady, + importFrom, + importFile, + remove, + example + } +} diff --git a/src/renderer/src/lib/performanceTestResults.ts b/src/renderer/src/lib/performanceTestResults.ts new file mode 100644 index 000000000..97909e917 --- /dev/null +++ b/src/renderer/src/lib/performanceTestResults.ts @@ -0,0 +1,122 @@ +import type { PerformanceTestResultsSummary } from '../types/ipc' + +type SystemInfo = PerformanceTestResultsSummary['systemInfo'] + +export const RUN_COUNT_LIMITS = { + warmup: { min: 0, max: 5, fallback: 1 }, + measured: { min: 1, max: 100, fallback: 5 } +} as const + +export type RunCountLimits = (typeof RUN_COUNT_LIMITS)[keyof typeof RUN_COUNT_LIMITS] + +export function clampRunCount(value: string | number, limits: RunCountLimits): number { + const raw = String(value).trim() + const parsed = raw === '' ? Number.NaN : Number(raw) + if (!Number.isFinite(parsed)) return limits.fallback + return Math.min(limits.max, Math.max(limits.min, Math.round(parsed))) +} + +export function formatDuration(seconds: number): string { + return `${seconds.toFixed(3)} s` +} + +export function formatMemory(megabytes: number): string { + return `${(megabytes / 1024).toFixed(1)} GB` +} + +export function formatOperatingSystem(info: SystemInfo): string { + return ( + [info.os_distro, info.os_release].filter(Boolean).join(' ') || + `${info.platform} ${info.os_version}` + ) +} + +export const DURATION_KEYS = ['fastest', 'median', 'average', 'slowest'] as const +export type DurationKey = (typeof DURATION_KEYS)[number] +export type RunDurations = Record + +export interface DurationRow { + key: DurationKey + seconds: number + share: number + highlight: boolean +} + +export function summaryDurations(summary: PerformanceTestResultsSummary): RunDurations | null { + const fastest = summary.fastestJobDurationSeconds + const median = summary.medianJobDurationSeconds + const average = summary.averageJobDurationSeconds + const slowest = summary.slowestJobDurationSeconds + if (fastest === null || median === null || average === null || slowest === null) return null + return { fastest, median, average, slowest } +} + +export function durationRows(durations: RunDurations): DurationRow[] { + const longest = Math.max(...DURATION_KEYS.map((key) => durations[key])) + return DURATION_KEYS.map((key) => ({ + key, + seconds: durations[key], + share: longest > 0 ? durations[key] / longest : 0, + highlight: key === 'median' + })) +} + +export type SystemFactKey = + | 'device' + | 'vram' + | 'ram' + | 'pytorchVersion' + | 'xformersVersion' + | 'cpu' + | 'cpuCores' + | 'operatingSystem' + | 'architecture' + +export interface SystemFact { + key: SystemFactKey + value: string +} + +export function systemFacts( + hardware: PerformanceTestResultsSummary['hardware'] | undefined, + systemInfo: SystemInfo | undefined +): SystemFact[] { + const facts: SystemFact[] = [] + const add = (key: SystemFactKey, value: string | null | undefined): void => { + if (value) facts.push({ key, value }) + } + if (hardware) { + add('device', hardware.devices.flatMap((device) => device.deviceName ?? []).join(', ')) + if (hardware.vramMb != null) add('vram', formatMemory(hardware.vramMb)) + if (hardware.ramMb != null) add('ram', formatMemory(hardware.ramMb)) + add('pytorchVersion', hardware.pytorchVersion) + add('xformersVersion', hardware.xformersVersion) + } + if (systemInfo) { + add('cpu', systemInfo.cpu_model) + add('cpuCores', String(systemInfo.cpu_cores)) + add('operatingSystem', formatOperatingSystem(systemInfo)) + add('architecture', systemInfo.arch) + } + return facts +} + +export function lastNonEmptyLine(text: string): string { + let end = text.length + while (end > 0) { + const start = text.lastIndexOf('\n', end - 1) + const line = text.slice(start + 1, end).trim() + if (line) return line + end = Math.max(start, 0) + } + return '' +} + +export function fileName(filePath: string): string { + return filePath.split(/[\\/]/).pop() ?? '' +} + +export function parentFolder(filePath: string): string | null { + const separatorIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\')) + return separatorIndex > 0 ? filePath.slice(0, separatorIndex) : null +} diff --git a/src/renderer/src/lib/performanceTestResultsSvg.test.ts b/src/renderer/src/lib/performanceTestResultsSvg.test.ts index f7a690e90..e5bb916ba 100644 --- a/src/renderer/src/lib/performanceTestResultsSvg.test.ts +++ b/src/renderer/src/lib/performanceTestResultsSvg.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { createPerformanceTestResultsSvg } from './performanceTestResultsSvg' +import { createPerformanceTestResultsSvg, estimateTextWidth } from './performanceTestResultsSvg' describe('createPerformanceTestResultsSvg', () => { it('renders the result metrics and escapes system values as valid XML', () => { @@ -54,6 +54,29 @@ describe('createPerformanceTestResultsSvg', () => { expect(Number(bars[0]![1]) * 2).toBeCloseTo(Number(bars[1]![1])) }) + it('shrinks a slow median so it stays clear of the duration chart', () => { + const image = (median: string) => + createPerformanceTestResultsSvg({ + title: 'Performance Test: video.json', + aggregateTitle: 'Run duration', + systemInformationTitle: 'System information', + testDateTime: 'Sep 11, 2026, 12:34 PM', + headline: { label: 'Median run · 5 measured · 0 failed', value: median }, + durations: [{ label: 'Median run', value: median, durationSeconds: 1, highlight: true }], + system: [{ label: 'CPU', value: 'Example CPU' }] + }) + const headlineSize = (svg: string) => + Number(svg.match(/\.headline \{[^}]*font-size: (\d+)px/)![1]) + const chartLeft = Number(image('1.875 s').match(/]*class="chart-label"/)![1]) + + expect(headlineSize(image('1.875 s'))).toBe(64) + for (const median of ['123.456 s', '1234.567 s']) { + const size = headlineSize(image(median)) + expect(size).toBeLessThan(64) + expect(56 + estimateTextWidth(median, size)).toBeLessThan(chartLeft) + } + }) + it('shortens long system values so they stay inside their column', () => { const svg = createPerformanceTestResultsSvg({ title: 'Performance Test: cat-workflow.json', diff --git a/src/renderer/src/lib/performanceTestResultsSvg.ts b/src/renderer/src/lib/performanceTestResultsSvg.ts index 8a431eb1c..d6b8a5943 100644 --- a/src/renderer/src/lib/performanceTestResultsSvg.ts +++ b/src/renderer/src/lib/performanceTestResultsSvg.ts @@ -35,8 +35,38 @@ function text(x: number, y: number, value: string, className: string, anchor = ' return `${escapeXml(value)}` } -function fitText(value: string, maxCharacters: number): string { - return value.length > maxCharacters ? `${value.slice(0, maxCharacters - 1).trimEnd()}…` : value +const WIDE_CHARACTER = /[ᄀ-ᅟ⺀-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]/u + +function characterWidthEm(character: string): number { + if (WIDE_CHARACTER.test(character)) return 1 + if (/\d/.test(character)) return 0.62 + if (character === ' ') return 0.28 + if (/[.,:;'|!il]/.test(character)) return 0.3 + if (/[A-Z]/.test(character)) return 0.66 + return 0.55 +} + +export function estimateTextWidth(value: string, fontSize: number): number { + let width = 0 + for (const character of value) width += characterWidthEm(character) + return width * fontSize +} + +export function fitText(value: string, maxWidth: number, fontSize: number): string { + if (estimateTextWidth(value, fontSize) <= maxWidth) return value + const characters = [...value] + while ( + characters.length > 0 && + estimateTextWidth(`${characters.join('')}…`, fontSize) > maxWidth + ) { + characters.pop() + } + return `${characters.join('').trimEnd()}…` +} + +export function fitFontSize(value: string, maxWidth: number, maxFontSize: number): number { + const widthAtMax = estimateTextWidth(value, maxFontSize) + return widthAtMax <= maxWidth ? maxFontSize : Math.floor((maxFontSize * maxWidth) / widthAtMax) } export function createPerformanceTestResultsSvg(data: PerformanceTestResultsImageData): string { @@ -44,7 +74,12 @@ export function createPerformanceTestResultsSvg(data: PerformanceTestResultsImag const margin = 56 const contentWidth = width - margin * 2 const resultsY = 132 + const headlineColumnWidth = 288 const chartX = margin + 320 + const titleSize = 26 + const headlineMaxSize = 64 + const headlineSize = fitFontSize(data.headline.value, headlineColumnWidth, headlineMaxSize) + const factValueSize = 15 const chartLabelWidth = 120 const chartValueWidth = 96 const trackX = chartX + chartLabelWidth @@ -68,7 +103,7 @@ export function createPerformanceTestResultsSvg(data: PerformanceTestResultsImag const barWidth = Math.max((row.durationSeconds / longestDuration) * trackWidth, 8) const tone = row.highlight ? 'strong' : 'soft' return [ - text(chartX, y + 20, row.label, 'chart-label'), + text(chartX, y + 20, fitText(row.label, chartLabelWidth - 12, 14), 'chart-label'), ``, ``, text(width - margin, y + 21, row.value, `chart-value-${tone}`, 'end') @@ -82,7 +117,7 @@ export function createPerformanceTestResultsSvg(data: PerformanceTestResultsImag const y = factsTop + Math.floor(index / columns) * factHeight return [ text(x, y + 18, fact.label, 'fact-label'), - text(x, y + 40, fitText(fact.value, Math.floor(columnWidth / 8.4)), 'fact-value') + text(x, y + 40, fitText(fact.value, columnWidth, factValueSize), 'fact-value') ].join('') }) .join('') @@ -92,9 +127,9 @@ export function createPerformanceTestResultsSvg(data: PerformanceTestResultsImag - ${text(margin, 72, data.title, 'title')} + ${text(margin, 72, fitText(data.title, contentWidth, titleSize), 'title')} ${text(margin, resultsY + 86, data.headline.value, 'headline')} - ${text(margin, resultsY + 120, data.headline.label, 'headline-label')} + ${text(margin, resultsY + 120, fitText(data.headline.label, headlineColumnWidth, 15), 'headline-label')} ${text(chartX, resultsY + 14, data.aggregateTitle.toUpperCase(), 'section-label')} ${chart} ${text(margin, systemY + 14, data.systemInformationTitle.toUpperCase(), 'section-label')} diff --git a/src/renderer/src/panel/PanelApp.test.ts b/src/renderer/src/panel/PanelApp.test.ts index 9adb1e31b..e3120adb7 100644 --- a/src/renderer/src/panel/PanelApp.test.ts +++ b/src/renderer/src/panel/PanelApp.test.ts @@ -496,9 +496,7 @@ async function openWorkflowMenu(wrapper: ReturnType) { async function waitForBuildMenuFocusReturn() { await vi.waitFor(() => - expect(document.activeElement).toBe( - document.querySelector('.performance-test__instance-select button') - ) + expect(document.activeElement).toBe(document.querySelector('.performance-test__build-trigger')) ) } @@ -684,11 +682,9 @@ describe('PanelApp', () => { await flushPromises() expect(useDashboardScopeStore().selectedWorkspaceId).toBe('workspace-2') - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - expect(document.querySelectorAll('.ui-select-option')).toHaveLength(1) + expect(document.querySelectorAll('.performance-test__build-option')).toHaveLength(1) }) it('shows only installed Personal instances on Performance Test while signed out', async () => { @@ -720,12 +716,10 @@ describe('PanelApp', () => { await flushPromises() expect(wrapper.find('.performance-test__content').exists()).toBe(true) - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() expect( - Array.from(document.querySelectorAll('.ui-select-option-label')).map( + Array.from(document.querySelectorAll('.performance-test__build-option-label')).map( (option) => option.textContent ) ).toEqual(['Personal Installed']) @@ -862,7 +856,13 @@ describe('PanelApp', () => { ) expect(wrapper.get('.performance-test__results-section h2').text()).toBe('Results') expect( - wrapper.findAll('.performance-test__content > section').map((section) => section.classes()[0]) + wrapper + .findAll('.performance-test__content > section') + .map((section) => + ['performance-test__results-section', 'performance-test__logs-section'].find((name) => + section.classes(name) + ) + ) ).toEqual(['performance-test__results-section', 'performance-test__logs-section']) expect(wrapper.find('.performance-test__system-section').exists()).toBe(false) expect(wrapper.get('.performance-test__results').text()).toContain('No results yet') @@ -877,7 +877,7 @@ describe('PanelApp', () => { expect(wrapper.find('.performance-test__logs').text()).toBe('Build logs will appear here.') expect(wrapper.get('.performance-test__logs').classes()).toContain('scroll-visible') await logsToggle.trigger('click') - const instanceSelect = wrapper.get('.performance-test__instance-select button') + const instanceSelect = wrapper.get('.performance-test__build-trigger') expect(instanceSelect.attributes()).toMatchObject({ 'aria-haspopup': 'menu', 'aria-label': 'Select a build', @@ -887,19 +887,19 @@ describe('PanelApp', () => { await instanceSelect.trigger('keydown', { key: 'ArrowDown' }) await flushPromises() expect( - Array.from(document.querySelectorAll('.ui-select-option-label')).map( + Array.from(document.querySelectorAll('.performance-test__build-option-label')).map( (option) => option.textContent ) ).toEqual(['Workspace Install', 'Legacy Install', 'Missing Install']) expect( - Array.from(document.querySelectorAll('.ui-select-option-desc')).map( + Array.from(document.querySelectorAll('.performance-test__build-option-description')).map( (option) => option.textContent ) ).toEqual(['Standalone · 0.3.50', 'Standalone', 'Standalone']) expect(wrapper.text()).not.toContain('Other Workspace Install') expect(wrapper.find('.branded-page-header__description').exists()).toBe(false) expect(wrapper.find('[data-testid="chooser-view"]').exists()).toBe(false) - ;(document.querySelectorAll('.ui-select-option')[0] as HTMLElement).dispatchEvent( + ;(document.querySelectorAll('.performance-test__build-option')[0] as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -925,7 +925,7 @@ describe('PanelApp', () => { } } ).api - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') await flushPromises() expect(api.importPerformanceTestWorkflow).toHaveBeenCalledWith(undefined) expect(wrapper.get('.performance-test__workflow-file').text()).toContain('cat-workflow.json') @@ -1053,19 +1053,19 @@ describe('PanelApp', () => { expect(results).toContain('1.875 s') expect(results).toContain('Median run · 5 measured · 0 failed') expect(wrapper.get('.performance-test__summary').findAll(':scope > *')).toHaveLength(2) - const aggregateChart = wrapper.get('.performance-test__aggregate-chart') - expect(aggregateChart.findAll('dt').map((label) => label.text())).toEqual([ + const durationChart = wrapper.get('.performance-test__duration-chart') + expect(durationChart.findAll('dt').map((label) => label.text())).toEqual([ 'Fastest run', 'Median run', 'Average run', 'Slowest run' ]) expect( - aggregateChart - .findAll('.performance-test__aggregate-bar i') + durationChart + .findAll('.performance-test__duration-row i') .map((bar) => Math.round(Number.parseFloat(bar.element.style.width))) ).toEqual([45, 68, 73, 100]) - expect(aggregateChart.attributes('aria-label')).toBe('Run duration') + expect(durationChart.attributes('aria-label')).toBe('Run duration') const systemSection = wrapper.get('.performance-test__system-section') expect(systemSection.get('h2').text()).toBe('System information') expect(systemSection.get('.performance-test__system').isVisible()).toBe(true) @@ -1085,7 +1085,11 @@ describe('PanelApp', () => { expect(system).not.toContain(hidden) } expect( - wrapper.get('.performance-test__results-head .performance-test__results-actions').exists() + wrapper + .get( + '.performance-test__results-section .performance-test__card-head .performance-test__results-actions' + ) + .exists() ).toBe(true) const openResultsFolder = wrapper.get('.performance-test__open-results') expect(openResultsFolder.text()).toBe('Open folder') @@ -1177,11 +1181,11 @@ describe('PanelApp', () => { await instanceSelect.trigger('keydown', { key: 'ArrowDown' }) await flushPromises() expect( - Array.from(document.querySelectorAll('.ui-select-option-label')).map( + Array.from(document.querySelectorAll('.performance-test__build-option-label')).map( (option) => option.textContent ) ).toEqual(['Unmanaged Install']) - ;(document.querySelector('.ui-select-option') as HTMLElement).dispatchEvent( + ;(document.querySelector('.performance-test__build-option') as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -1503,11 +1507,9 @@ describe('PanelApp', () => { window.history.replaceState({}, '', '/?panel=performance-test&firstUseCompleted=true') const wrapper = mountPanel() await flushPromises() - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;(document.querySelector('.ui-select-option') as HTMLElement).dispatchEvent( + ;(document.querySelector('.performance-test__build-option') as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -1640,7 +1642,7 @@ describe('PanelApp', () => { download: { status: 'done', percent: 100, message: 'Template models ready' } }) await chooseExampleWorkflow(wrapper) - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') await flushPromises() expect(wrapper.get('.performance-test__workflow-file').text()).toContain('cat-workflow.json') const telemetryEvents = captureTelemetry() @@ -1727,7 +1729,7 @@ describe('PanelApp', () => { } ]) const importedPath = 'C:\\ComfyUI\\performance-tests\\20260907225500\\cat-workflow.json' - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') await flushPromises() let resolvePrepare!: (result: unknown) => void api.preparePerformanceTestExampleWorkflow.mockImplementationOnce( @@ -1737,11 +1739,9 @@ describe('PanelApp', () => { }) ) await chooseExampleWorkflow(wrapper) - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;[...document.querySelectorAll('.ui-select-option')] + ;[...document.querySelectorAll('.performance-test__build-option')] .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() @@ -1785,11 +1785,9 @@ describe('PanelApp', () => { await wrapper.get('.performance-test__run').trigger('click') await flushPromises() - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;[...document.querySelectorAll('.ui-select-option')] + ;[...document.querySelectorAll('.performance-test__build-option')] .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() @@ -1824,11 +1822,9 @@ describe('PanelApp', () => { expect(wrapper.get('.performance-test__run').attributes('disabled')).toBeUndefined() api.deletePerformanceTestWorkflow.mockResolvedValueOnce({ ok: false, message: 'File in use' }) - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;[...document.querySelectorAll('.ui-select-option')] + ;[...document.querySelectorAll('.performance-test__build-option')] .find((option) => option.textContent?.includes('Other Install'))! .dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) await flushPromises() @@ -1866,11 +1862,11 @@ describe('PanelApp', () => { ) }) - it('cancels the model download when the example workflow is removed', async () => { + it('cancels the model download from the download status line', async () => { const { wrapper, api } = await mountWithInstance() await chooseExampleWorkflow(wrapper) - await chooseWorkflowItem(wrapper, '.performance-test__delete-workflow') + await wrapper.get('.performance-test__cancel-download').trigger('click') await flushPromises() expect(api.deletePerformanceTestWorkflow).toHaveBeenCalledWith(EXAMPLE_PATH) @@ -1995,12 +1991,10 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;(document.querySelector('.ui-select-option') as HTMLElement).dispatchEvent( + ;(document.querySelector('.performance-test__build-option') as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -2015,7 +2009,7 @@ describe('PanelApp', () => { resolveImport = resolve }) ) - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') expect(runButton.attributes('disabled')).toBe('') await runButton.trigger('click') expect(api.runAction).not.toHaveBeenCalled() @@ -2032,7 +2026,7 @@ describe('PanelApp', () => { const workflowImportCalls = api.importPerformanceTestWorkflow.mock.calls.length expect(wrapper.get('.performance-test__workflow-trigger').attributes('disabled')).toBe('') await openWorkflowMenu(wrapper) - expect(workflowMenuItem('.performance-test__drop-content')).toBeNull() + expect(workflowMenuItem('.performance-test__import-workflow')).toBeNull() await wrapper.get('.performance-test__drop-zone').trigger('drop', { dataTransfer: dataTransferWith( new File(['{}'], 'replacement.json', { type: 'application/json' }) @@ -2103,12 +2097,10 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;(document.querySelector('.ui-select-option') as HTMLElement).dispatchEvent( + ;(document.querySelector('.performance-test__build-option') as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -2167,12 +2159,10 @@ describe('PanelApp', () => { const wrapper = mountPanel() await flushPromises() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') - await wrapper - .get('.performance-test__instance-select button') - .trigger('keydown', { key: 'ArrowDown' }) + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + await wrapper.get('.performance-test__build-trigger').trigger('keydown', { key: 'ArrowDown' }) await flushPromises() - ;(document.querySelector('.ui-select-option') as HTMLElement).dispatchEvent( + ;(document.querySelector('.performance-test__build-option') as HTMLElement).dispatchEvent( new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }) ) await flushPromises() @@ -2277,7 +2267,7 @@ describe('PanelApp', () => { it('reports a test whose measured runs all failed without showing a median', async () => { const { wrapper } = await mountWithInstance() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') const runApi = ( window as unknown as { api: { runPerformanceTestWorkflow: ReturnType } } ).api @@ -2305,12 +2295,12 @@ describe('PanelApp', () => { expect(wrapper.get('.performance-test__median-summary').text()).toBe('0 measured · 5 failed') expect(wrapper.get('.performance-test__results').text()).not.toContain('Median run') - expect(wrapper.find('.performance-test__aggregate-chart').exists()).toBe(false) + expect(wrapper.find('.performance-test__duration-chart').exists()).toBe(false) }) it('returns the results card to its empty state when a run is stopped before results', async () => { const { wrapper } = await mountWithInstance() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') const runApi = (window as unknown as { api: { runAction: ReturnType } }).api let finishLaunch!: (result: { ok: boolean; cancelled: boolean }) => void runApi.runAction.mockReturnValueOnce(new Promise((resolve) => (finishLaunch = resolve))) @@ -2332,7 +2322,7 @@ describe('PanelApp', () => { it('shows the results as soon as they arrive, while the logs are still being saved', async () => { const { wrapper } = await mountWithInstance() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') const logsApi = ( window as unknown as { api: { savePerformanceTestLogs: ReturnType } } ).api @@ -2349,24 +2339,38 @@ describe('PanelApp', () => { expect(wrapper.get('.performance-test__median-summary').text()).toBe( 'Median run · 5 measured · 0 failed' ) - expect(wrapper.find('.performance-test__aggregate-chart').exists()).toBe(true) + expect(wrapper.find('.performance-test__duration-chart').exists()).toBe(true) expect(wrapper.find('.performance-test__open-results').exists()).toBe(true) finishSavingLogs({ ok: true, logsPath: 'C:\\ComfyUI\\performance-tests\\logs.txt' }) await flushPromises() expect(wrapper.find('.performance-test__stop').exists()).toBe(false) - expect(wrapper.find('.performance-test__aggregate-chart').exists()).toBe(true) + expect(wrapper.find('.performance-test__duration-chart').exists()).toBe(true) }) - it('shows the system information it has when the hardware snapshot is missing', async () => { + it('shows and exports the system information it has when the hardware snapshot is missing', async () => { const { wrapper } = await mountWithInstance() - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') const runApi = ( - window as unknown as { api: { runPerformanceTestWorkflow: ReturnType } } + window as unknown as { + api: { + runPerformanceTestWorkflow: ReturnType + readPerformanceTestResultsSummary: ReturnType + } + } ).api const successfulRun = runApi.runPerformanceTestWorkflow.getMockImplementation()! - runApi.runPerformanceTestWorkflow.mockImplementationOnce(async (...args: unknown[]) => ({ - ...((await successfulRun(...args)) as RunPerformanceTestWorkflowResult), + runApi.runPerformanceTestWorkflow.mockImplementationOnce(async (...args: unknown[]) => { + const result = (await successfulRun(...args)) as RunPerformanceTestWorkflowResult + return { + ...result, + hardware: null, + resultsSummary: { ...result.resultsSummary!, hardware: null } + } + }) + const savedSummary = runApi.readPerformanceTestResultsSummary.getMockImplementation()! + runApi.readPerformanceTestResultsSummary.mockImplementationOnce(async (...args: unknown[]) => ({ + ...(await savedSummary(...args)), hardware: null })) @@ -2381,6 +2385,119 @@ describe('PanelApp', () => { 'Architecture' ]) expect(system.text()).toContain('AMD Ryzen 9 7950X') + + await wrapper.get('.performance-test__export-results').trigger('click') + await flushPromises() + const svg = createResultsPngMock.mock.calls.at(-1)![0] + expect(svg).toContain('Results JSON CPU') + expect(svg).not.toContain('Compute device') + expect(wrapper.find('.performance-test__export-error').exists()).toBe(false) + }) + + it('stops the build and says why when the workflow cannot be submitted', async () => { + const { wrapper } = await mountWithInstance() + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + const runApi = ( + window as unknown as { + api: { + runAction: ReturnType + runPerformanceTestWorkflow: ReturnType + stopComfyUI: ReturnType + } + } + ).api + runApi.runPerformanceTestWorkflow.mockResolvedValueOnce({ + ok: false, + submitted: 0, + preparationRuns: 0, + totalSubmitted: 0, + message: 'Performance Test request 1 failed: 400 Bad Request — missing node KSamplerX' + }) + + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + + expect(runApi.stopComfyUI).toHaveBeenCalledWith('performance-test:workspace-install') + expect(wrapper.find('.performance-test__stop').exists()).toBe(false) + expect(wrapper.get('.performance-test__run').attributes('disabled')).toBeUndefined() + const failure = wrapper.get('.performance-test__failure') + expect(failure.text()).toContain("The test didn't finish") + expect(failure.text()).toContain('missing node KSamplerX') + expect(wrapper.get('.performance-test__run-label').text()).toBe( + 'cat-workflow.json on Workspace Install' + ) + expect(wrapper.get('.performance-test__logs-section button').attributes('aria-expanded')).toBe( + 'true' + ) + + const launches = runApi.runAction.mock.calls.length + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + expect(runApi.runAction).toHaveBeenCalledTimes(launches + 1) + expect(wrapper.find('.performance-test__failure').exists()).toBe(false) + expect(wrapper.get('.performance-test__median-summary').text()).toBe( + 'Median run · 5 measured · 0 failed' + ) + }) + + it('says the build is starting until it is ready, then counts the runs', async () => { + const { wrapper } = await mountWithInstance() + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + const runApi = ( + window as unknown as { + api: { + runAction: ReturnType + runPerformanceTestWorkflow: ReturnType + } + } + ).api + let finishLaunch!: (result: { ok: boolean }) => void + runApi.runAction.mockReturnValueOnce(new Promise((resolve) => (finishLaunch = resolve))) + runApi.runPerformanceTestWorkflow.mockReturnValueOnce(new Promise(() => {})) + + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + expect(wrapper.get('.performance-test__progress-heading').text()).toBe('Starting the build...') + expect(wrapper.find('.performance-test__progress-detail').exists()).toBe(false) + + finishLaunch({ ok: true }) + await flushPromises() + expect(wrapper.get('.performance-test__progress-heading').text()).toBe('Run 1 of 6') + expect(wrapper.get('.performance-test__progress-detail').text()).toBe('warm-up run') + }) + + it('ignores results that arrive after the test was stopped', async () => { + const { wrapper } = await mountWithInstance() + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') + const runApi = ( + window as unknown as { api: { runPerformanceTestWorkflow: ReturnType } } + ).api + const successfulRun = runApi.runPerformanceTestWorkflow.getMockImplementation()! + let deliverLateResult!: () => Promise + runApi.runPerformanceTestWorkflow.mockImplementationOnce( + (...args: unknown[]) => + new Promise((resolve) => { + deliverLateResult = async () => resolve(await successfulRun(...args)) + }) + ) + const telemetryEvents = captureTelemetry() + + await wrapper.get('.performance-test__run').trigger('click') + await flushPromises() + await wrapper.get('.performance-test__stop').trigger('click') + await flushPromises() + await deliverLateResult() + await flushPromises() + + expect(wrapper.find('.performance-test__stop').exists()).toBe(false) + expect(wrapper.find('.performance-test__summary').exists()).toBe(false) + expect(wrapper.find('.performance-test__open-results').exists()).toBe(false) + expect(wrapper.get('.performance-test__results').text()).toContain('No results yet') + expect( + telemetryEvents + .map((event) => event.actionName) + .filter((name) => name.startsWith('comfy.desktop.performance_test.')) + ).toEqual(['comfy.desktop.performance_test.started', 'comfy.desktop.performance_test.stopped']) }) it('keeps the model download visible when importing another workflow fails', async () => { @@ -2394,7 +2511,7 @@ describe('PanelApp', () => { message: 'This file is not an API workflow.' }) - await chooseWorkflowItem(wrapper, '.performance-test__drop-content') + await chooseWorkflowItem(wrapper, '.performance-test__import-workflow') expect(api.preparePerformanceTestExampleWorkflow).toHaveBeenCalled() expect(wrapper.get('.performance-test__workflow-error').text()).toBe( @@ -2405,24 +2522,36 @@ describe('PanelApp', () => { expect(wrapper.text()).toContain(downloading.message) }) - it('clears the drop highlight once a dragged file leaves the workflow control', async () => { + it('highlights the workflow control only while a file is dragged over it', async () => { window.history.replaceState({}, '', '/?panel=performance-test&firstUseCompleted=true') const wrapper = mountPanel() await flushPromises() const zone = wrapper.get('.performance-test__drop-zone') const trigger = wrapper.get('.performance-test__workflow-trigger').element - const drag = (type: string, relatedTarget?: EventTarget): Promise => { - trigger.dispatchEvent(new DragEvent(type, { bubbles: true, cancelable: true, relatedTarget })) + const text = new DataTransfer() + text.setData('text/plain', 'not a workflow') + const file = dataTransferWith(new File(['{}'], 'workflow.json', { type: 'application/json' })) + const drag = ( + type: string, + dataTransfer: DataTransfer, + relatedTarget?: EventTarget + ): Promise => { + trigger.dispatchEvent( + new DragEvent(type, { bubbles: true, cancelable: true, dataTransfer, relatedTarget }) + ) return flushPromises() } - await drag('dragenter') + await drag('dragenter', text) + expect(zone.classes()).not.toContain('performance-test__drop-zone--dragging') + + await drag('dragenter', file) expect(zone.classes()).toContain('performance-test__drop-zone--dragging') - await drag('dragleave', zone.element) + await drag('dragleave', file, zone.element) expect(zone.classes()).toContain('performance-test__drop-zone--dragging') - await drag('dragleave', document.body) + await drag('dragleave', file, document.body) expect(zone.classes()).not.toContain('performance-test__drop-zone--dragging') }) diff --git a/src/renderer/src/views/PerformanceTestView.vue b/src/renderer/src/views/PerformanceTestView.vue index 060ffe26b..53d91f371 100644 --- a/src/renderer/src/views/PerformanceTestView.vue +++ b/src/renderer/src/views/PerformanceTestView.vue @@ -1,67 +1,39 @@