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
43 changes: 36 additions & 7 deletions e2e/chooser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import {
expectNewBuildModalOpen,
openNewBuildChangeSetup,
pickFromTitleMenu,
openDesktopSettings,
showBuildsPage
} from './support/chooserHelpers'
import {
closeTitlePopupIfOpen,
findWebContentsId,
isPopupVisible,
TITLE_REOPEN_SUPPRESSION_MS,
waitForWebContents
} from './support/cdpPages'
import { evalWithRetry } from './support/evalRetry'
import { captureHostWindow } from './support/windowCapture'

let ctx: AppContext

Expand All @@ -41,6 +44,38 @@ test('title bar shows install-less pill on chooser host @windows @macos @linux',
expect(await ctx.titleBar.textOf('.title-install-name')).toMatch(/Comfy Desktop/i)
})

test('Desktop Settings opens from the sidebar footer when expanded and collapsed @windows @macos @linux', async () => {
const settings = '[data-testid="app-sidebar-settings"]'
const sidebar = '[data-testid="app-sidebar"]'

for (const collapsed of [false, true]) {
expect(await ctx.panel.textOf(settings)).toBe(collapsed ? '' : 'Desktop Settings')
expect(
await ctx.panel.evaluate<boolean>(`(() => {
const sidebar = document.querySelector('${sidebar}').getBoundingClientRect()
const settings = document.querySelector('${settings}').getBoundingClientRect()
const account = document.querySelector('.sidebar-account').getBoundingClientRect()
return settings.top >= sidebar.top && settings.bottom <= account.top && account.bottom <= sidebar.bottom
})()`)
).toBe(true)
const name = collapsed ? 'sidebar-collapsed.png' : 'sidebar-expanded.png'
const shot = await captureHostWindow(ctx.app, ctx.panel, test.info().outputPath(name))
await test.info().attach(name, { path: shot, contentType: 'image/png' })

await openDesktopSettings(ctx.app, ctx.panel)
expect(await ctx.panel.isVisible('.chooser-view')).toBe(true)
await closeTitlePopupIfOpen(ctx.app)
expect(await ctx.panel.click('[data-testid="app-sidebar-toggle"]')).toBe(true)
await ctx.panel.waitFor(
() =>
ctx.panel.evaluate<boolean>(
`document.querySelector('${sidebar}').dataset.collapsed === '${!collapsed}'`
),
{ message: 'the sidebar did not toggle' }
)
}
})

test('clicking New Install tile opens the new-install takeover @windows @macos @linux', async () => {
await clickNewInstallTile(ctx.panel)
await expectNewBuildModalOpen(ctx.panel)
Expand Down Expand Up @@ -159,13 +194,7 @@ test('title popup opens, renders menu items, and closes via bridge @windows @mac
.toBe(true)

const popupItems = await readPopupMenuItems(ctx.app, 'comfyTitlePopup.html')
expect(popupItems).toEqual([
'Performance Tests',
'Benchmarks',
'Desktop Settings',
'Close Window',
'Quit Desktop'
])
expect(popupItems).toEqual(['Performance Tests', 'Benchmarks', 'Close Window', 'Quit Desktop'])

await evalWithRetry(() =>
ctx.app.evaluate(({ webContents }) => {
Expand Down
11 changes: 4 additions & 7 deletions e2e/core-beta-optin.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'
import { launchApp, type AppContext } from './launchApp'
import { openTitleMenu } from './support/chooserHelpers'
import { openDesktopSettings } from './support/chooserHelpers'
import {
closeTitlePopupIfOpen,
titlePopupPage,
Expand Down Expand Up @@ -37,13 +37,10 @@ async function readBetaRow(popup: WebContentsPage): Promise<BetaRowState | null>
})()`)
}

async function openDesktopSettings(ctx: AppContext, popup: WebContentsPage): Promise<void> {
async function openBetaSettings(ctx: AppContext, popup: WebContentsPage): Promise<void> {
await closeTitlePopupIfOpen(ctx.app)
await new Promise((resolve) => setTimeout(resolve, TITLE_REOPEN_SUPPRESSION_MS))
await openTitleMenu(ctx.titleBar)
await popup.waitForVisible('[role="menuitem"]', { timeout: 10_000 })
expect(await popup.clickByText('[role="menuitem"]', 'Desktop Settings')).toBe(true)
await popup.waitForVisible('.global-settings', { timeout: 10_000 })
await openDesktopSettings(ctx.app, ctx.panel)
await popup.waitForVisible(BETA_SWITCH, { timeout: 10_000 })
}

Expand All @@ -57,7 +54,7 @@ function betaScenario(settings: Record<string, unknown>): () => WebContentsPage
})

test.beforeEach(async () => {
await openDesktopSettings(ctx, popup)
await openBetaSettings(ctx, popup)
})

test.afterAll(async () => {
Expand Down
9 changes: 2 additions & 7 deletions e2e/hardware-acceleration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import path from 'node:path'
import process from 'node:process'
import { expect, test, type ElectronApplication } from '@playwright/test'
import { launchApp, type AppContext } from './launchApp'
import { openTitleMenu } from './support/chooserHelpers'
import { titlePopupPage } from './support/cdpPages'
import { openDesktopSettings } from './support/chooserHelpers'

const MIB = 1024 * 1024
const GPU_MEMORY_COUNTER = '\\GPU Process Memory(*)\\Dedicated Usage'
Expand Down Expand Up @@ -115,11 +114,7 @@ async function measureApp(application: ElectronApplication): Promise<{
}

async function disableHardwareAccelerationFromDesktopSettings(ctx: AppContext): Promise<void> {
const popup = titlePopupPage(ctx.app)
await openTitleMenu(ctx.titleBar)
await popup.waitForVisible('[role="menuitem"]', { timeout: 5_000 })
expect(await popup.clickByText('[role="menuitem"]', 'Desktop Settings')).toBe(true)
await popup.waitForVisible('.global-settings', { timeout: 5_000 })
const popup = await openDesktopSettings(ctx.app, ctx.panel)
expect(await popup.clickByText('.gs-tab', 'Advanced')).toBe(true)

const selector = '[role="switch"][aria-label="Use hardware acceleration"]'
Expand Down
9 changes: 3 additions & 6 deletions e2e/shared-controls-input.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { expect, test } from '@playwright/test'
import { launchApp } from './launchApp'
import { openTitleMenu } from './support/chooserHelpers'
import { isPopupVisible, titlePopupPage } from './support/cdpPages'
import { openDesktopSettings } from './support/chooserHelpers'
import { isPopupVisible } from './support/cdpPages'

test('the WebContents facade drives shared selects and tabs with native input @windows @macos @linux', async () => {
const ctx = await launchApp({
settings: { firstUseCompleted: true, language: 'en', autoLaunchOnStartup: 'none' }
})
try {
const popup = titlePopupPage(ctx.app)
await openTitleMenu(ctx.titleBar)
await popup.waitForVisible('[role="menuitem"]')
expect(await popup.clickByText('[role="menuitem"]', 'Desktop Settings')).toBe(true)
const popup = await openDesktopSettings(ctx.app, ctx.panel)

const trigger = '[data-field-id="autoLaunchOnStartup"] [role="combobox"]'
await popup.waitForVisible(trigger)
Expand Down
7 changes: 2 additions & 5 deletions e2e/storage-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path'
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { expect, test } from '@playwright/test'
import { launchApp, type AppContext } from './launchApp'
import { openTitleMenu } from './support/chooserHelpers'
import { openDesktopSettings } from './support/chooserHelpers'
import { titlePopupPage, type WebContentsPage } from './support/cdpPages'
import { evalWithRetry } from './support/evalRetry'

Expand Down Expand Up @@ -84,10 +84,7 @@ test.afterAll(async () => {
})

test('Desktop Settings Storage renders the seeded shared model directory @windows @macos @linux', async () => {
await openTitleMenu(ctx.titleBar)
await popup.waitForVisible('[role="menuitem"]', { timeout: 5_000 })
expect(await popup.clickByText('[role="menuitem"]', 'Desktop Settings')).toBe(true)
await popup.waitForVisible('.global-settings', { timeout: 5_000 })
await openDesktopSettings(ctx.app, ctx.panel)
expect(await popup.clickByText('.gs-tab', 'Storage')).toBe(true)
await popup.waitFor(
async () => (await popup.allText('.models-dir-name')).includes(defaultModelsDir),
Expand Down
12 changes: 12 additions & 0 deletions e2e/support/chooserHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ export async function openTitleMenu(titleBar: WebContentsPage): Promise<void> {
expect(ok, 'Title menu button click dispatched').toBe(true)
}

export async function openDesktopSettings(
app: ElectronApplication,
panel: WebContentsPage
): Promise<WebContentsPage> {
const selector = '[data-testid="app-sidebar-settings"]'
await panel.waitForVisible(selector)
expect(await panel.click(selector), 'Desktop Settings clicked in the sidebar').toBe(true)
const popup = titlePopupPage(app)
await popup.waitForVisible('.global-settings', { timeout: 10_000 })
return popup
}

export async function pickFromTitleMenu(
app: ElectronApplication,
titleBar: WebContentsPage,
Expand Down
40 changes: 24 additions & 16 deletions src/main/popups/titlePopup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,31 @@ describe('buildTitlePopupMenuItems', () => {
expect(items[0]).toMatchObject({ id: 'skip-onboarding' })
})

it.each([null, 'inst-1'] as const)(
'lists the tools, settings and window actions on host %s',
(installationId) => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId }))
expect(items.map((item) => item.id ?? 'separator')).toEqual([
'performance-test',
'benchmarks',
'separator',
'settings',
'separator',
'exit-window',
'close-all-windows'
])
}
)
it('chooser host leaves Desktop Settings to the sidebar', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
expect(items.map((item) => item.id ?? 'separator')).toEqual([
'performance-test',
'benchmarks',
'separator',
'exit-window',
'close-all-windows'
])
})

it('install host keeps Desktop Settings because it has no sidebar', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: 'inst-1' }))
expect(items.map((item) => item.id ?? 'separator')).toEqual([
'performance-test',
'benchmarks',
'separator',
'settings',
'separator',
'exit-window',
'close-all-windows'
])
})

it('install host lists Reset Zoom after Settings when zoomed', () => {
it('install host lists Reset Zoom after Desktop Settings when zoomed', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: 'inst-1', zoomLevel: 2 }))
const ids = items.map((i) => i.id ?? null).filter((id) => id !== null)
expect(ids).toEqual([
Expand Down
14 changes: 7 additions & 7 deletions src/main/popups/titlePopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ export function buildTitlePopupMenuItems(entry: ComfyWindowEntry): TitlePopupMen
label: 'Performance Tests',
labelKey: 'fileMenu.performanceTest'
},
{ id: 'benchmarks', label: 'Benchmarks', labelKey: 'fileMenu.benchmarks' },
{ kind: 'separator' },
{
id: 'settings',
label: 'Desktop Settings',
labelKey: 'fileMenu.globalSettings'
}
{ id: 'benchmarks', label: 'Benchmarks', labelKey: 'fileMenu.benchmarks' }
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
]
if (entry.installationId !== null) {
items.push(
{ kind: 'separator' },
{ id: 'settings', label: 'Desktop Settings', labelKey: 'fileMenu.globalSettings' }
)
}
if (entry.installationId !== null && !entry.comfyView.webContents.isDestroyed()) {
const level = entry.comfyView.webContents.getZoomLevel()
if (level !== 0) {
Expand Down
45 changes: 45 additions & 0 deletions src/renderer/src/panel/AppSidebar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AppSidebar from './AppSidebar.vue'
import { useDashboardScopeStore } from '../stores/dashboardScopeStore'
import { useInstallationStore } from '../stores/installationStore'
import { useSessionStore } from '../stores/sessionStore'
import { TELEMETRY_ACTION_EVENT_NAME, type TelemetryActionEventDetail } from '../lib/telemetry'
import type { DashboardPage, Installation } from '../types/ipc'

function build(over: Partial<Installation> & { id: string; name: string }): Installation {
Expand All @@ -25,6 +26,7 @@ const NEW = build({ id: 'new', name: 'Video Lab', lastLaunchedAt: 300 })
const TEAM = build({ id: 'team', name: 'Team Build', lastLaunchedAt: 400, workspaceId: 'ws-team' })

const navigatePanel = vi.fn()
const openGlobalSettings = vi.fn()
const getAppsEnabled = vi.fn<() => Promise<boolean>>()

beforeEach(() => {
Expand All @@ -33,6 +35,7 @@ beforeEach(() => {
getAppsEnabled.mockResolvedValue(false)
;(window as unknown as { api: unknown }).api = {
navigatePanel,
openGlobalSettings,
getAppsEnabled,
getInstallations: vi.fn().mockResolvedValue([]),
onInstallationsChanged: vi.fn(() => () => {}),
Expand Down Expand Up @@ -153,6 +156,48 @@ describe('AppSidebar', () => {
expect(navigatePanel).toHaveBeenCalledExactlyOnceWith('home')
})

it('opens Desktop Settings above the account section without changing pages', async () => {
const wrapper = await mountSidebar('assets')
const settings = wrapper.get('[data-testid="app-sidebar-settings"]')

expect(settings.text()).toBe('Desktop Settings')
expect(settings.attributes('aria-haspopup')).toBe('dialog')
expect(settings.element.closest('nav')).toBeNull()
expect(settings.element.nextElementSibling?.classList.contains('sidebar-account')).toBe(true)

const events: TelemetryActionEventDetail[] = []
const record: EventListener = (event) => {
events.push((event as CustomEvent<TelemetryActionEventDetail>).detail)
}
window.addEventListener(TELEMETRY_ACTION_EVENT_NAME, record)
await settings.trigger('click')
window.removeEventListener(TELEMETRY_ACTION_EVENT_NAME, record)

expect(openGlobalSettings).toHaveBeenCalledExactlyOnceWith()
expect(events).toEqual([
expect.objectContaining({
actionName: 'comfy.desktop.sidebar.settings_opened',
context: { from_page: 'assets' }
})
])
expect(navigatePanel).not.toHaveBeenCalled()
expect(wrapper.findAll('[aria-current="page"]').map((row) => row.text())).toEqual(['Assets'])
})

it('keeps Desktop Settings accessible as an icon when the sidebar is collapsed', async () => {
const wrapper = await mountSidebar()

await wrapper.get('[data-testid="app-sidebar-toggle"]').trigger('click')
const settings = wrapper.get('[data-testid="app-sidebar-settings"]')
expect(settings.text()).toBe('')
expect(settings.attributes('aria-label')).toBe('Desktop Settings')
expect(settings.attributes('title')).toBe('Desktop Settings')

await settings.trigger('click')

expect(openGlobalSettings).toHaveBeenCalledExactlyOnceWith()
})

it('collapses to icons with tooltips and stays collapsed when reopened', async () => {
const wrapper = await mountSidebar()
const home = wrapper.get('[data-testid="app-sidebar-home"]')
Expand Down
29 changes: 27 additions & 2 deletions src/renderer/src/panel/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
Laptop,
LoaderCircle,
Plus,
Server
Server,
Settings
} from '@lucide/vue'
import type { Component } from 'vue'
import Button from '@comfyorg/design-system/button/Button'
Expand All @@ -26,6 +27,7 @@ import { useProgressStore } from '../stores/progressStore'
import { useDashboardScopeStore } from '../stores/dashboardScopeStore'
import { useInstallationStore } from '../stores/installationStore'
import { useSessionStore } from '../stores/sessionStore'
import { emitTelemetryAction } from '../lib/telemetry'
import { isInstallationInWorkspace } from '../../../shared/workspaces'
import type { DashboardPage, Installation } from '../types/ipc'

Expand Down Expand Up @@ -134,6 +136,11 @@ function navigate(page: DashboardPage): void {
emit('navigate', page)
window.api.navigatePanel(page)
}

function openSettings(): void {
emitTelemetryAction('comfy.desktop.sidebar.settings_opened', { from_page: activePage })
window.api.openGlobalSettings()
}
</script>

<template>
Expand Down Expand Up @@ -292,6 +299,24 @@ function navigate(page: DashboardPage): void {
</template>
</nav>

<SidebarAccount class="mt-2 w-full shrink-0" :collapsed="collapsed" />
<div class="mt-2 flex w-full shrink-0 flex-col gap-1">
<Button
variant="muted-textonly"
size="unset"
class="h-8 w-full shrink-0 rounded-lg text-[13px]/5 font-normal hover:bg-secondary hover:text-foreground"
:class="collapsed ? 'justify-center px-0' : 'justify-start gap-2.5 px-3'"
:aria-label="t('fileMenu.globalSettings')"
aria-haspopup="dialog"
:title="collapsed ? t('fileMenu.globalSettings') : undefined"
data-testid="app-sidebar-settings"
@click="openSettings"
>
<Settings :size="15" aria-hidden="true" />
<span v-if="!collapsed" class="min-w-0 flex-1 truncate text-left">{{
t('fileMenu.globalSettings')
}}</span>
</Button>
<SidebarAccount :collapsed="collapsed" />
</div>
</aside>
</template>
Loading