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
1 change: 0 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,6 @@
"newInstall": "New Instance",
"addExistingInstall": "Add Existing Instance",
"loadSnapshot": "Load Snapshot",
"signIn": "Log in",
"performanceTest": "Performance Tests",
"benchmarks": "Benchmarks",
"globalSettings": "Desktop Settings",
Expand Down
1 change: 0 additions & 1 deletion locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,6 @@
"newInstall": "新建实例",
"addExistingInstall": "添加现有实例",
"loadSnapshot": "加载快照",
"signIn": "登录",
"performanceTest": "性能测试",
"benchmarks": "基准比较",
"globalSettings": "桌面端设置",
Expand Down
6 changes: 0 additions & 6 deletions src/main/lib/ipc/registerDevPlatformHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ export async function signOutOfCloud(host: ComfyWindowEntry | undefined): Promis
return SIGNED_OUT
}

/** Sign-in state for main-side surfaces that decide what to render (the file
* menu). Renderer surfaces read it over `getAuthStatus` instead. */
export function isSignedInToCloud(): boolean {
return getCloudSession().status().signedIn
}

/**
* Register the dev-platform IPC handlers. Call once at startup.
*
Expand Down
95 changes: 4 additions & 91 deletions src/main/popups/titlePopup.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'

const devPlatformMocks = vi.hoisted(() => ({
isSignedInToCloud: vi.fn(() => false),
signInToCloud: vi.fn(async () => ({ signedIn: true }))
}))

// The file menu decides on sign-in state and starts sign-ins from main. Stub
// both so the menu tests drive that state directly instead of opening a browser.
vi.mock('../lib/ipc/registerDevPlatformHandlers', () => ({
isSignedInToCloud: devPlatformMocks.isSignedInToCloud,
signInToCloud: devPlatformMocks.signInToCloud
}))

// shared.ts (via registry.ts) loads electron at import, so mock it first.
vi.mock('electron', () => ({
app: {
Expand Down Expand Up @@ -62,9 +50,6 @@ import * as settings from '../settings'

beforeEach(() => {
vi.clearAllMocks()
// Signed out is the default: every assertion that does not say otherwise
// describes a user who has not logged in yet.
devPlatformMocks.isSignedInToCloud.mockReturnValue(false)
})

afterEach(() => {
Expand Down Expand Up @@ -184,25 +169,21 @@ describe('buildTitlePopupMenuItems', () => {
expect(quit?.label).toBe('Quit Desktop')
})

it('chooser host matches the canonical order, signed out', () => {
it('chooser host matches the canonical order', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
const ids = items.map((i) => i.id ?? null).filter((id) => id !== null)
expect(ids).toEqual([
'new-window',
'new-install',
'track',
'load-snapshot',
'sign-in',
'performance-test',
'benchmarks',
'settings',
'feedback',
'exit-window',
'close-all-windows'
])
const signIn = items.find((i) => i.id === 'sign-in')
expect(signIn?.label).toBe('Log in')
expect(signIn?.labelKey).toBe('fileMenu.signIn')
})

it('install host matches the canonical order with Close Window between Send Feedback and Quit Desktop', () => {
Expand All @@ -213,7 +194,6 @@ describe('buildTitlePopupMenuItems', () => {
'new-install',
'track',
'load-snapshot',
'sign-in',
'performance-test',
'benchmarks',
'settings',
Expand All @@ -227,33 +207,14 @@ describe('buildTitlePopupMenuItems', () => {
expect(quit?.label).toBe('Quit Desktop')
})

it('chooser host matches the canonical order once signed in', () => {
devPlatformMocks.isSignedInToCloud.mockReturnValue(true)
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
const ids = items.map((i) => i.id ?? null).filter((id) => id !== null)
expect(ids).toEqual([
'new-window',
'new-install',
'track',
'load-snapshot',
'performance-test',
'benchmarks',
'settings',
'feedback',
'exit-window',
'close-all-windows'
])
})

it('install host keeps Log in ahead of Reset Zoom when both are live', () => {
it('install host lists Reset Zoom after Send Feedback 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([
'new-window',
'new-install',
'track',
'load-snapshot',
'sign-in',
'performance-test',
'benchmarks',
'settings',
Expand All @@ -264,15 +225,7 @@ describe('buildTitlePopupMenuItems', () => {
])
})

// Login is the precondition for the account-scoped Comfy Developer Platform rollout, so
// it is never gated on that rollout — only on whether you are already in.
it('omits Log in once the user is signed in', () => {
devPlatformMocks.isSignedInToCloud.mockReturnValue(true)
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
expect(items.find((i) => i.id === 'sign-in')).toBeUndefined()
})

it('keeps the post-consent menu to Skip Onboarding, with no Log in item', () => {
it('keeps the post-consent menu to Skip Onboarding', () => {
const items = buildTitlePopupMenuItems(makeEntry({ firstUseMode: 'post-consent' }))
expect(items.map((i) => i.id ?? null)).toEqual(['skip-onboarding'])
})
Expand Down Expand Up @@ -309,16 +262,7 @@ describe('buildTitlePopupMenuItems', () => {
expect(ids[ids.length - 1]).toBe('close-all-windows')
})

it('separates Log in from the Performance Test and Benchmarks group', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
const signInIdx = items.findIndex((i) => i.id === 'sign-in')
expect(items[signInIdx + 1]?.kind).toBe('separator')
expect(items[signInIdx + 2]?.id).toBe('performance-test')
expect(items[signInIdx + 3]?.id).toBe('benchmarks')
})

it('does not leave a doubled separator above Performance Test once signed in', () => {
devPlatformMocks.isSignedInToCloud.mockReturnValue(true)
it('has a single separator above Performance Test', () => {
const items = buildTitlePopupMenuItems(makeEntry({ installationId: null }))
const performanceTestsIdx = items.findIndex((i) => i.id === 'performance-test')
expect(items[performanceTestsIdx - 1]?.kind).toBe('separator')
Expand Down Expand Up @@ -421,37 +365,6 @@ describe('activateTitlePopupMenuItem', () => {

expect(bindings.resetComfyZoom).not.toHaveBeenCalled()
})

// The shared primitive, not `session.login()` — it carries the sign-out race
// guard the `comfybuilder:signIn` IPC relies on.
it('routes Log in through the shared login primitive', () => {
const host = makeEntry({ installationId: null })
comfyWindows.set(host.windowKey, host)

activateTitlePopupMenuItem(
makePopupEntry(host.windowKey),
'sign-in',
{} as unknown as TitlePopupHostBindings
)

expect(devPlatformMocks.signInToCloud).toHaveBeenCalledOnce()
})

it('swallows a cancelled or failed sign-in handoff', async () => {
const host = makeEntry({ installationId: null })
comfyWindows.set(host.windowKey, host)
devPlatformMocks.signInToCloud.mockRejectedValueOnce(new Error('user closed the browser'))

expect(() =>
activateTitlePopupMenuItem(
makePopupEntry(host.windowKey),
'sign-in',
{} as unknown as TitlePopupHostBindings
)
).not.toThrow()
// Let the rejected promise settle so an unhandled rejection would surface.
await Promise.resolve()
})
})

describe('decideFlowMenuItemTarget', () => {
Expand Down
29 changes: 2 additions & 27 deletions src/main/popups/titlePopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
buildModelsPayload,
buildInstallLocationFields
} from '../lib/ipc/registerSettingsHandlers'
import { isSignedInToCloud, signInToCloud } from '../lib/ipc/registerDevPlatformHandlers'
import { globalSettingsEvents } from '../lib/globalSettingsEvents'
import * as installations from '../installations'
import { getCachedGithubStarCount, getGithubStarCount } from '../lib/githubStars'
Expand Down Expand Up @@ -759,7 +758,6 @@ export function buildTitlePopupMenuItems(entry: ComfyWindowEntry): TitlePopupMen
// Add Existing Install
// Load Snapshot
// ── separator ──
// (Log in — while signed out, followed by its own separator)
// Performance Test
// Benchmarks
// ── separator ──
Expand All @@ -786,12 +784,6 @@ export function buildTitlePopupMenuItems(entry: ComfyWindowEntry): TitlePopupMen
// - "Return to Dashboard" is absent: the picker's Home icon is
// the canonical dashboard escape (opens a fresh chooser window
// instead of detaching, so the running ComfyUI stays alive).
// - "Log in" sits in its own group above Desktop Settings while
// signed out, and is the app's ONLY sign-in affordance. Deliberately
// NOT behind the Comfy Developer Platform rollout flag: that flag gates
// what a signed-in account may do, and gating login itself
// would put it behind a decision that cannot be made until the
// user has logged in.
const items: TitlePopupMenuItem[] = [
{ id: 'new-window', label: 'Open Dashboard', labelKey: 'fileMenu.newWindow' },
{ kind: 'separator' },
Expand All @@ -802,15 +794,7 @@ export function buildTitlePopupMenuItems(entry: ComfyWindowEntry): TitlePopupMen
labelKey: 'fileMenu.addExistingInstall'
},
{ id: 'load-snapshot', label: 'Load Snapshot', labelKey: 'fileMenu.loadSnapshot' },
{ kind: 'separator' }
]
if (!isSignedInToCloud()) {
items.push(
{ id: 'sign-in', label: 'Log in', labelKey: 'fileMenu.signIn' },
{ kind: 'separator' }
)
}
items.push(
{ kind: 'separator' },
{
id: 'performance-test',
label: 'Performance Tests',
Expand All @@ -824,7 +808,7 @@ export function buildTitlePopupMenuItems(entry: ComfyWindowEntry): TitlePopupMen
labelKey: 'fileMenu.globalSettings'
},
{ id: 'feedback', label: 'Send Beta Feedback', labelKey: 'fileMenu.sendFeedback' }
)
]
// Reset Zoom — discoverable recovery path for users who zoom the live
// ComfyUI view too far to read. Dashboard hosts do not expose zoom controls.
if (entry.installationId !== null && !entry.comfyView.webContents.isDestroyed()) {
Expand Down Expand Up @@ -2058,15 +2042,6 @@ export function activateTitlePopupMenuItem(
// via `comfy-window:click-feedback`; `source` distinguishes the
// two entry points in the telemetry payload.
bindings.triggerOpenFeedback(entry.parentEntryId, 'menu')
} else if (id === 'sign-in') {
// No renderer in this loop — the popup is its own WebContentsView — so the
// menu calls the same primitive `comfybuilder:signIn` does, which is what
// keeps the sign-out race guard shared instead of forked. Fire-and-forget:
// the browser handoff can take minutes and every surface repaints off the
// `authChanged` broadcast the primitive sends, not off this call.
void signInToCloud().catch(() => {
// Cancelled or failed handoff: the menu item re-arms on the next open.
})
} else if (id === 'reset-zoom') {
// Route through the shared reset so the title-bar pill picks up the
// `comfy-titlebar:zoom-changed` push (that event fires only for
Expand Down
Loading