Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion browser_tests/tests/liveCloud/openOnCloud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()
})

Expand Down
7 changes: 6 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<typeof userEvent.setup>, 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'
)
})
})
59 changes: 59 additions & 0 deletions src/platform/openOnCloud/components/DeploySetupAgentMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<Menu
align="end"
:side-offset="6"
:class="cn('min-w-52', switcherMenuMotionClass)"
@update:open="clearCopiedOnOpen"
>
<template #trigger>
<Button
variant="inverted"
size="lg"
:class="cn('w-full @xl:w-auto', !copied && 'gap-3')"
data-testid="deploy-setup-agent"
:loading="isCopying"
>
<template v-if="copied">
<i class="icon-[lucide--check]" aria-hidden="true" />
{{ $t('deployToComfyApi.copied') }}
</template>
<template v-else>
<DesktopAgentMarks />
{{ $t('deployToComfyApi.deployWithAgent') }}
</template>
<i class="icon-[lucide--chevron-down]" aria-hidden="true" />
</Button>
</template>
<MenuItem @select="openBriefIn('claude')">
<AgentMark agent="claude" />
{{ $t('openOnCloud.agentMenu.openInClaude') }}
</MenuItem>
<MenuItem @select="openBriefIn('codex')">
<AgentMark agent="codex" />
{{ $t('openOnCloud.agentMenu.openInCodex') }}
</MenuItem>
<MenuItem @select="copyWith(copyBrief)">
<i class="icon-[lucide--copy]" aria-hidden="true" />
{{ $t('openOnCloud.agentMenu.copyPrompt') }}
</MenuItem>
</Menu>
</template>

<script setup lang="ts">
import { cn } from '@comfyorg/tailwind-utils'
import Button from '@comfyorg/design-system/button/Button'
import Menu from '@comfyorg/design-system/menu/Menu'
import MenuItem from '@comfyorg/design-system/menu/MenuItem'
import DesktopAgentMarks from '@/platform/openOnCloud/components/DesktopAgentMarks.vue'
import AgentMark from '@/platform/workflow/deploy/components/AgentMark.vue'
import { useAgentHandoff } from '@/platform/workflow/deploy/composables/useAgentHandoff'
import { switcherMenuMotionClass } from '@/platform/workspace/components/deploymentSwitcherStyles'
import { useBriefCopy } from '@/platform/workspace/composables/useBriefCopy'

const { copyBrief, openBriefIn } = useAgentHandoff()
const { isCopying, copied, copyWith } = useBriefCopy()

function clearCopiedOnOpen(open: boolean) {
if (open) copied.value = false
}
</script>
2 changes: 2 additions & 0 deletions src/platform/openOnCloud/components/DeploySetupCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
aria-hidden="true"
/>
</Button>
<DeploySetupAgentMenu />
</footer>
</section>
</DeploymentDialogFrame>
Expand All @@ -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'

Expand Down
71 changes: 71 additions & 0 deletions src/platform/openOnCloud/components/DesktopAgentMarks.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<svg
width="38"
height="28"
viewBox="0 -4 38 28"
class="shrink-0"
aria-hidden="true"
>
<defs>
<mask
:id="cutoutId"
maskUnits="userSpaceOnUse"
x="0"
y="-4"
width="38"
height="28"
>
<rect x="0" y="-4" width="38" height="28" fill="#fff" />
<circle cx="10" cy="10" r="12" fill="#000" />
</mask>
<linearGradient
:id="codexGradientId"
gradientUnits="userSpaceOnUse"
x1="12"
x2="12"
y1="3"
y2="21"
>
<stop
v-for="stop in CODEX_GRADIENT_STOPS"
:key="stop.offset"
:offset="stop.offset"
:stop-color="stop.color"
/>
</linearGradient>
</defs>
<g :mask="`url(#${cutoutId})`">

Check warning on line 37 in src/platform/openOnCloud/components/DesktopAgentMarks.vue

View workflow job for this annotation

GitHub Actions / fallow / fallow

Code duplication

18 duplicated lines (51 tokens) 3 instances found. Also in: → deploy/components/AgentMark.vue:14-31 → deploy/components/AgentMarks.vue:20-37 Extract a shared function to eliminate this duplication.
<g transform="rotate(10 28 10)">
<circle cx="28" cy="10" r="10" fill="#fff" />
<path
transform="translate(20 2) scale(0.8421) translate(-2.5 -2.5)"
:fill="`url(#${codexGradientId})`"
:d="CODEX_MARK_PATH"
/>
</g>
</g>
<g transform="rotate(-10 10 10)">
<circle cx="10" cy="10" r="10" fill="#d97757" />
<path
transform="translate(2 2) scale(0.6667)"
fill="#fff"
fill-rule="evenodd"
clip-rule="evenodd"
:d="CLAUDE_MARK_PATH"
/>
</g>
</svg>
</template>

<script setup lang="ts">
import { useId } from 'vue'

import {
CLAUDE_MARK_PATH,
CODEX_GRADIENT_STOPS,
CODEX_MARK_PATH
} from '@/platform/workflow/deploy/components/agentMarkPaths'

const cutoutId = useId()
const codexGradientId = useId()
</script>
6 changes: 3 additions & 3 deletions src/platform/settings/globalSettingsApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand All @@ -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' },
Expand Down
6 changes: 2 additions & 4 deletions src/platform/settings/globalSettingsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<unknown> {
Expand Down
Loading
Loading