From 2689f49884d85f80a90897cbf9bbe66643fde5f8 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Tue, 4 Aug 2026 19:36:35 -0700 Subject: [PATCH 01/62] test: decouple node-title goldens from the CI container (#14744) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Pin the node display names that Playwright goldens capture, so screenshots stop tracking whatever ComfyUI build the CI container happens to ship — and make the failure mode legible when a pinned node type goes missing. ## Changes - **What**: - New `setNodeDisplayName(objectInfo, nodeType, displayName)` mutator in `browser_tests/fixtures/utils/objectInfo.ts`, alongside `setStringInputTooltip` / `setComboInputOptions`. - `imageCompare.spec.ts` pins `ImageCompare` -> `Image Compare`; `nodeBadge.spec.ts` pins `ImageBatch` -> `Batch Images`. - Both install the stub by extending the `page` fixture, so the route is live before `comfyPage.setup()` boots the node-definition store. That is the same pattern as `propertiesPanel/errorsTabModeAware.spec.ts` and avoids the extra `reloadAndWaitForApp()` that `widgetTooltip.spec.ts` needs when routing mid-test. - **Pre-existing bug fix:** `routeObjectInfoFromSetupApi` only wrapped the fetch and JSON parse in a `try`. A throwing `customize` callback rejected the route handler, so `route.fulfill` never ran and the request hung — the test then died on an opaque Playwright timeout rather than reporting the cause. The mutators throw precisely when a node type is missing from `/object_info`, which is what a container bump triggers, so shipping the pins without this would turn "node was renamed upstream" into a mystery hang. `customize` is now guarded and fulfills a 500 naming the failure, with the message logged to test output. No baselines were regenerated. The pinned strings are the ones the committed PNGs already encode, so the images are byte-identical to `main`. ## Review Focus Since #14541, English node titles resolve from the backend `/object_info` rather than from a bundled file. That makes every golden containing a node header a function of the CI container image, which is pinned to `ghcr.io/comfy-org/comfyui-ci-container:0.0.21` (ComfyUI v0.19.3) in four workflows: `ci-tests-e2e.yaml:57` and `:115`, `pr-update-playwright-expectations.yaml:84`, `ci-perf-report.yaml:34`. `0.0.22` (ComfyUI v0.30.0) already exists in the registry, and whoever bumps the pin currently gets unrelated node-title screenshot diffs with nothing in-repo explaining them. This makes that bump safe. The chosen strings are not guesses. #14541 itself re-baselined these goldens, so they encode the container's names, and the rename is visible in the diff of that commit: in `image-compare-default-50`, the title descenders move from `p` at x=60 / `g` at x=112 (bundled `Compare Images`) to `g` at x=56 / `p` at x=98 (container `Image Compare`). `Batch Images` is legible directly in `node-lifecycle-*`. No unit test covers the hang fix: `browser_tests/**` is outside vitest's `include` globs (`src/`, `packages/`, `scripts/`), and widening them would sweep the Playwright `.spec.ts` files into `pnpm test:unit`. Exercising the path for real needs a running ComfyUI backend. Still coupled to the container, deliberately out of scope here: the `api-pricing-*` goldens (title `Flux 1.1 [pro] Ultra Image`, from `FluxProUltraImageNode`) and `node-badge-*` (titles from the `nodes/execution_error` workflow). Same fix applies if we want them covered. Fixes #14630 --------- Co-authored-by: Connor Byrne --- browser_tests/fixtures/utils/objectInfo.ts | 33 +++++++++++++++++++- browser_tests/tests/imageCompare.spec.ts | 30 ++++++++++++++++++- browser_tests/tests/nodeBadge.spec.ts | 35 +++++++++++++++++++--- 3 files changed, 92 insertions(+), 6 deletions(-) diff --git a/browser_tests/fixtures/utils/objectInfo.ts b/browser_tests/fixtures/utils/objectInfo.ts index fc639ade70d..72f0d4bbb12 100644 --- a/browser_tests/fixtures/utils/objectInfo.ts +++ b/browser_tests/fixtures/utils/objectInfo.ts @@ -46,6 +46,19 @@ function getRequiredInput( return input } +export function setNodeDisplayName( + objectInfo: ObjectInfoResponse, + nodeType: string, + displayName: string +): void { + const nodeInfo = objectInfo[nodeType] + if (!nodeInfo) { + throw new Error(`Missing object_info entry for ${nodeType}`) + } + + nodeInfo.display_name = displayName +} + export function setStringInputTooltip( objectInfo: ObjectInfoResponse, nodeType: string, @@ -140,7 +153,25 @@ export async function routeObjectInfoFromSetupApi( return } - await customize?.(objectInfo) + try { + await customize?.(objectInfo) + } catch (error) { + // A throwing mutator (e.g. a node type that disappeared from a newer + // ComfyUI build) must still fulfill the route. An unfulfilled request + // hangs the page, so the test dies on an opaque Playwright timeout + // instead of reporting the reason. + const message = error instanceof Error ? error.message : String(error) + console.error(`Failed to customize object_info: ${message}`) + await route.fulfill({ + status: 500, + contentType: 'application/json', + body: JSON.stringify({ + error: `Failed to customize object_info from ${objectInfoUrl}: ${message}` + }) + }) + return + } + await route.fulfill({ status: 200, contentType: 'application/json', diff --git a/browser_tests/tests/imageCompare.spec.ts b/browser_tests/tests/imageCompare.spec.ts index deabf1986fb..835b07dc4b3 100644 --- a/browser_tests/tests/imageCompare.spec.ts +++ b/browser_tests/tests/imageCompare.spec.ts @@ -2,11 +2,39 @@ import type { Locator, Page } from '@playwright/test' import { expect } from '@playwright/test' import type { ComfyPage } from '@e2e/fixtures/ComfyPage' -import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' +import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' import { TestIds } from '@e2e/fixtures/selectors' +import { + routeObjectInfoFromSetupApi, + setNodeDisplayName +} from '@e2e/fixtures/utils/objectInfo' import { toNodeId } from '@/types/nodeId' const IMAGE_COMPARE_NODE_ID = toNodeId(1) +const IMAGE_COMPARE_NODE_TYPE = 'ImageCompare' +const IMAGE_COMPARE_DISPLAY_NAME = 'Image Compare' + +// English node titles come from the backend, so any golden containing a node +// header would otherwise track whatever ComfyUI build the CI container ships. +// Pinning the name before the app boots keeps those baselines stable. +const test = comfyPageFixture.extend({ + page: async ({ page }, use) => { + const unrouteObjectInfo = await routeObjectInfoFromSetupApi( + page, + (objectInfo) => + setNodeDisplayName( + objectInfo, + IMAGE_COMPARE_NODE_TYPE, + IMAGE_COMPARE_DISPLAY_NAME + ) + ) + try { + await use(page) + } finally { + await unrouteObjectInfo() + } + } +}) test.describe('Image Compare', { tag: ['@widget', '@vue-nodes'] }, () => { test.beforeEach(async ({ comfyPage }) => { diff --git a/browser_tests/tests/nodeBadge.spec.ts b/browser_tests/tests/nodeBadge.spec.ts index 975225b389c..5a358a45c22 100644 --- a/browser_tests/tests/nodeBadge.spec.ts +++ b/browser_tests/tests/nodeBadge.spec.ts @@ -2,15 +2,42 @@ import { expect } from '@playwright/test' import type { ComfyApp } from '@/scripts/app' import { NodeBadgeMode } from '@/types/nodeSource' -import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' +import { comfyPageFixture } from '@e2e/fixtures/ComfyPage' +import { + routeObjectInfoFromSetupApi, + setNodeDisplayName +} from '@e2e/fixtures/utils/objectInfo' + +const DEPRECATED_NODE_TYPE = 'ImageBatch' +const DEPRECATED_NODE_DISPLAY_NAME = 'Batch Images' +const API_NODE_TYPE = 'FluxProUltraImageNode' + +// English node titles come from the backend, so any golden containing a node +// header would otherwise track whatever ComfyUI build the CI container ships. +// Pinning the name before the app boots keeps those baselines stable. +const test = comfyPageFixture.extend({ + page: async ({ page }, use) => { + const unrouteObjectInfo = await routeObjectInfoFromSetupApi( + page, + (objectInfo) => + setNodeDisplayName( + objectInfo, + DEPRECATED_NODE_TYPE, + DEPRECATED_NODE_DISPLAY_NAME + ) + ) + try { + await use(page) + } finally { + await unrouteObjectInfo() + } + } +}) test.beforeEach(async ({ comfyPage }) => { await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled') }) -const DEPRECATED_NODE_TYPE = 'ImageBatch' -const API_NODE_TYPE = 'FluxProUltraImageNode' - test.describe('Node Badge', { tag: ['@screenshot', '@smoke', '@node'] }, () => { test('Can add badge', async ({ comfyPage }) => { await comfyPage.page.evaluate(() => { From b8ec06f893b774c309a3733e345314d97f3ff1a6 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Tue, 4 Aug 2026 19:41:22 -0700 Subject: [PATCH 02/62] fix: resolve widget labels, output names and tooltips from the backend (#14747) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Widget labels, socket labels, output names, node descriptions and tooltips now resolve from the live `/object_info` response instead of the bundled `en/nodeDefs.json` snapshot, so a backend rename no longer leaves a new node title beside old widget labels and old tooltips. ## Changes - **What**: `resolveNodeDefInputText()` / `resolveNodeDefOutputText()` (`src/i18n.ts`) extend the precedence introduced in #14541 to slot text. They own all `nodeDefs.*.inputs|outputs.*` key construction and apply the same per-locale order: | locale | order | | ------ | ---------------------------------------------------------------------------------------- | | `en` | custom-node `/api/i18n` -> backend `/object_info` -> bundled snapshot -> caller fallback | | other | custom-node `/api/i18n` -> bundled snapshot -> backend -> caller fallback | The existing `resolveNodeDefText` and the new slot resolvers share one core (`resolveNodeDefPath`), which now takes the message reader as a parameter — the only behavioural difference between a name and a tooltip. - **What**: Call sites moved onto the resolvers: - `litegraphService.addInputWidget` — `widget.label` and the widget's socket `localized_name` - `litegraphService.addInputSocket` — socket `localized_name` - `litegraphService.addOutputs` — output `localized_name` (the `dataTypes.*` branch, used when the output name equals its type, is unchanged) - `NodeTooltip.vue` — input slot, output slot and widget tooltips - `useNodeTooltips.ts` — input slot, output slot and widget tooltips - **What**: `useNodeTooltips.getNodeDescription` no longer re-resolves the description against the snapshot. `getNodeDefs()` has already resolved it, so wrapping it in `st()` let the stale bundled value win. - **Breaking**: None. ## Review Focus - **The raw/compiled split is the risk in this PR.** `scripts/nodeDefLocaleSerializer.ts` escapes `name` and leaves `tooltip` verbatim, because tooltips are read through `stRaw`/`tm()` uncompiled — an escaped `{'@'}` would render literally to the user. `slotMessageReader()` is the single place that picks `st` vs `stRaw`, keyed on the field. Nothing new is escaped at runtime, and no backend value is merged into the vue-i18n message tree. - Widget labels previously always came from the snapshot, whose `inputs.*.name` is the raw input name rather than `display_name` — so a backend `display_name` on an input was never shown. It now is. Where the backend sends no `display_name` the snapshot still applies, which is the existing behaviour. - Tests are verified by mutation, not by inspection, because `st()` swallows a vue-i18n `SyntaxError` and falls back to the raw stored message — a fixture with a throwing character passes either way. The `raw / compiled split` fixture uses `50{'%'} {'@'}`, which compiles cleanly, so `name` -> `50% @` and `tooltip` -> `50{'%'} {'@'}` genuinely diverge. Forcing either reader in both directions fails that test; dropping the `en` backend bypass, the custom-node precedence, or the backend fallback each fails a distinct test; passing `undefined` for the backend value at each of the seven call sites fails the test covering it. Fixes #14631 Co-authored-by: Connor Byrne --- src/components/graph/NodeTooltip.test.ts | 51 ++++++ src/components/graph/NodeTooltip.vue | 36 +++-- src/i18n.test.ts | 151 +++++++++++++++++- src/i18n.ts | 117 +++++++++++--- .../composables/useNodeTooltips.test.ts | 50 +++++- .../vueNodes/composables/useNodeTooltips.ts | 34 ++-- src/services/litegraphService.test.ts | 58 ++++++- src/services/litegraphService.ts | 47 ++++-- 8 files changed, 479 insertions(+), 65 deletions(-) diff --git a/src/components/graph/NodeTooltip.test.ts b/src/components/graph/NodeTooltip.test.ts index 11ff90bdb69..13fe7f2e3e5 100644 --- a/src/components/graph/NodeTooltip.test.ts +++ b/src/components/graph/NodeTooltip.test.ts @@ -137,6 +137,14 @@ function mergeOutputTooltipMessage(tooltip: string | null) { }) } +function mergeInputTooltipMessage(tooltip: string | null) { + i18n.global.mergeLocaleMessage('en', { + nodeDefs: { + SAM3_Detect: { inputs: { positive_coords: { tooltip } } } + } + }) +} + async function renderAndHoverCanvas() { const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime }) @@ -219,4 +227,47 @@ describe('NodeTooltip', () => { expect(screen.getByText(jsonTooltip)).toBeInTheDocument() expect(consoleError).not.toHaveBeenCalled() }) + + describe('when the bundled snapshot has gone stale', () => { + const staleInputTooltip = 'stale bundled input tooltip' + const staleOutputTooltip = 'stale bundled output tooltip' + + beforeEach(() => { + mergeInputTooltipMessage(staleInputTooltip) + mergeOutputTooltipMessage(staleOutputTooltip) + }) + + afterEach(() => { + mergeInputTooltipMessage(jsonTooltip) + }) + + it('shows the live backend input slot tooltip', async () => { + vi.mocked(mockIsOverNodeInput).mockReturnValue(0) + + await renderAndHoverCanvas() + + expect(screen.getByText(jsonTooltip)).toBeInTheDocument() + expect(screen.queryByText(staleInputTooltip)).not.toBeInTheDocument() + }) + + it('shows the live backend output slot tooltip', async () => { + vi.mocked(mockIsOverNodeOutput).mockReturnValue(0) + + await renderAndHoverCanvas() + + expect(screen.getByText(jsonTooltip)).toBeInTheDocument() + expect(screen.queryByText(staleOutputTooltip)).not.toBeInTheDocument() + }) + + it('shows the live backend widget tooltip', async () => { + vi.mocked(mockCanvas.getWidgetAtCursor).mockReturnValue({ + name: 'positive_coords' + }) + + await renderAndHoverCanvas() + + expect(screen.getByText(jsonTooltip)).toBeInTheDocument() + expect(screen.queryByText(staleInputTooltip)).not.toBeInTheDocument() + }) + }) }) diff --git a/src/components/graph/NodeTooltip.vue b/src/components/graph/NodeTooltip.vue index fd21640c686..20f016085d3 100644 --- a/src/components/graph/NodeTooltip.vue +++ b/src/components/graph/NodeTooltip.vue @@ -13,7 +13,7 @@ import { useEventListener } from '@vueuse/core' import { nextTick, ref } from 'vue' -import { stRaw } from '@/i18n' +import { resolveNodeDefInputText, resolveNodeDefOutputText } from '@/i18n' import { LiteGraph, isOverNodeInput, @@ -23,7 +23,6 @@ import { useSettingStore } from '@/platform/settings/settingStore' import { app as comfyApp } from '@/scripts/app' import { isDOMWidget } from '@/scripts/domWidget' import { useNodeDefStore } from '@/stores/nodeDefStore' -import { normalizeI18nKey } from '@/utils/formatUtil' let idleTimeout: number const nodeDefStore = useNodeDefStore() @@ -65,7 +64,8 @@ function onIdle() { if (!node || node.flags?.ghost) return const ctor = node.constructor as { title_mode?: 0 | 1 | 2 | 3 } - const nodeDef = nodeDefStore.nodeDefsByName[node.type ?? ''] + const nodeType = node.type ?? '' + const nodeDef = nodeDefStore.nodeDefsByName[nodeType] if ( ctor.title_mode !== LiteGraph.NO_TITLE && @@ -84,11 +84,14 @@ function onIdle() { ) if (inputSlot !== -1) { const inputName = node.inputs[inputSlot].name - const translatedTooltip = stRaw( - `nodeDefs.${normalizeI18nKey(node.type ?? '')}.inputs.${normalizeI18nKey(inputName)}.tooltip`, - nodeDef?.inputs[inputName]?.tooltip ?? '' + return showTooltip( + resolveNodeDefInputText( + 'tooltip', + nodeType, + inputName, + nodeDef?.inputs[inputName]?.tooltip + ) ) - return showTooltip(translatedTooltip) } const outputSlot = isOverNodeOutput( @@ -98,19 +101,24 @@ function onIdle() { [0, 0] ) if (outputSlot !== -1) { - const translatedTooltip = stRaw( - `nodeDefs.${normalizeI18nKey(node.type ?? '')}.outputs.${outputSlot}.tooltip`, - nodeDef?.outputs[outputSlot]?.tooltip ?? '' + return showTooltip( + resolveNodeDefOutputText( + 'tooltip', + nodeType, + outputSlot, + nodeDef?.outputs[outputSlot]?.tooltip + ) ) - return showTooltip(translatedTooltip) } const widget = comfyApp.canvas.getWidgetAtCursor() // Dont show for DOM widgets, these use native browser tooltips as we dont get proper mouse events on these if (widget && !isDOMWidget(widget)) { - const translatedTooltip = stRaw( - `nodeDefs.${normalizeI18nKey(node.type ?? '')}.inputs.${normalizeI18nKey(widget.name)}.tooltip`, - nodeDef?.inputs[widget.name]?.tooltip ?? '' + const translatedTooltip = resolveNodeDefInputText( + 'tooltip', + nodeType, + widget.name, + nodeDef?.inputs[widget.name]?.tooltip ) // Widget tooltip can be set dynamically, current translation collection does not support this. return showTooltip(widget.tooltip ?? translatedTooltip) diff --git a/src/i18n.test.ts b/src/i18n.test.ts index b6b6e848db4..37a0b82f7f8 100644 --- a/src/i18n.test.ts +++ b/src/i18n.test.ts @@ -5,6 +5,8 @@ import type * as I18nModule from './i18n' let i18n: typeof I18nModule.i18n let loadLocale: typeof I18nModule.loadLocale let resolveNodeDefText: typeof I18nModule.resolveNodeDefText +let resolveNodeDefInputText: typeof I18nModule.resolveNodeDefInputText +let resolveNodeDefOutputText: typeof I18nModule.resolveNodeDefOutputText let setBackendNodeText: typeof I18nModule.setBackendNodeText let mergeCustomNodesI18n: typeof I18nModule.mergeCustomNodesI18n let resolveSupportedLocale: typeof I18nModule.resolveSupportedLocale @@ -16,6 +18,8 @@ async function importI18nModule() { i18n = i18nModule.i18n loadLocale = i18nModule.loadLocale resolveNodeDefText = i18nModule.resolveNodeDefText + resolveNodeDefInputText = i18nModule.resolveNodeDefInputText + resolveNodeDefOutputText = i18nModule.resolveNodeDefOutputText setBackendNodeText = i18nModule.setBackendNodeText mergeCustomNodesI18n = i18nModule.mergeCustomNodesI18n resolveSupportedLocale = i18nModule.resolveSupportedLocale @@ -37,7 +41,18 @@ function restoreEnNodeDefsMock() { } Object.assign(enNodeDefsMock, { testNode: 'Test Node', - KSampler: { display_name: 'KSampler (bundled)' } + KSampler: { + display_name: 'KSampler (bundled)', + inputs: { + seed: { name: 'seed (bundled)', tooltip: 'Seed tooltip (bundled)' }, + // The serializer escapes `name` and leaves `tooltip` verbatim, so the + // same source text is stored differently per field. + syntax: { name: "50{'%'} {'@'}", tooltip: "50{'%'} {'@'}" } + }, + outputs: { + 0: { name: 'LATENT (bundled)', tooltip: 'Latent tooltip (bundled)' } + } + } }) } @@ -54,7 +69,12 @@ vi.mock('./locales/en/settings.json', () => ({ // Mock lazy-loaded locales vi.mock('./locales/zh/main.json', () => ({ default: { welcome: '欢迎' } })) vi.mock('./locales/zh/nodeDefs.json', () => ({ - default: { testNode: '测试节点' } + default: { + testNode: '测试节点', + KSampler: { + inputs: { seed: { name: '种子', tooltip: '种子提示' } } + } + } })) vi.mock('./locales/zh/commands.json', () => ({ default: { save: '保存' } })) vi.mock('./locales/zh/settings.json', () => ({ default: { theme: '主题' } })) @@ -154,7 +174,9 @@ describe('i18n', () => { // 4. Also verify base locale data is present expect(zhMessages.welcome).toBe('欢迎') - expect(zhMessages.nodeDefs).toEqual({ testNode: '测试节点' }) + expect(zhMessages.nodeDefs).toEqual( + expect.objectContaining({ testNode: '测试节点' }) + ) }) it('should handle multiple locales in custom nodes i18n data', async () => { @@ -366,6 +388,129 @@ describe('i18n', () => { }) }) + describe('slot text', () => { + describe('precedence', () => { + it('en: the live backend value beats the bundled snapshot', () => { + expect( + resolveNodeDefInputText('name', 'KSampler', 'seed', 'Live Seed') + ).toBe('Live Seed') + expect( + resolveNodeDefInputText('tooltip', 'KSampler', 'seed', 'Live tooltip') + ).toBe('Live tooltip') + expect( + resolveNodeDefOutputText('name', 'KSampler', 0, 'Live Latent') + ).toBe('Live Latent') + expect( + resolveNodeDefOutputText('tooltip', 'KSampler', 0, 'Live tooltip') + ).toBe('Live tooltip') + }) + + it('en: the bundled snapshot is used when the backend sends nothing', () => { + expect(resolveNodeDefInputText('name', 'KSampler', 'seed')).toBe( + 'seed (bundled)' + ) + expect(resolveNodeDefInputText('tooltip', 'KSampler', 'seed')).toBe( + 'Seed tooltip (bundled)' + ) + expect(resolveNodeDefOutputText('tooltip', 'KSampler', 0)).toBe( + 'Latent tooltip (bundled)' + ) + }) + + it('en: falls back to the caller fallback when nothing supplies text', () => { + expect( + resolveNodeDefInputText('name', 'Unknown', 'seed', undefined, 'seed') + ).toBe('seed') + expect(resolveNodeDefOutputText('tooltip', 'Unknown', 0)).toBe('') + }) + + it('en: a custom-node translation beats the backend', () => { + mergeCustomNodesI18n({ + en: { + nodeDefs: { + KSampler: { inputs: { seed: { name: 'Custom Seed' } } } + } + } + }) + + expect( + resolveNodeDefInputText('name', 'KSampler', 'seed', 'Live Seed') + ).toBe('Custom Seed') + }) + + it('non-en: the translation stays authoritative over the backend', async () => { + await setActiveLocale('zh') + + expect( + resolveNodeDefInputText('name', 'KSampler', 'seed', 'Live Seed') + ).toBe('种子') + expect( + resolveNodeDefInputText('tooltip', 'KSampler', 'seed', 'Live tooltip') + ).toBe('种子提示') + }) + + it('non-en: falls back to the live backend value, not the en snapshot', async () => { + await setActiveLocale('zh') + + expect( + resolveNodeDefOutputText('name', 'KSampler', 0, 'Live Latent') + ).toBe('Live Latent') + }) + }) + + describe('raw / compiled split', () => { + it('compiles a bundled name but returns a bundled tooltip uncompiled', () => { + expect(resolveNodeDefInputText('name', 'KSampler', 'syntax')).toBe( + '50% @' + ) + expect(resolveNodeDefInputText('tooltip', 'KSampler', 'syntax')).toBe( + "50{'%'} {'@'}" + ) + }) + + it('returns backend slot text verbatim, never through the compiler', () => { + const raw = "Mask {'@'} 100% | D:\\output" + + expect( + resolveNodeDefInputText('tooltip', 'KSampler', 'seed', raw) + ).toBe(raw) + expect(resolveNodeDefInputText('name', 'KSampler', 'seed', raw)).toBe( + raw + ) + }) + }) + + describe('key resolution', () => { + it('normalizes dotted input names', () => { + mergeCustomNodesI18n({ + en: { + nodeDefs: { + KSampler: { inputs: { a_b: { name: 'Dotted Input' } } } + } + } + }) + + expect(resolveNodeDefInputText('name', 'KSampler', 'a.b', 'Live')).toBe( + 'Dotted Input' + ) + }) + + it('resolves the legacy nested shape hand-written locales use', () => { + mergeCustomNodesI18n({ + en: { + nodeDefs: { + my: { node: { inputs: { seed: { name: 'Nested Seed' } } } } + } + } + }) + + expect(resolveNodeDefInputText('name', 'my.node', 'seed', 'Live')).toBe( + 'Nested Seed' + ) + }) + }) + }) + describe('loadLocale', () => { it('should not reload already loaded locale', async () => { await loadLocale('zh') diff --git a/src/i18n.ts b/src/i18n.ts index 569c99fd45b..4a48d001553 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -167,25 +167,22 @@ export function setBackendNodeText( } } -function customNodesProvide( - nodeName: string, - field: NodeDefTextField -): boolean { +function customNodesProvide(nodeName: string, path: string): boolean { const data = customNodesI18nData[i18n.global.locale.value] if (typeof data !== 'object' || data === null) return false const nodeDefs = (data as Record)['nodeDefs'] if (typeof nodeDefs !== 'object' || nodeDefs === null) return false - for (const path of nodeDefKeyCandidates(nodeName)) { + for (const candidate of nodeDefKeyCandidates(nodeName)) { let cursor: unknown = nodeDefs - for (const segment of path.split('.')) { - if (typeof cursor !== 'object' || cursor === null) break + for (const segment of `${candidate}.${path}`.split('.')) { + if (typeof cursor !== 'object' || cursor === null) { + cursor = undefined + break + } cursor = (cursor as Record)[segment] } - if (typeof cursor === 'object' && cursor !== null) { - if (typeof (cursor as Record)[field] === 'string') - return true - } + if (typeof cursor === 'string') return true } return false } @@ -200,14 +197,20 @@ function nodeDefKeyCandidates(nodeName: string): string[] { return normalized === nodeName ? [normalized] : [normalized, nodeName] } +/** + * Reads a resolved locale message. `st` compiles it; `stRaw` does not. + */ +type MessageReader = (key: string, fallbackMessage: string) => string + function translateNodeDefText( nodeName: string, - field: NodeDefTextField, - fallback: string + path: string, + fallback: string, + read: MessageReader ): string { - for (const path of nodeDefKeyCandidates(nodeName)) { - const key = `nodeDefs.${path}.${field}` - if (te(key)) return st(key, fallback) + for (const candidate of nodeDefKeyCandidates(nodeName)) { + const key = `nodeDefs.${candidate}.${path}` + if (te(key)) return read(key, fallback) } return fallback } @@ -222,6 +225,21 @@ function translateNodeDefText( * Other locales: translations stay authoritative, falling back to the live * backend value rather than the stale English snapshot. */ +function resolveNodeDefPath( + nodeName: string, + path: string, + backend: string | undefined, + fallback: string, + read: MessageReader +): string { + if (customNodesProvide(nodeName, path)) { + return translateNodeDefText(nodeName, path, fallback, read) + } + if (i18n.global.locale.value === 'en' && backend !== undefined) return backend + + return translateNodeDefText(nodeName, path, fallback, read) +} + export function resolveNodeDefText( field: NodeDefTextField, nodeName: string, @@ -230,12 +248,69 @@ export function resolveNodeDefText( const backend = backendValue ?? backendNodeText.get(nodeName)?.[field] const fallback = backend ?? (field === 'display_name' ? nodeName : '') - if (customNodesProvide(nodeName, field)) { - return translateNodeDefText(nodeName, field, fallback) - } - if (i18n.global.locale.value === 'en' && backend !== undefined) return backend + return resolveNodeDefPath(nodeName, field, backend, fallback, st) +} + +/** Slot fields the generated locales carry text for. */ +export type NodeDefSlotTextField = 'name' | 'tooltip' + +/** + * `name` is escaped by `scripts/nodeDefLocaleSerializer.ts` and has to be + * compiled back; `tooltip` is stored verbatim and must never reach the message + * compiler, or a literal `{'@'}` would render to the user. + */ +function slotMessageReader(field: NodeDefSlotTextField): MessageReader { + return field === 'tooltip' ? stRaw : st +} + +function resolveNodeDefSlotText( + field: NodeDefSlotTextField, + nodeName: string, + slotPath: string, + backendValue: string | undefined, + fallbackValue: string +): string { + return resolveNodeDefPath( + nodeName, + `${slotPath}.${field}`, + backendValue, + backendValue ?? fallbackValue, + slotMessageReader(field) + ) +} + +/** Resolves an input slot's label or tooltip, same precedence as node text. */ +export function resolveNodeDefInputText( + field: NodeDefSlotTextField, + nodeName: string, + inputName: string, + backendValue?: string, + fallbackValue = '' +): string { + return resolveNodeDefSlotText( + field, + nodeName, + `inputs.${normalizeI18nKey(inputName)}`, + backendValue, + fallbackValue + ) +} - return translateNodeDefText(nodeName, field, fallback) +/** Resolves an output slot's label or tooltip, same precedence as node text. */ +export function resolveNodeDefOutputText( + field: NodeDefSlotTextField, + nodeName: string, + outputIndex: number, + backendValue?: string, + fallbackValue = '' +): string { + return resolveNodeDefSlotText( + field, + nodeName, + `outputs.${outputIndex}`, + backendValue, + fallbackValue + ) } // Only include English in the initial bundle; other locales lazy-load. diff --git a/src/renderer/extensions/vueNodes/composables/useNodeTooltips.test.ts b/src/renderer/extensions/vueNodes/composables/useNodeTooltips.test.ts index c51f17c11e8..5fa9f6bbf7d 100644 --- a/src/renderer/extensions/vueNodes/composables/useNodeTooltips.test.ts +++ b/src/renderer/extensions/vueNodes/composables/useNodeTooltips.test.ts @@ -38,12 +38,28 @@ function mergeOutputTooltipMessage(tooltip: string | null) { }) } +function mergeBundledMessages(messages: { + description: string | null + inputTooltip: string | null + outputTooltip: string | null +}) { + i18n.global.mergeLocaleMessage('en', { + nodeDefs: { + SAM3_Detect: { + description: messages.description, + inputs: { positive_coords: { tooltip: messages.inputTooltip } }, + outputs: { 0: { tooltip: messages.outputTooltip } } + } + } + }) +} + const sam3DetectNodeDef: ComfyNodeDef = { name: 'SAM3_Detect', display_name: 'SAM3 Detect', category: 'detection/', python_module: 'comfy_extras.nodes_sam3', - description: '', + description: 'Live SAM3 description', input: { required: {}, optional: { @@ -130,4 +146,36 @@ describe('useNodeTooltips', () => { expect(textClass).toContain('whitespace-pre-line') expect(config.value).toContain('\n\n') }) + + describe('when the bundled snapshot has gone stale', () => { + beforeEach(() => { + mergeBundledMessages({ + description: 'stale bundled description', + inputTooltip: 'stale bundled input tooltip', + outputTooltip: 'stale bundled output tooltip' + }) + }) + + afterEach(() => { + mergeBundledMessages({ + description: null, + inputTooltip: jsonTooltip, + outputTooltip: null + }) + }) + + it('prefers the live backend text over the snapshot', () => { + const { + getNodeDescription, + getInputSlotTooltip, + getOutputSlotTooltip, + getWidgetTooltip + } = useNodeTooltips('SAM3_Detect') + + expect(getNodeDescription.value).toBe('Live SAM3 description') + expect(getInputSlotTooltip('positive_coords')).toBe(jsonTooltip) + expect(getOutputSlotTooltip(0)).toBe(jsonTooltip) + expect(getWidgetTooltip(positiveCoordsWidget)).toBe(jsonTooltip) + }) + }) }) diff --git a/src/renderer/extensions/vueNodes/composables/useNodeTooltips.ts b/src/renderer/extensions/vueNodes/composables/useNodeTooltips.ts index ff843b1cdc5..3dff192cf25 100644 --- a/src/renderer/extensions/vueNodes/composables/useNodeTooltips.ts +++ b/src/renderer/extensions/vueNodes/composables/useNodeTooltips.ts @@ -6,10 +6,9 @@ import { computed, ref, unref } from 'vue' import type { MaybeRef } from 'vue' import type { SafeWidgetData } from '@/composables/graph/useGraphNodeManager' -import { st, stRaw } from '@/i18n' +import { resolveNodeDefInputText, resolveNodeDefOutputText } from '@/i18n' import { useSettingStore } from '@/platform/settings/settingStore' import { useNodeDefStore } from '@/stores/nodeDefStore' -import { normalizeI18nKey } from '@/utils/formatUtil' import { cn } from '@comfyorg/tailwind-utils' // PrimeVue adds this internal property to elements with tooltips @@ -107,8 +106,8 @@ export function useNodeTooltips(nodeType: MaybeRef) { const getNodeDescription = computed(() => { if (!tooltipsEnabled.value || !nodeDef.value) return '' - const key = `nodeDefs.${normalizeI18nKey(unref(nodeType))}.description` - return st(key, nodeDef.value.description || '') + // Already resolved against the backend and the locale by `getNodeDefs()`. + return nodeDef.value.description || '' }) /** @@ -117,9 +116,12 @@ export function useNodeTooltips(nodeType: MaybeRef) { const getInputSlotTooltip = (slotName: string) => { if (!tooltipsEnabled.value || !nodeDef.value) return '' - const key = `nodeDefs.${normalizeI18nKey(unref(nodeType))}.inputs.${normalizeI18nKey(slotName)}.tooltip` - const inputTooltip = nodeDef.value.inputs?.[slotName]?.tooltip ?? '' - return stRaw(key, inputTooltip) + return resolveNodeDefInputText( + 'tooltip', + unref(nodeType), + slotName, + nodeDef.value.inputs?.[slotName]?.tooltip + ) } /** @@ -128,9 +130,12 @@ export function useNodeTooltips(nodeType: MaybeRef) { const getOutputSlotTooltip = (slotIndex: number) => { if (!tooltipsEnabled.value || !nodeDef.value) return '' - const key = `nodeDefs.${normalizeI18nKey(unref(nodeType))}.outputs.${slotIndex}.tooltip` - const outputTooltip = nodeDef.value.outputs?.[slotIndex]?.tooltip ?? '' - return stRaw(key, outputTooltip) + return resolveNodeDefOutputText( + 'tooltip', + unref(nodeType), + slotIndex, + nodeDef.value.outputs?.[slotIndex]?.tooltip + ) } /** @@ -144,9 +149,12 @@ export function useNodeTooltips(nodeType: MaybeRef) { if (widgetTooltip) return widgetTooltip // Then try input-based tooltip lookup - const key = `nodeDefs.${normalizeI18nKey(unref(nodeType))}.inputs.${normalizeI18nKey(widget.name)}.tooltip` - const inputTooltip = nodeDef.value.inputs?.[widget.name]?.tooltip ?? '' - return stRaw(key, inputTooltip) + return resolveNodeDefInputText( + 'tooltip', + unref(nodeType), + widget.name, + nodeDef.value.inputs?.[widget.name]?.tooltip + ) } /** diff --git a/src/services/litegraphService.test.ts b/src/services/litegraphService.test.ts index 25a065bae5f..74421f3bd81 100644 --- a/src/services/litegraphService.test.ts +++ b/src/services/litegraphService.test.ts @@ -1,12 +1,15 @@ import { createTestingPinia } from '@pinia/testing' import { setActivePinia } from 'pinia' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' vi.mock('@/scripts/app', () => ({ app: { canvas: undefined }, ComfyApp: class {} })) +import { i18n } from '@/i18n' +import { LiteGraph } from '@/lib/litegraph/src/litegraph' +import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema' import { app } from '@/scripts/app' import { useLitegraphService } from '@/services/litegraphService' @@ -41,3 +44,56 @@ describe('useLitegraphService().getCanvasCenter', () => { expect(center).toEqual([110, 70]) }) }) + +describe('useLitegraphService().registerNodeDef slot text', () => { + const nodeName = 'TestBackendSlotText' + + const nodeDef: ComfyNodeDefV1 = { + name: nodeName, + display_name: 'Test Backend Slot Text', + category: 'testing', + python_module: 'nodes', + description: '', + input: { + required: { + seed: ['INT', { display_name: 'Live Seed Label', default: 0 }], + mask: ['MASK', { display_name: 'Live Mask Label' }] + } + }, + output: ['LATENT'], + output_name: ['Live Latent Name'], + output_node: false + } + + function mergeBundledSlotText(text: string | null) { + i18n.global.mergeLocaleMessage('en', { + nodeDefs: { + [nodeName]: { + inputs: { seed: { name: text }, mask: { name: text } }, + outputs: { 0: { name: text } } + } + } + }) + } + + beforeEach(async () => { + setActivePinia(createTestingPinia({ stubActions: false })) + mergeBundledSlotText('stale bundled label') + await useLitegraphService().registerNodeDef(nodeName, nodeDef) + }) + + afterEach(() => { + mergeBundledSlotText(null) + }) + + it('labels widgets, sockets and outputs from the live backend', () => { + const node = LiteGraph.createNode(nodeName) + const localizedName = (name: string) => + node?.inputs.find((input) => input.name === name)?.localized_name + + expect(node?.widgets?.[0]?.label).toBe('Live Seed Label') + expect(localizedName('seed')).toBe('Live Seed Label') + expect(localizedName('mask')).toBe('Live Mask Label') + expect(node?.outputs[0]?.localized_name).toBe('Live Latent Name') + }) +}) diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index b4beadc87d1..3d13775bf91 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -11,7 +11,12 @@ import { isPreviewPseudoWidget } from '@/core/graph/subgraph/promotionUtils' import { applyDynamicInputs } from '@/core/graph/widgets/dynamicWidgets' -import { st, t } from '@/i18n' +import { + resolveNodeDefInputText, + resolveNodeDefOutputText, + st, + t +} from '@/i18n' import { LGraphCanvas, LGraphEventMode, @@ -207,17 +212,16 @@ export const useLitegraphService = () => { } /** - * @internal The key for the node definition in the i18n file. + * @internal The node definition name used to resolve the node's i18n text. */ - function nodeKey(node: LGraphNode): string { - return `nodeDefs.${normalizeI18nKey(node.constructor.nodeData?.name ?? '')}` + function nodeDefName(node: LGraphNode): string { + return node.constructor.nodeData?.name ?? '' } /** * @internal Add input sockets to the node. (No widget) */ function addInputSocket(node: LGraphNode, inputSpec: InputSpec) { const inputName = inputSpec.name - const nameKey = `${nodeKey(node)}.inputs.${normalizeI18nKey(inputName)}.name` const widgetConstructor = widgetStore.widgets.get( inputSpec.widgetType ?? inputSpec.type ) @@ -229,7 +233,13 @@ export const useLitegraphService = () => { const input = node.addInput(inputName, inputSpec.type, { shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined, - localized_name: st(nameKey, inputName) + localized_name: resolveNodeDefInputText( + 'name', + nodeDefName(node), + inputName, + inputSpec.display_name, + inputName + ) }) input.label ??= inputSpec.display_name } @@ -279,7 +289,14 @@ export const useLitegraphService = () => { widgetInputSpec.type = inputSpec.widgetType } const inputName = inputSpec.name - const nameKey = `${nodeKey(node)}.inputs.${normalizeI18nKey(inputName)}.name` + const resolveLabel = (fallback: string) => + resolveNodeDefInputText( + 'name', + nodeDefName(node), + inputName, + widgetInputSpec.display_name, + fallback + ) const widgetConstructor = widgetStore.widgets.get(widgetInputSpec.type) if (!widgetConstructor || inputSpec.forceInput) return @@ -295,8 +312,7 @@ export const useLitegraphService = () => { ) ?? {} if (widget) { - widget.label = st( - nameKey, + widget.label = resolveLabel( widget.label ?? widgetInputSpec.display_name ?? inputName ) widget.options ??= {} @@ -312,7 +328,7 @@ export const useLitegraphService = () => { const inputSpecV1 = transformInputSpecV2ToV1(widgetInputSpec) node.addInput(inputName, inputSpec.type, { shape: inputSpec.isOptional ? RenderShape.HollowCircle : undefined, - localized_name: st(nameKey, inputName), + localized_name: resolveLabel(inputName), widget: { name: inputName, [GET_CONFIG]: () => inputSpecV1 } }) } @@ -344,7 +360,6 @@ export const useLitegraphService = () => { // TODO: Fix the typing at the node spec level const type = output.type === 'COMFY_MATCHTYPE_V3' ? '*' : output.type const shapeOptions = is_list ? { shape: LiteGraph.GRID_SHAPE } : {} - const nameKey = `${nodeKey(node)}.outputs.${output.index}.name` const typeKey = `dataTypes.${normalizeI18nKey(type)}` const outputOptions = { ...shapeOptions, @@ -352,7 +367,15 @@ export const useLitegraphService = () => { // e.g. // - type ("INT"); name ("Positive") => translate name // - type ("FLOAT"); name ("FLOAT") => translate type - localized_name: type !== name ? st(nameKey, name) : st(typeKey, name) + localized_name: + type !== name + ? resolveNodeDefOutputText( + 'name', + nodeDefName(node), + output.index, + name + ) + : st(typeKey, name) } node.addOutput(name, type, outputOptions) } From 20715a4db850d356c204552fd91de42763b32d8c Mon Sep 17 00:00:00 2001 From: jaeone lee <89377375+jaeone94@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:35:37 +0900 Subject: [PATCH 03/62] fix(workflow): repair the A1111 import lifecycle and report broken installs accurately (#14556) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Splits out of #14251. Five lifecycle fixes on the A1111 image-import path. 30 production lines. ## What Dropping an A1111-generated PNG parses its `parameters` string and builds a ComfyUI graph from it. The path had four defects that only show up when something goes wrong, plus one that shows up always: 1. **`afterLoadNewGraph` was not awaited.** It suspends before the active workflow is reassigned, so `rootGraph.serialize()` on the next line captured the *outgoing* graph — the new tab was born dirty against a stale baseline. 2. **A rejection escaped an async DOM handler.** `importA1111` awaits `api.getEmbeddings()`, which does not check `resp.ok`. On a 500 with an HTML body it throws, `fileInput.value = ''` never runs, the input still holds the file, re-selecting it fires no `change` event, and Open silently does nothing on every retry. Now: `try`/`catch` with a toast, `finally` resets the input. 3. **Two identical alerts for one file.** The invalid-structure `else` and the parse `catch` each called `showErrorOnFileLoad`, then fell through to the final call at the end of `handleFile`. Those two are the `else` and `catch` of one `try`, so the maximum is two alerts, not three. 4. **`beforeLoadNewGraph()` ran before an import that might bail.** It calls `domWidgetStore.clear()`, and nothing re-registers on a bail path — a workflow with a multiline prompt on screen lost its DOM widget overlays when the user dropped a PNG that did not parse. It now runs immediately before the mutation, and the A1111 path gets the subgraph guard `clean()` already had. 5. **No message at all when required node types are unavailable, and silent corruption of the open workflow.** `importA1111` logged to the console and returned `void`. Because the call was unawaited, `afterLoadNewGraph` then registered the user's *unchanged* graph under the dropped file's name, after `beforeLoadNewGraph` had already cleared `domWidgetStore`. See below. ## The message The seven types this importer needs — `CheckpointLoaderSimple`, `CLIPSetLastLayer`, `CLIPTextEncode`, `KSampler`, `EmptyLatentImage`, `VAEDecode`, `SaveImage` — are all **core nodes**, as are `LoraLoader` and the hires chain. Their absence does not mean a node pack is missing. It means the backend did not load, or the install is broken. So this path deliberately writes nothing to the missing-node panel: no card, no entry, no placeholder. A type that was never added to the graph does not belong in a list of nodes missing *from the graph*, and naming the individual types would read as "install this pack" and send people looking for something that does not exist. ``` "Could not load the workflow because this ComfyUI installation is missing core nodes. Check that the backend started correctly." ``` `importA1111` returns `Promise<'imported' | 'not-a1111' | 'core-nodes-unavailable'>` — three string literals, replacing `Promise`. The boolean could not distinguish "bailed and already told the user" from "bailed silently", which is how an ordinary A1111 PNG could vanish with no feedback at all: A1111 omits the `Negative prompt:` line entirely when the negative prompt is empty. The `core-nodes-unavailable` return happens **before** the graph is touched, so a failed import leaves the open workflow intact. `pnginfo.test.ts` asserts that directly. ## What this deliberately does not do `pnginfo.ts` is **+8 −4**, with zero re-indentation (`git diff` and `git diff -w` report the same line count). The nesting in that file is not pretty and it is not this PR's business. An earlier revision restructured it; that diff was 759 lines, ~72% of it re-indentation, and none of it fixed a bug. If it deserves a refactor it deserves a PR where a reviewer sees only that. ## Verification 6 unit tests across `app.test.ts`, `pnginfo.test.ts` and `ui.test.ts`, each mutation-proved. typecheck, lint, format, knip clean. Full unit suite: only pre-existing timeout flakes, confirmed by re-running the same files at the merge base and getting byte-identical results. ## Related - Follow-up to #14251 (closed) - Independent of #14555 and of the narrow submission fix — no ordering constraint --- src/locales/en/main.json | 1 + src/scripts/app.test.ts | 128 ++++++++++++++++++++++++++++++++++-- src/scripts/app.ts | 18 +++-- src/scripts/pnginfo.test.ts | 69 ++++++++++++++++++- src/scripts/pnginfo.ts | 21 ++++-- src/scripts/ui.test.ts | 86 ++++++++++++++++++++++++ src/scripts/ui.ts | 10 ++- 7 files changed, 316 insertions(+), 17 deletions(-) create mode 100644 src/scripts/ui.test.ts diff --git a/src/locales/en/main.json b/src/locales/en/main.json index a6c4b35e05a..229253452f5 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -2277,6 +2277,7 @@ "failedToExportModel": "Failed to export model as {format}", "exportSuccess": "Successfully exported model as {format}", "fileLoadError": "Unable to find workflow in {fileName}", + "a1111CoreNodesUnavailable": "Could not load the workflow because this ComfyUI installation is missing core nodes. Check that the backend started correctly.", "dropFileError": "Unable to process dropped item: {error}", "missingMediaVerificationFailed": "Failed to verify missing media. Some inputs may not be shown in the Errors tab.", "missingModelVerificationFailed": "Failed to verify missing models. Some models may not be shown in the Errors tab.", diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index e78450bfe69..b870a45bb88 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -39,6 +39,10 @@ import { createTestSubgraphNode } from '@/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers' import { useWidgetValueStore } from '@/stores/widgetValueStore' +import type { importA1111 } from './pnginfo' +import type { useWorkflowService } from '@/platform/workflow/core/services/workflowService' + +type WorkflowService = ReturnType const { mockApiKeyAuthStore, @@ -48,7 +52,9 @@ const { mockExtensionService, mockNodeOutputStore, mockWorkspaceWorkflow, - mockRefreshMissingModelPipeline + mockRefreshMissingModelPipeline, + mockImportA1111, + mockWorkflowService } = vi.hoisted(() => ({ mockApiKeyAuthStore: { getApiKey: vi.fn() @@ -74,7 +80,13 @@ const { mockWorkspaceWorkflow: { activeWorkflow: null as ComfyWorkflow | null }, - mockRefreshMissingModelPipeline: vi.fn() + mockRefreshMissingModelPipeline: vi.fn(), + mockImportA1111: vi.fn(), + mockWorkflowService: { + beforeLoadNewGraph: vi.fn(), + afterLoadNewGraph: vi.fn(), + showPendingWarnings: vi.fn() + } })) vi.mock('@/utils/litegraphUtil', () => ({ @@ -111,6 +123,14 @@ vi.mock('@/scripts/metadata/parser', () => ({ getWorkflowDataFromFile: vi.fn() })) +vi.mock('./pnginfo', () => ({ + importA1111: mockImportA1111 +})) + +vi.mock('@/platform/workflow/core/services/workflowService', () => ({ + useWorkflowService: vi.fn(() => mockWorkflowService) +})) + vi.mock('@/extensions/core/load3d/Load3dUtils', () => ({ default: { uploadFile: vi.fn() @@ -160,7 +180,8 @@ function createMockCanvas(): Partial { return { graph: mockGraph as LGraph, draw: vi.fn(), - selectItems: vi.fn() + selectItems: vi.fn(), + setGraph: vi.fn() } } @@ -187,7 +208,7 @@ describe('ComfyApp', () => { beforeEach(() => { setActivePinia(createTestingPinia({ stubActions: false })) - vi.clearAllMocks() + vi.resetAllMocks() app = new ComfyApp() mockCanvas = createMockCanvas() as LGraphCanvas app.canvas = mockCanvas as LGraphCanvas @@ -196,6 +217,8 @@ describe('ComfyApp', () => { mockAuthStore.getAuthToken.mockResolvedValue(undefined) mockExtensionService.invokeExtensions.mockReturnValue([]) mockExtensionService.invokeExtensionsAsync.mockResolvedValue(undefined) + mockImportA1111.mockResolvedValue('imported') + mockWorkflowService.afterLoadNewGraph.mockResolvedValue() mockSettingStore.get.mockImplementation((key: string) => key === 'Comfy.RightSidePanel.ShowErrorsTab' ? true : undefined ) @@ -1202,6 +1225,103 @@ describe('ComfyApp', () => { mockNode ) }) + + it.each([ + ['an invalid structure', '[]'], + ['invalid JSON', '{invalid'] + ])('shows one error for %s', async (_case, workflow) => { + const consoleError = vi + .spyOn(console, 'error') + .mockImplementation(() => {}) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ workflow }) + + await app.handleFile(createTestFile('broken.json', 'application/json')) + + expect(mockToastStore.addAlert).toHaveBeenCalledTimes(1) + expect(mockToastStore.addAlert).toHaveBeenCalledWith( + 'Unable to find workflow in broken.json' + ) + consoleError.mockRestore() + }) + + it('preserves the current graph when A1111 core nodes are unavailable', async () => { + const graph = new LGraph() + const parameters = 'positive\nNegative prompt: negative\nSteps: 20' + Reflect.set(app, 'rootGraphInternal', graph) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ parameters }) + mockImportA1111.mockResolvedValue('core-nodes-unavailable') + + await app.handleFile(createTestFile('a1111.png', 'image/png')) + + expect(mockImportA1111).toHaveBeenCalledWith( + graph, + parameters, + expect.any(Function) + ) + expect(mockCanvas.setGraph).not.toHaveBeenCalled() + expect(mockWorkflowService.beforeLoadNewGraph).not.toHaveBeenCalled() + expect(mockWorkflowService.afterLoadNewGraph).not.toHaveBeenCalled() + expect(mockToastStore.addAlert).toHaveBeenCalledOnce() + expect(mockToastStore.addAlert).toHaveBeenCalledWith( + 'Could not load the workflow because this ComfyUI installation is missing core nodes. Check that the backend started correctly.' + ) + }) + + it('shows one file-load error when parameters are not A1111-shaped', async () => { + const graph = new LGraph() + const parameters = 'positive\nSteps: 20' + Reflect.set(app, 'rootGraphInternal', graph) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ parameters }) + mockImportA1111.mockResolvedValue('not-a1111') + + await app.handleFile(createTestFile('parameters.png', 'image/png')) + + expect(mockToastStore.addAlert).toHaveBeenCalledOnce() + expect(mockToastStore.addAlert).toHaveBeenCalledWith( + 'Unable to find workflow in parameters.png' + ) + expect(mockWorkflowService.beforeLoadNewGraph).not.toHaveBeenCalled() + expect(mockWorkflowService.afterLoadNewGraph).not.toHaveBeenCalled() + }) + + it('awaits persistence and orders its clear callback before setGraph', async () => { + const graph = new LGraph() + const parameters = 'positive\nNegative prompt: negative\nSteps: 20' + Reflect.set(app, 'rootGraphInternal', graph) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ parameters }) + mockImportA1111.mockImplementation( + async (_graph, _parameters, beforeGraphClear) => { + beforeGraphClear?.() + return 'imported' + } + ) + let resolveAfterLoad: (() => void) | undefined + const afterLoad = new Promise((resolve) => { + resolveAfterLoad = resolve + }) + mockWorkflowService.afterLoadNewGraph.mockReturnValue(afterLoad) + + let settled = false + const handleFile = app + .handleFile(createTestFile('a1111.png', 'image/png')) + .then(() => { + settled = true + }) + await vi.waitFor(() => + expect(mockWorkflowService.afterLoadNewGraph).toHaveBeenCalled() + ) + + expect(mockCanvas.setGraph).toHaveBeenCalledWith(graph) + expect(mockWorkflowService.beforeLoadNewGraph).toHaveBeenCalledOnce() + expect( + mockWorkflowService.beforeLoadNewGraph.mock.invocationCallOrder[0] + ).toBeLessThan(vi.mocked(mockCanvas.setGraph).mock.invocationCallOrder[0]) + expect(settled).toBe(false) + + resolveAfterLoad?.() + await handleFile + expect(settled).toBe(true) + }) }) describe('drop handler', () => { diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 31433dcb251..43e2fd8df4e 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1982,11 +1982,9 @@ export class ComfyApp { console.error( 'Invalid workflow structure, trying parameters fallback' ) - this.showErrorOnFileLoad(file) } } catch (err) { console.error('Failed to parse workflow:', err) - this.showErrorOnFileLoad(file) // Fall through to check parameters as fallback } } @@ -2009,9 +2007,19 @@ export class ComfyApp { // Use parameters strictly as the final fallback if (parameters && typeof parameters === 'string') { - useWorkflowService().beforeLoadNewGraph() - importA1111(this.rootGraph, parameters) - useWorkflowService().afterLoadNewGraph( + const outcome = await importA1111(this.rootGraph, parameters, () => { + useWorkflowService().beforeLoadNewGraph() + this.canvas.setGraph(this.rootGraph) + }) + if (outcome === 'core-nodes-unavailable') { + useToastStore().addAlert(t('toastMessages.a1111CoreNodesUnavailable')) + return + } + if (outcome === 'not-a1111') { + this.showErrorOnFileLoad(file) + return + } + await useWorkflowService().afterLoadNewGraph( fileName, this.rootGraph.serialize() as unknown as ComfyWorkflowJSON ) diff --git a/src/scripts/pnginfo.test.ts b/src/scripts/pnginfo.test.ts index c10aaa4b1ab..ae416be03a9 100644 --- a/src/scripts/pnginfo.test.ts +++ b/src/scripts/pnginfo.test.ts @@ -2,6 +2,9 @@ import fs from 'fs' import path from 'path' import { afterEach, describe, expect, it, vi } from 'vitest' +import { LGraph, LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph' + +import { api } from './api' import { getFromAvifFile } from './metadata/avif' import { getFromFlacFile } from './metadata/flac' import { getFromPngFile } from './metadata/png' @@ -10,9 +13,16 @@ import { getFlacMetadata, getLatentMetadata, getPngMetadata, - getWebpMetadata + getWebpMetadata, + importA1111 } from './pnginfo' +vi.mock('./api', () => ({ + api: { + getEmbeddings: vi.fn() + } +})) + vi.mock('./metadata/png', () => ({ getFromPngFile: vi.fn() })) @@ -234,3 +244,60 @@ describe('format-specific metadata wrappers', () => { expect(result).toEqual({ workflow: '{"avif":1}' }) }) }) + +describe('importA1111', () => { + const parameters = + 'positive\nNegative prompt: negative\nSteps: 20, Sampler: Euler, CFG scale: 7, Seed: 1, Size: 512x512, Model: model.safetensors' + + it.each([ + ['has no steps', 'positive'], + ['has no options', 'positive\nNegative prompt: negative\nSteps:'], + ['has no negative prompt', 'positive\nSteps: 20'] + ])('returns not-a1111 when parameters %s', async (_case, input) => { + const graph = new LGraph() + const beforeGraphClear = vi.fn() + vi.mocked(api.getEmbeddings).mockResolvedValue([]) + + const imported = await importA1111(graph, input, beforeGraphClear) + + expect(imported).toBe('not-a1111') + expect(beforeGraphClear).not.toHaveBeenCalled() + }) + + it('returns core-nodes-unavailable without clearing the graph', async () => { + const graph = new LGraph() + const clear = vi.spyOn(graph, 'clear') + const beforeGraphClear = vi.fn() + vi.mocked(api.getEmbeddings).mockResolvedValue([]) + vi.spyOn(LiteGraph, 'createNode').mockReturnValue(null) + + const imported = await importA1111(graph, parameters, beforeGraphClear) + + expect(imported).toBe('core-nodes-unavailable') + expect(beforeGraphClear).not.toHaveBeenCalled() + expect(clear).not.toHaveBeenCalled() + }) + + it('runs the lifecycle callback immediately before clearing the graph', async () => { + const graph = new LGraph() + const clear = vi.spyOn(graph, 'clear') + const beforeGraphClear = vi.fn() + vi.mocked(api.getEmbeddings).mockResolvedValue([]) + vi.spyOn(console, 'warn').mockImplementation(() => {}) + vi.spyOn(graph, 'arrange').mockImplementation(() => {}) + vi.spyOn(LiteGraph, 'createNode').mockImplementation((type) => { + const node = new LGraphNode(type) + node.type = type + vi.spyOn(node, 'connect').mockReturnValue(null) + return node + }) + + const imported = await importA1111(graph, parameters, beforeGraphClear) + + expect(imported).toBe('imported') + expect(beforeGraphClear).toHaveBeenCalledOnce() + expect(beforeGraphClear.mock.invocationCallOrder[0]).toBeLessThan( + clear.mock.invocationCallOrder[0] + ) + }) +}) diff --git a/src/scripts/pnginfo.ts b/src/scripts/pnginfo.ts index c27ee505282..ddebb685034 100644 --- a/src/scripts/pnginfo.ts +++ b/src/scripts/pnginfo.ts @@ -180,10 +180,16 @@ interface LoraEntry { weight: number } +export type A1111ImportOutcome = + | 'imported' + | 'not-a1111' + | 'core-nodes-unavailable' + export async function importA1111( graph: LGraph, - parameters: string -): Promise { + parameters: string, + beforeGraphClear?: () => void +): Promise { const p = parameters.lastIndexOf('\nSteps:') if (p > -1) { const embeddings = await api.getEmbeddings() @@ -193,7 +199,7 @@ export async function importA1111( .match( new RegExp('\\s*([^:]+:\\s*([^"\\{].*?|".*?"|\\{.*?\\}))\\s*(,|$)', 'g') ) - if (!matchResult) return + if (!matchResult) return 'not-a1111' const opts: Record = matchResult.reduce( (acc: Record, n: string) => { @@ -231,7 +237,7 @@ export async function importA1111( !saveNode ) { console.error('Failed to create required nodes for A1111 import') - return + return 'core-nodes-unavailable' } let hrSamplerNode: LGraphNode | null = null @@ -331,6 +337,7 @@ export async function importA1111( return v } + beforeGraphClear?.() graph.clear() graph.add(ckptNode) graph.add(clipSkipNode) @@ -550,7 +557,11 @@ export async function importA1111( delete opts[opt] } - console.warn('Unhandled parameters:', opts) + if (Object.keys(opts).length) { + console.warn('Unhandled parameters:', opts) + } + return 'imported' } } + return 'not-a1111' } diff --git a/src/scripts/ui.test.ts b/src/scripts/ui.test.ts new file mode 100644 index 00000000000..abd27ae616b --- /dev/null +++ b/src/scripts/ui.test.ts @@ -0,0 +1,86 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +import { ComfyUI } from './ui' + +const { mockApp } = vi.hoisted(() => ({ + mockApp: { + handleFile: vi.fn<(file: File, source: string) => Promise>(), + showErrorOnFileLoad: vi.fn(), + queuePrompt: vi.fn(), + loadGraphData: vi.fn(), + refreshComboInNodes: vi.fn(), + openClipspace: vi.fn(), + clean: vi.fn(), + lastExecutionError: null + } +})) + +vi.mock('./app', () => ({ + ComfyApp: class {}, + app: mockApp +})) + +vi.mock('./api', () => ({ + api: { + addEventListener: vi.fn() + } +})) + +vi.mock('./ui/dialog', () => ({ + ComfyDialog: class {} +})) + +vi.mock('./ui/settings', () => ({ + ComfySettingsDialog: class {} +})) + +vi.mock('./ui/toggleSwitch', () => ({ + toggleSwitch: vi.fn(() => document.createElement('div')) +})) + +describe('ComfyUI file input', () => { + beforeEach(() => { + vi.stubGlobal( + 'ResizeObserver', + class { + observe = vi.fn() + disconnect = vi.fn() + unobserve = vi.fn() + } + ) + mockApp.handleFile.mockReset() + mockApp.showErrorOnFileLoad.mockReset() + }) + + afterEach(() => { + document.body.replaceChildren() + vi.unstubAllGlobals() + }) + + it('reports rejected imports and resets the selected file', async () => { + const file = new File([''], 'a1111.png', { type: 'image/png' }) + const error = new Error('import failed') + mockApp.handleFile.mockRejectedValue(error) + new ComfyUI(mockApp) + const fileInput = document.getElementById( + 'comfy-file-input' + ) as HTMLInputElement + Object.defineProperties(fileInput, { + files: { value: [file], configurable: true }, + value: { value: 'a1111.png', writable: true, configurable: true } + }) + const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}) + + fileInput.dispatchEvent(new Event('change')) + + await vi.waitFor(() => + expect(mockApp.showErrorOnFileLoad).toHaveBeenCalledWith(file) + ) + expect(mockApp.handleFile).toHaveBeenCalledWith(file, 'file_button') + expect(consoleError).toHaveBeenCalledWith('Failed to load file:', error) + expect(consoleError.mock.invocationCallOrder[0]).toBeLessThan( + mockApp.showErrorOnFileLoad.mock.invocationCallOrder[0] + ) + expect(fileInput.value).toBe('') + }) +}) diff --git a/src/scripts/ui.ts b/src/scripts/ui.ts index df094a2c8c1..441e74079ed 100644 --- a/src/scripts/ui.ts +++ b/src/scripts/ui.ts @@ -407,8 +407,14 @@ export class ComfyUI { onchange: async () => { const file = fileInput.files?.[0] if (file) { - await app.handleFile(file, 'file_button') - fileInput.value = '' + try { + await app.handleFile(file, 'file_button') + } catch (error) { + console.error('Failed to load file:', error) + app.showErrorOnFileLoad(file) + } finally { + fileInput.value = '' + } } } }) From 8a3e9c90856c2e9cc1108ed748c9eb3a09dbc4cd Mon Sep 17 00:00:00 2001 From: Maanil Verma Date: Wed, 5 Aug 2026 08:09:10 +0530 Subject: [PATCH 04/62] feat(cloud): align logo, content and terms on one edge (#14697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > **Stacked PR 4 of 5** — cloud auth redesign. Merge in order, bottom-up. > > | | PR | What it does | > |---|---|---| > | 1 | #14694 | Dark theme, brand tokens, PP Formula shipped cloud-only | > | 2 | #14695 | Button keeps its label for screen readers while loading | > | 3 | #14696 | Brand button variants; login, sign-up and forgot-password rebuilt on them | > | 4 | #14697 | Logo, content and terms share one left edge | > | 5 | #14698 | Static hero collage becomes a video carousel | ## Summary The logo sat in its own padded header while the content column centred independently, so the two never lined up — measured 96px apart at 1600w. ## Changes - **What**: One wrapper now owns the horizontal bounds, giving the three-zone layout the design asks for: logo pinned top, content centred, terms pinned bottom, all sharing a single left edge. - Moves the terms copy — previously duplicated verbatim in both auth views — into `CloudTermsNotice`, shown via a `showTermsNotice` route meta. Other cloud routes keep the existing link footer. ## Review Focus `route.meta.showTermsNotice` swaps the footer for the terms notice on login and sign-up only. Every other cloud route — survey, user-check, forgot-password — keeps `CloudTemplateFooter` exactly as before, asserted at the route level in `onboardingCloudRoutes.test.ts`. Verified logo x === headline x at 1600 / 1280 / 1024 / 768 / 390, with no horizontal overflow at any width. Stacked on the auth panel PR. --- public/icons/logo.svg | 3 + .../components/CloudTemplate.test.ts | 72 +++++++++++++++++-- .../onboarding/components/CloudTemplate.vue | 48 ++++++++----- .../components/CloudTemplateFooter.vue | 4 +- .../components/CloudTermsNotice.vue | 44 ++++++++++++ .../onboarding/onboardingCloudRoutes.test.ts | 11 +++ .../cloud/onboarding/onboardingCloudRoutes.ts | 2 + 7 files changed, 158 insertions(+), 26 deletions(-) create mode 100644 public/icons/logo.svg create mode 100644 src/platform/cloud/onboarding/components/CloudTermsNotice.vue diff --git a/public/icons/logo.svg b/public/icons/logo.svg new file mode 100644 index 00000000000..34210e0d662 --- /dev/null +++ b/public/icons/logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/platform/cloud/onboarding/components/CloudTemplate.test.ts b/src/platform/cloud/onboarding/components/CloudTemplate.test.ts index 35650cc838b..b0ab43c3876 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplate.test.ts +++ b/src/platform/cloud/onboarding/components/CloudTemplate.test.ts @@ -1,9 +1,40 @@ import { render, screen } from '@testing-library/vue' -import { describe, expect, it } from 'vitest' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { createI18n } from 'vue-i18n' import { createMemoryHistory, createRouter } from 'vue-router' import CloudTemplate from './CloudTemplate.vue' +const i18n = createI18n({ + legacy: false, + locale: 'en', + messages: { en: { g: { comfyOrgLogoAlt: 'ComfyOrg Logo' } } } +}) + +/** + * Drives the real `useMediaQuery`, so the breakpoint the component asks for is + * part of what these tests pin rather than something a mock papers over. + */ +function stubViewportWidth(pixels: number) { + vi.stubGlobal( + 'matchMedia', + vi.fn((query: string) => { + const minWidth = /min-width:\s*([\d.]+)(px|rem)/.exec(query) + const threshold = minWidth + ? Number(minWidth[1]) * (minWidth[2] === 'rem' ? 16 : 1) + : 0 + return { + matches: pixels >= threshold, + media: query, + onchange: null, + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn() + } + }) + ) +} + const renderWithMeta = async (meta: Record) => { const router = createRouter({ history: createMemoryHistory(), @@ -13,23 +44,56 @@ const renderWithMeta = async (meta: Record) => { await router.isReady() return render(CloudTemplate, { global: { - plugins: [router], + plugins: [router, i18n], stubs: { CloudHeroCarousel: { template: '
' }, - CloudTemplateFooter: true + CloudTemplateFooter: { template: '
' }, + CloudTermsNotice: { template: '
' } } } }) } +afterEach(() => { + vi.unstubAllGlobals() +}) + describe('CloudTemplate', () => { - it('shows the hero carousel when the route does not hide it', async () => { + it('shows the hero carousel on a wide viewport', async () => { + stubViewportWidth(1280) await renderWithMeta({}) expect(screen.getByTestId('hero')).toBeInTheDocument() }) it('hides the hero carousel when route.meta.hideHero is set', async () => { + stubViewportWidth(1280) await renderWithMeta({ hideHero: true }) expect(screen.queryByTestId('hero')).not.toBeInTheDocument() }) + + it('does not mount the hero carousel on a tablet-width viewport', async () => { + stubViewportWidth(1024) + await renderWithMeta({}) + expect( + screen.queryByTestId('hero'), + 'mounting below `xl` would download the hero video on devices that never display it' + ).not.toBeInTheDocument() + }) + + it('swaps the footer for the terms notice when the route asks for it', async () => { + stubViewportWidth(1280) + await renderWithMeta({ showTermsNotice: true }) + expect(screen.getByTestId('terms')).toBeInTheDocument() + expect( + screen.queryByTestId('footer'), + 'the notice and the generic footer are alternatives, never both' + ).not.toBeInTheDocument() + }) + + it('shows the generic footer by default', async () => { + stubViewportWidth(1280) + await renderWithMeta({}) + expect(screen.getByTestId('footer')).toBeInTheDocument() + expect(screen.queryByTestId('terms')).not.toBeInTheDocument() + }) }) diff --git a/src/platform/cloud/onboarding/components/CloudTemplate.vue b/src/platform/cloud/onboarding/components/CloudTemplate.vue index a05717835a9..b4548066bf7 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplate.vue +++ b/src/platform/cloud/onboarding/components/CloudTemplate.vue @@ -1,37 +1,47 @@ - diff --git a/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue b/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue index 049747903e4..4ca3db216d2 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue +++ b/src/platform/cloud/onboarding/components/CloudTemplateFooter.vue @@ -1,7 +1,5 @@ + + diff --git a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts index 1aaf1349565..89cb3edbec5 100644 --- a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts +++ b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts @@ -33,6 +33,17 @@ describe('cloudOnboardingRoutes', () => { expect(consentRoute?.path).toBe('consent') }) + it('forgot-password keeps the footer its terms and help links live in', () => { + const cloudLayout = cloudOnboardingRoutes.find((r) => r.path === '/cloud') + const forgotPassword = cloudLayout?.children?.find( + (c) => c.name === 'cloud-forgot-password' + ) + + expect(forgotPassword).toBeDefined() + expect(forgotPassword?.meta?.hideFooter).toBeFalsy() + expect(forgotPassword?.meta?.showTermsNotice).toBeFalsy() + }) + it('consent route carries no requiresAuth meta', () => { const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') const consentRoute = oauthLayout?.children?.find( diff --git a/src/platform/cloud/onboarding/onboardingCloudRoutes.ts b/src/platform/cloud/onboarding/onboardingCloudRoutes.ts index 2dda8e45c9a..dbee2617a80 100644 --- a/src/platform/cloud/onboarding/onboardingCloudRoutes.ts +++ b/src/platform/cloud/onboarding/onboardingCloudRoutes.ts @@ -54,6 +54,7 @@ export const cloudOnboardingRoutes: RouteRecordRaw[] = [ name: 'cloud-login', component: () => import('@/platform/cloud/onboarding/CloudLoginView.vue'), + meta: { showTermsNotice: true }, beforeEnter: async (to, _from, next) => { if (!to.query.switchAccount) { const { useCurrentUser } = @@ -72,6 +73,7 @@ export const cloudOnboardingRoutes: RouteRecordRaw[] = [ name: 'cloud-signup', component: () => import('@/platform/cloud/onboarding/CloudSignupView.vue'), + meta: { showTermsNotice: true }, beforeEnter: async (to, _from, next) => { if (!to.query.switchAccount) { const { useCurrentUser } = From b1028b27a81bd1f8b101180f2507c4b67a66cdec Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Tue, 4 Aug 2026 20:07:02 -0700 Subject: [PATCH 05/62] fix: block canvas undo while modal is open (#14718) I will refactor the entire keybinding system later, this is a hotfix for the cloud/1.49 release ## Summary Block legacy canvas undo/redo shortcuts while a modal is open. This follows up on #14024: command keybindings were guarded there, but `ChangeTracker` handles Ctrl/Cmd+Z independently in a capture-phase listener and could still restore workflow state behind a dialog. ## Changes - **What**: Share the existing modal predicate with `ChangeTracker` and add focused unit regression coverage for the real window shortcut path. ## Review Focus Confirm the modal check runs synchronously before `ChangeTracker` schedules undo/redo work, while popover content remains excluded from modal detection. ## Validation - `pnpm test:unit src/scripts/changeTracker.test.ts src/platform/keybindings/keybindingService.dialog.test.ts` (65 passed) - Pre-commit: oxfmt, type-aware oxlint, ESLint, and `pnpm typecheck` - Pre-push: `pnpm knip` --- src/platform/keybindings/keybindingService.ts | 15 +----- src/scripts/changeTracker.test.ts | 49 +++++++++++++++++++ src/scripts/changeTracker.ts | 4 ++ src/utils/modalUtil.ts | 30 ++++++++++++ 4 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 src/utils/modalUtil.ts diff --git a/src/platform/keybindings/keybindingService.ts b/src/platform/keybindings/keybindingService.ts index 0d401994c2c..d7c53f31b25 100644 --- a/src/platform/keybindings/keybindingService.ts +++ b/src/platform/keybindings/keybindingService.ts @@ -2,20 +2,13 @@ import { isCloud } from '@/platform/distribution/types' import { useSettingStore } from '@/platform/settings/settingStore' import { useCommandStore } from '@/stores/commandStore' import { useDialogStore } from '@/stores/dialogStore' +import { isModalOpen } from '@/utils/modalUtil' import { CORE_KEYBINDINGS } from './defaults' import { KeyComboImpl } from './keyCombo' import { KeybindingImpl } from './keybinding' import { useKeybindingStore } from './keybindingStore' -function hasOpenRekaDialog(): boolean { - return Array.from( - document.querySelectorAll('[role="dialog"][data-state="open"]') - ).some( - (dialog) => dialog.closest('[data-reka-popper-content-wrapper]') === null - ) -} - export function useKeybindingService() { const keybindingStore = useKeybindingStore() const commandStore = useCommandStore() @@ -57,11 +50,7 @@ export function useKeybindingService() { return } } - if ( - dialogStore.dialogStack.length > 0 || - document.querySelector('[role="dialog"][aria-modal="true"]') || - hasOpenRekaDialog() - ) { + if (isModalOpen(dialogStore.dialogStack.length)) { return } diff --git a/src/scripts/changeTracker.test.ts b/src/scripts/changeTracker.test.ts index 0aca3746a41..80cde24d4e8 100644 --- a/src/scripts/changeTracker.test.ts +++ b/src/scripts/changeTracker.test.ts @@ -1237,4 +1237,53 @@ describe('ChangeTracker', () => { expect(tracker.activeState).toEqual(changed) }) }) + + describe('keyboard shortcuts', () => { + function createRekaDialog() { + const dialog = document.createElement('div') + dialog.setAttribute('role', 'dialog') + dialog.setAttribute('data-state', 'open') + return dialog + } + + function createNativeDialog() { + const dialog = document.createElement('dialog') + dialog.setAttribute('open', '') + return dialog + } + + function createLegacyComfyModal() { + const modal = document.createElement('div') + modal.className = 'comfy-modal' + modal.style.display = 'flex' + return modal + } + + it.each([ + ['a reka dialog', createRekaDialog], + ['a native dialog', createNativeDialog], + ['a legacy comfy modal', createLegacyComfyModal] + ])('does not undo while %s is open', async (_kind, createModal) => { + const previousState = createState(1) + const currentState = createState(2) + const tracker = createTracker(currentState) + tracker.undoQueue.push(previousState) + const modal = createModal() + document.body.appendChild(modal) + + try { + ChangeTracker.init() + window.dispatchEvent( + new KeyboardEvent('keydown', { key: 'z', ctrlKey: true }) + ) + await vi.runAllTimersAsync() + + expect(app.loadGraphData).not.toHaveBeenCalled() + expect(tracker.activeState).toEqual(currentState) + expect(tracker.undoQueue).toEqual([previousState]) + } finally { + document.body.removeChild(modal) + } + }) + }) }) diff --git a/src/scripts/changeTracker.ts b/src/scripts/changeTracker.ts index ac5d719b075..5108bbcf246 100644 --- a/src/scripts/changeTracker.ts +++ b/src/scripts/changeTracker.ts @@ -8,11 +8,13 @@ import type { ComfyWorkflow } from '@/platform/workflow/management/stores/workfl import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' import type { ExecutedWsMessage } from '@/schemas/apiSchema' +import { useDialogStore } from '@/stores/dialogStore' import { useExecutionStore } from '@/stores/executionStore' import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { useQueueSettingsStore } from '@/stores/queueSettingsStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' import { serializeNodeId } from '@/types/nodeId' +import { isModalOpen } from '@/utils/modalUtil' import { api } from './api' import type { ComfyApp } from './app' @@ -515,6 +517,7 @@ export class ChangeTracker { const getCurrentChangeTracker = () => useWorkflowStore().activeWorkflow?.changeTracker const captureState = () => getCurrentChangeTracker()?.captureCanvasState() + const dialogStore = useDialogStore() let keyIgnored = false window.addEventListener( @@ -527,6 +530,7 @@ export class ChangeTracker { // If the mask editor is opened, we don't want to trigger on key events const comfyApp = app.constructor as typeof ComfyApp if (comfyApp.maskeditor_is_opended?.()) return + if (isModalOpen(dialogStore.dialogStack.length)) return const activeEl = document.activeElement requestAnimationFrame(async () => { diff --git a/src/utils/modalUtil.ts b/src/utils/modalUtil.ts new file mode 100644 index 00000000000..e948dcf662b --- /dev/null +++ b/src/utils/modalUtil.ts @@ -0,0 +1,30 @@ +function hasOpenRekaDialog(): boolean { + return Array.from( + document.querySelectorAll('[role="dialog"][data-state="open"]') + ).some( + (dialog) => dialog.closest('[data-reka-popper-content-wrapper]') === null + ) +} + +function hasOpenNativeDialog(): boolean { + return document.querySelector('dialog[open]') !== null +} + +/** ComfyDialog toggles visibility via inline display ('flex' / 'none'). */ +function hasVisibleLegacyModal(): boolean { + return Array.from( + document.querySelectorAll('.comfy-modal') + ).some( + (modal) => modal.style.display !== '' && modal.style.display !== 'none' + ) +} + +export function isModalOpen(managedDialogCount: number): boolean { + return ( + managedDialogCount > 0 || + document.querySelector('[role="dialog"][aria-modal="true"]') !== null || + hasOpenRekaDialog() || + hasOpenNativeDialog() || + hasVisibleLegacyModal() + ) +} From 636f15986ed811b1b8fb3917933f27c893049c1d Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 21:41:14 -0700 Subject: [PATCH 06/62] feat: add Instagram and X links to website footer (#14721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _Requested by **June** · [Slack thread](https://comfy-organization.slack.com/archives/C09NWURUPMF/p1785882398589369?thread_ts=1785882398.589369&cid=C09NWURUPMF)_ ## Summary Adds Instagram and X (Twitter) links to the site footer, directly under the existing YouTube link. ## Changes - **What**: The footer's "Resources" link list now shows Instagram and X below YouTube, using the site's existing profile URLs (`externalLinks.instagram`, `externalLinks.x`) and existing `nav.instagram` / `nav.x` translation strings. Before: footer listed Blog, Discord, GitHub, Docs, YouTube, Affiliate Program. After: the same list with Instagram and X inserted between YouTube and Affiliate Program. Both links open in a new tab with the same external-link arrow icon and hover styling as the other footer links (no new icon component — the site's footer links are text-based, not icon-based, so this follows that existing pattern). - **Fix (unrelated, pre-existing)**: `apps/website/e2e/minimax.spec.ts` accessed `minimaxPage.faq.items` directly, but `faq` is typed as optional on `ModelLaunchPage`. This was already broken on `main` (verified via `git stash`) and isn't covered by any CI workflow, but it blocks the repo's `apps/website` pre-commit typecheck hook for any commit touching this app, so it's fixed here with a one-line non-null assertion consistent with existing usage elsewhere in the same test suite. ## How - `apps/website/src/components/common/SiteFooter.vue`: added two entries (Instagram, X) to the `topColumns` "Resources" links array, right after the YouTube entry. - `apps/website/e2e/minimax.spec.ts`: one-line non-null assertion fix, unrelated to the footer change (see above). ## Review Focus - Confirm Instagram/X are meant to sit in the "Resources" column alongside Discord/GitHub/YouTube rather than a separate "Company"/"Contact" column. - `externalLinks.instagram` and `externalLinks.x` already existed in `src/config/routes.ts` (used in the header nav's Community dropdown) and are clean profile URLs already, with no UTM/tracking params. ## Screenshots (if applicable) image --------- Co-authored-by: Claude --- apps/website/e2e/minimax.spec.ts | 2 +- apps/website/src/components/common/SiteFooter.vue | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/website/e2e/minimax.spec.ts b/apps/website/e2e/minimax.spec.ts index b1f69df0de6..d293148bff6 100644 --- a/apps/website/e2e/minimax.spec.ts +++ b/apps/website/e2e/minimax.spec.ts @@ -17,7 +17,7 @@ const CTA_HEADING = t('minimax.cta.heading', 'en') const CTA_PRIMARY = t('minimax.cta.primaryCta', 'en') const CLOUD_URL = externalLinks.cloud const CLOUD_RUN_URL = minimaxLinks.cloudRun -const FAQS = minimaxPage.faq.items +const FAQS = minimaxPage.faq!.items const FAQ_COUNT = FAQS.length const FIRST_FAQ = FAQS[0] const PRICING_HEADING = t('pricing.title', 'en') diff --git a/apps/website/src/components/common/SiteFooter.vue b/apps/website/src/components/common/SiteFooter.vue index 92372d8b839..983f2befc74 100644 --- a/apps/website/src/components/common/SiteFooter.vue +++ b/apps/website/src/components/common/SiteFooter.vue @@ -73,6 +73,16 @@ const topColumns: { title: string; links: FooterLink[] }[] = [ href: externalLinks.youtube, external: true }, + { + label: t('nav.instagram', locale), + href: externalLinks.instagram, + external: true + }, + { + label: t('nav.x', locale), + href: externalLinks.x, + external: true + }, { label: t('footer.affiliateProgram', locale), href: routes.affiliates @@ -123,7 +133,7 @@ const contactColumn: { title: string; links: FooterLink[] } = { class="bg-primary-comfy-ink px-6 py-8 text-primary-comfy-canvas lg:px-20" >

From cfec133795c8c87dd32a872d7299230d7f434ab6 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Tue, 4 Aug 2026 23:24:12 -0700 Subject: [PATCH 07/62] chore: remove unused dependencies (#13275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove direct dependencies fallow flagged as never imported. No install-graph capability is lost: the primeuix/primevue packages remain available transitively via `primevue`, and `jiti` remains via `eslint`. Removed: - `@primeuix/forms`, `@primeuix/styled`, `@primevue/icons` (transitive via primevue) - `jiti` (transitive via eslint; only used to load the TS eslint config) - stale `@types/eslint: '-'` override (nothing requests `@types/eslint`) - the three removed packages from `knip.config.ts` ignoreDependencies Kept after verification (fallow false positives): - `eslint-plugin-playwright` — registered in `.oxlintrc.json` `jsPlugins` - `postcss-html` — `.stylelintrc.json` `customSyntax` - `@iconify-json/lucide` — design-system `loadIconSet` at build time Gates: `pnpm install` clean (catalog auto-pruned), lint / typecheck / knip pass. Stacked PR (bottom of series). Base: `drjkl/fallow` (adds the fallow dev dependency). --------- Co-authored-by: Claude Opus 4.8 Co-authored-by: Amp --- knip.config.ts | 5 +---- package.json | 4 ---- pnpm-lock.yaml | 25 ------------------------- pnpm-workspace.yaml | 5 ----- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/knip.config.ts b/knip.config.ts index 874d9a2e604..3d6f9b8dc65 100644 --- a/knip.config.ts +++ b/knip.config.ts @@ -39,10 +39,7 @@ const config: KnipConfig = { }, ignoreDependencies: [ // Weird importmap things - '@iconify/json', - '@primeuix/forms', - '@primeuix/styled', - '@primevue/icons' + '@iconify/json' ], ignore: [ // Auto generated API types diff --git a/package.json b/package.json index b63516551e5..c21a6df9596 100644 --- a/package.json +++ b/package.json @@ -78,12 +78,9 @@ "@floating-ui/vue": "catalog:", "@formkit/auto-animate": "catalog:", "@iconify/json": "catalog:", - "@primeuix/forms": "catalog:", - "@primeuix/styled": "catalog:", "@primeuix/utils": "catalog:", "@primevue/core": "catalog:", "@primevue/forms": "catalog:", - "@primevue/icons": "catalog:", "@primevue/themes": "catalog:", "@sentry/vue": "catalog:", "@sparkjsdev/spark": "catalog:", @@ -182,7 +179,6 @@ "globals": "catalog:", "happy-dom": "catalog:", "husky": "catalog:", - "jiti": "catalog:", "jsdom": "catalog:", "knip": "catalog:", "lint-staged": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4fdd4b3a6a7..af7b0f77d3a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,12 +69,6 @@ catalogs: '@playwright/test': specifier: ^1.61.1 version: 1.61.1 - '@primeuix/forms': - specifier: 0.0.2 - version: 0.0.2 - '@primeuix/styled': - specifier: 0.3.2 - version: 0.3.2 '@primeuix/utils': specifier: ^0.3.2 version: 0.3.2 @@ -84,9 +78,6 @@ catalogs: '@primevue/forms': specifier: 4.2.5 version: 4.2.5 - '@primevue/icons': - specifier: 4.2.5 - version: 4.2.5 '@primevue/themes': specifier: 4.2.5 version: 4.2.5 @@ -270,9 +261,6 @@ catalogs: husky: specifier: ^9.1.7 version: 9.1.7 - jiti: - specifier: 2.7.0 - version: 2.7.0 jsdom: specifier: ^29.1.1 version: 29.1.1 @@ -433,7 +421,6 @@ catalogs: overrides: vite: ^8.1.4 '@tiptap/pm': 2.27.2 - '@types/eslint': '-' lodash: ^4.18.0 yaml: ^2.8.3 minimatch@^9.0.0: ^9.0.7 @@ -489,12 +476,6 @@ importers: '@iconify/json': specifier: 'catalog:' version: 2.2.500 - '@primeuix/forms': - specifier: 'catalog:' - version: 0.0.2 - '@primeuix/styled': - specifier: 'catalog:' - version: 0.3.2 '@primeuix/utils': specifier: 'catalog:' version: 0.3.2 @@ -504,9 +485,6 @@ importers: '@primevue/forms': specifier: 'catalog:' version: 4.2.5(vue@3.5.39(typescript@6.0.3)) - '@primevue/icons': - specifier: 'catalog:' - version: 4.2.5(vue@3.5.39(typescript@6.0.3)) '@primevue/themes': specifier: 'catalog:' version: 4.2.5 @@ -796,9 +774,6 @@ importers: husky: specifier: 'catalog:' version: 9.1.7 - jiti: - specifier: 'catalog:' - version: 2.7.0 jsdom: specifier: 'catalog:' version: 29.1.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 9dd808e084b..beef7e3c244 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -31,12 +31,9 @@ catalog: '@lucide/vue': ^1.17.0 '@pinia/testing': ^2.0.1 '@playwright/test': ^1.61.1 - '@primeuix/forms': 0.0.2 - '@primeuix/styled': 0.3.2 '@primeuix/utils': ^0.3.2 '@primevue/core': 4.2.5 '@primevue/forms': 4.2.5 - '@primevue/icons': 4.2.5 '@primevue/themes': 4.2.5 '@sentry/vite-plugin': ^4.6.0 '@sentry/vue': ^10.32.1 @@ -99,7 +96,6 @@ catalog: gsap: ^3.14.2 happy-dom: 20.9.0 husky: ^9.1.7 - jiti: 2.7.0 jsdom: ^29.1.1 jsonata: ^2.1.0 knip: ^6.27.0 @@ -171,7 +167,6 @@ allowBuilds: overrides: vite: 'catalog:' '@tiptap/pm': 2.27.2 - '@types/eslint': '-' # Security overrides lodash: ^4.18.0 yaml: ^2.8.3 From 5a90305c4a913dad1bd601fc6f25b0dffa9f946e Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 00:21:43 -0700 Subject: [PATCH 08/62] ci: bump pnpm/action-setup to v6.0.9 (#14452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All 22 usages across 19 files were pinned to `fc06bc12`. Three reasons to move: **It predates pnpm v11 support.** That landed in the action's `v6.0.0`. This repo runs pnpm `11.13.1`. We have been running an action that does not officially support our package manager version. **The version comment is wrong.** `fc06bc12` carries *both* the `v4.4.0` and `v5.0.0` tags, so `# v4.4.0` understates what is actually pinned. Anyone auditing the pin gets a misleading answer. **It is the specific commit a pnpm maintainer fingered for OIDC publish failures.** In [pnpm/pnpm#11513](https://github.com/pnpm/pnpm/issues/11513), `pnpm publish` with trusted publishing failed with a 404; zkochan replied "The issue might be related to `pnpm/action-setup@fc06bc12…`. We had some issues with this action." The reporter moved to `v6.0.6` and it worked. That issue is closed, but nothing in pnpm itself fixed it — the fix was the action bump, and we still pin the bad commit. That last point is why this matters now: #14430 grants `id-token: write` for design-system trusted publishing, but if this pin is what was breaking OIDC, that change alone will not be enough. This also affects `desktop-ui`, `desktop-bridge-types`, and `npm-types`, which publish through the same action. Mechanical change — SHA and comment only, no inputs touched. `v5.0.0` moved the action to Node 24; `v6.0.0` added pnpm 11 support. Neither changes the input surface. Unrelated thing spotted while surveying, not changed here: `ci-tests-e2e.yaml:184` passes `version: 10`, pinning pnpm 10 in that one job while `packageManager` says 11.13.1. Might be deliberate, worth a look. --- .github/actions/setup-frontend/action.yaml | 2 +- .github/workflows/api-update-electron-api-types.yaml | 2 +- .github/workflows/api-update-manager-api-types.yaml | 2 +- .github/workflows/ci-dist-telemetry-scan.yaml | 2 +- .github/workflows/ci-oss-assets-validation.yaml | 4 ++-- .github/workflows/ci-tests-e2e.yaml | 2 +- .github/workflows/ci-vercel-website-preview.yaml | 4 ++-- .github/workflows/pr-claude-review.yaml | 2 +- .github/workflows/publish-design-system.yaml | 2 +- .github/workflows/publish-desktop-bridge-types.yaml | 2 +- .github/workflows/publish-desktop-ui.yaml | 2 +- .github/workflows/release-draft-create.yaml | 2 +- .github/workflows/release-npm-types.yaml | 2 +- .github/workflows/release-pypi-dev.yaml | 2 +- .github/workflows/release-version-bump.yaml | 2 +- .github/workflows/release-weekly-comfyui.yaml | 4 ++-- .github/workflows/version-bump-design-system.yaml | 2 +- .github/workflows/version-bump-desktop-ui.yaml | 2 +- .github/workflows/weekly-docs-check.yaml | 2 +- 19 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/actions/setup-frontend/action.yaml b/.github/actions/setup-frontend/action.yaml index cc42f2b935e..474255ed95c 100644 --- a/.github/actions/setup-frontend/action.yaml +++ b/.github/actions/setup-frontend/action.yaml @@ -12,7 +12,7 @@ runs: # Install pnpm, Node.js, build frontend - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/api-update-electron-api-types.yaml b/.github/workflows/api-update-electron-api-types.yaml index befffc6f1d6..25ce45cc03e 100644 --- a/.github/workflows/api-update-electron-api-types.yaml +++ b/.github/workflows/api-update-electron-api-types.yaml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/api-update-manager-api-types.yaml b/.github/workflows/api-update-manager-api-types.yaml index 99a148fff7a..1f6800211be 100644 --- a/.github/workflows/api-update-manager-api-types.yaml +++ b/.github/workflows/api-update-manager-api-types.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/ci-dist-telemetry-scan.yaml b/.github/workflows/ci-dist-telemetry-scan.yaml index 8ef924825cb..b141cd8a8a3 100644 --- a/.github/workflows/ci-dist-telemetry-scan.yaml +++ b/.github/workflows/ci-dist-telemetry-scan.yaml @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Use Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/ci-oss-assets-validation.yaml b/.github/workflows/ci-oss-assets-validation.yaml index b0973054d82..8ab43deabb5 100644 --- a/.github/workflows/ci-oss-assets-validation.yaml +++ b/.github/workflows/ci-oss-assets-validation.yaml @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Use Node.js uses: actions/setup-node@v6 @@ -88,7 +88,7 @@ jobs: - uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Use Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/ci-tests-e2e.yaml b/.github/workflows/ci-tests-e2e.yaml index 0dbb235cfdf..ba43e0a96c9 100644 --- a/.github/workflows/ci-tests-e2e.yaml +++ b/.github/workflows/ci-tests-e2e.yaml @@ -170,7 +170,7 @@ jobs: if: ${{ !cancelled() && needs.changes.outputs.should-run == 'true' }} steps: - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 with: version: 10 diff --git a/.github/workflows/ci-vercel-website-preview.yaml b/.github/workflows/ci-vercel-website-preview.yaml index a85dda86ade..f75d45924e6 100644 --- a/.github/workflows/ci-vercel-website-preview.yaml +++ b/.github/workflows/ci-vercel-website-preview.yaml @@ -41,7 +41,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node uses: actions/setup-node@v6 @@ -139,7 +139,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node uses: actions/setup-node@v6 diff --git a/.github/workflows/pr-claude-review.yaml b/.github/workflows/pr-claude-review.yaml index af07fb99cc8..42a22c89dd5 100644 --- a/.github/workflows/pr-claude-review.yaml +++ b/.github/workflows/pr-claude-review.yaml @@ -29,7 +29,7 @@ jobs: ref: refs/pull/${{ github.event.pull_request.number }}/head - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/publish-design-system.yaml b/.github/workflows/publish-design-system.yaml index dd4d4d616b8..de18ed79be0 100644 --- a/.github/workflows/publish-design-system.yaml +++ b/.github/workflows/publish-design-system.yaml @@ -69,7 +69,7 @@ jobs: persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/publish-desktop-bridge-types.yaml b/.github/workflows/publish-desktop-bridge-types.yaml index 2116bbfad21..5d0da88f757 100644 --- a/.github/workflows/publish-desktop-bridge-types.yaml +++ b/.github/workflows/publish-desktop-bridge-types.yaml @@ -80,7 +80,7 @@ jobs: persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/publish-desktop-ui.yaml b/.github/workflows/publish-desktop-ui.yaml index cfa8cb21f7c..ee0dcf72843 100644 --- a/.github/workflows/publish-desktop-ui.yaml +++ b/.github/workflows/publish-desktop-ui.yaml @@ -84,7 +84,7 @@ jobs: persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/release-draft-create.yaml b/.github/workflows/release-draft-create.yaml index 5ed222046c3..380292e6a78 100644 --- a/.github/workflows/release-draft-create.yaml +++ b/.github/workflows/release-draft-create.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - uses: actions/setup-node@v6 with: diff --git a/.github/workflows/release-npm-types.yaml b/.github/workflows/release-npm-types.yaml index 5c43f353c40..0432ca38153 100644 --- a/.github/workflows/release-npm-types.yaml +++ b/.github/workflows/release-npm-types.yaml @@ -75,7 +75,7 @@ jobs: fetch-depth: 1 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/release-pypi-dev.yaml b/.github/workflows/release-pypi-dev.yaml index 315e7566b1f..ac947bf81b8 100644 --- a/.github/workflows/release-pypi-dev.yaml +++ b/.github/workflows/release-pypi-dev.yaml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v6 - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - uses: actions/setup-node@v6 with: diff --git a/.github/workflows/release-version-bump.yaml b/.github/workflows/release-version-bump.yaml index f30115d3b51..91e50c26555 100644 --- a/.github/workflows/release-version-bump.yaml +++ b/.github/workflows/release-version-bump.yaml @@ -187,7 +187,7 @@ jobs: fi - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/release-weekly-comfyui.yaml b/.github/workflows/release-weekly-comfyui.yaml index 193e30431b0..77c07a0b484 100644 --- a/.github/workflows/release-weekly-comfyui.yaml +++ b/.github/workflows/release-weekly-comfyui.yaml @@ -87,7 +87,7 @@ jobs: path: comfyui - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 with: package_json_file: frontend/package.json @@ -217,7 +217,7 @@ jobs: ref: v${{ needs.resolve-version.outputs.target_version }} - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - uses: actions/setup-node@v6 with: diff --git a/.github/workflows/version-bump-design-system.yaml b/.github/workflows/version-bump-design-system.yaml index 32d82850804..c9cf612be1c 100644 --- a/.github/workflows/version-bump-design-system.yaml +++ b/.github/workflows/version-bump-design-system.yaml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/version-bump-desktop-ui.yaml b/.github/workflows/version-bump-desktop-ui.yaml index fc20daa8b66..f47f388e89c 100644 --- a/.github/workflows/version-bump-desktop-ui.yaml +++ b/.github/workflows/version-bump-desktop-ui.yaml @@ -51,7 +51,7 @@ jobs: echo "✅ Branch '$BRANCH' exists" - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 diff --git a/.github/workflows/weekly-docs-check.yaml b/.github/workflows/weekly-docs-check.yaml index 23f4e90dc91..6be6dd95ab3 100644 --- a/.github/workflows/weekly-docs-check.yaml +++ b/.github/workflows/weekly-docs-check.yaml @@ -29,7 +29,7 @@ jobs: ref: main - name: Install pnpm - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 + uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - name: Setup Node.js uses: actions/setup-node@v6 From 49e307aba56dd18b28893e64b6ba02eb88ea5f41 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 00:30:35 -0700 Subject: [PATCH 09/62] fix(onboarding): pick the first-run nudge's copy from how the tour ended (#14677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The first-run nudge picked its copy from whether a tour _started_, so a user who skipped on step 1 — or one whose tour was torn down by a target that never mounted — was congratulated for a first result they never made. This makes the copy follow how the tour actually ended. **The nudge's visibility is unchanged: every ending still shows it.** ## The defect `FirstRunTourNudge.vue` chose its copy with `` `…nudge.${tourWasShown ? 'ran' : 'noTour'}` ``, and `tourWasShown` was assigned from `started` — the return of `engine.startTour()` in `useFirstRunTourController.ts` — which means _a tour began_, not _the user completed one_: | ending | copy before | copy now | | -------------------------------- | ------------------------------------------------ | -------- | | completed | `ran` | `ran` | | never appeared | `noTour` ✓ | `noTour` | | **skipped on step 1** | **`ran`** — "You just made your first" | `noTour` | | **abandoned (`target_timeout`)** | **`ran`**, shown alongside the `loadError` toast | `noTour` | | postponed (paywall) | `ran` | `noTour` | | `trigger_lost` | `ran` | `noTour` | The abandoned case is the sharp one: the same event raises an error toast and a congratulation. ## Changes - **What**: `finish()` in `onboardingTourStore.ts` already computes `outcome` and `skipReason`; the store now hands that on as `lastEnding` (a discriminated union, cleared when a new run is requested so the previous ending cannot speak for it). `useFirstRunTourController` derives `tourWasCompleted` from it in place of `tourWasShown`, and the nudge reserves the `ran` copy for `completed`. Every other ending gets `noTour`, which reads as "here's where to go next" for a skipper or an abandoner. - **Breaking**: none. `lastEnding` is additive; `tourWasShown` had exactly one consumer (the nudge). ## Visibility is deliberately unchanged Every ending still arms the nudge, including the ones that now read as `noTour`. That is @MaanilVerma's product decision in #14144: _"a user who saw no tour is the one who most needs somewhere to go next, so suppressing it there removes the way forward."_ #14672 tried to suppress the nudge on the abandoned ending and was closed for exactly this reason — this PR treats the copy, not the visibility, as the defect. The regression guard for that is `still offers the nudge after a tour $named` in `useFirstRunTourController.test.ts`, which asserts `nudgeArmed` for all five endings, plus a sixth test for the never-started case and a component-level check that the nudge renders whether or not the tour finished. ## Tests New coverage, 19 tests: - `onboardingTourStore.test.ts` (6) — the ending recorded for a user skip, a `target_timeout` teardown, a `trigger_lost` teardown, a walked-to-the-end tour; that a running tour has no ending; that a new run drops the last one. - `useFirstRunTourController.test.ts` (10, plus an existing never-started test extended to assert visibility) — `completed` → congratulation; `user` / `target_timeout` / `postponed` / `trigger_lost` → none; **all five endings still arm the nudge**; never-started arms it too, with no congratulation. - `FirstRunTourNudge.test.ts` (3) — completed → `ran`, unfinished → `noTour`, and the nudge appears either way. ### Mutation evidence - Revert the rule to the old semantics (`tourWasCompleted = ending?.tour === 'firstRun'`, i.e. "a tour ran"): **4 failed | 45 passed**. The four are the skipped/abandoned/postponed/lost-context copy cases. The five visibility tests stayed green, confirming they are not coupled to the copy rule. - Pin the component's copy key to `ran`: **1 failed | 10 passed**. Pin it to `noTour`: **1 failed | 10 passed**. - Restored: **374 passed (23 files)** across `src/renderer/extensions/firstRunTour` and `src/platform/onboarding`. `pnpm install --frozen-lockfile`, `format:check`, `lint`, `typecheck` and `knip` all clean. ## Review Focus - `lastEnding` carries `skipReason` although no production code reads it today — the tests name each ending, so the reason has to be observable, and it is the shape `finish()` already computes. Say the word if you would rather it be trimmed to `{ tour, outcome }`. - The controller latches `tourWasCompleted` when the nudge arms rather than deriving it live, so a later tour ending cannot rewrite the copy of a nudge already on screen. - Not verified: no e2e run. `gettingStartedTour.spec.ts` → "leaves the nudge until the upgrade dialog closes" asserts visibility only (postponed still arms), and no e2e or unit test elsewhere asserts the nudge's copy strings — checked by grep, not by running Playwright. - Telemetry is untouched: `nudge_shown` and `explore_templates_clicked` still report only `{ tour: 'firstRun' }`, so the funnel still cannot tell a toured user from a tour-less one. That is a real gap, and deliberately out of scope here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) --- .../onboarding/onboardingTourStore.test.ts | 98 +++++++++++++++++++ .../onboarding/onboardingTourStore.ts | 23 +++++ .../nudge/FirstRunTourNudge.test.ts | 35 ++++++- .../firstRunTour/nudge/FirstRunTourNudge.vue | 8 +- .../tour/useFirstRunTourController.test.ts | 82 +++++++++++++++- .../tour/useFirstRunTourController.ts | 13 ++- 6 files changed, 245 insertions(+), 14 deletions(-) diff --git a/src/platform/onboarding/onboardingTourStore.test.ts b/src/platform/onboarding/onboardingTourStore.test.ts index 8299c17b4fd..87446fca92c 100644 --- a/src/platform/onboarding/onboardingTourStore.test.ts +++ b/src/platform/onboarding/onboardingTourStore.test.ts @@ -247,6 +247,104 @@ describe('onboardingTourStore', () => { expect(skipped?.[1]).toMatchObject({ skip_reason: 'user' }) }) + describe('the ending it hands on', () => { + it('has none to report before a tour has ended', async () => { + const store = mountStore() + store.replayTour('appMode') + await nextTick() + + expect( + store.lastEnding, + 'a running tour has not ended, so nothing may act on how it did' + ).toBeNull() + }) + + it('records a deliberate dismissal as the user’s own', async () => { + const store = mountStore() + store.replayTour('appMode') + await nextTick() + + store.skip() + + expect(store.lastEnding).toEqual({ + tour: 'appMode', + outcome: 'skipped', + skipReason: 'user' + }) + }) + + it('records a tour torn down by a target that never mounted', async () => { + vi.useFakeTimers() + const store = mountStore() + store.replayTour('appMode') + await vi.advanceTimersByTimeAsync(0) + store.next() + // The deferred target (inputs list) is never registered; exhaust the wait. + await vi.advanceTimersByTimeAsync(8000) + + expect( + store.lastEnding, + 'whatever follows the tour has to tell this apart from a finished one' + ).toEqual({ + tour: 'appMode', + outcome: 'skipped', + skipReason: 'target_timeout' + }) + }) + + it('records a tour that lost the context its steps point at', async () => { + settings.store.set(TOUR_SEEN_SETTING, ['appMode']) + const store = mountStore() + enterApp('app', false) + await nextTick() + store.replayTour('appMode') + await nextTick() + + enterApp('graph', false) + await nextTick() + + expect(store.lastEnding).toEqual({ + tour: 'appMode', + outcome: 'skipped', + skipReason: 'trigger_lost' + }) + }) + + it('records a walked-to-the-end tour with no skip reason', async () => { + registerAppModeTargets() + const store = mountStore() + store.replayTour('appMode') + await nextTick() + + // Capped so a stuck tour fails instead of hanging. + for (let i = 0; i < 12 && !seenTours().includes('appMode'); i++) { + store.next() + await nextTick() + } + + expect(store.lastEnding).toEqual({ + tour: 'appMode', + outcome: 'completed' + }) + }) + + it('drops the last ending as soon as a new run is requested', async () => { + const store = mountStore() + store.replayTour('appMode') + await nextTick() + store.skip() + expect(store.lastEnding).not.toBeNull() + + store.replayTour('appMode') + await nextTick() + + expect( + store.lastEnding, + 'a run still going has no ending, and the last one does not speak for it' + ).toBeNull() + }) + }) + it('holds the card on its step while a deferred target is awaited', async () => { vi.useFakeTimers() const store = mountStore() diff --git a/src/platform/onboarding/onboardingTourStore.ts b/src/platform/onboarding/onboardingTourStore.ts index bd53394a62a..7ab68e826ac 100644 --- a/src/platform/onboarding/onboardingTourStore.ts +++ b/src/platform/onboarding/onboardingTourStore.ts @@ -28,6 +28,20 @@ import { useTourTriggers } from './useTourTriggers' const DEFER_TIMEOUT_MS = 8000 +/** + * How the last run of a tour ended. Whatever follows a tour has to know which + * ending it is following: "a tour ran" cannot tell a tour walked to the end + * apart from one the user waved away on step 1, or one a missing target tore + * down. + */ +export type TourEnding = + | { tour: EntryPath; outcome: 'completed' } + | { + tour: EntryPath + outcome: 'skipped' + skipReason: OnboardingTourSkipReason + } + /** Empty when a runtime resolver fails, so one bad graph costs only its own tour. */ async function resolveDefinition( definition: TourDefinition @@ -51,6 +65,7 @@ export const useOnboardingTourStore = defineStore('onboardingTour', () => { const telemetry = useTelemetry() const state = shallowRef(IDLE) + const lastEnding = shallowRef(null) let stepController: AbortController | null = null let lastRun = 0 @@ -283,6 +298,11 @@ export const useOnboardingTourStore = defineStore('onboardingTour', () => { if (!dispatch({ type: 'ended', run })) return + if (ending.tour) + lastEnding.value = + outcome === 'skipped' + ? { tour: ending.tour, outcome, skipReason } + : { tour: ending.tour, outcome } trackTour( outcome, outcome === 'skipped' ? skipReason : undefined, @@ -330,6 +350,8 @@ export const useOnboardingTourStore = defineStore('onboardingTour', () => { if (!definition) return false const run = nextRun() if (!dispatch({ type: 'requested', tour: entryPath, run })) return false + // A new run has no ending yet; the one before it must not speak for it. + lastEnding.value = null const built = await resolveDefinition(definition) const resolved = resolveSteps(built.steps, targetMounted) if (!resolved.length) { @@ -373,6 +395,7 @@ export const useOnboardingTourStore = defineStore('onboardingTour', () => { return { activeTour: readonly(activeTour), + lastEnding: readonly(lastEnding), step, isLast, canGoBack, diff --git a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts index b9e59941ee5..b02f06e31ec 100644 --- a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts +++ b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts @@ -15,7 +15,7 @@ const mocks = await vi.hoisted(async () => { const { ref } = await import('vue') return { nudgeArmed: ref(false), - tourWasShown: ref(true), + tourWasCompleted: ref(true), openDialogs: ref([]), dismissNudge: vi.fn(() => { mocks.nudgeArmed.value = false @@ -28,7 +28,7 @@ const mocks = await vi.hoisted(async () => { vi.mock('../tour/useFirstRunTourController', () => ({ useFirstRunTourController: () => ({ nudgeArmed: mocks.nudgeArmed, - tourWasShown: mocks.tourWasShown, + tourWasCompleted: mocks.tourWasCompleted, dismissNudge: mocks.dismissNudge }) })) @@ -71,6 +71,7 @@ describe('FirstRunTourNudge', () => { vi.clearAllMocks() vi.useFakeTimers() mocks.nudgeArmed.value = false + mocks.tourWasCompleted.value = true mocks.openDialogs.value = [] }) @@ -157,19 +158,43 @@ describe('FirstRunTourNudge', () => { ).toHaveLength(1) }) - it('offers no congratulation for a tour that never appeared', async () => { - mocks.tourWasShown.value = false + it('congratulates a tour the user walked to the end', async () => { + mocks.tourWasCompleted.value = true + mocks.nudgeArmed.value = true + renderNudge() + await vi.advanceTimersByTimeAsync(APPEAR_DELAY_MS) + + expect(screen.getByText(nudgeCopy.ran.title)).toBeTruthy() + }) + + it('offers no congratulation for a tour nobody finished', async () => { + mocks.tourWasCompleted.value = false mocks.nudgeArmed.value = true renderNudge() await vi.advanceTimersByTimeAsync(APPEAR_DELAY_MS) expect( screen.queryByText(nudgeCopy.ran.title), - 'a user whose tour never ran made nothing to be congratulated for' + 'a user who skipped, was cut off or saw no tour made no first result' ).toBeNull() expect(screen.getByText(nudgeCopy.noTour.title)).toBeTruthy() }) + it.for([{ finished: true }, { finished: false }])( + 'appears whether or not the tour finished ($finished)', + async ({ finished }) => { + mocks.tourWasCompleted.value = finished + mocks.nudgeArmed.value = true + renderNudge() + await vi.advanceTimersByTimeAsync(APPEAR_DELAY_MS) + + expect( + nudge(), + 'the copy is all that the ending changes; the way forward is offered either way' + ).not.toBeNull() + } + ) + it('stays gone once the user closes it', async () => { const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime }) mocks.nudgeArmed.value = true diff --git a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue index 083935f6ab5..3d299bcf28f 100644 --- a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue +++ b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.vue @@ -70,15 +70,17 @@ const NUDGE_IMAGE = '/assets/images/og-image.png' const APPEAR_DELAY_MS = 1500 const { t } = useI18n() -const { nudgeArmed, tourWasShown, dismissNudge } = useFirstRunTourController() +const { nudgeArmed, tourWasCompleted, dismissNudge } = + useFirstRunTourController() const dialogStore = useDialogStore() const telemetry = useTelemetry() const titleId = useId() -// A tour that never appeared made nothing to congratulate the user for. +// Only a tour walked to the end made a first result to congratulate; every +// other ending still gets a nudge, pointing at the templates instead. const copyKey = computed( () => - `onboardingCoachmarks.firstRun.nudge.${tourWasShown.value ? 'ran' : 'noTour'}` + `onboardingCoachmarks.firstRun.nudge.${tourWasCompleted.value ? 'ran' : 'noTour'}` ) const onScreen = ref(false) diff --git a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts index 038f76c1b63..6d4b038fd85 100644 --- a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts +++ b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts @@ -5,10 +5,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { effectScope, nextTick, ref } from 'vue' import type { EffectScope, Ref } from 'vue' +import type { TourEnding } from '@/platform/onboarding/onboardingTourStore' import type { CoachStep, SpotlightStep } from '@/platform/onboarding/onboardingTours' +import type { OnboardingTourSkipReason } from '@/platform/telemetry/types' const TOUR_WORKFLOW = { path: 'tour.json' } const OTHER_WORKFLOW = { path: 'other.json' } @@ -28,6 +30,7 @@ const mocks = vi.hoisted(() => ({ releaseFirstRunTargets: vi.fn(), engine: { activeTour: null as string | null, + lastEnding: null as TourEnding | null, step: null as CoachStep | null, isLast: false, startTour: vi.fn(), @@ -159,6 +162,36 @@ async function tourOnRunStep() { return { controller, started: await starting } } +/** The engine ending the tour and recording how, the way `finish()` leaves it. */ +function endTour(ending: TourEnding) { + mocks.engine.lastEnding = ending + mocks.engine.activeTour = null + mocks.engine.step = null + return nextTick() +} + +const COMPLETED: TourEnding = { tour: 'firstRun', outcome: 'completed' } + +function skippedBecause(skipReason: OnboardingTourSkipReason): TourEnding { + return { tour: 'firstRun', outcome: 'skipped', skipReason } +} + +/** Every ending short of walking the tour to the end. */ +const UNFINISHED_ENDINGS: { named: string; ending: TourEnding }[] = [ + { named: 'the user waved away on step 1', ending: skippedBecause('user') }, + { + named: 'a missing target tore down', + ending: skippedBecause('target_timeout') + }, + { named: 'the paywall parked', ending: skippedBecause('postponed') }, + { named: 'a lost context ended', ending: skippedBecause('trigger_lost') } +] + +const EVERY_ENDING: { named: string; ending: TourEnding }[] = [ + { named: 'the user walked to the end', ending: COMPLETED }, + ...UNFINISHED_ENDINGS +] + function finishRun(workflow: unknown, status: string) { mocks.workflowStatus.value = new Map(mocks.workflowStatus.value).set( workflow, @@ -209,6 +242,7 @@ describe('useFirstRunTourController', () => { mocks.vueNodesEnabled = true mocks.steps = [] mocks.engine.activeTour = null + mocks.engine.lastEnding = null mocks.engine.step = null mocks.engine.isLast = false }) @@ -644,11 +678,52 @@ describe('useFirstRunTourController', () => { ).toBe(false) }) + it('congratulates a tour the user walked to the end', async () => { + const { controller } = await tourOnRunStep() + + await endTour(COMPLETED) + + expect(controller.tourWasCompleted.value).toBe(true) + }) + + it.for(UNFINISHED_ENDINGS)( + 'congratulates nobody for a tour $named', + async ({ ending }) => { + const { controller } = await tourOnRunStep() + + await endTour(ending) + + expect( + controller.tourWasCompleted.value, + 'a tour the user never walked to the end made no first result to congratulate' + ).toBe(false) + } + ) + + it.for(EVERY_ENDING)( + 'still offers the nudge after a tour $named', + async ({ ending }) => { + const { controller } = await tourOnRunStep() + + await endTour(ending) + + expect( + controller.nudgeArmed.value, + 'suppressing the nudge takes the way forward from the user who most needs it (#14144)' + ).toBe(true) + } + ) + it('congratulates nobody when the tour never appeared', async () => { mocks.steps = [] mocks.activeWorkflow.value = TOUR_WORKFLOW mocks.engine.startTour.mockImplementation(async () => { await resolveRegisteredTour() + // The store requests the run, resolves no steps and returns to idle, so + // nothing ever calls `finish()` and no ending is recorded. + mocks.engine.activeTour = 'firstRun' + await nextTick() + mocks.engine.activeTour = null return false }) const controller = await freshController() @@ -656,11 +731,16 @@ describe('useFirstRunTourController', () => { const starting = controller.beginTour('image_z_image_turbo') await vi.advanceTimersByTimeAsync(INTRO_PREVIEW_MS) await starting + await nextTick() expect( - controller.tourWasShown.value, + controller.tourWasCompleted.value, 'a tour that resolved no steps made nothing for the nudge to celebrate' ).toBe(false) + expect( + controller.nudgeArmed.value, + 'a user who saw no tour is the one who most needs somewhere to go next' + ).toBe(true) }) it('stops offering the nudge once it is waved away', async () => { diff --git a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.ts b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.ts index ff4a0fe02aa..36cd1fda129 100644 --- a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.ts +++ b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.ts @@ -43,8 +43,8 @@ function useFirstRunTourControllerInternal() { const desktopLayout = useBreakpoints(breakpointsTailwind).greaterOrEqual('md') const tourWorkflow = shallowRef(null) const nudgeArmed = ref(false) - /** A tour that never appeared leaves the user nothing to be congratulated for. */ - const tourWasShown = ref(false) + /** Only a tour walked to the end made a first result to be congratulated for. */ + const tourWasCompleted = ref(false) // The tour's node ids are graph-local, so they only describe the workflow it // resolved against: swapping workflows leaves it pointing at strangers. @@ -125,6 +125,11 @@ function useFirstRunTourControllerInternal() { () => engine.activeTour === 'firstRun', (active) => { if (active) return + // Every ending leaves the user somewhere to go next, so every ending arms + // the nudge; only what it says depends on how the tour ended. + const ending = engine.lastEnding + tourWasCompleted.value = + ending?.tour === 'firstRun' && ending.outcome === 'completed' nudgeArmed.value = true stopOfflineGrace() releaseFirstRunTargets() @@ -147,7 +152,6 @@ function useFirstRunTourControllerInternal() { tourWorkflow.value = workflowStore.activeWorkflow ?? null runState.value = 'idle' nudgeArmed.value = false - tourWasShown.value = false registerTour( 'firstRun', () => firstRunTourSteps(templateId, runState), @@ -155,7 +159,6 @@ function useFirstRunTourControllerInternal() { ) await delay(INTRO_PREVIEW_MS) const started = await engine.startTour('firstRun') - tourWasShown.value = started if (!started) { releaseFirstRunTargets() tourWorkflow.value = null @@ -168,7 +171,7 @@ function useFirstRunTourControllerInternal() { return { beginTour, nudgeArmed: readonly(nudgeArmed), - tourWasShown: readonly(tourWasShown), + tourWasCompleted: readonly(tourWasCompleted), dismissNudge } } From 06e901fb20d21cb15fbdce941c3a424178becfa4 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 00:30:42 -0700 Subject: [PATCH 10/62] test(firstRunTour): close the two remaining mutation gaps from #14625 (#14676) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #14625. #14625 found three mutations of the first-run tour stack that leave the suite green. The first — the `GraphCanvas` activation seam — is already fixed in #14674. This PR closes the other two, so **together with #14674** the issue is complete. On its own this PR does not cover gap 1. Test-only: no source file is touched. ## Gap 2 — `hasPromptError` was asserted only in the negative The run-state watcher in `useFirstRunTourController` sources `hasNodeError || hasPromptError`. The positive case was covered for `hasNodeError` alone; the only test naming `hasPromptError` asserted that errors already on screen *before* the tour runs anything are ignored — which passes precisely when the term does nothing. Added `gives up on a run the validator refused before it reached a node`: a prompt-level refusal arriving while `runState` is `generating` must move the card to a terminal state. Without it, a prompt rejected whole never reaches a node and never gets a queue status, so the Result step spins forever. **Mutation evidence** — delete `|| executionErrorStore.hasPromptError` from the watcher source: | | before this PR | after | |---|---|---| | mutation applied | 39 passed, 0 failed (green — the gap) | 1 failed, 39 passed | | mutation reverted | 39 passed | 40 passed | ## Gap 3 — the nudge telemetry source was ungated `FirstRunTourNudge` calls `useWorkflowTemplateSelectorDialog().show('first_run_nudge')`. The existing test asserted only `toHaveBeenCalled()`, so the argument was free. Pinned it to `toHaveBeenCalledWith('first_run_nudge')`. Worth noting: `'command'` is also the *default* value of that parameter, so dropping the argument entirely regresses identically — the pinned assertion catches both. **Mutation evidence** — change the argument to `'command'`: | | before this PR | after | |---|---|---| | mutation applied | 8 passed, 0 failed (green — the gap) | 1 failed, 7 passed | | mutation reverted | 8 passed | 8 passed | ## Verification - `pnpm install --frozen-lockfile`, `pnpm format:check`, `pnpm lint`, `pnpm typecheck` — all exit 0. - `pnpm test:unit src/renderer/extensions/firstRunTour/` — 10 files, 174 passed. - Both mutations were applied and reverted individually; source files confirmed restored (`git status` shows only the two `.test.ts` files changed). ## Unverified - Gap 1 is out of scope here and is not re-verified in this branch — it is #14674's. - Mutation testing was scoped to the two named mutations and the `firstRunTour` suites; this is not a full re-run of the 31-mutation sweep from #14625. - No e2e/browser coverage was added; both gaps are unit-level assertions on existing behaviour. - CI note: `playwright-tests-chromium-sharded (2, 16)` failed on the first run in `changeTracker.spec.ts › Does not restore invalid navigation stack` (subgraph undo `expect.poll` assertions, one of which is already annotated `Currently bugged:`). Unrelated to this diff, which touches no source and no `browser_tests`. It passed on re-run; all 51 non-skipped checks now pass. Co-authored-by: Claude Opus 5 (1M context) --- .../firstRunTour/nudge/FirstRunTourNudge.test.ts | 5 ++++- .../tour/useFirstRunTourController.test.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts index b02f06e31ec..bfa2a773a44 100644 --- a/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts +++ b/src/renderer/extensions/firstRunTour/nudge/FirstRunTourNudge.test.ts @@ -226,7 +226,10 @@ describe('FirstRunTourNudge', () => { await user.click(screen.getByTestId('first-run-nudge-explore')) - expect(mocks.showTemplates).toHaveBeenCalled() + expect( + mocks.showTemplates, + 'the source is what separates a nudge conversion from a command-palette one, and it defaults to command' + ).toHaveBeenCalledWith('first_run_nudge') expect(mocks.dismissNudge).toHaveBeenCalled() expect(mocks.trackOnboardingTour).toHaveBeenCalledWith( 'explore_templates_clicked', diff --git a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts index 6d4b038fd85..ba58cb1e851 100644 --- a/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts +++ b/src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts @@ -621,6 +621,19 @@ describe('useFirstRunTourController', () => { ).toBe('failed') }) + it('gives up on a run the validator refused before it reached a node', async () => { + await tourOnRunStep() + mountRunButton('queue-button', () => {}).click() + + mocks.executionErrors.hasPromptError = true + await nextTick() + + expect( + mocks.runState.value, + 'a prompt refused whole never reaches a node, so no node error and no status will ever end the wait' + ).toBe('failed') + }) + it('leaves errors alone until the tour has run something', async () => { await tourOnRunStep() From ce6d5dc8ff473d6e89140a0dce1b329a8ad9a8c7 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 00:30:50 -0700 Subject: [PATCH 11/62] test: resolve two heavy dynamic imports out of the test body (#14675) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #14666 ## The failure Both tests `await` a large module graph **inside the test body**, where the time is billed against the 5 s `testTimeout`. They were never close to safe. Measured on this branch's parent, in isolation, on an idle machine: ``` ✓ GraphView - reconnect wiring > wires the reconnected event ... 3017ms ✓ cloudOnboardingRoutes > lazily resolves the /oauth layout ... 4097ms ``` 60 % and 82 % of the budget with zero contention. Under a full 1091-file run the worker pool serialises transform work behind other files and both slide past 5000 ms — hence the 5005 ms / 5002 ms in the issue, and hence "passes in isolation". The cost is transform, not the code under test: - `onboardingCloudRoutes` calls the two real route loaders, compiling `OAuthLayoutView.vue`, `OAuthConsentView.vue` and their whole import graphs, to assert `toHaveProperty('default')`. - `GraphView` did `await import('./GraphView.vue')` inside the test. Every heavy child is already `vi.mock`ed, but GraphView.vue's own graph is not. **This is not a real regression.** Confirmed on parent `dad1b94ebd`: both pass, and the failure is duration alone — no assertion ever fails. ## The fix — deterministic, not a raised timeout Neither test needed to await anything inside the body. **`onboardingCloudRoutes.test.ts`** — resolve the lazy imports explicitly at module scope and assert on the results. The `typeof loader === 'function'` assertions (the actual laziness claim) stay in the test, and the loaders are the real ones, so the import cost is still paid and still meaningful. The test body is now synchronous. **`GraphView.test.ts`** — import the component at module scope. `vi.mock` is hoisted above all imports, so every stub still applies. Then `vi.waitFor` goes: `handleReconnected` calls `onReconnected()` and `refreshOnReconnect()` before its first `await`, so dispatching the event is enough. The `waitFor` was waiting for something that had already happened — it only ever masked how long the import was taking. ``` ✓ GraphView - reconnect wiring > wires the reconnected event ... 15ms ✓ cloudOnboardingRoutes > lazily resolves the /oauth layout ... 0ms ``` 7.12 s of test time → 20 ms. The transform cost moves to collection, which no timeout guards. ## Why not `vi.mock` the two SFCs That was the obvious way to make the cloud-routes test instant, and it is wrong. I checked: **`vi.mock` on a path that does not exist passes silently** (verified with a throwaway spec). Mocking the two views would have deleted the only thing that test catches — a route pointing at a module that isn't there. ## Verified - Full `pnpm test:unit`: **1095 files, 14954 passed, 8 skipped**, exit 0. - Both files, isolated: 8/8, timings above. - `pnpm format:check`, `pnpm lint`, `pnpm typecheck` clean. - **Mutation-checked, both.** Deleting `useEventListener(api, 'reconnected', handleReconnected)` from `GraphView.vue` → *"expected vi.fn() to be called 1 times, but got 0 times"*. Pointing the consent route at `OAuthConsentViewGone.vue` → the file fails to load with a resolve error. Both reverted; green again. ## Not verified - I could not reproduce the intermittent 5005/5002 ms failure locally — this machine ran the full suite green on the parent commit too. The claim rests on the measured headroom (3017/4097 ms of 5000 ms idle), which explains the reported numbers exactly, rather than on a local reproduction of the flake. - I did not sweep the rest of the suite for the same shape (a heavy `await import` inside a test body). If #14666 recurs elsewhere, that sweep is the follow-up. Co-authored-by: Claude Opus 5 (1M context) --- .../onboarding/onboardingCloudRoutes.test.ts | 47 ++++++++++++------- src/views/GraphView.test.ts | 19 +++++--- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts index 89cb3edbec5..702a0e9e1fd 100644 --- a/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts +++ b/src/platform/cloud/onboarding/onboardingCloudRoutes.test.ts @@ -17,6 +17,34 @@ vi.mock('@/platform/auth/session/useSessionCookie', () => ({ useSessionCookie: () => ({ createSessionOrThrow }) })) +const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') +const consentRoute = oauthLayout?.children?.find( + (c) => c.name === 'cloud-oauth-consent' +) +const layoutLoader = oauthLayout?.component +const consentLoader = consentRoute?.component + +/** + * Resolved here rather than inside the test. + * + * These are the real loaders, so calling them compiles `OAuthLayoutView.vue`, + * `OAuthConsentView.vue` and everything they import — seconds of work even on + * an idle machine. Awaited inside a test body that time is billed against the + * 5 s test timeout, which is what made this test fail under a loaded worker + * pool while passing in isolation (#14666). At module scope it is collection + * cost, which nothing times out, and the test itself becomes synchronous. + * + * The loaders are still the ones the router will call: a route pointing at a + * module that does not exist still fails here, at import time. + */ +const resolvedComponents = await Promise.all( + [layoutLoader, consentLoader].map(async (loader) => + typeof loader === 'function' + ? await (loader as () => Promise)() + : undefined + ) +) + describe('cloudOnboardingRoutes', () => { it('consent route is not a child of the /cloud layout', () => { const cloudLayout = cloudOnboardingRoutes.find((r) => r.path === '/cloud') @@ -25,10 +53,6 @@ describe('cloudOnboardingRoutes', () => { }) it('consent route lives under a standalone /oauth layout', () => { - const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') - const consentRoute = oauthLayout?.children?.find( - (c) => c.name === 'cloud-oauth-consent' - ) expect(consentRoute).toBeDefined() expect(consentRoute?.path).toBe('consent') }) @@ -45,25 +69,14 @@ describe('cloudOnboardingRoutes', () => { }) it('consent route carries no requiresAuth meta', () => { - const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') - const consentRoute = oauthLayout?.children?.find( - (c) => c.name === 'cloud-oauth-consent' - ) expect(consentRoute?.meta?.requiresAuth).toBeFalsy() }) - it('lazily resolves the /oauth layout and consent view components', async () => { - const oauthLayout = cloudOnboardingRoutes.find((r) => r.path === '/oauth') - const consentRoute = oauthLayout?.children?.find( - (c) => c.name === 'cloud-oauth-consent' - ) - const layoutLoader = oauthLayout?.component - const consentLoader = consentRoute?.component + it('lazily resolves the /oauth layout and consent view components', () => { expect(typeof layoutLoader).toBe('function') expect(typeof consentLoader).toBe('function') - const layoutModule = await (layoutLoader as () => Promise)() - const consentModule = await (consentLoader as () => Promise)() + const [layoutModule, consentModule] = resolvedComponents expect(layoutModule).toHaveProperty('default') expect(consentModule).toHaveProperty('default') }) diff --git a/src/views/GraphView.test.ts b/src/views/GraphView.test.ts index 64356960af0..86459b4dbc9 100644 --- a/src/views/GraphView.test.ts +++ b/src/views/GraphView.test.ts @@ -193,23 +193,30 @@ vi.mock('@/components/MenuHamburger.vue', () => stubModule) vi.mock('@/components/dialog/UnloadWindowConfirmDialog.vue', () => stubModule) vi.mock('@/renderer/extensions/firstRunTour/FirstRunTour.vue', () => stubModule) +// Imported at module scope, not inside the test. `vi.mock` is hoisted above +// every import, so the stubs above still apply — but compiling GraphView.vue +// and its import graph costs seconds, and awaited inside a test body that is +// billed against the 5 s test timeout. That is what failed this test under a +// loaded worker pool while it passed in isolation (#14666). +const { default: GraphView } = await import('./GraphView.vue') + describe('GraphView - reconnect wiring', () => { beforeEach(() => { vi.restoreAllMocks() setActivePinia(createTestingPinia({ stubActions: false })) }) - it('wires the reconnected event to the toast and queue refresh', async () => { - const GraphView = (await import('./GraphView.vue')).default + it('wires the reconnected event to the toast and queue refresh', () => { render(GraphView) apiMock.dispatchEvent(new Event('reconnected')) + // `handleReconnected` calls both before its first `await`, so dispatching + // the event is enough — there is nothing to wait for, and waiting for it + // only hid how long the import above was taking. const { onReconnected } = useReconnectingNotification() const refreshOnReconnect = useReconnectQueueRefresh() - await vi.waitFor(() => { - expect(onReconnected).toHaveBeenCalledTimes(1) - expect(refreshOnReconnect).toHaveBeenCalledTimes(1) - }) + expect(onReconnected).toHaveBeenCalledTimes(1) + expect(refreshOnReconnect).toHaveBeenCalledTimes(1) }) }) From 3e675f3b563e96fc17bb9af52b887ea1686fe873 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 00:30:56 -0700 Subject: [PATCH 12/62] test(graph): cover the first-run tour's activation seam (#14674) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partially addresses #14625 ## The gap `GraphCanvas.vue` is the only place the first-run tour is connected to startup. Its `onMounted` makes two calls: ```ts startupOutcome = await workflowPersistence.initializeWorkflow() await workflowPersistence.restoreWorkflowTabsState() urlTemplateId = await workflowPersistence.loadTemplateFromUrlIfPresent() await useFirstRunEntry().handleStartupOutcome(startupOutcome) // :569 ... await useFirstRunEntry().handleUrlWorkflow( // :595 startupOutcome, urlTemplateId, sharedStatus ) ``` There was no `GraphCanvas` test file. Deleting **either** call left the entire suite green. `useFirstRunEntry` and `useFirstRunTourController` are both well covered on their own — what was untested was the line joining them, so the whole feature could be disconnected in a refactor and CI would not notice. Nothing user-visible is broken today. This closes a hole that would let it break silently: no Getting Started screen and no template-browser fallback for new users (first call), or a template/share link that silently never offers the tour (second call). ## What the test does `src/components/graph/GraphCanvas.firstRunEntry.test.ts` mounts the real component and asserts both hand-offs happen with the values startup produced: - `handleStartupOutcome` receives the outcome from `initializeWorkflow()`. - `handleUrlWorkflow` receives that outcome, the template id from `loadTemplateFromUrlIfPresent()`, and the status from `loadSharedWorkflowFromUrlIfPresent()`. Asserting the *arguments*, not just the calls, also pins the data flow — swapping the template id and the shared status, or passing a re-read outcome, fails. ### On mounting a 630-line component I looked at cheaper options first and rejected them. A source-text or AST assertion over `GraphCanvas.vue` would go red on the mutation, but it would also pass if the calls were in dead code, and it gates the spelling of the call rather than the behaviour. Mounting turned out to be practical, so that is what this does. The cost is a block of `vi.mock` calls, which is why it is a separate file rather than a general `GraphCanvas.test.ts`: children are stubbed via `shallow`, the startup dependencies (`@/scripts/app`, `useWorkflowPersistenceV2`, `ChangeTracker`, `useNewUserService`, the canvas/lifecycle composables) are faked, and the two readiness gates the sequence waits on — `settingStore.isReady` and `bootstrapStore.isI18nReady` — are set before mounting. The mocks are startup infrastructure only; the component's own `onMounted` runs for real. Two notes for future readers: - `@/stores/workspaceStore` is mocked because instantiating the real one reaches the Firebase auth store. - `shallow` is forwarded verbatim to Vue Test Utils' `mount`, which honours it; `@testing-library/vue` just omits it from its own option type, hence the cast. Runtime is ~30 ms of test time (the rest is module import). ## Verified - `pnpm install --frozen-lockfile`, `pnpm format:check`, `pnpm lint`, `pnpm typecheck` — all clean. - `pnpm test:unit src/components/graph/GraphCanvas.firstRunEntry.test.ts` — 2 passed. - Full `pnpm test:unit` — 14955 passed, 8 skipped, 1 failed: `onboardingCloudRoutes.test.ts > lazily resolves the /oauth layout and consent view components` times out at 5 s. Confirmed flaky and unrelated: it fails the same way when run alone on a sibling worktree that does not contain this file, and it passed in a subsequent full run (1095/1095 files). It is a lazy dynamic-import timing flake in this environment, not something this PR touches. ### Mutation results Each call was deleted in turn, the suite run, then restored: | Mutation | Result | | --- | --- | | remove `await useFirstRunEntry().handleStartupOutcome(startupOutcome)` | `hands the startup outcome to the first-run entry point` **fails** (1 failed, 1 passed) | | remove `await useFirstRunEntry().handleUrlWorkflow(...)` | `offers the tour over a workflow that arrived from the URL` **fails** (1 failed, 1 passed) | | both restored | 2 passed; `git diff` on `GraphCanvas.vue` empty | Each mutation fails only its own test, so neither assertion is carrying the other. ## Not covered - No production code changed; this PR is test-only. - The issue lists two further surviving mutations that this PR does **not** close: `hasPromptError` in `useFirstRunTourController` (only the negative case is asserted) and the nudge's `show('first_run_nudge')` telemetry source. Both are single assertions in existing files and are worth a small follow-up; flagging them since this PR closes the issue that tracks them. - `handleUrlWorkflow` is asserted with a template-id boot. The share-link path (`sharedStatus === 'loaded'`) is covered by `firstRunEntry.test.ts`, not here. --- **⚠️ Do not let this auto-close #14625.** The issue lists **three** surviving mutations and this PR closes only the first — the activation seam. Two remain, both single assertions: - **`hasPromptError` is asserted only in the negative**, so the test passes precisely when the term does nothing. Remove the term and the suite stays green, yet a prompt-level validation refusal then leaves the Result step spinning — the defect that term exists to prevent. - **`show('first_run_nudge')` → `show('command')` stays green**, so the telemetry source can silently regress back to filing every nudge conversion under the command palette. Reworded the close reference to `Partially addresses` so the issue survives this merge. --------- Co-authored-by: Claude Opus 5 (1M context) --- .../graph/GraphCanvas.firstRunEntry.test.ts | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 src/components/graph/GraphCanvas.firstRunEntry.test.ts diff --git a/src/components/graph/GraphCanvas.firstRunEntry.test.ts b/src/components/graph/GraphCanvas.firstRunEntry.test.ts new file mode 100644 index 00000000000..93922c69c28 --- /dev/null +++ b/src/components/graph/GraphCanvas.firstRunEntry.test.ts @@ -0,0 +1,206 @@ +import { createTestingPinia } from '@pinia/testing' +import { render } from '@testing-library/vue' +import type { RenderOptions } from '@testing-library/vue' +import { setActivePinia } from 'pinia' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { nextTick } from 'vue' +import { createI18n } from 'vue-i18n' + +import { useSettingStore } from '@/platform/settings/settingStore' +import { useBootstrapStore } from '@/stores/bootstrapStore' + +import GraphCanvas from './GraphCanvas.vue' + +/** + * GraphCanvas is the only place the first-run tour is wired into startup: it + * feeds the startup outcome to `handleStartupOutcome`, and the URL workflow + * results to `handleUrlWorkflow`. Both composables are unit-tested on their + * own; this file covers the seam, so deleting either call from the startup + * sequence fails a test instead of silently disconnecting the feature. + */ +const mocks = vi.hoisted(() => ({ + handleStartupOutcome: vi.fn(), + handleUrlWorkflow: vi.fn(), + initializeWorkflow: vi.fn(), + loadTemplateFromUrlIfPresent: vi.fn(), + loadSharedWorkflowFromUrlIfPresent: vi.fn(), + workspaceStore: { + spinner: false, + focusMode: false, + sidebarTab: { activeSidebarTab: null } + } +})) + +vi.mock( + '@/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry', + () => ({ + useFirstRunEntry: () => ({ + gettingStartedVisible: { value: false }, + handleStartupOutcome: mocks.handleStartupOutcome, + handleUrlWorkflow: mocks.handleUrlWorkflow, + dismissGettingStarted: vi.fn() + }) + }) +) + +vi.mock( + '@/platform/workflow/persistence/composables/useWorkflowPersistenceV2', + () => ({ + useWorkflowPersistenceV2: () => ({ + initializeWorkflow: mocks.initializeWorkflow, + restoreWorkflowTabsState: vi.fn(), + loadTemplateFromUrlIfPresent: mocks.loadTemplateFromUrlIfPresent, + loadSharedWorkflowFromUrlIfPresent: + mocks.loadSharedWorkflowFromUrlIfPresent + }) + }) +) + +vi.mock('@/scripts/app', () => { + const canvas = { + render_canvas_border: false, + graph: null, + onSelectionChange: null, + setDirty: vi.fn(), + canvas: document.createElement('canvas') + } + return { + app: { + vueAppReady: false, + canvas, + graph: null, + rootGraph: null, + ui: { settings: { dispatchChange: vi.fn() } }, + setup: vi.fn() + } + } +}) + +vi.mock('@/scripts/changeTracker', () => ({ + ChangeTracker: { init: vi.fn() } +})) + +vi.mock('@/services/useNewUserService', () => ({ + useNewUserService: () => ({ + initializeIfNewUser: vi.fn(), + isNewUser: () => false + }) +})) + +vi.mock('@/composables/useUrlActionLoaders', () => ({ + useUrlActionLoaders: () => ({ runUrlActionLoaders: vi.fn() }) +})) + +vi.mock('@/platform/updates/common/releaseStore', () => ({ + useReleaseStore: () => ({ initialize: vi.fn() }) +})) + +vi.mock('@/composables/graph/useVueNodeLifecycle', () => ({ + useVueNodeLifecycle: () => ({ + nodeManager: { value: null }, + setupEmptyGraphListener: vi.fn(), + initializeNodeManager: vi.fn(), + disposeNodeManagerAndSyncs: vi.fn(), + cleanup: vi.fn() + }) +})) + +vi.mock('@/composables/graph/useErrorClearingHooks', () => ({ + installErrorClearingHooks: () => vi.fn() +})) + +vi.mock('@/services/colorPaletteService', () => ({ + useColorPaletteService: () => ({ loadColorPalette: vi.fn() }) +})) + +vi.mock('@/renderer/core/canvas/useCanvasInteractions', () => ({ + useCanvasInteractions: () => ({ forwardEventToCanvas: vi.fn() }) +})) + +vi.mock('@/composables/useCanvasDrop', () => ({ useCanvasDrop: vi.fn() })) +vi.mock('@/platform/settings/composables/useLitegraphSettings', () => ({ + useLitegraphSettings: vi.fn() +})) +vi.mock('@/composables/node/useNodeBadge', () => ({ useNodeBadge: vi.fn() })) +vi.mock('@/composables/useGlobalLitegraph', () => ({ + useGlobalLitegraph: vi.fn() +})) +vi.mock('@/composables/useContextMenuTranslation', () => ({ + useContextMenuTranslation: vi.fn() +})) +vi.mock('@/composables/graph/useGroupContextMenu', () => ({ + useGroupContextMenu: vi.fn() +})) +// Instantiating the real one pulls in the Firebase auth store. +vi.mock('@/stores/workspaceStore', () => ({ + useWorkspaceStore: () => mocks.workspaceStore +})) + +vi.mock('@/composables/useCopy', () => ({ useCopy: vi.fn() })) +vi.mock('@/composables/usePaste', () => ({ usePaste: vi.fn() })) +vi.mock( + '@/platform/workflow/persistence/composables/useWorkflowAutoSave', + () => ({ useWorkflowAutoSave: vi.fn() }) +) + +async function mountGraphCanvas() { + // Handed to the component rather than left to the active-Pinia fallback, so + // the readiness gates below are set on the instance startup actually reads. + const pinia = createTestingPinia({ stubActions: false }) + setActivePinia(pinia) + + // Startup waits on both readiness gates before it reaches the tour hand-off. + useSettingStore().isReady = true + useBootstrapStore().isI18nReady = true + + render(GraphCanvas, { + // Child components are stubbed: this covers the startup sequence, not the + // canvas chrome. `shallow` is forwarded verbatim to Vue Test Utils' mount, + // which honours it — @testing-library/vue just omits it from its own type. + shallow: true, + global: { + plugins: [ + pinia, + createI18n({ legacy: false, locale: 'en', missingWarn: false }) + ] + } + } as RenderOptions) + + // The startup sequence is a chain of awaits; flush until it settles. + for (let i = 0; i < 50; i++) { + await nextTick() + await Promise.resolve() + } +} + +describe('GraphCanvas first-run tour wiring', () => { + beforeEach(() => { + vi.clearAllMocks() + // Startup writes to the workspace store, and clearAllMocks does not undo + // writes to a plain object. + Object.assign(mocks.workspaceStore, { + spinner: false, + focusMode: false, + sidebarTab: { activeSidebarTab: null } + }) + mocks.initializeWorkflow.mockResolvedValue('url-intent') + mocks.loadTemplateFromUrlIfPresent.mockResolvedValue('image_to_image') + mocks.loadSharedWorkflowFromUrlIfPresent.mockResolvedValue(undefined) + }) + + it('hands the startup outcome to the first-run entry point', async () => { + await mountGraphCanvas() + + expect(mocks.handleStartupOutcome).toHaveBeenCalledWith('url-intent') + }) + + it('offers the tour over a workflow that arrived from the URL', async () => { + await mountGraphCanvas() + + expect(mocks.handleUrlWorkflow).toHaveBeenCalledWith( + 'url-intent', + 'image_to_image', + undefined + ) + }) +}) From da10de96f12519d9979d8a4ff86eac02dcc1fc72 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 01:54:59 -0700 Subject: [PATCH 13/62] fix: name the malformed node definitions dropped from object_info (#14773) ## Summary `ComfyApp.getNodeDefs()` discards `/object_info` entries that are not objects with a string `name`, so a single malformed def cannot abort node registration for every node. It did so silently, which makes a node vanishing from the UI undiagnosable. Warn once per fetch, naming the discarded keys. ## Why this shape This is the decision half of #14644, which asks whether node definitions should be structurally validated at the API boundary and what should happen to ones that fail. Validation was removed deliberately: #1190 disabled it by default and #4038 removed it outright along with its setting. `/object_info` carries definitions from arbitrary custom nodes whose shapes vary in ways `ComfyNodeDefV1` does not fully capture, so tightening the contract risks silently dropping a node the user installed and expects to see. That posture is kept here. What was actually wrong was not the permissiveness, it was the silence. Naming the dropped keys keeps the permissive behaviour while making the data loss visible, and it is the cheapest way to learn whether real payloads ever reach this path. If telemetry later shows they do, #14644 can be decided with evidence rather than speculation. - **Breaking**: none. Same defs are dropped as before; only the logging changes. ## Review Focus Verified by mutation: removing the warning fails the suite. A second test pins that a well-formed response stays silent, so the warning cannot become unconditional noise. Related: #14644, #14541 --------- Co-authored-by: Connor Byrne --- src/scripts/app.getNodeDefs.test.ts | 28 ++++++++++++++++++++++++++++ src/scripts/app.ts | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/src/scripts/app.getNodeDefs.test.ts b/src/scripts/app.getNodeDefs.test.ts index 598a5618ec8..30e0ac9eeb8 100644 --- a/src/scripts/app.getNodeDefs.test.ts +++ b/src/scripts/app.getNodeDefs.test.ts @@ -143,6 +143,34 @@ describe('ComfyApp.getNodeDefs', () => { expect(result.TestNode.category).toBe('') }) + test('names the malformed entries it discards', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) + vi.mocked(api.getNodeDefs).mockResolvedValue({ + TestNode: nodeDef({}), + NullEntry: null, + NamelessEntry: { category: 'test' } + } as unknown as Record) + + await comfyApp.getNodeDefs() + + expect(warn).toHaveBeenCalledTimes(1) + const [message] = warn.mock.calls[0] + expect(message).toContain('NullEntry') + expect(message).toContain('NamelessEntry') + expect(message).not.toContain('TestNode') + warn.mockRestore() + }) + + test('stays silent when every entry is well formed', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) + mockDefs(nodeDef({})) + + await comfyApp.getNodeDefs() + + expect(warn).not.toHaveBeenCalled() + warn.mockRestore() + }) + test('discards malformed entries inside an otherwise valid response', async () => { vi.mocked(api.getNodeDefs).mockResolvedValue({ TestNode: nodeDef({ display_name: 'Good Node' }), diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 43e2fd8df4e..af979a5cb1e 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1127,6 +1127,15 @@ export class ComfyApp { !Array.isArray(response) ? Object.entries(response) : [] + const droppedNames = entries + .filter(([, value]) => !isNodeDef(value)) + .map(([name]) => name) + if (droppedNames.length > 0) { + console.warn( + `Ignored ${droppedNames.length} malformed node definition(s) from /object_info: ${droppedNames.join(', ')}` + ) + } + const defs: Record = Object.fromEntries( entries.filter((entry): entry is [string, ComfyNodeDefV1] => isNodeDef(entry[1]) From 73ea940873689e621087f1303c8c1d606eb49fcf Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 01:55:02 -0700 Subject: [PATCH 14/62] test: pin remaining container-coupled node titles in goldens (#14774) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Finishes what #14744 started: the last two node-title goldens that still track the CI container image are now pinned. No baselines regenerated. ## Changes `browser_tests/tests/nodeBadge.spec.ts` already extended the `page` fixture to stub `/object_info` for `ImageBatch`. That map now also carries: | golden | node type | pinned title | | --- | --- | --- | | `api-pricing-{on,off}-{classic,vue}` | `FluxProUltraImageNode` | `Flux 1.1 [pro] Ultra Image` | | `node-badge-{Show-all,Hide-built-in,None}` | `PreviewImage` | `Preview Image` | The route shape, the `try`/`finally` unroute and the pre-boot install are unchanged — only the mutator body generalises to a loop. `nodes/execution_error` also renders `DevToolsErrorRaiseNode` (`Raise Error`), which is **deliberately not pinned**. That name is defined in this repo at `tools/devtools/nodes/errors.py:76` and copied into `custom_nodes` during CI, so it is not a function of the container image. Pinning it would mask a deliberate in-repo rename. ## Review Focus **Motivation.** Since #14541 English node display names resolve from the backend `/object_info`, so every golden containing a node header is a function of `ghcr.io/comfy-org/comfyui-ci-container`. #14682 moves that pin from `0.0.21` (ComfyUI v0.19.3) to `0.0.22` (v0.30.0) — eleven minors. The goal is that after this lands, a node-title golden that moves on that bump means a real structural change, not an upstream rename. **How the strings were established.** Both are read off the committed PNGs, not guessed: - `Flux 1.1 [pro] Ultra Image` is legible in the title band of `api-pricing-on-classic` and `api-pricing-on-vue`, and matches `src/locales/en/nodeDefs.json`. - `Preview Image` is legible in the title band of all three `node-badge-*` goldens, likewise matching the bundled snapshot. Two independent corroborations that these strings hold on both sides of the bump: 1. #14541 re-baselined only `image-compare-*` and `node-lifecycle-*`. It left `api-pricing-*` and `node-badge-*` byte-identical, so at `0.0.21` the container name already equalled the bundled name. 2. Diffing every golden #14682 regenerates against its committed counterpart, the changed pixels in `node-badge-*` sit at x 454–509 / y 69–81 — an `images` output slot appearing on `PreviewImage`. The title band is byte-identical, and `api-pricing-*` is not regenerated at all. So neither title moves at `0.0.22` either. **Sweep.** All 26 goldens #14682 regenerates were diffed old-vs-new and classified. **None move because of a node display name:** | cause | goldens | | --- | --- | | `SaveImage`/`PreviewImage` gained an `images` output | `colorPalette` ×9, `node-badge-*` ×3, `loadWorkflowInMedia` ×4, `save-image-and-webm-preview`, `lod-comparison-high-quality` | | `control after generate` default `randomize` -> `fixed` | `static-primitive-connected` | | 3D render differences | `load3d-*` ×3 | | sub-5px antialiasing | `interaction` ×3, `lod-comparison-low-quality` | So there is no evidence-backed third site. The remaining exposure is the default-workflow titles (`KSampler`, `CLIP Text Encode (Prompt)`, `Load Checkpoint`, `Save Image`, …), which appear across roughly 37 spec files and 257 goldens. Pinning those would touch most of the screenshot suite for a rename that has not happened, so it is left out; the fixture pattern applies unchanged if one ever does. ## Testing `typecheck`, `lint`, `format`, `knip` pass locally. The stub itself needs a running ComfyUI backend, so CI is the verifier — the proof is that the `nodeBadge` and `imageCompare` screenshot tests stay green with the goldens unmodified, which also exercises the route-install ordering. Related: #14630 (closed by #14744; this is the follow-through) Co-authored-by: Connor Byrne --- browser_tests/tests/nodeBadge.spec.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/browser_tests/tests/nodeBadge.spec.ts b/browser_tests/tests/nodeBadge.spec.ts index 5a358a45c22..7fba5f7ec98 100644 --- a/browser_tests/tests/nodeBadge.spec.ts +++ b/browser_tests/tests/nodeBadge.spec.ts @@ -9,22 +9,31 @@ import { } from '@e2e/fixtures/utils/objectInfo' const DEPRECATED_NODE_TYPE = 'ImageBatch' -const DEPRECATED_NODE_DISPLAY_NAME = 'Batch Images' const API_NODE_TYPE = 'FluxProUltraImageNode' // English node titles come from the backend, so any golden containing a node // header would otherwise track whatever ComfyUI build the CI container ships. // Pinning the name before the app boots keeps those baselines stable. +// `nodes/execution_error` also renders `DevToolsErrorRaiseNode`, which is not +// pinned: it ships from this repo's `tools/devtools/`, so a rename there is a +// deliberate in-repo change that its goldens should keep tracking. +const PINNED_DISPLAY_NAMES: Record = { + [DEPRECATED_NODE_TYPE]: 'Batch Images', + [API_NODE_TYPE]: 'Flux 1.1 [pro] Ultra Image', + PreviewImage: 'Preview Image' +} + const test = comfyPageFixture.extend({ page: async ({ page }, use) => { const unrouteObjectInfo = await routeObjectInfoFromSetupApi( page, - (objectInfo) => - setNodeDisplayName( - objectInfo, - DEPRECATED_NODE_TYPE, - DEPRECATED_NODE_DISPLAY_NAME - ) + (objectInfo) => { + for (const [nodeType, displayName] of Object.entries( + PINNED_DISPLAY_NAMES + )) { + setNodeDisplayName(objectInfo, nodeType, displayName) + } + } ) try { await use(page) From 1def140b25c1454df51edf92c0a1fc17ac7ba798 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 5 Aug 2026 02:17:31 -0700 Subject: [PATCH 15/62] refactor: resolve node display name and description at read time (#14775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary `ComfyNodeDefImpl.display_name` and `.description` become getters that resolve against the active locale on read, instead of `ComfyApp.getNodeDefs()` baking resolved text into every def at fetch time. ## Changes - **What**: `getNodeDefs()` no longer resolves `display_name`/`description` (it still resolves `category`), so `nodeDefStore` holds the raw `/object_info` text and resolves it per read via `resolveNodeDefText`. Precedence is unchanged — that logic still lives solely in `src/i18n.ts`. `setBackendNodeText` stays, because consumers like `nodeTitleUtil` only have a node type string. - **Breaking**: extensions receiving defs through `beforeRegisterNodeDef`, `addCustomNodeDefs` and `beforeRegisterVueAppNodeDefs` now see raw backend `display_name`/`description` rather than pre-translated text. Anything reading those fields off a `ComfyNodeDefImpl` is unaffected. Property-access shape is preserved deliberately, so the ~96 files reading `display_name` needed no changes. Consequences that fall out: `allNodeDefsByDisplayName`, `nodeTree` and the Fuse search index are `computed`, and the getters read `i18n.global.locale.value`, so all three now re-resolve on a locale change with no refetch. ## Review Focus A getter is not an own enumerable property, so the two constructor details are load-bearing: - The raw values are held in TypeScript `private` fields, **not** `#private`. Vue wraps store instances in a Proxy and `#private` reads throw through one (`TypeError: Cannot read private member`). - The constructor destructures `display_name`/`description` out before `Object.assign(this, obj)`. Assigning to a setter-less accessor throws in strict mode, which would have broken every construction. Audited for silent loss of the accessors: object spread, `JSON.stringify`, `structuredClone`, `Object.keys/values/entries`, `Object.assign`, `toRaw`, and `cloneDeep`. The only place a `ComfyNodeDefImpl` instance is structurally copied is `nodeBookmarkStore.buildBookmarkTree`, which uses es-toolkit's `clone` — that preserves the prototype, so the accessors survive. Covered by a regression test, since swapping it for a spread would blank every bookmark label. Two things left alone, noted for follow-up: - `nodeDefsByDisplayName` (the plain `ref`, not the `computed`) still snapshots its keys at write time, so they go stale after a locale switch. It has no consumer in `src/`. - `litegraphService` still assigns `node.title` once at registration, so existing canvas nodes keep their old title until reload — the pre-existing behaviour this refactor makes fixable, but does not fix. Fixes #14629 Co-authored-by: Connor Byrne --- src/locales/CONTRIBUTING.md | 23 +++ src/scripts/app.getNodeDefs.test.ts | 37 ++--- src/scripts/app.ts | 12 +- src/stores/nodeDefStore.nodeText.test.ts | 170 +++++++++++++++++++++++ src/stores/nodeDefStore.ts | 42 ++++-- 5 files changed, 238 insertions(+), 46 deletions(-) create mode 100644 src/stores/nodeDefStore.nodeText.test.ts diff --git a/src/locales/CONTRIBUTING.md b/src/locales/CONTRIBUTING.md index 56fd4c1c591..a604eaaecf3 100644 --- a/src/locales/CONTRIBUTING.md +++ b/src/locales/CONTRIBUTING.md @@ -115,6 +115,29 @@ Each language has 4 translation files: - `settings.json` - Settings panel (~400+ entries) - `nodeDefs.json` - Node definitions (~varies based on installed nodes) +### What `en/nodeDefs.json` is (and is not) + +It is **not** the source of English node text. The backend is: `/object_info` +ships each node's `display_name` and `description`, and those are the English +strings users see. + +`en/nodeDefs.json` is a point-in-time snapshot of that backend text, serving two +purposes: + +1. **An extraction basis** for the lobe-i18n pipeline, which translates it into + the other locales. +2. **An offline fallback** for nodes the connected backend does not describe. + +Treating it as authoritative is what produced the bug where a renamed or +custom-built node showed a stale name: the snapshot outranked the live backend. +So `resolveNodeDefText` in `src/i18n.ts` prefers, in order, a custom node's +`/api/i18n` translation, then the live backend value, then this snapshot — and +in English it returns the backend value uncompiled, because English is source +text rather than a translation. + +Because the snapshot lags whatever nodes are actually installed, a missing entry +here is normal and is not a bug to fix by hand-editing the file. + ## Translation Quality - **Auto-translations are high quality** but may need refinement diff --git a/src/scripts/app.getNodeDefs.test.ts b/src/scripts/app.getNodeDefs.test.ts index 30e0ac9eeb8..b787fd36e83 100644 --- a/src/scripts/app.getNodeDefs.test.ts +++ b/src/scripts/app.getNodeDefs.test.ts @@ -49,12 +49,12 @@ describe('ComfyApp.getNodeDefs', () => { expect(result.TestNode.display_name).toBe('Custom Display Name') }) - test('falls back to the node name when display_name is empty', async () => { + test('leaves an empty display_name unresolved for the store to fill in', async () => { mockDefs(nodeDef({ display_name: '' })) const result = await comfyApp.getNodeDefs() - expect(result.TestNode.display_name).toBe('TestNode') + expect(result.TestNode.display_name).toBe('') }) test('renders backend names containing i18n syntax verbatim', async () => { @@ -65,7 +65,10 @@ describe('ComfyApp.getNodeDefs', () => { expect(result.TestNode.display_name).toBe('Load Image {batch} | v2') }) - test('lets custom-node translations win over the backend name', async () => { + // Resolution happens on read, in ComfyNodeDefImpl — see + // nodeDefStore.nodeText.test.ts. Baking it in here is what froze the text to + // the fetch-time locale, so the raw value has to survive this layer intact. + test('hands the store raw text rather than a translation', async () => { mergeCustomNodesI18n({ en: { nodeDefs: { TestNode: { display_name: 'Translated Name' } } } }) @@ -73,18 +76,7 @@ describe('ComfyApp.getNodeDefs', () => { const result = await comfyApp.getNodeDefs() - expect(result.TestNode.display_name).toBe('Translated Name') - }) - - test('resolves dotted node names against the normalized key', async () => { - mergeCustomNodesI18n({ - en: { nodeDefs: { my_node: { display_name: 'Dotted Translated' } } } - }) - mockDefs(nodeDef({ name: 'my.node', display_name: 'My Node' })) - - const result = await comfyApp.getNodeDefs() - - expect(result['my.node'].display_name).toBe('Dotted Translated') + expect(result.TestNode.display_name).toBe('Object Info Display Name') }) test('publishes backend text for consumers that only know the node name', async () => { @@ -111,7 +103,7 @@ describe('ComfyApp.getNodeDefs', () => { } ) - test('falls back to the bundled name when the backend omits display_name', async () => { + test('does not substitute the bundled snapshot for an omitted field', async () => { mockDefs( nodeDef({ name: 'CLIPTextEncode', @@ -122,17 +114,8 @@ describe('ComfyApp.getNodeDefs', () => { const result = await comfyApp.getNodeDefs() - expect(result.CLIPTextEncode.display_name).toBe('CLIP Text Encode (Prompt)') - }) - - test('falls back to the bundled description when the backend omits one', async () => { - mockDefs( - nodeDef({ name: 'CLIPTextEncode', display_name: 'x', description: '' }) - ) - - const result = await comfyApp.getNodeDefs() - - expect(result.CLIPTextEncode.description).toMatch(/^Encodes a text prompt/) + expect(result.CLIPTextEncode.display_name).toBeUndefined() + expect(result.CLIPTextEncode.description).toBe('') }) test('resolves a def without a category to an empty category', async () => { diff --git a/src/scripts/app.ts b/src/scripts/app.ts index af979a5cb1e..bddd4d4c87d 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -11,7 +11,7 @@ import { flushScheduledSlotLayoutSync } from '@/renderer/extensions/vueNodes/com import { promotedInputSource } from '@/core/graph/subgraph/promotedInputWidget' import { resolveConcretePromotedWidget } from '@/core/graph/subgraph/resolveConcretePromotedWidget' -import { resolveNodeDefText, setBackendNodeText, st, t } from '@/i18n' +import { setBackendNodeText, st, t } from '@/i18n' import { normalizeI18nKey } from '@/utils/formatUtil' import { ChangeTracker } from '@/scripts/changeTracker' import type { IContextMenuValue } from '@/lib/litegraph/src/interfaces' @@ -1096,16 +1096,6 @@ export class ComfyApp { const translateNodeDef = (def: ComfyNodeDefV1): ComfyNodeDefV1 => { return { ...def, - display_name: resolveNodeDefText( - 'display_name', - def.name, - def.display_name || undefined - ), - description: resolveNodeDefText( - 'description', - def.name, - def.description || undefined - ), category: (typeof def.category === 'string' ? def.category : '') .split('/') .map((category: string) => diff --git a/src/stores/nodeDefStore.nodeText.test.ts b/src/stores/nodeDefStore.nodeText.test.ts new file mode 100644 index 00000000000..1bca8e75094 --- /dev/null +++ b/src/stores/nodeDefStore.nodeText.test.ts @@ -0,0 +1,170 @@ +import { createTestingPinia } from '@pinia/testing' +import { clone } from 'es-toolkit/compat' +import { setActivePinia } from 'pinia' +import { afterEach, beforeEach, describe, expect, it } from 'vitest' + +import { mergeCustomNodesI18n, setActiveLocale } from '@/i18n' +import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema' +import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore' + +function def(overrides: Partial): ComfyNodeDefV1 { + return { + name: 'TestNode', + display_name: 'Test Node', + category: 'test', + description: '', + input: {}, + output: [], + output_node: false, + python_module: 'test.module', + ...overrides + } as ComfyNodeDefV1 +} + +// `KSampler` is chosen because the shipped zh bundle translates both fields and +// neither translation contains vue-i18n syntax, so a compile failure cannot be +// mistaken for a passing assertion. +const KSAMPLER_EN = 'KSampler' +const KSAMPLER_ZH = 'K采样器' + +describe('ComfyNodeDefImpl node text', () => { + afterEach(async () => { + await setActiveLocale('en') + mergeCustomNodesI18n({}) + }) + + it('resolves display_name and description against the active locale on every read', async () => { + const nodeDef = new ComfyNodeDefImpl( + def({ + name: 'KSampler', + display_name: KSAMPLER_EN, + description: 'Backend description' + }) + ) + + expect(nodeDef.display_name).toBe(KSAMPLER_EN) + expect(nodeDef.description).toBe('Backend description') + + await setActiveLocale('zh') + + // Same instance, never rebuilt from a fresh /object_info fetch. + expect(nodeDef.display_name).toBe(KSAMPLER_ZH) + expect(nodeDef.description).toMatch(/^使用提供的模型/) + }) + + // `mergeCustomNodesI18n` merges into the vue-i18n message tree, which clearing + // the side map does not undo, so this uses a name no other test resolves. + it('keeps custom-node translations ahead of the backend value', () => { + mergeCustomNodesI18n({ + en: { nodeDefs: { CustomNode: { display_name: 'Translated Name' } } } + }) + + const nodeDef = new ComfyNodeDefImpl( + def({ name: 'CustomNode', display_name: 'Object Info Display Name' }) + ) + + expect(nodeDef.display_name).toBe('Translated Name') + }) + + it('resolves dotted node names against the normalized key', () => { + mergeCustomNodesI18n({ + en: { nodeDefs: { my_node: { display_name: 'Dotted Translated' } } } + }) + + const nodeDef = new ComfyNodeDefImpl( + def({ name: 'my.node', display_name: 'My Node' }) + ) + + expect(nodeDef.display_name).toBe('Dotted Translated') + }) + + it('returns an English backend value verbatim rather than compiling it', () => { + const nodeDef = new ComfyNodeDefImpl( + def({ display_name: 'Load Image {batch} | v2' }) + ) + + expect(nodeDef.display_name).toBe('Load Image {batch} | v2') + }) + + it('falls back to the node name when the backend sends no display_name', () => { + expect(new ComfyNodeDefImpl(def({ display_name: '' })).display_name).toBe( + 'TestNode' + ) + expect(new ComfyNodeDefImpl(def({ description: '' })).description).toBe('') + }) + + it('prefers the bundled snapshot when the backend omits the field', () => { + const nodeDef = new ComfyNodeDefImpl( + def({ name: 'CLIPTextEncode', display_name: '', description: '' }) + ) + + expect(nodeDef.display_name).toBe('CLIP Text Encode (Prompt)') + expect(nodeDef.description).toMatch(/^Encodes a text prompt/) + }) + + it('constructs from a def carrying display_name without assigning the accessor', () => { + const build = () => + new ComfyNodeDefImpl( + def({ display_name: 'Assignable?', search_aliases: ['alias'] }) + ) + + expect(build).not.toThrow() + expect(build().search_aliases).toEqual(['alias']) + }) + + // `nodeBookmarkStore.buildBookmarkTree` re-categorises defs via es-toolkit's + // `clone`. That keeps the prototype, so the accessors survive; a copy that + // drops it (spread, structuredClone) would blank every bookmark label. + it('still resolves text after a prototype-preserving clone', () => { + const nodeDef = new ComfyNodeDefImpl( + def({ name: 'KSampler', display_name: KSAMPLER_EN }) + ) + + const copy = clone(nodeDef) + copy.category = 'bookmarks' + + expect(copy.display_name).toBe(KSAMPLER_EN) + expect(copy.nodePath).toBe('bookmarks/KSampler') + }) +}) + +describe('useNodeDefStore locale reactivity', () => { + beforeEach(() => { + setActivePinia(createTestingPinia({ stubActions: false })) + }) + + afterEach(async () => { + await setActiveLocale('en') + }) + + it('re-resolves the search index when the locale changes', async () => { + const store = useNodeDefStore() + store.updateNodeDefs([def({ name: 'KSampler', display_name: KSAMPLER_EN })]) + + expect(store.nodeSearchService.searchNode(KSAMPLER_EN)).toHaveLength(1) + expect(store.nodeSearchService.searchNode(KSAMPLER_ZH)).toHaveLength(0) + + await setActiveLocale('zh') + + expect(store.nodeSearchService.searchNode(KSAMPLER_ZH)).toHaveLength(1) + }) + + it('keys nodeDefsByDisplayName by the resolved name', async () => { + const store = useNodeDefStore() + await setActiveLocale('zh') + store.updateNodeDefs([def({ name: 'KSampler', display_name: KSAMPLER_EN })]) + + expect(Object.keys(store.nodeDefsByDisplayName)).toEqual([KSAMPLER_ZH]) + }) + + it('re-keys allNodeDefsByDisplayName when the locale changes', async () => { + const store = useNodeDefStore() + store.updateNodeDefs([def({ name: 'KSampler', display_name: KSAMPLER_EN })]) + + expect(store.allNodeDefsByDisplayName[KSAMPLER_EN]?.name).toBe('KSampler') + + await setActiveLocale('zh') + + expect(store.allNodeDefsByDisplayName[KSAMPLER_ZH]?.name).toBe('KSampler') + }) +}) diff --git a/src/stores/nodeDefStore.ts b/src/stores/nodeDefStore.ts index 9cf0bd3ac94..1c1078336b6 100644 --- a/src/stores/nodeDefStore.ts +++ b/src/stores/nodeDefStore.ts @@ -3,7 +3,7 @@ import { cloneDeep, uniq } from 'es-toolkit/compat' import { defineStore } from 'pinia' import { computed, ref, watchEffect } from 'vue' -import { t } from '@/i18n' +import { resolveNodeDefText, t } from '@/i18n' import { promotedInputSource } from '@/core/graph/subgraph/promotedInputWidget' import { resolveConcretePromotedWidget } from '@/core/graph/subgraph/resolveConcretePromotedWidget' import { resolveInputType } from '@/core/graph/widgets/dynamicTypes' @@ -36,7 +36,6 @@ export class ComfyNodeDefImpl { // ComfyNodeDef fields (V1) readonly name: string - readonly display_name: string /** * Category is not marked as readonly as the bookmark system * needs to write to it to assign a node to a custom folder. @@ -44,7 +43,6 @@ export class ComfyNodeDefImpl category: string readonly main_category?: string readonly python_module: string - readonly description: string readonly help: string readonly deprecated: boolean readonly experimental: boolean @@ -101,6 +99,15 @@ export class ComfyNodeDefImpl readonly nodeSource: NodeSource readonly inputTypes: string[] + /** + * Raw `/object_info` text, kept unresolved so `display_name` and + * `description` can be resolved against the active locale on every read. + * Declared with TypeScript `private` rather than `#private`: Vue wraps store + * instances in a Proxy, and `#private` reads throw through one. + */ + private readonly backendDisplayName?: string + private readonly backendDescription?: string + /** * @internal * Migrate default input options to forceInput. @@ -139,16 +146,19 @@ export class ComfyNodeDefImpl /** * Copy fields that are declared on this class but not explicitly assigned * below (e.g. `search_aliases`) straight from the source definition. + * `display_name` and `description` are held out: they are accessors with no + * setter, so assigning them here would throw. */ - Object.assign(this, obj) + const { display_name, description, ...assignable } = obj + Object.assign(this, assignable) // Initialize V1 fields this.name = obj.name - this.display_name = obj.display_name + this.backendDisplayName = display_name || undefined + this.backendDescription = description || undefined this.category = obj.category this.main_category = obj.main_category this.python_module = obj.python_module - this.description = obj.description this.help = obj.help ?? '' this.deprecated = obj.deprecated ?? obj.category === '' this.experimental = @@ -181,6 +191,22 @@ export class ComfyNodeDefImpl this.inputTypes = uniq(Object.values(this.inputs).flatMap(resolveInputType)) } + /** + * Resolved against the active locale on read, so a locale switch retitles + * every def without refetching `/object_info`. + */ + get display_name(): string { + return resolveNodeDefText( + 'display_name', + this.name, + this.backendDisplayName + ) + } + + get description(): string { + return resolveNodeDefText('description', this.name, this.backendDescription) + } + get nodePath(): string { return (this.category ? this.category + '/' : '') + this.name } @@ -397,7 +423,7 @@ export const useNodeDefStore = defineStore('nodeDef', () => { : new ComfyNodeDefImpl(nodeDef) newNodeDefsByName[nodeDef.name] = nodeDefImpl - newNodeDefsByDisplayName[nodeDef.display_name] = nodeDefImpl + newNodeDefsByDisplayName[nodeDefImpl.display_name] = nodeDefImpl } nodeDefsByName.value = newNodeDefsByName @@ -406,7 +432,7 @@ export const useNodeDefStore = defineStore('nodeDef', () => { function addNodeDef(nodeDef: ComfyNodeDefV1) { const nodeDefImpl = new ComfyNodeDefImpl(nodeDef) nodeDefsByName.value[nodeDef.name] = nodeDefImpl - nodeDefsByDisplayName.value[nodeDef.display_name] = nodeDefImpl + nodeDefsByDisplayName.value[nodeDefImpl.display_name] = nodeDefImpl } function fromLGraphNode(node: LGraphNode): ComfyNodeDefImpl | null { const nodeTypeName = node.constructor?.nodeData?.name ?? node.type From 85f486e12705f175e4d75a35445094da7f5cbf1a Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Wed, 5 Aug 2026 03:58:00 -0700 Subject: [PATCH 16/62] fix: escape node names in search results (#14574) ## Summary Escapes node names before rendering search-highlight markup so workflow-provided group node names are always displayed as text. ## Changes - **What**: Escape source text before adding the generated highlight span, including when the search query is empty. - **What**: Restrict the final rendered markup to the generated `span.highlight` structure. - **What**: Add utility and component regression coverage for markup in node names. ## Review Focus Confirm highlighting remains unchanged while node display names and internal names cannot contribute rendered markup. ## Testing - `pnpm test:unit packages/shared-frontend-utils/src/formatUtil.test.ts src/components/searchbox/v2/NodeSearchListItem.test.ts` (115 passed) - `pnpm typecheck` - `pnpm lint` - `pnpm knip` - `pnpm format:check packages/shared-frontend-utils/src/formatUtil.ts packages/shared-frontend-utils/src/formatUtil.test.ts src/components/searchbox/v2/NodeSearchListItem.test.ts` - targeted ESLint and Oxlint Co-authored-by: Amp --- .../src/formatUtil.test.ts | 17 +++++++++-- .../shared-frontend-utils/src/formatUtil.ts | 29 +++++++++++++++---- .../searchbox/v2/NodeSearchListItem.test.ts | 12 ++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/packages/shared-frontend-utils/src/formatUtil.test.ts b/packages/shared-frontend-utils/src/formatUtil.test.ts index 1b7d5896e26..1bc7eb1f82f 100644 --- a/packages/shared-frontend-utils/src/formatUtil.test.ts +++ b/packages/shared-frontend-utils/src/formatUtil.test.ts @@ -201,8 +201,10 @@ describe('formatUtil', () => { }) describe('highlightQuery', () => { - it('should return text unchanged when query is empty', () => { - expect(highlightQuery('Hello World', '')).toBe('Hello World') + it('should sanitize text when query is empty', () => { + expect(highlightQuery('Hello', '')).toBe( + '<img src=x onerror=alert(1)>Hello' + ) }) it('should wrap matching text in highlight span', () => { @@ -220,6 +222,17 @@ describe('formatUtil', () => { expect(result).not.toContain(' diff --git a/src/platform/cloud/onboarding/components/CloudTemplate.vue b/src/platform/cloud/onboarding/components/CloudTemplate.vue index b4548066bf7..7da3224defd 100644 --- a/src/platform/cloud/onboarding/components/CloudTemplate.vue +++ b/src/platform/cloud/onboarding/components/CloudTemplate.vue @@ -1,8 +1,8 @@ + + diff --git a/apps/website/src/components/common/PlayPauseButton.vue b/apps/website/src/components/common/PlayPauseButton.vue index 8c990d0f86a..08d5940e4ec 100644 --- a/apps/website/src/components/common/PlayPauseButton.vue +++ b/apps/website/src/components/common/PlayPauseButton.vue @@ -12,8 +12,8 @@ const { playing = false, size = 'md' } = defineProps<{ type="button" :class=" cn( - 'bg-primary-comfy-yellow flex shrink-0 cursor-pointer items-center justify-center rounded-xl', - size === 'sm' ? 'size-8 lg:size-10' : 'size-12' + 'bg-primary-comfy-yellow flex shrink-0 cursor-pointer items-center justify-center', + size === 'sm' ? 'size-8 rounded-lg lg:size-10' : 'size-12 rounded-xl' ) " > @@ -36,7 +36,7 @@ const { playing = false, size = 'md' } = defineProps<{ v-else :class=" cn( - 'text-primary-comfy-ink ml-0.5', + 'ml-0.5 text-primary-comfy-ink', size === 'sm' ? 'size-3 lg:size-4' : 'size-4' ) " diff --git a/apps/website/src/components/common/VideoPlayer.vue b/apps/website/src/components/common/VideoPlayer.vue index ca95e2cacc6..ad5702ccb48 100644 --- a/apps/website/src/components/common/VideoPlayer.vue +++ b/apps/website/src/components/common/VideoPlayer.vue @@ -14,6 +14,8 @@ import type { HTMLAttributes } from 'vue' import { t } from '../../i18n/translations' import type { Locale } from '../../i18n/translations' +import VolumeMutedIcon from '../icons/VolumeMutedIcon.vue' +import VolumeUnmutedIcon from '../icons/VolumeUnmutedIcon.vue' import PlayPauseButton from './PlayPauseButton.vue' export type VideoTrack = { @@ -30,8 +32,10 @@ const { tracks = [], autoplay = false, autoplayUnmuted = false, + lazyAutoplay = false, loop = false, minimal = false, + muteOnly = false, hideControls = false, fit = 'cover', ariaLabel, @@ -45,8 +49,15 @@ const { /** Attempt autoplay with sound; browsers without engagement-based * permission reject it, and playback falls back to muted. */ autoplayUnmuted?: boolean + /** Omit the native autoplay attribute and keep preload conservative so + * media loads and plays only after hydration; pair with `client:visible` + * to start the preview when it scrolls into view. */ + lazyAutoplay?: boolean loop?: boolean minimal?: boolean + /** Replace the control bar with persistent play/pause and mute toggles + * in the top-right corner. */ + muteOnly?: boolean hideControls?: boolean fit?: 'cover' | 'contain' ariaLabel?: string @@ -253,13 +264,13 @@ function toggleFullscreen() { " :src :poster - :preload="autoplay ? 'auto' : 'metadata'" + :preload="autoplay && !lazyAutoplay ? 'auto' : 'metadata'" crossorigin="anonymous" playsinline - :autoplay + :autoplay="autoplay && !lazyAutoplay" :loop muted - @click="hideControls ? undefined : (playing = !playing)" + @click="hideControls || muteOnly ? undefined : (playing = !playing)" > + +

+ + +
+
diff --git a/apps/website/src/components/home/ModelReleaseSection.vue b/apps/website/src/components/home/ModelReleaseSection.vue new file mode 100644 index 00000000000..9d449dbbcd4 --- /dev/null +++ b/apps/website/src/components/home/ModelReleaseSection.vue @@ -0,0 +1,29 @@ + + + diff --git a/apps/website/src/components/icons/VolumeMutedIcon.vue b/apps/website/src/components/icons/VolumeMutedIcon.vue new file mode 100644 index 00000000000..f3d1d0ff21c --- /dev/null +++ b/apps/website/src/components/icons/VolumeMutedIcon.vue @@ -0,0 +1,24 @@ + + + diff --git a/apps/website/src/components/icons/VolumeUnmutedIcon.vue b/apps/website/src/components/icons/VolumeUnmutedIcon.vue new file mode 100644 index 00000000000..00ff4df36a5 --- /dev/null +++ b/apps/website/src/components/icons/VolumeUnmutedIcon.vue @@ -0,0 +1,34 @@ + + + diff --git a/apps/website/src/i18n/translations.ts b/apps/website/src/i18n/translations.ts index acd4e212071..4f04ffe9a07 100644 --- a/apps/website/src/i18n/translations.ts +++ b/apps/website/src/i18n/translations.ts @@ -6,6 +6,10 @@ const translations = { en: 'Partner Nodes', 'zh-CN': '合作伙伴节点' }, + 'tags.openWeights': { + en: 'Open Weights', + 'zh-CN': '开放权重' + }, 'tags.imageToVideo': { en: 'Image To Video', 'zh-CN': '图像生成视频' @@ -115,6 +119,33 @@ const translations = { 'zh-CN': '运行你的第一个工作流' }, + // Model release card (home page) + 'modelRelease.eyebrow': { + en: 'New Model Release', + 'zh-CN': '新模型发布' + }, + 'modelRelease.title': { + en: 'MiniMax H3', + 'zh-CN': 'MiniMax H3' + }, + 'modelRelease.body': { + en: 'Full multi-modal I/O, native stereo clip. Up to 2K, 5 to 15s per generation. H3 actually conditions on input audio where others overwrite or drop it.', + 'zh-CN': + '完整的多模态输入输出,原生立体声剪辑。最高 2K,每次生成 5 至 15 秒。H3 真正基于输入音频进行条件生成,而其他模型则会覆盖或丢弃它。' + }, + 'modelRelease.viewFeatures': { + en: 'View Model Features', + 'zh-CN': '查看模型特性' + }, + 'modelRelease.tryWorkflows': { + en: 'Try Workflows', + 'zh-CN': '试用工作流' + }, + 'modelRelease.videoAriaLabel': { + en: 'MiniMax H3 preview', + 'zh-CN': 'MiniMax H3 预览' + }, + // ProductShowcaseSection 'showcase.subtitle1': { en: 'Connect models, processing steps, and outputs on a canvas where every decision is visible and every step is inspectable.', diff --git a/apps/website/src/pages/index.astro b/apps/website/src/pages/index.astro index 079089234b0..b97fab216cf 100644 --- a/apps/website/src/pages/index.astro +++ b/apps/website/src/pages/index.astro @@ -2,6 +2,7 @@ import BaseLayout from "../layouts/BaseLayout.astro"; import ProductCardsSection from "../components/home/ProductCardsSection.vue"; import HeroSection from "../components/home/HeroSection.vue"; +import ModelReleaseSection from "../components/home/ModelReleaseSection.vue"; import SocialProofBarSection from "../components/common/SocialProofBarSection.vue"; import ProductShowcaseSection from "../components/home/ProductShowcaseSection.vue"; import UseCaseSection from "../components/home/UseCaseSection.vue"; @@ -45,6 +46,7 @@ const { siteUrl } = pageContext( > + diff --git a/apps/website/src/pages/zh-CN/index.astro b/apps/website/src/pages/zh-CN/index.astro index 030006addc1..9a38701604d 100644 --- a/apps/website/src/pages/zh-CN/index.astro +++ b/apps/website/src/pages/zh-CN/index.astro @@ -2,6 +2,7 @@ import BaseLayout from '../../layouts/BaseLayout.astro' import ProductCardsSection from '../../components/home/ProductCardsSection.vue' import HeroSection from '../../components/home/HeroSection.vue' +import ModelReleaseSection from '../../components/home/ModelReleaseSection.vue' import SocialProofBarSection from '../../components/common/SocialProofBarSection.vue' import ProductShowcaseSection from '../../components/home/ProductShowcaseSection.vue' import UseCaseSection from '../../components/home/UseCaseSection.vue' @@ -32,6 +33,7 @@ const { siteUrl } = pageContext( > + From 673fb515ff9e8ed0a7a4f0c06f4bf091816053cb Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 5 Aug 2026 14:17:14 -0700 Subject: [PATCH 29/62] ci: run typecheck:browser unconditionally so browser_tests type errors block main (FE-1507) (#14717) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *PR Created by the Glary-Bot Agent* --- ## Summary `pnpm typecheck:browser` was gated on a `browser_tests/**` paths filter, so type errors in the E2E suite could reach `main` — and nine of them already had. ## Changes - **What**: Removed the `dorny/paths-filter` step and the `if: steps.changed-paths.outputs.browser_tests == 'true'` gate from `.github/actions/lint-format-verify/action.yml`, so the browser typecheck runs on every PR, merge-queue and push run of the required `CI: Lint Format` check. Backfilled the `max_seats` / `occupied_seats` fields the cloud billing fixtures were missing, which is what the gate had been hiding. Why the gate was wrong on both sides: - A `src/` change can break `browser_tests` types without touching `browser_tests/**`. That is exactly what happened here: `BillingStatusResponse` gained required `max_seats` / `occupied_seats` in the ingest-types regen (#13499) and the fixtures were never updated. - `paths-filter` has no diff to inspect in `merge_group` runs, so the merge queue — the last gate before `main` — could not have caught it either. `pnpm typecheck:browser` on `main` today: ``` browser_tests/fixtures/data/cloudWorkspace.ts(84,3): error TS1360 browser_tests/fixtures/data/cloudWorkspace.ts(96,3): error TS1360 browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts(51,5): error TS2739 browser_tests/tests/dialogs/endedSubscription.spec.ts(22,7): error TS2345 browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts(103,3): error TS1360 browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts(115,3): error TS1360 browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts(121,3): error TS1360 browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts(126,3): error TS1360 browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts(300,3): error TS1360 ``` On this branch it exits 0 in ~11s, so the always-on step adds negligible CI time. ## Review Focus - The added `max_seats` / `occupied_seats` values are mock-only: nothing in `src/` reads either field (the app's own `BillingStatusResponse` in `workspaceApi.ts` does not declare them), so no E2E behaviour changes. Values are anchored to existing fixture data — `TEAM_PLAN_MAX_SEATS` for the team plan's seat limit, `DEFAULT_TEAM_MEMBERS.length` for occupancy, `STANDARD_ANNUAL_PLAN.max_seats` for the personal plan. - The derived statuses (`ACTIVE_CREATOR_STATUS`, `LEGACY_ACTIVE_STANDARD_STATUS`, `RECOVERED_3DS_STATUS`) inherit the new fields through their spreads, so only the two base objects needed editing. - `dorny/paths-filter` is still used by `.github/actions/changes-filter/action.yaml`, so its pin remains exercised by `CI: Validate Action Pins`. Fixes FE-1507 ## Verification Ran the composite action's exact command sequence locally on this branch — `pnpm lint && pnpm stylelint && pnpm format:check && pnpm knip && pnpm typecheck:browser` — exit 0. `yamllint` (the `CI: YAML Validation` gate) clean on the changed action, and the parsed action confirms no `if:` remains on the typecheck step. Playwright could not confirm the two touched specs end-to-end here: `@cloud` specs need the cloud-distribution build, and against a plain `pnpm dev` server the settings dialog has no Workspace panel, so `endedSubscription.spec.ts` times out. It times out identically with these changes stashed, i.e. the failure is environmental, not a regression. No screenshots — the change has no UI surface. --------- Co-authored-by: Glary-Bot --- .github/actions/lint-format-verify/action.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/actions/lint-format-verify/action.yml b/.github/actions/lint-format-verify/action.yml index 11420971237..6dcb8b32822 100644 --- a/.github/actions/lint-format-verify/action.yml +++ b/.github/actions/lint-format-verify/action.yml @@ -1,7 +1,7 @@ name: 'Lint and format verify' description: > - Runs the lint/format/knip verification suite plus a conditional - browser-tests typecheck. Shared by ci-lint-format.yaml (PR) and + Runs the lint/format/knip verification suite plus the browser-tests + typecheck. Shared by ci-lint-format.yaml (PR) and ci-lint-format-queue.yaml (merge queue) so both paths run the exact same checks. The caller is responsible for checkout and frontend setup before invoking this action. @@ -9,14 +9,6 @@ description: > runs: using: composite steps: - - name: Detect browser_tests changes - id: changed-paths - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 - with: - filters: | - browser_tests: - - 'browser_tests/**' - - name: Verify lint and format shell: bash run: | @@ -26,6 +18,5 @@ runs: pnpm knip - name: Typecheck browser tests - if: steps.changed-paths.outputs.browser_tests == 'true' shell: bash run: pnpm typecheck:browser From edf4fb8bed2ab07f858389c91a55db78697116a6 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Wed, 5 Aug 2026 14:20:42 -0700 Subject: [PATCH 30/62] fix: give pr-backport manual dispatch gh calls repo context (#13699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ELI-5 The auto-backport bot can be kicked off by hand (Actions → PR Backport → Run workflow) to retry a backport. That manual path was broken: the very first step asked `gh` "is this PR merged?" before the repo was ever checked out and without telling `gh` which repo to look in, so `gh` couldn't resolve a repository and the run aborted with `PR # not found or inaccessible`. This gives the manual-trigger `gh` calls the repo (and token) context they need so a hand-triggered backport actually runs. ## Summary Fix the `workflow_dispatch` (manual) path of `pr-backport.yaml`, which failed immediately because `gh` had no repository context. ## Changes - **What**: - Add `GH_REPO: ${{ github.repository }}` to the `workflow_dispatch`-only **Validate inputs for manual triggers** step. This step runs before `actions/checkout`, so `gh` has no git remote to infer the repo from; without `GH_REPO`/`--repo` it errors and reports `PR # not found or inaccessible`, aborting the run. (This is the ticket's core one-line fix.) - Also give the other two `workflow_dispatch`-only `gh` call sites the same context — **Collect backport targets** (no `env` block at all) and **Backport commits** (`env` had only `PR_NUMBER`) each call `gh pr view` in the manual branch but carried no `GH_TOKEN`. In GitHub Actions `gh` requires an explicit token, so without this the manual path would only get past step 1 and then fail again at these steps. Every other `gh` step in this workflow (and `backport-auto-merge.yaml`, `pr-update-playwright-expectations.yaml`) already sets `GH_TOKEN` explicitly — these two were the outliers, only exposed now that the manual path can proceed. - **Breaking**: None. ## Review Focus - The automatic path (`pull_request_target`) is unaffected: those branches read PR data from `GITHUB_EVENT_PATH` via `jq` and never invoke `gh`, so the added env vars are simply unused there. The `gh` calls that gained context all sit inside `if [ "$github.event_name" = "workflow_dispatch" ]` guards. - The load-bearing add on the two downstream steps is `GH_TOKEN` (they run post-checkout, so repo resolves from the remote); `GH_REPO` is added for explicit consistency with the validate step and this repo's `--repo`-everywhere convention. - Verification: `yamllint` (the repo's `CI: YAML Validation` gate) passes on the changed file; there is no product-code surface, so no unit/typecheck coverage applies to a CI-workflow-only change. The manual dispatch itself can only be exercised end-to-end once merged (running the workflow requires it to live on the default branch). --- .github/workflows/pr-backport.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pr-backport.yaml b/.github/workflows/pr-backport.yaml index 7b5d81a982c..2466f5b1540 100644 --- a/.github/workflows/pr-backport.yaml +++ b/.github/workflows/pr-backport.yaml @@ -62,6 +62,7 @@ jobs: fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} - name: Checkout repository uses: actions/checkout@v6 @@ -80,6 +81,9 @@ jobs: - name: Collect backport targets id: targets + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} run: | TARGETS=() declare -A SEEN=() @@ -230,6 +234,8 @@ jobs: id: backport env: PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} run: | FAILED="" SUCCESS="" From 6552cbe1942c5e989b7aa8a9342372a1ecc26fed Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 5 Aug 2026 15:34:42 -0700 Subject: [PATCH 31/62] refactor: remove dead exports (#13276) Re-evaluated dead exports against current `main` with Knip, Fallow, and repo-wide searches covering tests, stories, aliases, and dynamic imports. Removed or localized symbols with zero consumers: - `createMarkdownRenderer` (`markdownRendererUtil.ts`): used only within its own module, downgraded from `export` to local. - `getGalleryItemById` (`gallery.ts`): deleted after its old stacked-PR suppression no longer had a consumer or a corresponding open PR. - `BUNDLE_CATEGORIES` and `BACKPORT_LABEL`: used only within their defining CLI scripts, downgraded from `export` to local. Restored from the original proposal because current `main` now consumes them: - `clampUsd`: used by the credits tests. - `getRootParentNode`: used by first-run-tour role resolution. Deliberately kept Fallow findings: - telemetry and sharing exports consumed through dynamic imports. - Storybook mock exports consumed through `.storybook` Vite aliases. - menu shims, the `src/types` barrel, LiteGraph, and group/image helpers that are public or custom-node compatibility surfaces. - `useNextInvoice`, retained for the open Plan & Credits integration PR. - `ButtonMask`, retained by the existing follow-up-use Knip configuration. Validation: targeted ESLint and formatting, root and website typechecks, Knip, and `scripts/cicd/backport-label.test.ts` (13 passing). --------- Co-authored-by: Claude Opus 4.8 Co-authored-by: Amp --- apps/website/src/data/gallery.ts | 5 ----- scripts/bundle-categories.js | 2 +- scripts/cicd/backport-label.ts | 2 +- src/utils/markdownRendererUtil.ts | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/website/src/data/gallery.ts b/apps/website/src/data/gallery.ts index bf066ed8d3d..c9a2c4d12f4 100644 --- a/apps/website/src/data/gallery.ts +++ b/apps/website/src/data/gallery.ts @@ -184,8 +184,3 @@ const galleryItems: GalleryItem[] = [ export const visibleGalleryItems: GalleryItem[] = galleryItems.filter( (item) => item.visible !== false ) - -/** @knipIgnoreUsedByStackedPR */ -export function getGalleryItemById(id: string): GalleryItem | undefined { - return galleryItems.find((item) => item.id === id) -} diff --git a/scripts/bundle-categories.js b/scripts/bundle-categories.js index a0848888ae8..05d74b296c4 100644 --- a/scripts/bundle-categories.js +++ b/scripts/bundle-categories.js @@ -15,7 +15,7 @@ */ /** @type {BundleCategory[]} */ -export const BUNDLE_CATEGORIES = [ +const BUNDLE_CATEGORIES = [ { name: 'App Entry Points', description: 'Main entry bundles and manifests', diff --git a/scripts/cicd/backport-label.ts b/scripts/cicd/backport-label.ts index 5d2d779ff3d..b18473f9f70 100644 --- a/scripts/cicd/backport-label.ts +++ b/scripts/cicd/backport-label.ts @@ -57,7 +57,7 @@ export interface PullRequestSummary { labels: { name: string }[] } -export const BACKPORT_LABEL = 'backport' +const BACKPORT_LABEL = 'backport' /** * Returns the numbers of the PRs that are backports by branch convention but diff --git a/src/utils/markdownRendererUtil.ts b/src/utils/markdownRendererUtil.ts index 64004789219..d45aa014268 100644 --- a/src/utils/markdownRendererUtil.ts +++ b/src/utils/markdownRendererUtil.ts @@ -18,7 +18,7 @@ const MEDIA_SRC_REGEX = /(<(?:img|source|video)[^>]*\ssrc=['"])(?!(?:\/|https?:\/\/))([^'"\s>]+)(['"])/gi // Create a marked Renderer that prefixes relative URLs with base -export function createMarkdownRenderer(baseUrl?: string): Renderer { +function createMarkdownRenderer(baseUrl?: string): Renderer { const normalizedBase = baseUrl ? baseUrl.replace(/\/+$/, '') : '' const renderer = new Renderer() renderer.image = ({ href, title, text }) => { From 57812beee6c3bdd496c87e0f167b5ac395f8ab6b Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Wed, 5 Aug 2026 16:09:30 -0700 Subject: [PATCH 32/62] chore: configure Amp orb development environment (#14823) ## Summary Prepare fresh Amp orbs with the pinned frontend toolchain, browser dependencies, and a supervised cloud-backed development server. ## Changes - **What**: Persist Node.js 25 and pnpm 11.13.1 for login shells, declare the frontend portal service, and allow generated portal hostnames inside Amp orbs. - **Breaking**: None. - **Dependencies**: None. ## Review Focus Confirm the cloud-backed `pnpm dev:cloud` service is the preferred default for orb development. ## Screenshots (if applicable) Not applicable. --------- Co-authored-by: Amp --- .agents/setup | 19 +++++++++---------- .amp/services.yaml | 6 ++++++ vite.config.mts | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 .amp/services.yaml diff --git a/.agents/setup b/.agents/setup index c3c6d02e7e7..67f3fa889c7 100755 --- a/.agents/setup +++ b/.agents/setup @@ -3,6 +3,11 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" + +if [[ "${AMP_ORB:-}" == 1 ]]; then + gh auth setup-git +fi + node_major="$(tr -d '[:space:]' < "$repo_root/.nvmrc")" node_home="$HOME/.local/share/comfyui-frontend-node-v$node_major" @@ -56,16 +61,10 @@ if [[ ! -x "$node_home/bin/pnpm" ]] || npm install --global --prefix "$node_home" "pnpm@$pnpm_version" fi -profile_marker="# ComfyUI Frontend orb toolchain" -if ! grep -Fqx "$profile_marker" "$HOME/.bash_profile" 2>/dev/null; then - cat >> "$HOME/.bash_profile" < Date: Wed, 5 Aug 2026 16:33:31 -0700 Subject: [PATCH 33/62] test: restructure cloud secrets E2E scaffolding into fixtures (#13565) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ELI-5 The cloud "API keys" browser test had ~150 lines of setup living inside the test file — a fake `/secrets` server and a helper to open the Secrets settings panel. This moves that setup into a reusable fixtures file next to the other cloud mocks, so the test itself reads as just the user flow. It also tightens two checks: the secret value must never appear in any input field (not just as visible text), and a small unit test now proves the "don't close on focus loss" dialog option is actually wired up. ## Summary Test-structure cleanup for the cloud secrets E2E, per post-merge reviewer notes. No product code changes. ## Changes - **What**: - Extract the in-memory `/secrets` backend and the open-panel helper out of `browser_tests/tests/cloudSecrets.spec.ts` into `browser_tests/fixtures/utils/cloudSecretsMocks.ts`, alongside the sibling cloud mocks (`cloudBillingMocks`, `workspaceMocks`). The path-anchoring, method-branching, and 204-on-delete behavior are preserved verbatim. - `openSecretsPanel` now drives the shared `SettingDialog` page object (`.open()` / `.category('Secrets')`) instead of hand-rolling the `Comfy.ShowSettingsDialog` command dispatch and nav click. The `Promise.all([...waitForResponse])` sync is kept. The spec constructs a bare `ComfyPage` (never `setup()`) to obtain the page object without the backend-touching fixture setup — the established raw-page pattern from `linearMode.spec.ts`. - Strengthen the write-only assertion: alongside the existing `getByText` check (text nodes only), assert the secret value is reflected into no `` / `