diff --git a/browser_tests/fixtures/utils/cloudBootMocks.ts b/browser_tests/fixtures/utils/cloudBootMocks.ts
index c607eaa3cbc..36b147f6be9 100644
--- a/browser_tests/fixtures/utils/cloudBootMocks.ts
+++ b/browser_tests/fixtures/utils/cloudBootMocks.ts
@@ -5,6 +5,7 @@ import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
import { mockSystemStats } from '@e2e/fixtures/data/systemStats'
import { CloudAuthHelper } from '@e2e/fixtures/helpers/CloudAuthHelper'
+import { FeatureFlagHelper } from '@e2e/fixtures/helpers/FeatureFlagHelper'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
import {
mockDeploymentRolloutRefusal,
@@ -32,6 +33,10 @@ export async function mockCloudBootRoutes(
) {
await mockDeploymentRolloutRefusal(page)
await page.route('**/api/features', (r) => r.fulfill(jsonRoute(features)))
+ if (features['agent-in-app-experience'] === true)
+ await new FeatureFlagHelper(page).seedServerFlags({
+ agent: { state: 'ready' }
+ })
await page.route('**/api/system_stats', (r) =>
r.fulfill(jsonRoute(mockSystemStats))
)
diff --git a/src/components/topbar/AgentEntryButton.vue b/src/components/topbar/AgentEntryButton.vue
index c8ed174f4e9..6467e715c48 100644
--- a/src/components/topbar/AgentEntryButton.vue
+++ b/src/components/topbar/AgentEntryButton.vue
@@ -6,10 +6,21 @@
cn(
'group no-drag shrink-0 gap-1 rounded-lg',
active && 'bg-secondary-background-hover',
- inviting && !active && 'agent-shimmer-outline'
+ inviting && !active && !comfyAgent && 'agent-shimmer-outline',
+ comfyAgent && 'cursor-default opacity-50'
)
"
:aria-pressed="active"
+ :aria-disabled="comfyAgent !== undefined || undefined"
+ :title="
+ comfyAgent?.state === 'failed'
+ ? $t('agent.entryFailedReason', {
+ reason: comfyAgent.reason ?? 'unknown'
+ })
+ : comfyAgent?.reason
+ ? $t('agent.entryStartingReason', { reason: comfyAgent.reason })
+ : undefined
+ "
>
- {{ $t('agent.entryButton') }}
+ {{
+ comfyAgent?.state === 'starting'
+ ? $t('agent.entryStarting')
+ : comfyAgent?.state === 'failed'
+ ? $t('agent.entryFailed')
+ : $t('agent.entryButton')
+ }}
@@ -27,10 +44,17 @@
import { cn } from '@comfyorg/tailwind-utils'
import Button from '@/components/ui/button/Button.vue'
+import type { AgentServerFeature } from '@/workbench/extensions/agent/schemas/agentApiSchema'
-const { active = false, inviting = false } = defineProps<{
+const {
+ active = false,
+ inviting = false,
+ comfyAgent
+} = defineProps<{
active?: boolean
/** Draw attention to the button for a user who has never opened the panel. */
inviting?: boolean
+ /** ComfyUI's agent while it is not ready: shown, but inert. */
+ comfyAgent?: AgentServerFeature
}>()
diff --git a/src/components/topbar/WorkflowTabs.test.ts b/src/components/topbar/WorkflowTabs.test.ts
index 01f19f592c4..0ad7eb5b45b 100644
--- a/src/components/topbar/WorkflowTabs.test.ts
+++ b/src/components/topbar/WorkflowTabs.test.ts
@@ -218,6 +218,7 @@ describe('WorkflowTabs agent entry button', () => {
beforeEach(() => {
useAgentPanelStore().enabled = true
api.serverFeatureFlagsSettled.value = false
+ api.serverFeatureFlags.value = {}
})
it('does not render the entry button in the legacy tab bar even with the flag on', () => {
@@ -255,6 +256,70 @@ describe('WorkflowTabs agent entry button', () => {
expect(screen.getByTestId('agent-entry-separator')).toBeInTheDocument()
})
+ it("shows ComfyUI's agent starting, then failed with its reason, inert until ready", async () => {
+ const store = useAgentPanelStore()
+ store.enabled = false
+ api.serverFeatureFlags.value = {
+ agent: { state: 'starting', reason: null }
+ }
+ const { user } = renderComponent()
+
+ const starting = screen.getByRole('button', {
+ name: enMessages.agent.entryStarting
+ })
+ expect(starting).toHaveAttribute('aria-disabled', 'true')
+ expect(starting).not.toHaveAttribute('title')
+ await user.click(starting)
+ expect(withConsent).not.toHaveBeenCalled()
+
+ api.serverFeatureFlags.value = {
+ agent: { state: 'failed', reason: 'not_found' }
+ }
+ await nextTick()
+ const failed = screen.getByRole('button', {
+ name: enMessages.agent.entryFailed
+ })
+ expect(failed).toHaveAttribute('aria-disabled', 'true')
+ await user.click(failed)
+ expect(withConsent).not.toHaveBeenCalled()
+ expect(failed).toHaveAttribute(
+ 'title',
+ 'ComfyUI could not start the agent: not_found'
+ )
+
+ api.serverFeatureFlags.value = {
+ agent: { state: 'starting', reason: 'crashed' }
+ }
+ await nextTick()
+ expect(
+ screen.getByRole('button', { name: enMessages.agent.entryStarting })
+ ).toHaveAttribute('title', 'ComfyUI is starting the agent: crashed')
+
+ api.serverFeatureFlags.value = {
+ agent: { state: 'ready', reason: null }
+ }
+ store.enabled = true
+ await nextTick()
+ const ready = screen.getByRole('button', {
+ name: enMessages.agent.entryButton
+ })
+ expect(ready).not.toHaveAttribute('aria-disabled')
+ await user.click(ready)
+ expect(withConsent).toHaveBeenCalledOnce()
+ })
+
+ it('hides the entry button when the agent is ready but the panel extension is off', () => {
+ useAgentPanelStore().enabled = false
+ api.serverFeatureFlags.value = {
+ agent: { state: 'ready', reason: null }
+ }
+ renderComponent()
+
+ expect(
+ screen.queryByRole('button', { name: enMessages.agent.entryButton })
+ ).toBeNull()
+ })
+
// Two entry controls once shipped side by side after a merge, which broke
// every role-based lookup of the button in the Playwright suite.
it('renders exactly one agent entry control', () => {
diff --git a/src/components/topbar/WorkflowTabs.vue b/src/components/topbar/WorkflowTabs.vue
index 19d97d8e83e..9bb42fe68e3 100644
--- a/src/components/topbar/WorkflowTabs.vue
+++ b/src/components/topbar/WorkflowTabs.vue
@@ -93,6 +93,7 @@
@@ -161,12 +162,19 @@ const { withConsent, isChecking } = useAgentConsent()
const isOpeningAgent = ref(false)
const { isLoggedIn } = useCurrentUser()
+const comfyAgentNotReady = computed(() =>
+ agentPanelStore.enabled || agentPanelStore.comfyAgent?.state === 'ready'
+ ? undefined
+ : agentPanelStore.comfyAgent
+)
const showAgentEntry = computed(
- () => agentPanelStore.enabled && !(agentPanelStore.isOpen && isChecking.value)
+ () =>
+ (agentPanelStore.enabled || comfyAgentNotReady.value !== undefined) &&
+ !(agentPanelStore.isOpen && isChecking.value)
)
async function onAgentEntryClick(): Promise {
- if (isOpeningAgent.value) return
+ if (isOpeningAgent.value || comfyAgentNotReady.value) return
isOpeningAgent.value = true
try {
diff --git a/src/extensions/core/agentPanel.test.ts b/src/extensions/core/agentPanel.test.ts
index b6b74d0cba4..607c9afbf6e 100644
--- a/src/extensions/core/agentPanel.test.ts
+++ b/src/extensions/core/agentPanel.test.ts
@@ -10,14 +10,7 @@ import {
vi
} from 'vitest'
import type { Mocked } from 'vitest'
-import {
- computed,
- defineComponent,
- effectScope,
- nextTick,
- reactive,
- ref
-} from 'vue'
+import { computed, defineComponent, effectScope, nextTick, ref } from 'vue'
import type { EffectScope } from 'vue'
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
let setupScope: EffectScope
@@ -43,7 +36,6 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
import { useAgentComposerStore } from '@/workbench/extensions/agent/stores/agent/agentComposerStore'
import { useDialogStore } from '@/stores/dialogStore'
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
-import type { useFeatureFlags } from '@/composables/useFeatureFlags'
import { useAgentPanelStore } from '@/workbench/extensions/agent/stores/agent/agentPanelStore'
import { createMockLoadedWorkflow } from '@/utils/__tests__/litegraphTestUtils'
import {
@@ -142,18 +134,13 @@ vi.mock(
})
)
-const agentFlagEnabled = ref(false)
+const READY_AGENT = { state: 'ready', reason: null } as const
-vi.mock(import('@/composables/useFeatureFlags'), () => ({
- useFeatureFlags: () =>
- fromPartial>({
- flags: reactive({
- get agentInAppExperienceEnabled() {
- return agentFlagEnabled.value
- }
- })
- })
-}))
+function setAgentReady(ready: boolean): void {
+ Object.assign(agentStore, {
+ comfyAgent: ready ? { ...READY_AGENT } : undefined
+ })
+}
const { registerAgentPanelExtension } = await import('./agentPanel')
const importRegistrationCount = mocks.capturedExtensions.length
@@ -186,15 +173,6 @@ async function loadEntryAndSetup(): Promise {
await nextTick()
}
-async function setRemoteConfigState(
- state: 'unloaded' | 'loading' | 'authenticated' | 'error'
-): Promise {
- const { authenticatedRemoteConfigState } =
- await import('@/platform/remoteConfig/remoteConfig')
- authenticatedRemoteConfigState.value = state
- await nextTick()
-}
-
const DESKTOP_APPROVAL_KEY = 'global-desktop-login-confirm'
const EmptyDialog = defineComponent(() => () => null)
@@ -233,8 +211,9 @@ describe('AgentPanel extension flag gate', () => {
workflowStore = useWorkflowStore()
agentStore.close.mockClear()
agentStore.enabled = false
+ Object.assign(agentStore, { comfyAgent: undefined })
agentStore.isOpen = true
- agentFlagEnabled.value = false
+ setAgentReady(false)
releaseFirstRunScreen()
activeTour.value = null
startupDecision = Promise.resolve(true)
@@ -250,7 +229,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('attributes automatic acceptance with a restored open preference to the consent card', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(useAgentConsent().withConsent).mockImplementationOnce(
async (_trigger, onAccept, hooks) => {
@@ -280,7 +259,7 @@ describe('AgentPanel extension flag gate', () => {
{ session: 'cloud logged in without consent', user: { id: 'account-a' } },
{ session: 'local logged out', user: null }
])('opens after startup for $session', async ({ user }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
currentUser.value = user
Object.assign(consentStore, { accepted: false, isChecking: false })
agentStore.isOpen = false
@@ -301,7 +280,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('waits for the general onboarding decision before activation', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
agentStore.isOpen = false
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -319,7 +298,7 @@ describe('AgentPanel extension flag gate', () => {
it('opens again on the second visit and completes the discovery window', async () => {
localStorage.setItem(ACTIVATION_VISITS_STORAGE_KEY, '1')
- agentFlagEnabled.value = true
+ setAgentReady(true)
agentStore.isOpen = false
await loadEntryAndSetup()
@@ -332,7 +311,7 @@ describe('AgentPanel extension flag gate', () => {
it('counts a visit when the persisted panel is already open', async () => {
localStorage.setItem(ACTIVATION_VISITS_STORAGE_KEY, '1')
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: true, isChecking: false })
agentStore.isOpen = true
@@ -346,7 +325,7 @@ describe('AgentPanel extension flag gate', () => {
it('preserves a closed preference after the two-visit discovery window', async () => {
localStorage.setItem(ACTIVATION_VISITS_STORAGE_KEY, '2')
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
agentStore.isOpen = false
let finishConsentRead = (_: boolean) => {}
@@ -379,7 +358,7 @@ describe('AgentPanel extension flag gate', () => {
it('keeps a second-visit panel closed when consent finishes after dismissal', async () => {
localStorage.setItem(ACTIVATION_VISITS_STORAGE_KEY, '1')
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
agentStore.isOpen = true
let accept = () => {}
@@ -412,7 +391,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('does not reopen a dismissed activation panel after flag synchronization', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
agentStore.isOpen = false
await loadEntryAndSetup()
@@ -421,9 +400,9 @@ describe('AgentPanel extension flag gate', () => {
)
agentStore.close('close_button')
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await flush()
expect(agentStore.isOpen).toBe(false)
@@ -431,7 +410,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('keeps the panel closed if the feature is disabled before acceptance', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let accept = () => {}
let finish = () => {}
@@ -449,7 +428,7 @@ describe('AgentPanel extension flag gate', () => {
await vi.waitFor(() =>
expect(useAgentConsent().withConsent).toHaveBeenCalledOnce()
)
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
accept()
finish()
@@ -459,7 +438,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('records the automatic offer only after the card is displayed', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
const key = 'Comfy.AgentConsent.AutoShown.account-a.workspace-a'
let show = () => {}
@@ -495,7 +474,7 @@ describe('AgentPanel extension flag gate', () => {
await loadEntryAndSetup()
expect(useAgentConsent().withConsent).not.toHaveBeenCalled()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
await vi.waitFor(() =>
@@ -522,7 +501,7 @@ describe('AgentPanel extension flag gate', () => {
])(
'withholds the automatic offer while $surface, leaving the auto-shown key untouched',
async ({ arrange }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
arrange()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -538,7 +517,7 @@ describe('AgentPanel extension flag gate', () => {
)
it('offers in the same session once the Getting Started screen closes', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
showFirstRunScreen()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -558,7 +537,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('keeps waiting when Getting Started closes straight into the first-run tour', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
showFirstRunScreen()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -581,7 +560,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('offers when neither Getting Started took the screen nor a tour is active', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
await loadEntryAndSetup()
@@ -594,7 +573,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('waits for the startup decision before offering', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -613,7 +592,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('skips the automatic offer for the session when the boot never reports', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
startupDecision = Promise.resolve(false)
@@ -627,7 +606,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('offers once the tour that held it ends', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -644,7 +623,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('waits for the startup decision before re-offering after a tour ends', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
@@ -666,7 +645,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('does not re-offer while an offer is still in flight', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let finish = () => {}
const pending = new Promise((resolve) => {
@@ -693,7 +672,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('withholds a card whose tour started while the offer was in flight, then re-offers', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(useAgentConsent().withConsent).mockImplementationOnce(
async (_trigger, _onAccept, hooks) => {
@@ -721,7 +700,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('stays silent after a tour ends when the saved consent cannot be read', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(consentStore.load).mockRejectedValue(new Error('offline'))
@@ -762,7 +741,7 @@ describe('AgentPanel extension flag gate', () => {
] as const)(
'reports $reason once however often the offer re-runs',
async ({ reason, arrange }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
arrange()
@@ -770,9 +749,9 @@ describe('AgentPanel extension flag gate', () => {
await nextTick()
await flush()
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
await flush()
@@ -791,7 +770,7 @@ describe('AgentPanel extension flag gate', () => {
{
name: 'the panel was switched off',
change: async () => {
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
}
},
@@ -804,7 +783,7 @@ describe('AgentPanel extension flag gate', () => {
])(
'stays quiet about an undecided boot when $name meanwhile',
async ({ change }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -822,7 +801,7 @@ describe('AgentPanel extension flag gate', () => {
)
it('reports the first-run screen over a dialog sitting on top of it', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
showFirstRunScreen()
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -838,7 +817,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reports an in-flight tour against the workspace the offer was made for', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
localStorage.setItem(
'Comfy.AgentConsent.AutoShown.account-a.workspace-b',
@@ -865,7 +844,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reports a reason again for a second workspace', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -895,7 +874,7 @@ describe('AgentPanel extension flag gate', () => {
}
}
])('reports nothing for a held offer when $name', async ({ arrange }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
Object.assign(consentStore, { accepted: false, isChecking: false })
arrange()
@@ -910,9 +889,9 @@ describe('AgentPanel extension flag gate', () => {
describe('names the exit when the offer ends without naming a surface', () => {
const rerunFlagGate = async (): Promise => {
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
}
@@ -952,7 +931,7 @@ describe('AgentPanel extension flag gate', () => {
] as const)(
'reports $exit once however often the offer re-runs',
async ({ exit, arrange }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
arrange()
@@ -971,7 +950,7 @@ describe('AgentPanel extension flag gate', () => {
)
it('reports a signed-out offer separately from an unresolved account', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
const { useCurrentUser } =
await import('@/composables/auth/useCurrentUser')
@@ -991,7 +970,7 @@ describe('AgentPanel extension flag gate', () => {
// `isLoggedIn` true with no resolved id is the API-key rail before its
// user is known - the only way these two conditions come apart, and the
// reason they are separate values rather than one.
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
const { useCurrentUser } =
await import('@/composables/auth/useCurrentUser')
@@ -1015,7 +994,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reports an offer refused because another attempt is still in flight', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let finish = () => {}
const pending = new Promise((resolve) => {
@@ -1044,7 +1023,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reports an offer skipped because the card has already been on screen', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
await loadEntryAndSetup()
@@ -1090,7 +1069,7 @@ describe('AgentPanel extension flag gate', () => {
] as const)(
'reports $exit at the $stage stage',
async ({ exit, stage, arrange }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
arrange()
@@ -1108,7 +1087,7 @@ describe('AgentPanel extension flag gate', () => {
it('reports why an undecided boot was also ineligible', async () => {
// `boot_undecided` is gated on eligibility, so this combination used to
// forfeit the offer and report nothing at all.
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -1135,7 +1114,7 @@ describe('AgentPanel extension flag gate', () => {
// the offer was gone for the page load; after it the hold survives - and
// either way the only telemetry was a first `dialog_open`, because the
// reason is deduplicated per page load.
- agentFlagEnabled.value = true
+ setAgentReady(true)
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -1160,7 +1139,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reports the same exit again when its retry state changes', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -1200,7 +1179,7 @@ describe('AgentPanel extension flag gate', () => {
// `loadConsentIfEligible` returns on an off flag before reaching any
// reported exit. That is the whole mechanism keeping this event off the
// population outside the rollout, so it is asserted rather than assumed.
- agentFlagEnabled.value = false
+ setAgentReady(false)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(consentStore.load).mockRejectedValue(new Error('offline'))
@@ -1215,7 +1194,7 @@ describe('AgentPanel extension flag gate', () => {
// The flag was on when the offer started, so this attempt is already
// under way and its ending is real. A reporter gated on the current flag
// value would hide exactly this case, which is why it is not.
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let fail = (_: Error) => {}
vi.mocked(consentStore.load).mockReturnValueOnce(
@@ -1226,7 +1205,7 @@ describe('AgentPanel extension flag gate', () => {
await loadEntryAndSetup()
await vi.waitFor(() => expect(consentStore.load).toHaveBeenCalled())
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
await flush()
fail(new Error('offline'))
@@ -1242,7 +1221,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('offers in the same session once the dialog that held it closes', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -1259,7 +1238,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('keeps the held offer when the retry cannot be made, and offers on the next clear screen', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -1294,7 +1273,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('keeps waiting when a tour ends while a dialog is still open', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
activeTour.value = 'appMode'
openDialog()
Object.assign(consentStore, { accepted: false, isChecking: false })
@@ -1313,7 +1292,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('withholds a card whose dialog opened while the offer was in flight, then re-offers', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(useAgentConsent().withConsent).mockImplementationOnce(
async (_trigger, _onAccept, hooks) => {
@@ -1340,7 +1319,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('re-offers after a withheld in-flight offer settles on a clear screen', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let settleOffer = () => {}
const pendingOffer = new Promise((resolve) => {
@@ -1372,7 +1351,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('does not re-offer after the user declines a manually opened card', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -1392,7 +1371,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('skips the automatic offer for the session once the user has seen the card', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -1410,7 +1389,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('remembers a seen card per workspace across a switch away and back', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let decide = (_: boolean) => {}
startupDecision = new Promise((resolve) => {
@@ -1439,7 +1418,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('does not re-read consent on every dialog close while the read keeps failing', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(consentStore.load).mockRejectedValue(new Error('offline'))
@@ -1457,7 +1436,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('stays silent when the account already accepted', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: true, isChecking: false })
vi.mocked(consentStore.load).mockResolvedValue(true)
@@ -1483,7 +1462,7 @@ describe('AgentPanel extension flag gate', () => {
])(
'rechecks a missed account change once when the next consent load $outcome',
async ({ load, offers, shown }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
let finish = () => {}
const pending = new Promise((resolve) => {
@@ -1520,7 +1499,7 @@ describe('AgentPanel extension flag gate', () => {
])(
'offers independently for $userId / $workspaceId',
async ({ userId, workspaceId }) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(useAgentConsent().withConsent).mockImplementationOnce(
async (_trigger, _onAccept, hooks) => {
@@ -1554,7 +1533,7 @@ describe('AgentPanel extension flag gate', () => {
it.for(['getItem', 'setItem'] as const)(
'skips the automatic offer when storage %s fails',
async (method) => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.spyOn(localStorage, method).mockImplementation(() => {
throw new Error('Storage unavailable')
@@ -1571,7 +1550,7 @@ describe('AgentPanel extension flag gate', () => {
)
it('stays silent when the saved consent cannot be read', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
vi.mocked(consentStore.load).mockRejectedValue(new Error('offline'))
@@ -1584,7 +1563,8 @@ describe('AgentPanel extension flag gate', () => {
it('forces the panel on in development even while the flag is false', async () => {
vi.stubEnv('MODE', 'development')
- agentFlagEnabled.value = false
+ vi.stubEnv('VITE_AGENT_STANDALONE', 'true')
+ setAgentReady(false)
await loadEntryAndSetup()
@@ -1592,6 +1572,38 @@ describe('AgentPanel extension flag gate', () => {
expect(consentStore.load).toHaveBeenCalledOnce()
})
+ it("leaves a development build off cloud to ComfyUI's agent", async () => {
+ vi.stubEnv('MODE', 'development')
+ vi.stubEnv('VITE_AGENT_STANDALONE', '')
+ Object.assign(agentStore, { flagsSettled: false })
+
+ await loadEntryAndSetup()
+
+ expect(agentStore.enabled).toBe(false)
+ expect(agentStore.gateSettled).toBe(false)
+ })
+
+ it('enables the panel once ComfyUI reports its agent ready', async () => {
+ Object.assign(agentStore, {
+ comfyAgent: { state: 'starting', reason: null }
+ })
+
+ await loadEntryAndSetup()
+ expect(agentStore.enabled).toBe(false)
+
+ Object.assign(agentStore, {
+ comfyAgent: { state: 'ready', reason: null }
+ })
+ await nextTick()
+ expect(agentStore.enabled).toBe(true)
+
+ Object.assign(agentStore, {
+ comfyAgent: { state: 'failed', reason: 'unknown' }
+ })
+ await nextTick()
+ expect(agentStore.enabled).toBe(false)
+ })
+
it('leaves the panel disabled while the flag is undefined', async () => {
await loadEntryAndSetup()
expect(agentStore.enabled).toBe(false)
@@ -1609,7 +1621,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reloads consent when the resolved account changes', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
await loadEntryAndSetup()
expect(consentStore.load).toHaveBeenCalledOnce()
currentUser.value = { id: 'account-b' }
@@ -1618,7 +1630,7 @@ describe('AgentPanel extension flag gate', () => {
})
it('reloads consent when the same user changes workspace scope', async () => {
- agentFlagEnabled.value = true
+ setAgentReady(true)
await loadEntryAndSetup()
expect(consentStore.load).toHaveBeenCalledOnce()
Object.assign(consentStore, { identity: 'account-a/workspace-b' })
@@ -1642,102 +1654,29 @@ describe('AgentPanel extension flag gate', () => {
it('enables the panel when the flag turns true', async () => {
await loadEntryAndSetup()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
expect(agentStore.enabled).toBe(true)
})
- it('leaves the gate unsettled while only the anonymous config has landed', async () => {
- await setRemoteConfigState('unloaded')
-
- await loadEntryAndSetup()
-
- expect(agentStore.gateSettled).toBe(false)
- })
-
- it('settles the gate once the authenticated config lands', async () => {
- await loadEntryAndSetup()
- expect(agentStore.gateSettled).toBe(false)
-
- await setRemoteConfigState('authenticated')
-
- expect(agentStore.gateSettled).toBe(true)
- })
-
- it('settles the gate when the config load fails rather than waiting forever', async () => {
- await loadEntryAndSetup()
-
- await setRemoteConfigState('error')
-
- expect(agentStore.gateSettled).toBe(true)
- })
-
- it('settles the gate on the fallback when no authenticated config ever lands', async () => {
- currentUser.value = null
- await setRemoteConfigState('unloaded')
+ it('settles the gate once the server feature flags land', async () => {
+ Object.assign(agentStore, { flagsSettled: false })
await loadEntryAndSetup()
expect(agentStore.gateSettled).toBe(false)
- const { GATE_SETTLE_TIMEOUT_MS } = await import('./agentPanel')
- await vi.advanceTimersByTimeAsync(GATE_SETTLE_TIMEOUT_MS)
-
- expect(agentStore.gateSettled).toBe(true)
- })
-
- it('does not settle a signed-in gate while authenticated config is slow', async () => {
- await setRemoteConfigState('loading')
- await loadEntryAndSetup()
-
- const { GATE_SETTLE_TIMEOUT_MS } = await import('./agentPanel')
- await vi.advanceTimersByTimeAsync(GATE_SETTLE_TIMEOUT_MS)
-
- expect(agentStore.gateSettled).toBe(false)
- })
-
- it('does not treat unresolved auth as signed out', async () => {
- currentUser.value = null
- isAuthInitialized.value = false
- await setRemoteConfigState('unloaded')
- await loadEntryAndSetup()
-
- const { GATE_SETTLE_TIMEOUT_MS } = await import('./agentPanel')
- await vi.advanceTimersByTimeAsync(GATE_SETTLE_TIMEOUT_MS)
-
- expect(agentStore.gateSettled).toBe(false)
- })
-
- it('re-arms the signed-out fallback after an identity change', async () => {
- await setRemoteConfigState('authenticated')
- await loadEntryAndSetup()
- expect(agentStore.gateSettled).toBe(true)
-
- currentUser.value = null
- await setRemoteConfigState('unloaded')
- const { GATE_SETTLE_TIMEOUT_MS } = await import('./agentPanel')
- await vi.advanceTimersByTimeAsync(GATE_SETTLE_TIMEOUT_MS)
+ Object.assign(agentStore, { flagsSettled: true })
+ await nextTick()
expect(agentStore.gateSettled).toBe(true)
})
- it('returns the gate to unsettled when authenticated config reloads', async () => {
- await setRemoteConfigState('authenticated')
- await loadEntryAndSetup()
- expect(agentStore.gateSettled).toBe(true)
-
- await setRemoteConfigState('loading')
-
- expect(agentStore.gateSettled).toBe(false)
- })
-
- it('retries consent after a completed refresh with the same flag value', async () => {
- agentFlagEnabled.value = true
+ it('retries consent after a fresh feature push with the same agent state', async () => {
+ setAgentReady(true)
Object.assign(consentStore, { accepted: false, isChecking: false })
await loadEntryAndSetup()
vi.mocked(consentStore.load).mockClear()
- const { remoteConfigRevision } =
- await import('@/platform/remoteConfig/remoteConfig')
- remoteConfigRevision.value++
+ setAgentReady(true)
await nextTick()
expect(consentStore.load).toHaveBeenCalledOnce()
@@ -1745,9 +1684,9 @@ describe('AgentPanel extension flag gate', () => {
it('disables the panel without closing it when the flag flips back to false', async () => {
await loadEntryAndSetup()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
expect(agentStore.enabled).toBe(false)
@@ -1757,12 +1696,12 @@ describe('AgentPanel extension flag gate', () => {
it('stops node picking when the flag is disabled', async () => {
await loadEntryAndSetup()
- agentFlagEnabled.value = true
+ setAgentReady(true)
await nextTick()
const canvasStore = useCanvasStore()
canvasStore.isPickingNodes = true
- agentFlagEnabled.value = false
+ setAgentReady(false)
await nextTick()
expect(canvasStore.isPickingNodes).toBe(false)
diff --git a/src/extensions/core/agentPanel.ts b/src/extensions/core/agentPanel.ts
index a913e575ade..6bf4b7a0bae 100644
--- a/src/extensions/core/agentPanel.ts
+++ b/src/extensions/core/agentPanel.ts
@@ -3,12 +3,7 @@ import { storeToRefs } from 'pinia'
import { computed, ref, watch } from 'vue'
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
-import { useFeatureFlags } from '@/composables/useFeatureFlags'
import { useOnboardingTourStore } from '@/platform/onboarding/onboardingTourStore'
-import {
- authenticatedRemoteConfigState,
- remoteConfigRevision
-} from '@/platform/remoteConfig/remoteConfig'
import { useTelemetry } from '@/platform/telemetry'
import { reportError } from '@/platform/telemetry/reportError'
import type {
@@ -38,9 +33,6 @@ import { selectedNodeKey } from '@/workbench/extensions/agent/composables/agent/
import { useDialogStore } from '@/stores/dialogStore'
import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
-/** Upper bound on how long readiness consumers wait for a gate decision. */
-export const GATE_SETTLE_TIMEOUT_MS = 5_000
-
const CONSENT_AUTO_SHOWN_PREFIX = 'Comfy.AgentConsent.AutoShown'
const ACTIVATION_VISITS_STORAGE_KEY = 'Comfy.AgentPanel.activationVisits'
const AUTOMATIC_ACTIVATION_VISITS = 2
@@ -168,8 +160,7 @@ export function registerAgentPanelExtension(): void {
const consentStore = useAgentConsentStore()
const { enabled } = storeToRefs(agentPanelStore)
const workspaceStore = useTeamWorkspaceStore()
- const { isAuthInitialized, resolvedUserInfo, isLoggedIn } =
- useCurrentUser()
+ const { resolvedUserInfo, isLoggedIn } = useCurrentUser()
const { withConsent } = useAgentConsent()
const { firstRunHoldsScreen, whenStartupDecided } = useFirstRunEntry()
const onboardingTourStore = useOnboardingTourStore()
@@ -539,29 +530,25 @@ export function registerAgentPanelExtension(): void {
loadConsentIfEligible()
}
)
- setupFlagGate(
- loadConsentIfEligible,
- openWhenStartupDecided,
- () => isAuthInitialized.value && resolvedUserInfo.value === null
- )
+ setupFlagGate(loadConsentIfEligible, openWhenStartupDecided)
}
})
}
function setupFlagGate(
loadConsentIfEligible: () => void,
- openWhenStartupDecided: () => void,
- isSignedOut: () => boolean
+ openWhenStartupDecided: () => void
): void {
const agentPanelStore = useAgentPanelStore()
- const { flags } = useFeatureFlags()
+ const devForcedOn =
+ import.meta.env.MODE === 'development' &&
+ import.meta.env.VITE_AGENT_STANDALONE === 'true'
watch(
() =>
[
- import.meta.env.MODE === 'development' ||
- flags.agentInAppExperienceEnabled,
- remoteConfigRevision.value
+ devForcedOn || agentPanelStore.comfyAgent?.state === 'ready',
+ agentPanelStore.comfyAgent
] as const,
([enabled]) => {
agentPanelStore.enabled = enabled
@@ -571,37 +558,11 @@ function setupFlagGate(
},
{ immediate: true }
)
-
- const settle = (): void => {
- agentPanelStore.gateSettled = true
- }
- let settleTimer: ReturnType | undefined
- const clearSettleTimer = (): void => {
- clearTimeout(settleTimer)
- settleTimer = undefined
- }
- const scheduleSignedOutFallback = (): void => {
- clearSettleTimer()
- settleTimer = setTimeout(() => {
- if (isSignedOut()) settle()
- }, GATE_SETTLE_TIMEOUT_MS)
- }
watch(
- () =>
- [
- import.meta.env.MODE === 'development' ||
- authenticatedRemoteConfigState.value === 'authenticated' ||
- authenticatedRemoteConfigState.value === 'error',
- isSignedOut()
- ] as const,
- ([decided, signedOut]) => {
- agentPanelStore.gateSettled = decided
- clearSettleTimer()
- if (!decided && signedOut) scheduleSignedOutFallback()
+ () => devForcedOn || agentPanelStore.flagsSettled,
+ (settled) => {
+ agentPanelStore.gateSettled = settled
},
{ immediate: true }
)
- // A signed-out session never runs the authenticated /features refresh
- // (WorkspaceAuthGate returns early with no user), so the watch above never
- // reaches a decided state for it.
}
diff --git a/src/extensions/core/index.ts b/src/extensions/core/index.ts
index 54469921a5c..7a464034e64 100644
--- a/src/extensions/core/index.ts
+++ b/src/extensions/core/index.ts
@@ -40,16 +40,13 @@ import './widgetInputs'
// dead-code-eliminates this block from OSS builds.
if (__DISTRIBUTION__ === 'cloud') {
await import('./cloudRemoteConfig')
- const { registerAgentPanelExtension } = await import('./agentPanel')
- registerAgentPanelExtension()
await import('./cloudBadges')
await import('./cloudSessionCookie')
-} else if (import.meta.env.VITE_AGENT_STANDALONE === 'true') {
- // The local agent harness mounts the panel in any distribution.
- const { registerAgentPanelExtension } = await import('./agentPanel')
- registerAgentPanelExtension()
}
+const { registerAgentPanelExtension } = await import('./agentPanel')
+registerAgentPanelExtension()
+
// Feedback button for cloud and nightly builds
if (isCloud || isNightly) {
await import('./cloudFeedbackTopbarButton')
diff --git a/src/locales/en/main.json b/src/locales/en/main.json
index da1a830ecd7..d2fc4ca65af 100644
--- a/src/locales/en/main.json
+++ b/src/locales/en/main.json
@@ -5659,6 +5659,10 @@
},
"loadFailed": "The agent panel failed to load.",
"entryButton": "Agent",
+ "entryStarting": "Agent starting…",
+ "entryFailed": "Agent unavailable",
+ "entryFailedReason": "ComfyUI could not start the agent: {reason}",
+ "entryStartingReason": "ComfyUI is starting the agent: {reason}",
"feedbackCaption": "Share feedback",
"freeUseNoticeLabel": "Free use notice",
"freeUseNotice": "Try your first chat for free!",
diff --git a/src/platform/remote/comfyui/execution/types.ts b/src/platform/remote/comfyui/execution/types.ts
index e77d260b639..89c2177b6e1 100644
--- a/src/platform/remote/comfyui/execution/types.ts
+++ b/src/platform/remote/comfyui/execution/types.ts
@@ -120,6 +120,11 @@ export interface LogsRawResponse {
entries: LogEntry[]
}
export type FeatureFlagsWsMessage = Record
+/** ComfyUI's `agent` server feature, pushed again on every change. */
+export interface AgentStatusWsMessage {
+ state: 'starting' | 'ready' | 'failed'
+ reason?: string | null
+}
export interface AssetDownloadWsMessage {
task_id: string
asset_name: string
diff --git a/src/scripts/api.featureFlags.test.ts b/src/scripts/api.featureFlags.test.ts
index 81341e557df..bccf88af795 100644
--- a/src/scripts/api.featureFlags.test.ts
+++ b/src/scripts/api.featureFlags.test.ts
@@ -51,6 +51,21 @@ describe('API Feature Flags', () => {
})
describe('Feature flags negotiation', () => {
+ it("drops the previous account's agent feature when resetting the socket identity", async () => {
+ const resettingApi = new ComfyApi()
+ resettingApi.serverFeatureFlags.value = {
+ account_a_feature: true,
+ agent: { state: 'ready' }
+ }
+
+ const resetPromise = resettingApi.resetSocket()
+
+ expect(resettingApi.serverFeatureFlags.value).toEqual({
+ account_a_feature: true
+ })
+ await resetPromise
+ })
+
it('marks feature flags stale without clearing them when resetting the socket identity', async () => {
const resettingApi = new ComfyApi()
resettingApi.serverFeatureFlags.value = { account_a_feature: true }
@@ -124,6 +139,49 @@ describe('API Feature Flags', () => {
expect(api.serverFeatureFlagsSettled.value).toBe(true)
})
+ it("folds ComfyUI's agent_status pushes into the agent feature", () => {
+ void api.init()
+ const send = (type: string, data: unknown) =>
+ wsEventHandlers['message']({ data: JSON.stringify({ type, data }) })
+
+ send('feature_flags', {
+ api_version: '1.0.0',
+ agent: { state: 'starting', reason: null }
+ })
+ const onStatus = vi.fn()
+ api.addEventListener('agent_status', onStatus)
+ onTestFinished(() => api.removeEventListener('agent_status', onStatus))
+ send('agent_status', { state: 'ready', reason: null })
+
+ expect(onStatus).toHaveBeenCalledOnce()
+
+ expect(api.getServerFeature('agent')).toEqual({
+ state: 'ready',
+ reason: null
+ })
+ expect(api.getServerFeature('api_version')).toBe('1.0.0')
+ })
+
+ it('takes the agent feature from a handshake reply that follows an earlier agent_status push', () => {
+ void api.init()
+ const send = (type: string, data: unknown) =>
+ wsEventHandlers['message']({ data: JSON.stringify({ type, data }) })
+
+ send('agent_status', { state: 'starting', reason: null })
+ expect(api.serverFeatureFlagsSettled.value).toBe(false)
+
+ send('feature_flags', {
+ api_version: '1.0.0',
+ agent: { state: 'ready', reason: null }
+ })
+
+ expect(api.getServerFeature('agent')).toEqual({
+ state: 'ready',
+ reason: null
+ })
+ expect(api.serverFeatureFlagsSettled.value).toBe(true)
+ })
+
it('settles feature flags immediately when the server delivers an empty map', () => {
void api.init()
diff --git a/src/scripts/api.ts b/src/scripts/api.ts
index b0b77ca91d8..0db427c7ab6 100644
--- a/src/scripts/api.ts
+++ b/src/scripts/api.ts
@@ -38,6 +38,7 @@ import { useTelemetry } from '@/platform/telemetry'
import { reportError } from '@/platform/telemetry/reportError'
import type { components as ManagerComponents } from '@/workbench/extensions/manager/types/generatedManagerTypes'
import type {
+ AgentStatusWsMessage,
AssetDownloadWsMessage,
AssetExportWsMessage,
AssetSeedCompletedWsMessage,
@@ -268,6 +269,7 @@ interface BackendApiCalls {
progress_text: ProgressTextWsMessage
progress_state: ProgressStateWsMessage
feature_flags: FeatureFlagsWsMessage
+ agent_status: AgentStatusWsMessage
asset_download: AssetDownloadWsMessage
asset_export: AssetExportWsMessage
'assets.seed.completed': AssetSeedCompletedWsMessage
@@ -1117,6 +1119,13 @@ export class ComfyApi extends EventTarget {
this.serverFeatureFlagsSettled.value = true
this.dispatchCustomEvent('feature_flags', msg.data)
break
+ case 'agent_status':
+ this.serverFeatureFlags.value = {
+ ...this.serverFeatureFlags.value,
+ agent: msg.data
+ }
+ this.dispatchCustomEvent('agent_status', msg.data)
+ break
default:
if (this._registered.has(msg.type)) {
// Fallback for custom types - calls super direct.
@@ -1155,6 +1164,8 @@ export class ComfyApi extends EventTarget {
this.clientId = undefined
window.name = ''
sessionStorage.removeItem('clientId')
+ const { agent: _previousAgent, ...features } = this.serverFeatureFlags.value
+ this.serverFeatureFlags.value = features
await this.replaceSocket()
}
@@ -1169,8 +1180,9 @@ export class ComfyApi extends EventTarget {
private async replaceSocket(): Promise {
const previous = this.socket
- // serverFeatureFlags deliberately keeps the previous map: clearing it would
- // downgrade every serverSupportsFeature() caller until the next delivery.
+ // serverFeatureFlags deliberately keeps the previous map (resetSocket drops
+ // only `agent`): clearing it would downgrade every serverSupportsFeature()
+ // caller until the next delivery.
this.serverFeatureFlagsSettled.value = false
// Detach before closing so the previous socket's close handler sees it is
// no longer the active socket and does not start a competing reconnect.
diff --git a/src/workbench/extensions/agent/README.md b/src/workbench/extensions/agent/README.md
index c114dba4429..d4e8dec86f5 100644
--- a/src/workbench/extensions/agent/README.md
+++ b/src/workbench/extensions/agent/README.md
@@ -35,10 +35,15 @@ The panel speaks one contract on the cloud and on the local agent:
## Activation and consent
-The dock is visible only when the `agent-in-app-experience` feature flag is
-enabled, the panel has an open intent, and the current user and workspace have
-accepted Agent consent. Development mode enables the feature flag; consent is
-still required. A restored open intent cannot bypass consent.
+The dock is visible only when the server's `agent` feature reports
+`state: "ready"`, the panel has an open intent, and the current user and
+workspace have accepted Agent consent. Cloud and ComfyUI (`--enable-agent`)
+publish the same feature, and ComfyUI pushes `agent_status` when it changes;
+while it is `starting` or `failed` the entry button shows that, inert. Builds
+with `VITE_AGENT_STANDALONE=true` (the local agent harness) ignore the feature
+and, in development mode, force the panel on; consent is still required. A
+plain `pnpm dev` shows the panel only when the ComfyUI it proxies publishes the
+feature. A restored open intent cannot bypass consent.
On first use, click **Agent**, then **Start using Comfy Agent**.
Acceptance is stored through the hosted Global Settings API under
@@ -46,10 +51,7 @@ Acceptance is stored through the hosted Global Settings API under
Agent opens after the save succeeds. Skip, Escape and outside clicks dismiss
without saving; failed loads or saves keep the panel closed and allow retry.
Switching user or workspace invalidates the cached acceptance and loads the new
-scope. Desktop/Local sign-in continuation authenticates before saving; this
-branch mounts the Agent extension in Cloud builds and in builds with
-`VITE_AGENT_STANDALONE=true` (the local agent harness, in any distribution);
-FE-1931 owns the remaining Local and Desktop product entry points.
+scope. Desktop/Local sign-in continuation authenticates before saving.
## First-use tour
diff --git a/src/workbench/extensions/agent/composables/useAgentDockMount.test.ts b/src/workbench/extensions/agent/composables/useAgentDockMount.test.ts
index 3bf08ea744d..55ff115de4d 100644
--- a/src/workbench/extensions/agent/composables/useAgentDockMount.test.ts
+++ b/src/workbench/extensions/agent/composables/useAgentDockMount.test.ts
@@ -149,17 +149,8 @@ describe('useAgentDockMount', () => {
)
})
- it('returns an inert mount on non-cloud distributions', () => {
+ it('docks only once the gate enables and the panel opens, off cloud too', async () => {
vi.stubGlobal('__DISTRIBUTION__', 'localhost')
-
- const { docked, DockedAgentPanel } = useAgentDockMount()
-
- expect(docked.value).toBe(false)
- expect(DockedAgentPanel).toBeNull()
- })
-
- it('docks only once the gate enables and the panel opens on cloud', async () => {
- vi.stubGlobal('__DISTRIBUTION__', 'cloud')
const store = useAgentPanelStore()
const { docked, DockedAgentPanel } = useAgentDockMount()
diff --git a/src/workbench/extensions/agent/composables/useAgentDockMount.ts b/src/workbench/extensions/agent/composables/useAgentDockMount.ts
index 91ec7ff7800..1d6d1e7fcf3 100644
--- a/src/workbench/extensions/agent/composables/useAgentDockMount.ts
+++ b/src/workbench/extensions/agent/composables/useAgentDockMount.ts
@@ -8,24 +8,10 @@ import { useBillingIdentity } from './useBillingIdentity'
interface AgentDockMount {
docked: ComputedRef
- DockedAgentPanel: Component | null
+ DockedAgentPanel: Component
}
-/**
- * The one distribution seam for the dock mounts. The literal comparison is
- * what dead-code-eliminates the store and both panel component chunks from
- * OSS builds; on cloud the async component is only requested once the gate
- * enables and opens the panel, so a flag-off session fetches no agent chunk.
- */
export function useAgentDockMount(): AgentDockMount {
- // The local agent harness (VITE_AGENT_STANDALONE) mounts the panel in any
- // distribution; production keeps it cloud-only.
- if (
- __DISTRIBUTION__ !== 'cloud' &&
- import.meta.env.VITE_AGENT_STANDALONE !== 'true'
- ) {
- return { docked: computed(() => false), DockedAgentPanel: null }
- }
const agentPanelStore = useAgentPanelStore()
const { subscription } = useBillingContext()
diff --git a/src/workbench/extensions/agent/schemas/agentApiSchema.ts b/src/workbench/extensions/agent/schemas/agentApiSchema.ts
index 8e20bf9ee0c..d3e8ec70017 100644
--- a/src/workbench/extensions/agent/schemas/agentApiSchema.ts
+++ b/src/workbench/extensions/agent/schemas/agentApiSchema.ts
@@ -373,3 +373,9 @@ export function parseAgentWsEvent(
export const zAgentIdentity = zGeneratedAgentIdentity.extend({
user_id: z.string().min(1)
})
+
+/** The server's `agent` feature, pushed again on every change. */
+export interface AgentServerFeature {
+ state: 'starting' | 'ready' | 'failed'
+ reason?: string | null
+}
diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts b/src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts
index d7e71bcde9c..495060c45dc 100644
--- a/src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts
+++ b/src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts
@@ -1,4 +1,4 @@
-import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { nextTick } from 'vue'
import { useTelemetry } from '@/platform/telemetry'
@@ -33,6 +33,31 @@ describe('agentPanelStore engagement telemetry', () => {
expect(store.flagsSettled).toBe(true)
})
+ it.for([null, false, '', {}, { state: 'unknown' }])(
+ 'ignores an agent feature without a known state: %j',
+ (agent) => {
+ onTestFinished(() => {
+ api.serverFeatureFlags.value = {}
+ })
+ api.serverFeatureFlags.value = { agent }
+
+ expect(useAgentPanelStore().comfyAgent).toBeUndefined()
+ }
+ )
+
+ it("leaves the standalone harness on its own agent, not ComfyUI's", () => {
+ onTestFinished(() => {
+ api.serverFeatureFlags.value = {}
+ })
+ vi.stubEnv('VITE_AGENT_STANDALONE', 'true')
+ api.serverFeatureFlags.value = {
+ agent: { state: 'ready' }
+ }
+ const store = useAgentPanelStore()
+
+ expect(store.comfyAgent).toBeUndefined()
+ })
+
it('emits a restored open only once the rehydrated panel actually docks', async () => {
localStorage.setItem(OPEN_STORAGE_KEY, 'true')
const store = useConsentedAgentPanelStore()
diff --git a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts
index 7dd274b8728..bff2b367ab0 100644
--- a/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts
+++ b/src/workbench/extensions/agent/stores/agent/agentPanelStore.ts
@@ -15,6 +15,7 @@ import type {
import type { ComfyWorkflow } from '@/platform/workflow/management/stores/comfyWorkflow'
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
import { api } from '@/scripts/api'
+import type { AgentServerFeature } from '@/workbench/extensions/agent/schemas/agentApiSchema'
import type {
CreditTransitionNoticeEvent,
@@ -75,6 +76,16 @@ export const useAgentPanelStore = defineStore('agentPanel', () => {
const gateSettled = ref(false)
const view = shallowRef({ screen: 'chat' })
const flagsSettled = computed(() => api.serverFeatureFlagsSettled.value)
+ /** The server's `agent` feature; undefined unless its state is known. */
+ const comfyAgent = computed(() => {
+ if (import.meta.env.VITE_AGENT_STANDALONE === 'true') return undefined
+ const agent = api.getServerFeature<{ state?: unknown } | null>('agent')
+ return agent?.state === 'starting' ||
+ agent?.state === 'ready' ||
+ agent?.state === 'failed'
+ ? (agent as AgentServerFeature)
+ : undefined
+ })
const maximized = ref(false)
const draggedWidth = ref(PANEL_MIN_WIDTH)
/**
@@ -382,6 +393,7 @@ export const useAgentPanelStore = defineStore('agentPanel', () => {
view,
interruptHistorySelection,
flagsSettled,
+ comfyAgent,
reportedExhaustionIdentity,
reportedFreeUseExposure,
reportedFreeUseImpression,