From 5e333b0a341e8e2130ad0e77c6f6f62234fd6225 Mon Sep 17 00:00:00 2001 From: ShihChi Huang Date: Sun, 8 Nov 2026 05:04:42 +0000 Subject: [PATCH 1/2] feat: hand the deployment brief to a local agent from the Cloud setup card (#23077) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit

J9 agent menu and consent path

## Summary **J9, local-agent deployment request.** The Deploy your setup card offers Deploy with your agent: open the brief in Claude desktop or Codex, or copy the prompt. **Needs human review:** agent consent now goes through the Cloud ingest API (`globalSettingsApi` routing change), which is what the local deployment request needs to reach the configured environment. Flagging it explicitly rather than deciding it here. ## Verification
J2 · Missing node (step 4 of J2: the agent menu this PR adds) **4.** Claude, Codex and Copy prompt offered (screenshot predates the Codex relabel).
J2 · Missing node, step 4
J9 · Local-agent deployment request **1.** Load installed StringFunction node; no models.
J9 · Local-agent deployment request, step 1 **2.** Real incompatibility opens Deploy your setup to Comfy Cloud.
J9 · Local-agent deployment request, step 2 **3.** Real backend readiness exposes Use local agent.
J9 · Local-agent deployment request, step 3 **4.** One click: one acknowledged request with the right workflow, node, package and target.
J9 · Local-agent deployment request, step 4 **5.** Test turn stopped; one message remains. Downstream deployment excluded.
J9 · Local-agent deployment request, step 5
🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: huang47 <157390+huang47@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .../tests/liveCloud/openOnCloud.spec.ts | 23 +++++- .../workflowErrors.integration.test.ts | 4 +- src/locales/en/main.json | 7 +- .../components/DeploySetupAgentMenu.test.ts | 74 +++++++++++++++++++ .../components/DeploySetupAgentMenu.vue | 59 +++++++++++++++ .../components/DeploySetupCard.vue | 2 + .../components/DesktopAgentMarks.vue | 71 ++++++++++++++++++ .../settings/globalSettingsApi.test.ts | 6 +- src/platform/settings/globalSettingsApi.ts | 6 +- .../workflow/deploy/components/AgentMark.vue | 55 ++++++++++++++ .../components/DeployToComfyApiCard.test.ts | 4 +- .../composables/useAgentHandoff.test.ts | 63 ++++++++++++++++ .../deploy/composables/useAgentHandoff.ts | 64 ++++++++++------ .../workflow/deploy/utils/agentApps.test.ts | 54 ++++++++++++++ .../workflow/deploy/utils/agentApps.ts | 32 ++++++++ .../panel/DeploymentBuildActions.test.ts | 6 +- .../components/CustomDeploymentCard.test.ts | 2 +- .../composables/agent/useAgentConsent.test.ts | 7 +- 18 files changed, 496 insertions(+), 43 deletions(-) create mode 100644 src/platform/openOnCloud/components/DeploySetupAgentMenu.test.ts create mode 100644 src/platform/openOnCloud/components/DeploySetupAgentMenu.vue create mode 100644 src/platform/openOnCloud/components/DesktopAgentMarks.vue create mode 100644 src/platform/workflow/deploy/components/AgentMark.vue create mode 100644 src/platform/workflow/deploy/utils/agentApps.test.ts create mode 100644 src/platform/workflow/deploy/utils/agentApps.ts diff --git a/browser_tests/tests/liveCloud/openOnCloud.spec.ts b/browser_tests/tests/liveCloud/openOnCloud.spec.ts index aa24414a38e..b081cb100d7 100644 --- a/browser_tests/tests/liveCloud/openOnCloud.spec.ts +++ b/browser_tests/tests/liveCloud/openOnCloud.spec.ts @@ -84,13 +84,34 @@ test.describe( expect(compatibility.cloud.missing_models).toEqual([]) }) - await test.step('Offer the deployment', async () => { + await test.step('Offer the deployment and desktop agent choices', async () => { await expect( comfyPage.page.getByRole('heading', { name: 'Deploy your setup to Comfy Cloud', exact: true }) ).toBeVisible() + await comfyPage.page + .getByRole('button', { name: 'Deploy with your agent', exact: true }) + .click() + await expect( + comfyPage.page.getByRole('menuitem', { + name: 'Open in Claude desktop', + exact: true + }) + ).toBeVisible() + await expect( + comfyPage.page.getByRole('menuitem', { + name: 'Open in Codex', + exact: true + }) + ).toBeVisible() + await expect( + comfyPage.page.getByRole('menuitem', { + name: 'Copy prompt', + exact: true + }) + ).toBeVisible() await comfyPage.attachScreenshot('missing-cloud-node.png', { runInCI: true }) diff --git a/src/components/rightSidePanel/workflowErrors.integration.test.ts b/src/components/rightSidePanel/workflowErrors.integration.test.ts index 0ea4e5cf3cb..a823714935b 100644 --- a/src/components/rightSidePanel/workflowErrors.integration.test.ts +++ b/src/components/rightSidePanel/workflowErrors.integration.test.ts @@ -426,7 +426,7 @@ describe('ErrorGroupList selection emphasis', () => { ).toBe(sendsToBuild) expect( within(hero).queryByRole('button', { - name: /Build with your agent/ + name: /Deploy with your agent/ }) !== null ).toBe(sendsToBuild) } @@ -463,7 +463,7 @@ describe('ErrorGroupList selection emphasis', () => { ) ).toBeInTheDocument() expect( - within(hero).queryByRole('button', { name: /Build with your agent/ }) + within(hero).queryByRole('button', { name: /Deploy with your agent/ }) ).not.toBeInTheDocument() }) diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 3528bb28d51..082b8c5cceb 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -4278,6 +4278,11 @@ "asksToSignIn": "Comfy Cloud will ask you to sign in.", "openOnCloud": "Open on Comfy Cloud" }, + "agentMenu": { + "openInClaude": "Open in Claude desktop", + "openInCodex": "Open in Codex", + "copyPrompt": "Copy prompt" + }, "missingModels": { "title": "Missing {count} model | Missing {count} models", "unavailable": "Add these models to Comfy Cloud to run this workflow. Uploads from this ComfyUI are currently unavailable." @@ -4890,7 +4895,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": "Build with your agent", + "deployWithAgent": "Deploy 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.test.ts b/src/platform/openOnCloud/components/DeploySetupAgentMenu.test.ts new file mode 100644 index 00000000000..68e5a7a91cb --- /dev/null +++ b/src/platform/openOnCloud/components/DeploySetupAgentMenu.test.ts @@ -0,0 +1,74 @@ +import userEvent from '@testing-library/user-event' +import { render, screen } from '@testing-library/vue' +import { fromPartial } from '@total-typescript/shoehorn' +import { describe, expect, it, vi } from 'vitest' + +import DeploySetupAgentMenu from '@/platform/openOnCloud/components/DeploySetupAgentMenu.vue' +import { useAgentHandoff } from '@/platform/workflow/deploy/composables/useAgentHandoff' +import { testI18n } from '@/utils/__tests__/testI18n' + +vi.mock( + import('@/platform/workflow/deploy/composables/useAgentHandoff'), + () => { + const copyBrief = vi.fn(() => Promise.resolve(true)) + const openBriefIn = vi.fn() + return { useAgentHandoff: () => fromPartial({ copyBrief, openBriefIn }) } + } +) + +function renderMenu() { + render(DeploySetupAgentMenu, { global: { plugins: [testI18n] } }) + return userEvent.setup({ pointerEventsCheck: 0 }) +} + +async function pickRow(user: ReturnType, name: string) { + await user.click(screen.getByTestId('deploy-setup-agent')) + await user.click(await screen.findByRole('menuitem', { name })) +} + +describe('DeploySetupAgentMenu', () => { + it('offers the two desktop apps and Copy prompt, without Use local agent', async () => { + const user = renderMenu() + + await user.click(screen.getByTestId('deploy-setup-agent')) + + expect( + (await screen.findAllByRole('menuitem')).map((row) => + row.textContent.trim() + ) + ).toEqual(['Open in Claude desktop', 'Open in Codex', 'Copy prompt']) + }) + + it.for([ + { row: 'Open in Claude desktop', app: 'claude' }, + { row: 'Open in Codex', app: 'codex' } + ])('$row opens the brief in that app', async ({ row, app }) => { + const user = renderMenu() + + await pickRow(user, row) + + expect(useAgentHandoff().openBriefIn).toHaveBeenCalledExactlyOnceWith(app) + }) + + it('says Copied after Copy prompt, and shows its label again when the menu reopens', async () => { + const user = renderMenu() + const button = screen.getByTestId('deploy-setup-agent') + + await pickRow(user, 'Copy prompt') + expect(button).toHaveTextContent(/^Copied/) + + await user.click(button) + expect(button).toHaveTextContent('Deploy with your agent') + }) + + it('keeps its label when the brief did not reach the clipboard', async () => { + vi.mocked(useAgentHandoff().copyBrief).mockResolvedValueOnce(false) + const user = renderMenu() + + await pickRow(user, 'Copy prompt') + + expect(screen.getByTestId('deploy-setup-agent')).toHaveTextContent( + 'Deploy with your agent' + ) + }) +}) diff --git a/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue b/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue new file mode 100644 index 00000000000..cf6a96cd9e7 --- /dev/null +++ b/src/platform/openOnCloud/components/DeploySetupAgentMenu.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/platform/openOnCloud/components/DeploySetupCard.vue b/src/platform/openOnCloud/components/DeploySetupCard.vue index 216a95541f6..928d4355588 100644 --- a/src/platform/openOnCloud/components/DeploySetupCard.vue +++ b/src/platform/openOnCloud/components/DeploySetupCard.vue @@ -73,6 +73,7 @@ aria-hidden="true" /> + @@ -86,6 +87,7 @@ import Video from '@comfyorg/design-system/media/Video' import Button from '@comfyorg/design-system/button/Button' import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle' import { getComfyPlatformBaseUrl } from '@/config/comfyApi' +import DeploySetupAgentMenu from '@/platform/openOnCloud/components/DeploySetupAgentMenu.vue' import DeploymentDialogFrame from '@/platform/workspace/components/DeploymentDialogFrame.vue' import DeploymentDocsLink from '@/platform/workspace/components/DeploymentDocsLink.vue' diff --git a/src/platform/openOnCloud/components/DesktopAgentMarks.vue b/src/platform/openOnCloud/components/DesktopAgentMarks.vue new file mode 100644 index 00000000000..52b9eee8371 --- /dev/null +++ b/src/platform/openOnCloud/components/DesktopAgentMarks.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/platform/settings/globalSettingsApi.test.ts b/src/platform/settings/globalSettingsApi.test.ts index 03c69197c52..e4262a9ebba 100644 --- a/src/platform/settings/globalSettingsApi.test.ts +++ b/src/platform/settings/globalSettingsApi.test.ts @@ -13,7 +13,7 @@ import { } from './globalSettingsApi' vi.mock(import('@/config/comfyApi'), () => ({ - getComfyApiBaseUrl: () => 'https://api.comfy.test' + getComfyCloudBaseUrl: () => 'https://cloud.comfy.test' })) const distribution = vi.hoisted(() => ({ isCloud: true })) vi.mock(import('@/platform/distribution/types'), () => distribution) @@ -53,7 +53,7 @@ describe('Global Settings transport', () => { await expect(getGlobalSetting(key, authHeader)).resolves.toEqual(stored) expect(fetchWithUnifiedRemint).toHaveBeenCalledWith( - `${cloud ? '' : 'https://api.comfy.test'}/api/global-settings/${key}`, + `${cloud ? '' : 'https://cloud.comfy.test'}/api/global-settings/${key}`, expect.objectContaining({ cache: 'no-store', headers: authHeader }), false ) @@ -71,7 +71,7 @@ describe('Global Settings transport', () => { setGlobalSetting({ key, value: true }, authHeader) ).resolves.toEqual(stored) expect(fetchWithUnifiedRemint).toHaveBeenCalledWith( - `${cloud ? '' : 'https://api.comfy.test'}/api/global-settings`, + `${cloud ? '' : 'https://cloud.comfy.test'}/api/global-settings`, expect.objectContaining({ method: 'POST', headers: { ...authHeader, 'Content-Type': 'application/json' }, diff --git a/src/platform/settings/globalSettingsApi.ts b/src/platform/settings/globalSettingsApi.ts index 9b2cd9e7d3d..e0a984d5ece 100644 --- a/src/platform/settings/globalSettingsApi.ts +++ b/src/platform/settings/globalSettingsApi.ts @@ -5,13 +5,11 @@ import type { } from '@comfyorg/ingest-types' import { zErrorResponse, zGlobalSetting } from '@comfyorg/ingest-types/zod' -import { getComfyApiBaseUrl } from '@/config/comfyApi' +import { ingestApiUrl } from '@/platform/remote/ingest/ingestApiUrl' import { fetchWithUnifiedRemint, shouldRemintCloudRequest } from '@/platform/auth/unified/remintRetry' -import { isCloud } from '@/platform/distribution/types' -import { api } from '@/scripts/api' import type { WebSessionSend } from '@comfyorg/api-client/webSessionFetch' import type { AuthHeader } from '@comfyorg/api-client/authTypes' import { retryingSend } from '@comfyorg/api-client/fetchWithRetry' @@ -28,7 +26,7 @@ export class GlobalSettingsApiError extends Error { function globalSettingsUrl(key?: GlobalSettingKey): string { const path = `/global-settings${key ? `/${encodeURIComponent(key)}` : ''}` - return isCloud ? api.apiURL(path) : `${getComfyApiBaseUrl()}/api${path}` + return ingestApiUrl(path) } async function responseBody(response: Response): Promise { diff --git a/src/platform/workflow/deploy/components/AgentMark.vue b/src/platform/workflow/deploy/components/AgentMark.vue new file mode 100644 index 00000000000..237c27ead9d --- /dev/null +++ b/src/platform/workflow/deploy/components/AgentMark.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/platform/workflow/deploy/components/DeployToComfyApiCard.test.ts b/src/platform/workflow/deploy/components/DeployToComfyApiCard.test.ts index f061b0f7faa..d1fe3f688cd 100644 --- a/src/platform/workflow/deploy/components/DeployToComfyApiCard.test.ts +++ b/src/platform/workflow/deploy/components/DeployToComfyApiCard.test.ts @@ -134,7 +134,7 @@ describe('DeployToComfyApiCard', () => { await user.click(screen.getByTestId('deploy-to-comfy-api-agent')) expect(screen.getByTestId('deploy-to-comfy-api-agent')).toHaveTextContent( - 'Build with your agent' + 'Deploy with your agent' ) }) @@ -146,7 +146,7 @@ describe('DeployToComfyApiCard', () => { await user.click(button) - expect(button).toHaveTextContent('Build with your agent') + expect(button).toHaveTextContent('Deploy with your agent') }) it('links to the developer platform in a new tab without a referrer, and reports done', async () => { diff --git a/src/platform/workflow/deploy/composables/useAgentHandoff.test.ts b/src/platform/workflow/deploy/composables/useAgentHandoff.test.ts index 6de940c2ff2..e01cec8bda4 100644 --- a/src/platform/workflow/deploy/composables/useAgentHandoff.test.ts +++ b/src/platform/workflow/deploy/composables/useAgentHandoff.test.ts @@ -7,6 +7,7 @@ import { useCopyToClipboard } from '@/composables/useCopyToClipboard' import type { ComfyNodeDefImpl } from '@/core/graph/nodeDef/ComfyNodeDefImpl' import { reportError } from '@comfyorg/telemetry/reportError' import { useAgentHandoff } from '@/platform/workflow/deploy/composables/useAgentHandoff' +import { openAgentApp } from '@/platform/workflow/deploy/utils/agentApps' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useNodeDefStore } from '@/stores/nodeDefStore' @@ -26,6 +27,10 @@ vi.mock(import('@comfyorg/telemetry/reportError'), () => ({ reportError: vi.fn() })) +vi.mock(import('@/platform/workflow/deploy/utils/agentApps'), () => ({ + openAgentApp: vi.fn() +})) + const GRAPH = { nodes: [{ id: 1, type: 'KSampler' }], links: [] } function setActiveWorkflow( @@ -116,6 +121,64 @@ describe('useAgentHandoff', () => { } ) + it.for([ + { app: 'claude', distribution: 'localhost', downloads: 1 }, + { app: 'codex', distribution: 'desktop', downloads: 0 } + ] as const)( + 'opens the brief in the $app desktop app, downloading the workflow $downloads times on $distribution', + ({ app, distribution, downloads }) => { + setActiveWorkflow() + + useAgentHandoff(distribution).openBriefIn(app) + + expect(openAgentApp).toHaveBeenCalledExactlyOnceWith( + app, + expect.stringContaining( + '# Turn `portrait-upscale` into a Comfy API Build' + ) + ) + expect(downloadBlob).toHaveBeenCalledTimes(downloads) + } + ) + + it('downloads the workflow before opening the agent app', () => { + setActiveWorkflow() + const order: string[] = [] + vi.mocked(downloadBlob).mockImplementationOnce(() => { + order.push('download') + }) + vi.mocked(openAgentApp).mockImplementationOnce(() => { + order.push('open') + }) + + useAgentHandoff().openBriefIn('claude') + + expect(order).toEqual(['download', 'open']) + }) + + it('reports a failed download and leaves the agent app closed', () => { + setActiveWorkflow() + const downloadError = new Error('download blocked') + vi.mocked(downloadBlob).mockImplementationOnce(() => { + throw downloadError + }) + + useAgentHandoff().openBriefIn('claude') + + expect(openAgentApp).not.toHaveBeenCalled() + expect(reportError).toHaveBeenCalledExactlyOnceWith(downloadError, { + errorType: 'error_opening_deploy_agent_brief', + surface: 'platform' + }) + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + description: + 'The brief for your agent could not be prepared. Try again.', + kind: 'error' + }) + ]) + }) + it('lists the model a known loader loads, and not prompt text ending in .pt', async () => { useNodeDefStore().nodeDefsByName = { CheckpointLoaderSimple: fromPartial({ diff --git a/src/platform/workflow/deploy/composables/useAgentHandoff.ts b/src/platform/workflow/deploy/composables/useAgentHandoff.ts index 34c42b931af..20ea4008a0f 100644 --- a/src/platform/workflow/deploy/composables/useAgentHandoff.ts +++ b/src/platform/workflow/deploy/composables/useAgentHandoff.ts @@ -9,6 +9,8 @@ import { buildAgentHandoffDocument, handoffFileName } from '@/platform/workflow/deploy/utils/agentHandoff' +import { openAgentApp } from '@/platform/workflow/deploy/utils/agentApps' +import type { AgentApp } from '@/platform/workflow/deploy/utils/agentApps' import { deriveBuildInputs } from '@/platform/workflow/deploy/utils/buildInputs' import type { BuildInputs } from '@/platform/workflow/deploy/utils/buildInputs' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' @@ -59,41 +61,57 @@ export function useAgentHandoff(distribution: Distribution = DISTRIBUTION) { return snapshot().inputs } + function prepareHandoff() { + const { graph, inputs } = snapshot() + return { + brief: buildAgentHandoffDocument({ distribution, inputs }), + downloadWorkflow() { + if (distribution === 'desktop') return + downloadBlob( + inputs.workflowFileName, + new Blob([JSON.stringify(graph, null, 2)], { + type: 'application/json' + }) + ) + } + } + } + + function reportHandoffFailure(error: unknown, errorType: string) { + reportError(error, { errorType, surface: 'platform' }) + toast.error(t('g.error'), { + description: t('deployToComfyApi.briefFailed'), + duration: 5000 + }) + } + async function copyBrief(): Promise { try { - const { graph, inputs } = snapshot() - const document = buildAgentHandoffDocument({ - distribution, - inputs - }) - if (!(await copyToClipboard(document, { toastOnSuccess: false }))) { + const { brief, downloadWorkflow } = prepareHandoff() + if (!(await copyToClipboard(brief, { toastOnSuccess: false }))) { reportError(new Error('The clipboard refused the brief'), { errorType: 'error_copying_deploy_agent_brief', surface: 'platform' }) return false } - if (distribution !== 'desktop') { - downloadBlob( - inputs.workflowFileName, - new Blob([JSON.stringify(graph, null, 2)], { - type: 'application/json' - }) - ) - } + downloadWorkflow() return true } catch (error) { - reportError(error, { - errorType: 'error_copying_deploy_agent_brief', - surface: 'platform' - }) - toast.error(t('g.error'), { - description: t('deployToComfyApi.briefFailed'), - duration: 5000 - }) + reportHandoffFailure(error, 'error_copying_deploy_agent_brief') return false } } - return { captureInputs, copyBrief } + function openBriefIn(app: AgentApp): void { + try { + const { brief, downloadWorkflow } = prepareHandoff() + downloadWorkflow() + openAgentApp(app, brief) + } catch (error) { + reportHandoffFailure(error, 'error_opening_deploy_agent_brief') + } + } + + return { captureInputs, copyBrief, openBriefIn } } diff --git a/src/platform/workflow/deploy/utils/agentApps.test.ts b/src/platform/workflow/deploy/utils/agentApps.test.ts new file mode 100644 index 00000000000..b3dce1fcafc --- /dev/null +++ b/src/platform/workflow/deploy/utils/agentApps.test.ts @@ -0,0 +1,54 @@ +// @vitest-environment happy-dom +// @vitest-environment-options {"settings":{"disableIframePageLoading":false,"enableIframePageLoading":true}} +import { describe, expect, it, vi } from 'vitest' + +import { openAgentApp } from './agentApps' + +function recordFrameNavigations() { + const navigations: { url: string; hidden: boolean }[] = [] + vi.spyOn(HTMLIFrameElement.prototype, 'src', 'set').mockImplementation( + function (this: HTMLIFrameElement, url: string) { + navigations.push({ url, hidden: this.hidden && this.isConnected }) + } + ) + return navigations +} + +describe('openAgentApp', () => { + it.for([ + { app: 'claude', url: 'claude://code/new?q=a%20b%0Ac%26d%3D1%23e' }, + { app: 'codex', url: 'codex://new?prompt=a%20b%0Ac%26d%3D1%23e' } + ] as const)( + 'hands the whole prompt, encoded, to the $app app from a hidden frame', + ({ app, url }) => { + const navigations = recordFrameNavigations() + + openAgentApp(app, 'a b\nc&d=1#e') + + expect(navigations).toEqual([{ url, hidden: true }]) + } + ) + + it('replaces a lone surrogate instead of throwing, and keeps a pair whole', () => { + const navigations = recordFrameNavigations() + + openAgentApp('codex', '\uD800 build \uDC00 🙂') + + expect(navigations.map(({ url }) => url)).toEqual([ + 'codex://new?prompt=%EF%BF%BD%20build%20%EF%BF%BD%20%F0%9F%99%82' + ]) + }) + + it('reuses one frame for every launch', () => { + const navigations = recordFrameNavigations() + + openAgentApp('claude', 'first') + openAgentApp('codex', 'second') + + expect(navigations.map(({ url }) => url)).toEqual([ + 'claude://code/new?q=first', + 'codex://new?prompt=second' + ]) + expect(document.querySelectorAll('iframe')).toHaveLength(1) + }) +}) diff --git a/src/platform/workflow/deploy/utils/agentApps.ts b/src/platform/workflow/deploy/utils/agentApps.ts new file mode 100644 index 00000000000..bceec277103 --- /dev/null +++ b/src/platform/workflow/deploy/utils/agentApps.ts @@ -0,0 +1,32 @@ +export type AgentApp = 'claude' | 'codex' + +const AGENT_APP_LINKS: Record string> = { + claude: (encodedPrompt) => `claude://code/new?q=${encodedPrompt}`, + codex: (encodedPrompt) => `codex://new?prompt=${encodedPrompt}` +} + +const SURROGATES = /([\uD800-\uDBFF][\uDC00-\uDFFF])|[\uD800-\uDFFF]/g + +function wellFormed(text: string): string { + return text.replace(SURROGATES, (_, pair?: string) => pair ?? '\uFFFD') +} + +function agentAppUrl(app: AgentApp, prompt: string): string { + return AGENT_APP_LINKS[app](encodeURIComponent(wellFormed(prompt))) +} + +const LAUNCHER_FRAME_ID = 'agent-app-launcher' + +function hiddenLauncherFrame(): HTMLIFrameElement { + const existing = document.getElementById(LAUNCHER_FRAME_ID) + if (existing instanceof HTMLIFrameElement) return existing + const frame = document.createElement('iframe') + frame.id = LAUNCHER_FRAME_ID + frame.hidden = true + return document.body.appendChild(frame) +} + +/** Starts a new session in the desktop app with the prompt in its composer, unsent. */ +export function openAgentApp(app: AgentApp, prompt: string): void { + hiddenLauncherFrame().src = agentAppUrl(app, prompt) +} diff --git a/src/platform/workflowErrors/panel/DeploymentBuildActions.test.ts b/src/platform/workflowErrors/panel/DeploymentBuildActions.test.ts index 6bf59a61a66..0a1b460c47b 100644 --- a/src/platform/workflowErrors/panel/DeploymentBuildActions.test.ts +++ b/src/platform/workflowErrors/panel/DeploymentBuildActions.test.ts @@ -87,7 +87,7 @@ function renderActions( async function copiedBrief(user: UserEvent): Promise { copyToClipboard.mockResolvedValue(true) await user.click( - screen.getByRole('button', { name: /Build with your agent/ }) + screen.getByRole('button', { name: /Deploy with your agent/ }) ) const [brief] = copyToClipboard.mock.lastCall ?? [] return String(brief) @@ -130,7 +130,7 @@ describe('DeploymentBuildActions', () => { const user = renderActions() await user.click( - screen.getByRole('button', { name: /Build with your agent/ }) + screen.getByRole('button', { name: /Deploy with your agent/ }) ) const [brief] = copyToClipboard.mock.lastCall ?? [] @@ -248,7 +248,7 @@ describe('DeploymentBuildActions', () => { screen.queryByRole('link', { name: /on Platform/ }) ).not.toBeInTheDocument() expect( - screen.queryByRole('button', { name: /Build with your agent/ }) + screen.queryByRole('button', { name: /Deploy with your agent/ }) ).not.toBeInTheDocument() await user.click(screen.getByRole('button', { name: 'Reload' })) await waitFor(() => diff --git a/src/platform/workspace/components/CustomDeploymentCard.test.ts b/src/platform/workspace/components/CustomDeploymentCard.test.ts index 049c908b199..eeb0bf0661b 100644 --- a/src/platform/workspace/components/CustomDeploymentCard.test.ts +++ b/src/platform/workspace/components/CustomDeploymentCard.test.ts @@ -139,7 +139,7 @@ describe('CustomDeploymentCard', () => { await user.click(screen.getByTestId('custom-deployment-agent')) expect(screen.getByTestId('custom-deployment-agent')).toHaveTextContent( - 'Build with your agent' + 'Deploy with your agent' ) }) diff --git a/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts b/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts index 5a425a0d300..0c5d27b7b57 100644 --- a/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts +++ b/src/workbench/extensions/agent/composables/agent/useAgentConsent.test.ts @@ -26,7 +26,8 @@ import { useAgentConsent } from './useAgentConsent' vi.mock(import('@/composables/auth/useCurrentUser')) vi.mock(import('@/config/comfyApi'), () => ({ - getComfyApiBaseUrl: () => 'https://api.comfy.test' + getComfyApiBaseUrl: () => 'https://api.comfy.test', + getComfyCloudBaseUrl: () => 'https://cloud.comfy.test' })) const distribution = vi.hoisted(() => ({ isCloud: false })) @@ -669,7 +670,7 @@ describe('useAgentConsent', () => { await vi.waitFor(() => { expect(fetchWithUnifiedRemint).toHaveBeenLastCalledWith( - 'https://api.comfy.test/api/global-settings', + 'https://cloud.comfy.test/api/global-settings', expect.objectContaining({ method: 'POST', headers: expect.objectContaining({ @@ -880,7 +881,7 @@ describe('useAgentConsent', () => { expect(useTeamWorkspaceStore().initialize).toHaveBeenCalledOnce() expect(fetchWithUnifiedRemint).toHaveBeenCalledOnce() expect(fetchWithUnifiedRemint).toHaveBeenCalledWith( - 'https://api.comfy.test/api/global-settings', + 'https://cloud.comfy.test/api/global-settings', expect.objectContaining({ method: 'POST', body: JSON.stringify({ key: stored.key, value: true }) From 89e3383bd84a4dae726af56ebaf52559378083e9 Mon Sep 17 00:00:00 2001 From: huang47 <157390+huang47@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:09:36 +0800 Subject: [PATCH 2/2] fix: adapt #23077 for core/1.60 Drop the happy-dom 21 enableIframePageLoading setting from agentApps.test.ts: this branch pins happy-dom 20, where disableIframePageLoading:false is the equivalent. --- src/platform/workflow/deploy/utils/agentApps.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/workflow/deploy/utils/agentApps.test.ts b/src/platform/workflow/deploy/utils/agentApps.test.ts index b3dce1fcafc..777af770edb 100644 --- a/src/platform/workflow/deploy/utils/agentApps.test.ts +++ b/src/platform/workflow/deploy/utils/agentApps.test.ts @@ -1,5 +1,5 @@ // @vitest-environment happy-dom -// @vitest-environment-options {"settings":{"disableIframePageLoading":false,"enableIframePageLoading":true}} +// @vitest-environment-options {"settings":{"disableIframePageLoading":false}} import { describe, expect, it, vi } from 'vitest' import { openAgentApp } from './agentApps'