From ffe83463de3ab7cd532ea374cc078a7ed635d1bd Mon Sep 17 00:00:00 2001 From: ShihChi Huang Date: Mon, 9 Nov 2026 07:03:54 +0000 Subject: [PATCH] fix: keep Open on Cloud inert while its flag is off (#23134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary With `open_on_cloud_enabled` off (the default everywhere), four paths from #23074, #23075 and #23077 still changed behaviour. This gates them so the flag-off app matches the pre-feature app, which is the precondition for backporting the series to `cloud/1.59` and `core/1.59`. | Path | Before (flag off) | After (flag off) | |---|---|---| | `?desktop_workflow=` on local/Desktop (`main.ts` → `desktopWorkflowRelay`) | Skips `bootstrap()`; reads and deletes `userdata/open-on-cloud/*`, or strands the splash on "could not be transferred" | Loads `/features`, sees the flag off, boots normally; no userdata I/O | | First-run `?from_local=` (`useWorkflowPersistenceV2`) | Startup outcome `url-intent`, skipping Getting Started | `fresh`; onboarding unchanged | | Agent consent off Cloud (`globalSettingsApi`) | `cloud.comfy.org/api/global-settings` | `api.comfy.org/api/global-settings`, as before #23077; the ingest host only with the flag on | | `deployToComfyApi.deployWithAgent` on CustomDeploymentCard, DeployToComfyApiCard, DeploymentBuildActions | "Deploy with your agent" | "Build with your agent", as before; the Cloud setup menu uses a new `openOnCloud.deployWithAgent` | Notes: - The relay check runs before boot from the anonymous server features, so a `?ff=` employee override cannot enable the relay; it fails closed. - Left as is, with flag off: the Cloud pre-boot `#desktop_workflow=` capture (no network; strips the hash and writes a 10-minute sessionStorage entry the loader discards), the `from_local` preserved-query capture, and stripping `from_local` from the Cloud URL. Each needs a hand-made URL and has no network or UI effect. - Whether `api.comfy.org` and `cloud.comfy.org` share consent state when the flag flips on is still the open question #23077 raised. ## Verification - Unit: `desktopWorkflowRelay`, `useWorkflowPersistenceV2`, `globalSettingsApi` and the four relabelled surfaces, plus `src/platform/openOnCloud` — 161 + 66 passing. The new flag-off relay and `from_local` cases fail with the gate reverted. - E2E `openOnCloudGate.spec.ts` against a local CI-container backend: 5 passed. The two new flag-off relay cases (UUID and malformed nonce) boot the editor with no `open-on-cloud` traffic and fail with the gate reverted; a flag-on control proves the spec sees the userdata request. - Pre-commit: oxfmt, oxlint, eslint, `lint:server-facts`, `typecheck:app`, `typecheck:browser`; `pnpm deps:audit` clean. --------- Co-authored-by: huang47 <157390+huang47@users.noreply.github.com> --- .../fixtures/helpers/FeatureFlagHelper.ts | 31 ++++++++--- .../fixtures/helpers/openOnCloudTraffic.ts | 21 +++++++ browser_tests/tests/openOnCloudGate.spec.ts | 55 ++++++++++++++----- .../workflowErrors.integration.test.ts | 4 +- src/locales/en/main.json | 3 +- .../components/DeploySetupAgentMenu.vue | 2 +- .../openOnCloud/desktopWorkflowRelay.test.ts | 26 ++++++++- .../openOnCloud/desktopWorkflowRelay.ts | 12 +++- .../settings/globalSettingsApi.test.ts | 28 +++++++--- src/platform/settings/globalSettingsApi.ts | 7 ++- .../components/DeployToComfyApiCard.test.ts | 4 +- .../useWorkflowPersistenceV2.test.ts | 40 +++++++++++--- .../composables/useWorkflowPersistenceV2.ts | 3 + .../panel/DeploymentBuildActions.test.ts | 6 +- .../components/CustomDeploymentCard.test.ts | 2 +- 15 files changed, 191 insertions(+), 53 deletions(-) create mode 100644 browser_tests/fixtures/helpers/openOnCloudTraffic.ts diff --git a/browser_tests/fixtures/helpers/FeatureFlagHelper.ts b/browser_tests/fixtures/helpers/FeatureFlagHelper.ts index b646f807805..48f0c1dd0b6 100644 --- a/browser_tests/fixtures/helpers/FeatureFlagHelper.ts +++ b/browser_tests/fixtures/helpers/FeatureFlagHelper.ts @@ -1,7 +1,9 @@ import type { Page, Route } from '@playwright/test' +type FeaturesRouteHandler = (route: Route) => Promise + export class FeatureFlagHelper { - private featuresRouteHandler: ((route: Route) => void) | null = null + private readonly featuresRouteHandlers: FeaturesRouteHandler[] = [] constructor(private readonly page: Page) {} @@ -195,19 +197,34 @@ export class FeatureFlagHelper { * Mock server feature flags via route interception on /api/features. */ async mockServerFeatures(features: Record): Promise { - this.featuresRouteHandler = (route: Route) => + await this.routeFeatures((route) => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(features) }) - await this.page.route('**/api/features', this.featuresRouteHandler) + ) + } + + /** Merge features into the real /api/features response. */ + async mergeServerFeatures(features: Record): Promise { + await this.routeFeatures(async (route) => { + const response = await route.fetch() + await route.fulfill({ + response, + json: { ...(await response.json()), ...features } + }) + }) } async clearMocks(): Promise { - if (this.featuresRouteHandler) { - await this.page.unroute('**/api/features', this.featuresRouteHandler) - this.featuresRouteHandler = null - } + const handlers = this.featuresRouteHandlers.splice(0) + for (const handler of handlers) + await this.page.unroute('**/api/features', handler) + } + + private async routeFeatures(handler: FeaturesRouteHandler): Promise { + this.featuresRouteHandlers.push(handler) + await this.page.route('**/api/features', handler) } } diff --git a/browser_tests/fixtures/helpers/openOnCloudTraffic.ts b/browser_tests/fixtures/helpers/openOnCloudTraffic.ts new file mode 100644 index 00000000000..53372b8be8a --- /dev/null +++ b/browser_tests/fixtures/helpers/openOnCloudTraffic.ts @@ -0,0 +1,21 @@ +import type { Page, Request } from '@playwright/test' + +export const DESKTOP_RELAY_NONCE = '3f1c2b7e-9a4d-4c1e-8b2f-6d5e4a3b2c1d' + +function isOpenOnCloudTraffic(request: Request): boolean { + const url = new URL(request.url()) + return ( + url.pathname.endsWith('/api/cloud/compatibility') || + decodeURIComponent(url.pathname).includes('/userdata/open-on-cloud/') + ) +} + +/** Collect the decoded URLs of every Open on Cloud request the page sends. */ +export function recordOpenOnCloudTraffic(page: Page): string[] { + const traffic: string[] = [] + page.on('request', (request) => { + if (isOpenOnCloudTraffic(request)) + traffic.push(decodeURIComponent(request.url())) + }) + return traffic +} diff --git a/browser_tests/tests/openOnCloudGate.spec.ts b/browser_tests/tests/openOnCloudGate.spec.ts index 04d4198b3e0..35e5ad7a34a 100644 --- a/browser_tests/tests/openOnCloudGate.spec.ts +++ b/browser_tests/tests/openOnCloudGate.spec.ts @@ -1,15 +1,10 @@ -import type { Request } from '@playwright/test' import { expect } from '@playwright/test' import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' - -function isOpenOnCloudTraffic(request: Request): boolean { - const url = new URL(request.url()) - return ( - url.pathname.endsWith('/api/cloud/compatibility') || - decodeURIComponent(url.pathname).includes('/userdata/open-on-cloud/') - ) -} +import { + DESKTOP_RELAY_NONCE, + recordOpenOnCloudTraffic +} from '@e2e/fixtures/helpers/openOnCloudTraffic' test.describe('Open on Cloud gate', { tag: ['@ui'] }, () => { test('boots, loads and hovers the top menu without any Open on Cloud surface or traffic while the gate is off', async ({ @@ -18,10 +13,7 @@ test.describe('Open on Cloud gate', { tag: ['@ui'] }, () => { await comfyPage.featureFlags.seedServerFlags({ open_on_cloud_enabled: false }) - const traffic: string[] = [] - comfyPage.page.on('request', (request) => { - if (isOpenOnCloudTraffic(request)) traffic.push(request.url()) - }) + const traffic = recordOpenOnCloudTraffic(comfyPage.page) await comfyPage.workflow.reloadAndWaitForApp() await comfyPage.workflow.loadWorkflow('openOnCloud/01-runnable-on-cloud') @@ -31,6 +23,43 @@ test.describe('Open on Cloud gate', { tag: ['@ui'] }, () => { expect(traffic).toEqual([]) }) + for (const nonce of [DESKTOP_RELAY_NONCE, 'not-a-uuid']) { + test(`boots the editor from a Desktop relay link (${nonce}) without touching the transfer while the gate is off`, async ({ + comfyPage + }) => { + await comfyPage.featureFlags.mergeServerFeatures({ + open_on_cloud_enabled: false + }) + const traffic = recordOpenOnCloudTraffic(comfyPage.page) + + await comfyPage.goto({ + url: `/?desktop_workflow=${nonce}&user=e2e-relay-user` + }) + await comfyPage.waitForAppReady() + + expect(traffic).toEqual([]) + }) + } + + test('reads the staged transfer from a Desktop relay link while the gate is on, proving the gate-off check watches the right request', async ({ + comfyPage + }) => { + await comfyPage.featureFlags.mergeServerFeatures({ + open_on_cloud_enabled: true + }) + const traffic = recordOpenOnCloudTraffic(comfyPage.page) + + await comfyPage.goto({ + url: `/?desktop_workflow=${DESKTOP_RELAY_NONCE}&user=e2e-relay-user` + }) + + await expect + .poll(() => traffic) + .toContainEqual( + expect.stringContaining(`open-on-cloud/${DESKTOP_RELAY_NONCE}`) + ) + }) + test('shows the Cloud button while the gate is on, proving the gate-off check looks at the right control', async ({ comfyPage }) => { diff --git a/src/components/rightSidePanel/workflowErrors.integration.test.ts b/src/components/rightSidePanel/workflowErrors.integration.test.ts index dac21bd6355..f2b954a88c9 100644 --- a/src/components/rightSidePanel/workflowErrors.integration.test.ts +++ b/src/components/rightSidePanel/workflowErrors.integration.test.ts @@ -457,7 +457,7 @@ describe('ErrorGroupList selection emphasis', () => { ).toBe(sendsToBuild) expect( within(hero).queryByRole('button', { - name: /Deploy with your agent/ + name: /Build with your agent/ }) !== null ).toBe(sendsToBuild) } @@ -494,7 +494,7 @@ describe('ErrorGroupList selection emphasis', () => { ) ).toBeInTheDocument() expect( - within(hero).queryByRole('button', { name: /Deploy with your agent/ }) + within(hero).queryByRole('button', { name: /Build with your agent/ }) ).not.toBeInTheDocument() }) diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 7d19a60ed84..38d833a4f37 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -4251,6 +4251,7 @@ }, "openOnCloud": { "deploySetup": "Deploy your setup to Comfy Cloud", + "deployWithAgent": "Deploy with your agent", "deploySetupDialog": { "body": "This creates a deployment of your setup on Comfy Cloud. You manage it from Comfy Platform.", "pointGpu": "Work in ComfyUI on the GPU you choose", @@ -4898,7 +4899,7 @@ "body": "Deploy this workflow as a production API in minutes. Package your custom nodes, models and Python dependencies into a reproducible build, and Comfy API runs it as an autoscaling endpoint.", "readDocs": "Read the docs", "deployOnPlatform": "Deploy on Platform", - "deployWithAgent": "Deploy with your agent", + "deployWithAgent": "Build with your agent", "copied": "Copied", "summaryPacks": "{count} node pack | {count} node packs", "summaryModels": "{count} model | {count} models", diff --git a/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue b/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue index cf6a96cd9e7..332df3ca0a3 100644 --- a/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue +++ b/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue @@ -19,7 +19,7 @@