From 716959e3d6062744e0e07b94afc7bb113800fd83 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Mon, 16 Nov 2026 10:16:22 -0800 Subject: [PATCH] =?UTF-8?q?feat(titlebar):=20Home=20button=20in=20build=20?= =?UTF-8?q?windows,=20and=20the=20=E2=98=B0=20menu=20on=20the=20right=20(D?= =?UTF-8?q?ESK-293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A build window's title bar now starts with a Home button. It brings the Desktop window to the front, or opens one when none is open. The Desktop window itself has no Home button. The ☰ menu moves to the right end of the title bar in every window, after Downloads, and refresh moves to the right with the other build controls. Why: once a build opened in the Desktop window there was no way back to Desktop (Alexis, 1.1.11 QA, Nov 12). Pablo and Alexis settled on Home in build windows only and the ☰ on the right. The layout follows Mar's title bar in the New-Home Figma (Components > Organisms/Title bar, and the M2 Apps title bars): house icon and "Home" at 13px, no fill at rest, a grey pill on hover, ☰ last on the right. Home skips a Desktop window that is turning into a build window (it has claimed a launch or is previewing one), so it never brings forward a window that is about to show ComfyUI. This redoes the title bar part of Comfy-Org/Comfy-Desktop#2027 on main. That PR also opens every build in its own window; that is left for a separate change. --- locales/en.json | 1 + locales/zh.json | 1 + src/main/host/registry.test.ts | 68 +++++++++++ src/main/host/registry.ts | 22 ++++ src/main/index.ts | 8 ++ src/preload/comfyTitleBarPreload.ts | 4 + .../src/comfyTitleBar/TitleBarApp.test.ts | 108 +++++++++++++++++- .../src/comfyTitleBar/TitleBarApp.vue | 58 +++++++--- 8 files changed, 247 insertions(+), 23 deletions(-) diff --git a/locales/en.json b/locales/en.json index 2ea667807..c457f752d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -241,6 +241,7 @@ "appUpdateReady": "Restart to update", "installUpdateAvailable": "Update available", "installUpdateShort": "Update", + "home": "Home", "menu": "Menu", "feedback": "Feedback", "feedbackTooltip": "Send Feedback", diff --git a/locales/zh.json b/locales/zh.json index 228c181d0..502ac2d03 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -241,6 +241,7 @@ "appUpdateReady": "重启以更新", "installUpdateAvailable": "有可用更新", "installUpdateShort": "更新", + "home": "主页", "menu": "菜单", "feedback": "反馈", "feedbackTooltip": "发送反馈", diff --git a/src/main/host/registry.test.ts b/src/main/host/registry.test.ts index 7c65453d9..a9f280553 100644 --- a/src/main/host/registry.test.ts +++ b/src/main/host/registry.test.ts @@ -32,6 +32,7 @@ import { indexInstallationId, nextWindowKey, forceRevealHostWindow, + openOrFocusHomeHostWindow, hasRunningSessionForEntry, raiseAllHostWindows, registerHostEntry, @@ -601,3 +602,70 @@ describe('raiseAllHostWindows', () => { expect(fakeWin(min).raised).toContain('focus') }) }) + +describe('openOrFocusHomeHostWindow', () => { + function fakeWin(entry: ComfyWindowEntry): FakeWindow { + return entry.window as unknown as FakeWindow + } + + function trackChooserFactory(): ReturnType { + const createChooser = vi.fn(() => makeWindow() as unknown as ComfyWindowEntry['window']) + setHostFactories({ createChooser }) + return createChooser + } + + it('brings the open Desktop window to the front instead of opening another', () => { + const createChooser = trackChooserFactory() + const home = makeEntry({ installationId: null }) + const build = makeEntry({ installationId: 'inst-A' }) + registerHostEntry(home) + registerHostEntry(build) + + expect(openOrFocusHomeHostWindow()).toBe(home.window) + expect(fakeWin(home).raised).toContain('focus') + expect(fakeWin(build).raised).toEqual([]) + expect(createChooser).not.toHaveBeenCalled() + }) + + it('restores a minimised Desktop window', () => { + const createChooser = trackChooserFactory() + const home = makeEntry({ installationId: null, minimized: true }) + registerHostEntry(home) + + expect(openOrFocusHomeHostWindow()).toBe(home.window) + expect(fakeWin(home).raised).toEqual(expect.arrayContaining(['restore', 'focus'])) + expect(createChooser).not.toHaveBeenCalled() + }) + + it('opens a Desktop window when only build windows are open', () => { + const createChooser = trackChooserFactory() + registerHostEntry(makeEntry({ installationId: 'inst-A' })) + registerHostEntry(makeEntry({ installationId: 'inst-B' })) + + openOrFocusHomeHostWindow() + expect(createChooser).toHaveBeenCalledTimes(1) + }) + + it('opens a Desktop window when the only one is turning into a build window', () => { + const createChooser = trackChooserFactory() + const claimed = makeEntry({ installationId: null }) + const previewing = makeEntry({ installationId: null }) + previewing.previewInstallationId = 'inst-B' + registerHostEntry(claimed) + registerHostEntry(previewing) + claimAttachHost('inst-A', claimed.windowKey) + + openOrFocusHomeHostWindow() + expect(createChooser).toHaveBeenCalledTimes(1) + expect(fakeWin(claimed).raised).toEqual([]) + expect(fakeWin(previewing).raised).toEqual([]) + }) + + it('skips a closed Desktop window', () => { + const createChooser = trackChooserFactory() + registerHostEntry(makeEntry({ installationId: null, destroyed: true })) + + openOrFocusHomeHostWindow() + expect(createChooser).toHaveBeenCalledTimes(1) + }) +}) diff --git a/src/main/host/registry.ts b/src/main/host/registry.ts index 6d76b1946..e6166c3ca 100644 --- a/src/main/host/registry.ts +++ b/src/main/host/registry.ts @@ -327,6 +327,28 @@ export function openOrFocusChooserHostWindow(): BrowserWindow { return requireChooserFactory()() } +function isHandingOffToBuild(entry: ComfyWindowEntry): boolean { + if (entry.previewInstallationId !== null) return true + for (const claimedKey of pendingAttachClaims.values()) { + if (claimedKey === entry.windowKey) return true + } + return false +} + +function findHomeHostWindow(): BrowserWindow | null { + const entry = findPreferredHostByVisibility((e) => isChooserHost(e) && !isHandingOffToBuild(e)) + return entry?.window ?? null +} + +export function openOrFocusHomeHostWindow(): BrowserWindow { + const existing = findHomeHostWindow() + if (existing) { + bringToFront(existing) + return existing + } + return requireChooserFactory()() +} + export function openOrFocusAnyHostWindow(): BrowserWindow { const installWin = findPreferredInstallHostWindow() if (installWin) { diff --git a/src/main/index.ts b/src/main/index.ts index 89b51ea66..6bcffbd9e 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -147,6 +147,7 @@ import { isInstallHost, openOrFocusAnyHostWindow, openOrFocusChooserHostWindow, + openOrFocusHomeHostWindow, raiseAllHostWindows, setHostFactories, shouldConfirmKillForEntry @@ -759,6 +760,13 @@ ipcMain.on('comfy-window:new-chooser-window', () => { openChooserHostWindow() }) +ipcMain.on('comfy-window:show-home', (event) => { + const found = findEntryByTitleBarSender(event.sender) + if (!found || !isInstallHost(found.entry)) return + recordIpcInvocation('comfy-window:show-home') + openOrFocusHomeHostWindow() +}) + function focusOpenComfyWindow(installationId: string): boolean { const entry = getEntryByInstallationId(installationId) if (!entry || entry.window.isDestroyed()) return false diff --git a/src/preload/comfyTitleBarPreload.ts b/src/preload/comfyTitleBarPreload.ts index dae5abd25..22f68d036 100644 --- a/src/preload/comfyTitleBarPreload.ts +++ b/src/preload/comfyTitleBarPreload.ts @@ -76,6 +76,7 @@ export interface ComfyTitleBarBridge { clickFeedback(): void clickAnnouncement(): void clickRefreshInstance(): void + clickHome(): void resetZoom(): void showTooltip(payload: { text: string; leftX: number; rightX: number; bottomY: number }): void hideTooltip(): void @@ -266,6 +267,9 @@ const bridge: ComfyTitleBarBridge = { clickRefreshInstance: () => { ipcRenderer.send('comfy-window:click-refresh-instance') }, + clickHome: () => { + ipcRenderer.send('comfy-window:show-home') + }, resetZoom: () => { ipcRenderer.send('comfy-window:reset-zoom') }, diff --git a/src/renderer/src/comfyTitleBar/TitleBarApp.test.ts b/src/renderer/src/comfyTitleBar/TitleBarApp.test.ts index 88c2cbb33..d76663291 100644 --- a/src/renderer/src/comfyTitleBar/TitleBarApp.test.ts +++ b/src/renderer/src/comfyTitleBar/TitleBarApp.test.ts @@ -48,6 +48,7 @@ interface MockBridgeState { installPillClicks: { x: number; y: number }[] feedbackClicks: number refreshInstanceClicks: number + homeClicks: number resetZoomClicks: number showTooltipCalls: { text: string; leftX: number; rightX: number; bottomY: number }[] hideTooltipCalls: number @@ -98,6 +99,7 @@ function installMockBridge( installPillClicks: [], feedbackClicks: 0, refreshInstanceClicks: 0, + homeClicks: 0, resetZoomClicks: 0, showTooltipCalls: [], hideTooltipCalls: 0, @@ -209,6 +211,9 @@ function installMockBridge( clickRefreshInstance: () => { state.refreshInstanceClicks += 1 }, + clickHome: () => { + state.homeClicks += 1 + }, resetZoom: () => { state.resetZoomClicks += 1 }, @@ -410,7 +415,7 @@ describe('TitleBarApp', () => { const { default: TitleBarApp } = await import('./TitleBarApp.vue') const wrapper = mount(TitleBarApp) await flushPromises() - expect(wrapper.find('.title-menu-button--icon').exists()).toBe(true) + expect(wrapper.find('.title-menu-button[aria-haspopup="menu"]').exists()).toBe(true) expect(wrapper.find('.title-downloads-tray').exists()).toBe(true) expect(wrapper.find('.title-feedback-button').exists()).toBe(true) expect(wrapper.find('.title-install-pill.is-interactive').exists()).toBe(true) @@ -419,7 +424,7 @@ describe('TitleBarApp', () => { bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('consent-lockdown')) await flushPromises() expect(wrapper.find('header').classes()).toContain('is-consent-lockdown') - expect(wrapper.find('.title-menu-button--icon').exists()).toBe(false) + expect(wrapper.find('.title-menu-button[aria-haspopup="menu"]').exists()).toBe(false) expect(wrapper.find('.title-downloads-tray').exists()).toBe(false) expect(wrapper.find('.title-feedback-button').exists()).toBe(false) expect(wrapper.find('.title-install-pill.is-interactive').exists()).toBe(false) @@ -427,7 +432,7 @@ describe('TitleBarApp', () => { bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('post-consent')) await flushPromises() expect(wrapper.find('header').classes()).not.toContain('is-consent-lockdown') - expect(wrapper.find('.title-menu-button--icon').exists()).toBe(true) + expect(wrapper.find('.title-menu-button[aria-haspopup="menu"]').exists()).toBe(true) expect(wrapper.find('.title-downloads-tray').exists()).toBe(false) expect(wrapper.find('.title-feedback-button').exists()).toBe(false) expect(wrapper.find('.title-install-pill.is-interactive').exists()).toBe(false) @@ -435,7 +440,7 @@ describe('TitleBarApp', () => { bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('loading-lockdown')) await flushPromises() expect(wrapper.find('header').classes()).not.toContain('is-consent-lockdown') - expect(wrapper.find('.title-menu-button--icon').exists()).toBe(true) + expect(wrapper.find('.title-menu-button[aria-haspopup="menu"]').exists()).toBe(true) expect(wrapper.find('.title-downloads-tray').exists()).toBe(true) expect(wrapper.find('.title-feedback-button').exists()).toBe(true) expect(wrapper.find('.title-install-pill.is-interactive').exists()).toBe(true) @@ -443,13 +448,106 @@ describe('TitleBarApp', () => { bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('none')) await flushPromises() expect(wrapper.find('header').classes()).not.toContain('is-consent-lockdown') - expect(wrapper.find('.title-menu-button--icon').exists()).toBe(true) + expect(wrapper.find('.title-menu-button[aria-haspopup="menu"]').exists()).toBe(true) expect(wrapper.find('.title-downloads-tray').exists()).toBe(true) expect(wrapper.find('.title-feedback-button').exists()).toBe(true) expect(wrapper.find('.title-install-pill.is-interactive').exists()).toBe(true) wrapper.unmount() }) + describe('Home button and the ☰ on the right', () => { + const menuButton = '.title-menu-button[aria-haspopup="menu"]' + + it('puts Home alone on the left of a build window and sends the click to the Desktop window', async () => { + const { default: TitleBarApp } = await import('./TitleBarApp.vue') + const wrapper = mount(TitleBarApp) + await flushPromises() + bridgeState.sourceCategoryChangedCallbacks.forEach((cb) => cb('local')) + await flushPromises() + + const leading = wrapper.find('.title-cluster') + const home = leading.find('.title-home-button') + expect(home.exists()).toBe(true) + expect(home.text()).toBe('Home') + expect(leading.find(menuButton).exists()).toBe(false) + expect(leading.find('.title-refresh-button').exists()).toBe(false) + + await home.trigger('click') + expect(bridgeState.homeClicks).toBe(1) + wrapper.unmount() + }) + + it("ends the right side with the ☰, after refresh, What's new, Feedback and Downloads", async () => { + const { default: TitleBarApp } = await import('./TitleBarApp.vue') + const wrapper = mount(TitleBarApp) + await flushPromises() + bridgeState.sourceCategoryChangedCallbacks.forEach((cb) => cb('local')) + await flushPromises() + + const trailing = wrapper.find('.title-trailing').element + const controls: [string, string][] = [ + ['.title-refresh-button', 'refresh'], + ['.title-announcement-button', 'whats-new'], + ['.title-feedback-button', 'feedback'], + ['.title-downloads-tray', 'downloads'], + [menuButton, 'menu'] + ] + const order = Array.from(trailing.children).flatMap((el) => + controls.filter(([selector]) => el.matches(selector)).map(([, name]) => name) + ) + expect(order).toEqual(['refresh', 'whats-new', 'feedback', 'downloads', 'menu']) + wrapper.unmount() + }) + + it('shows no Home button in the Desktop window, and keeps its ☰ on the right', async () => { + bridgeState = installMockBridge({ installationId: null }) + vi.resetModules() + const { default: TitleBarApp } = await import('./TitleBarApp.vue') + const wrapper = mount(TitleBarApp) + await flushPromises() + + expect(wrapper.find('.title-home-button').exists()).toBe(false) + expect(wrapper.find('.title-cluster').element.children.length).toBe(0) + expect(wrapper.find('.title-trailing').element.lastElementChild?.matches(menuButton)).toBe( + true + ) + wrapper.unmount() + }) + + it('adds Home when the Desktop window starts a build in place', async () => { + bridgeState = installMockBridge({ installationId: null }) + vi.resetModules() + const { default: TitleBarApp } = await import('./TitleBarApp.vue') + const wrapper = mount(TitleBarApp) + await flushPromises() + expect(wrapper.find('.title-home-button').exists()).toBe(false) + + bridgeState.installationIdChangedCallbacks.forEach((cb) => cb('inst-started-here')) + await flushPromises() + expect(wrapper.find('.title-home-button').exists()).toBe(true) + wrapper.unmount() + }) + + it('hides Home through the first-use takeover and brings it back for loading', async () => { + const { default: TitleBarApp } = await import('./TitleBarApp.vue') + const wrapper = mount(TitleBarApp) + await flushPromises() + + bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('consent-lockdown')) + await flushPromises() + expect(wrapper.find('.title-home-button').exists()).toBe(false) + + bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('post-consent')) + await flushPromises() + expect(wrapper.find('.title-home-button').exists()).toBe(false) + + bridgeState.firstUseModeChangedCallbacks.forEach((cb) => cb('loading-lockdown')) + await flushPromises() + expect(wrapper.find('.title-home-button').exists()).toBe(true) + wrapper.unmount() + }) + }) + it('toggles is-fullscreen in response to onFullscreenChanged', async () => { const { default: TitleBarApp } = await import('./TitleBarApp.vue') const wrapper = mount(TitleBarApp) diff --git a/src/renderer/src/comfyTitleBar/TitleBarApp.vue b/src/renderer/src/comfyTitleBar/TitleBarApp.vue index 914dde843..134b2e789 100644 --- a/src/renderer/src/comfyTitleBar/TitleBarApp.vue +++ b/src/renderer/src/comfyTitleBar/TitleBarApp.vue @@ -6,6 +6,7 @@ import { Bell, ChevronDown, CloudDownload, + House, Loader2, Menu as MenuIcon, MessageSquarePlus, @@ -113,6 +114,7 @@ interface Bridge { clickFeedback: () => void clickAnnouncement: () => void clickRefreshInstance: () => void + clickHome: () => void resetZoom: () => void ready: () => void } @@ -139,6 +141,9 @@ const titleInstallPillClass = [ '[.title-bar.is-light_&.is-interactive.is-open]:border-[color-mix(in_srgb,var(--neutral-700)_55%,transparent)] [.title-bar.is-light_&.is-interactive.is-open]:text-neutral-700' ].join(' ') +const titleHomeButtonClass = + '[-webkit-app-region:no-drag] inline-flex h-7 shrink-0 items-center gap-2 rounded-control border border-solid border-transparent bg-transparent py-0 pr-2.5 pl-2 [font-family:inherit] text-[13px] leading-5 font-normal text-[var(--titlebar-icon)] opacity-85 cursor-pointer transition-[background-color,opacity] duration-[120ms] ease-[ease] [.title-bar.is-hover-active_&]:hover:opacity-100 [.title-bar.is-hover-active_&]:hover:bg-secondary focus-visible:outline-2 focus-visible:[outline-style:solid] focus-visible:outline-[var(--focus-ring)] focus-visible:outline-offset-1' + const titleDownloadsBadgeClass = 'pointer-events-none absolute -top-1 -right-1 inline-flex h-3.5 min-w-3.5 items-center justify-center rounded-[999px] bg-[var(--action,#60a5fa)] px-1 py-0 text-[9px] leading-none font-bold text-white tabular-nums [box-shadow:0_0_0_2px_var(--titlebar-bg-active,var(--titlebar-bg,var(--neutral-900)))] [.title-bar:not(.is-light)_&:not(.is-unseen,.is-error)]:text-background [&.is-unseen]:bg-[#22c55e] [&.is-error]:bg-[var(--danger)] [.title-downloads-tray.has-active_&]:animate-[title-downloads-pulse_1.6s_ease-in-out_infinite] [.title-downloads-tray.is-flashing_&]:[animation:title-downloads-flash_0.55s_cubic-bezier(0.2,0.9,0.3,1.4)_1,title-downloads-pulse_1.6s_ease-in-out_infinite_0.6s]' @@ -173,6 +178,8 @@ const showRefreshButton = computed( !isFirstUseLockdown.value ) +const showHomeButton = computed(() => !isInstallLess.value && !isFirstUseLockdown.value) + const zoomLevel = ref(0) const zoomPercent = computed(() => Math.round(Math.pow(1.2, zoomLevel.value) * 100)) const showZoomReset = computed( @@ -198,6 +205,11 @@ function handleRefreshInstance(): void { bridge?.clickRefreshInstance() } +function handleHome(): void { + hideTip() + bridge?.clickHome() +} + function handleResetZoom(): void { bridge?.resetZoom() } @@ -586,26 +598,14 @@ onUnmounted(() => { " > - @@ -741,6 +741,16 @@ onUnmounted(() => { {{ zoomPercent }}% + +