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
5 changes: 5 additions & 0 deletions browser_tests/fixtures/utils/cloudBootMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' }
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment on lines +36 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: the fixture turns the retired remote-config flag into the new server feature, so in cloud E2E the two inputs always agree. A regression that put the remote-config check back into the gate would pass the positive specs and the "flag off" case in agentPanel.spec.ts alike, and the fixture cannot express starting or failed. Seeding the server feature from its own boot option, and having one existing entry-button case set the remote flag off with the server agent ready, keeps the specs on the contract the product reads now. No suggestion block because it changes the boot option and its callers across files.

await page.route('**/api/system_stats', (r) =>
r.fulfill(jsonRoute(mockSystemStats))
)
Expand Down
30 changes: 27 additions & 3 deletions src/components/topbar/AgentEntryButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
"
>
<i
:class="
Expand All @@ -19,18 +30,31 @@
)
"
/>
<span>{{ $t('agent.entryButton') }}</span>
<span>{{
comfyAgent?.state === 'starting'
? $t('agent.entryStarting')
: comfyAgent?.state === 'failed'
? $t('agent.entryFailed')
: $t('agent.entryButton')
}}</span>
Comment on lines +33 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (P3): this label and the title above branch over the same state in two nested ternaries, and neither is exhaustive, so a fourth state renders as a plain "Agent" with no tooltip. docs/guidance/vue-components.md asks for complex conditionals to move into a computed. One computed that returns { label, title } from a switch on comfyAgent?.state keeps them together. No suggestion block because it changes two template ranges and the script.

</Button>
</template>

<script setup lang="ts">
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
Comment on lines +57 to +58

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (P3): the prop is typed as the whole server feature, but its presence means "show inert", even for { state: 'ready' }; WorkflowTabs.vue filters ready out first so the button stays usable. Naming it for what it carries (for example unavailableAgent, with state: 'starting' | 'failed') puts that contract in the signature and lets this JSDoc go. No suggestion block because the rename spans this component and WorkflowTabs.vue.

}>()
</script>
65 changes: 65 additions & 0 deletions src/components/topbar/WorkflowTabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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()
})
Comment on lines +259 to +309

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: four independent states are chained into one test, so the first wrong state hides the rest. Its last step sets store.enabled = true by hand and clicks, which waits for consent and marks the entry button pressed once the panel is visible already covers. A table gives each state its own row and adds the failed case without a reason, which the ?? 'unknown' fallback otherwise lacks. If the reactive switch from starting to failed is the point, keep a short separate test for that.

Suggested change
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.for([
{
agent: { state: 'starting', reason: null },
name: enMessages.agent.entryStarting,
title: null
},
{
agent: { state: 'starting', reason: 'crashed' },
name: enMessages.agent.entryStarting,
title: 'ComfyUI is starting the agent: crashed'
},
{
agent: { state: 'failed', reason: 'not_found' },
name: enMessages.agent.entryFailed,
title: 'ComfyUI could not start the agent: not_found'
},
{
agent: { state: 'failed', reason: null },
name: enMessages.agent.entryFailed,
title: 'ComfyUI could not start the agent: unknown'
}
])(
"shows ComfyUI's $agent.state agent ($agent.reason) as an inert button",
async ({ agent, name, title }) => {
useAgentPanelStore().enabled = false
api.serverFeatureFlags.value = { agent }
const { user } = renderComponent()
const button = screen.getByRole('button', { name })
expect(button).toHaveAttribute('aria-disabled', 'true')
expect(button.getAttribute('title')).toBe(title)
await user.click(button)
expect(withConsent).not.toHaveBeenCalled()
}
)


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', () => {
Expand Down
12 changes: 10 additions & 2 deletions src/components/topbar/WorkflowTabs.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
:class="
cn(

Check warning on line 4 in src/components/topbar/WorkflowTabs.vue

View workflow job for this annotation

GitHub Actions / fallow / fallow

High cognitive complexity (moderate)

Function '<template>' is hard to understand (cognitive: 19, threshold: 15). • Severity: moderate • Cyclomatic: 15 • Cognitive: 19 • Lines: 291 High cognitive complexity means deeply nested or interleaved logic. Consider flattening control flow or extracting helper functions.
'workflow-tabs-container flex h-full flex-auto flex-row gap-1 overflow-hidden bg-comfy-menu-bg px-1',
isDesktop ? 'max-w-[env(titlebar-area-width,100vw)]' : 'max-w-full'
)
Expand Down Expand Up @@ -93,6 +93,7 @@
<AgentEntryButton
:active="agentPanelStore.isVisible"
:inviting="!agentPanelStore.hasEverOpened"
:comfy-agent="comfyAgentNotReady"
@click="onAgentEntryClick"
/>
</template>
Expand Down Expand Up @@ -161,12 +162,19 @@
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<void> {
if (isOpeningAgent.value) return
if (isOpeningAgent.value || comfyAgentNotReady.value) return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — showAgentEntry shows the button when comfyAgentNotReady !== undefined, but this click guard tests truthiness. If the server sends agent: null, false or '', the button renders with aria-disabled="true" (and without the dimmed style, since the class check is truthy too), yet a click still runs withConsent and the consent or sign-in flow for an agent that is not available. Use one predicate, such as "is an object with a known non-ready state", in all three places.

Raised by 2 of 6 reviewers (claude-opus-5-5-xhigh adversarial, claude-opus-5-5-xhigh edge-case).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 413b00e: a non-object agent feature is ignored, so null, false or '' show no button.

isOpeningAgent.value = true

try {
Expand Down
Loading
Loading