diff --git a/e2e/assets-startup-failure.test.ts b/e2e/assets-startup-failure.test.ts index 40b24ca15..47e9628b9 100644 --- a/e2e/assets-startup-failure.test.ts +++ b/e2e/assets-startup-failure.test.ts @@ -4,7 +4,7 @@ import { mkdtemp, rm, writeFile } from 'node:fs/promises' import { test, expect } from '@playwright/test' import en from '../locales/en.json' import { launchApp, type AppContext } from './launchApp' -import { clickInstallTile, expectChooserVisible } from './support/chooserHelpers' +import { expectChooserVisible, pickFromBuildsTileMenu } from './support/chooserHelpers' import { hasActiveLaunch } from './support/devHooks' import { reserveFreePort, writeFakeComfyInstall } from './support/fakeComfyInstall' @@ -34,7 +34,7 @@ async function launchAndReadError(stderr: string): Promise { document.querySelector('.chooser-tile-error-badge')?.setAttribute('data-earlier-failure', '') return true })()`) - await clickInstallTile(ctx!.panel, INSTALL_NAME) + await pickFromBuildsTileMenu(ctx!.panel, INSTALL_ID, 'launch') await expect.poll(() => hasActiveLaunch(ctx!.app, INSTALL_ID), { timeout: 60_000 }).toBe(false) await ctx!.panel.waitForVisible(NEW_ERROR_BADGE, { timeout: 30_000 }) expect(await ctx!.panel.click(NEW_ERROR_BADGE)).toBe(true) diff --git a/e2e/comfybuilder-launch.test.ts b/e2e/comfybuilder-launch.test.ts index 050456b17..aba8c5281 100644 --- a/e2e/comfybuilder-launch.test.ts +++ b/e2e/comfybuilder-launch.test.ts @@ -4,7 +4,11 @@ import { chmod, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { test, expect } from '@playwright/test' import en from '../locales/en.json' import { launchApp, type AppContext, type SeedInstallation } from './launchApp' -import { clickInstallTile, expectChooserVisible } from './support/chooserHelpers' +import { + clickInstallTile, + expectChooserVisible, + pickFromBuildsTileMenu +} from './support/chooserHelpers' import { getIpcInvocations, hasActiveLaunch, resetIpcInvocations } from './support/devHooks' import { byTestId, TID } from './support/testIds' @@ -124,9 +128,18 @@ test('clicking an installed ComfyBuilder tile launches it instead of opening the await expectChooserVisible(ctx.panel) }) -test('clicking a not-ready ComfyBuilder tile explains itself instead of opening the new-install wizard @windows @macos', async () => { +test('clicking a not-ready ComfyBuilder tile opens its build page instead of the new-install wizard @windows @macos', async () => { await clickInstallTile(ctx.panel, FAILED.name) + await ctx.panel.waitForVisible('[data-testid="build-details"]', { timeout: 10_000 }) + expect(await ctx.panel.exists(NEW_INSTALL_WIZARD)).toBe(false) + expect(await ctx.panel.click('.build-details-back')).toBe(true) + await expectChooserVisible(ctx.panel) +}) + +test('launching a not-ready ComfyBuilder build from its menu explains itself instead of opening the new-install wizard @windows @macos', async () => { + await pickFromBuildsTileMenu(ctx.panel, FAILED.id, 'launch') + await ctx.panel.waitForVisible(byTestId(TID.baseAlertAction), { timeout: 10_000 }) expect(await ctx.panel.textOf('.base-alert-message-text')).toContain(en.errors.installNotReady) expect(await ctx.panel.exists(NEW_INSTALL_WIZARD)).toBe(false) diff --git a/e2e/dashboard-delete-flow.test.ts b/e2e/dashboard-delete-flow.test.ts index ce79f1f99..8a74975bc 100644 --- a/e2e/dashboard-delete-flow.test.ts +++ b/e2e/dashboard-delete-flow.test.ts @@ -3,7 +3,11 @@ import path from 'node:path' import { access, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { test, expect } from '@playwright/test' import { launchApp, type AppContext } from './launchApp' -import { expectChooserVisible } from './support/chooserHelpers' +import { + buildMenuItem, + expectChooserVisible, + pickFromBuildsTileMenu +} from './support/chooserHelpers' import { byTestId, TID } from './support/testIds' import { getIpcInvocations, resetIpcInvocations } from './support/devHooks' @@ -58,25 +62,24 @@ test('chooser shows the seeded tile @windows @macos @linux', async () => { ).toBe(INSTALL_NAME) }) -test('Delete from kebab opens confirm without invoking get-detail-sections @windows @macos @linux', async () => { +test('Uninstall from the ⋯ menu asks inside the menu without invoking get-detail-sections @windows @macos @linux', async () => { await resetIpcInvocations(ctx.app, 'get-detail-sections') - const kebabClicked = await ctx.panel.click(byTestId(TID.dashboardTileKebab(INSTALL_ID))) - expect(kebabClicked, 'kebab button click dispatched').toBe(true) + await pickFromBuildsTileMenu(ctx.panel, INSTALL_ID, 'delete') - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('delete')), { timeout: 5_000 }) - const deleteClicked = await ctx.panel.click(byTestId(TID.contextMenuItem('delete'))) - expect(deleteClicked, 'delete menu item click dispatched').toBe(true) - - await ctx.panel.waitForVisible(byTestId(TID.baseAlertAction), { timeout: 5_000 }) + await ctx.panel.waitForVisible(buildMenuItem('confirm-uninstall'), { timeout: 5_000 }) + expect(await ctx.panel.textOf('[data-testid="build-menu-uninstall-question"]')).toContain( + INSTALL_NAME + ) const invocations = await getIpcInvocations(ctx.app, 'get-detail-sections') expect(invocations, 'Delete dispatch must not call get-detail-sections').toEqual([]) }) test('Confirm removes the install directory and tile @windows @macos @linux', async () => { - const confirmClicked = await ctx.panel.click(byTestId(TID.baseAlertAction)) - expect(confirmClicked, 'confirm button click dispatched').toBe(true) + const confirmClicked = await ctx.panel.click(buildMenuItem('confirm-uninstall')) + expect(confirmClicked, 'confirm menu item click dispatched').toBe(true) + expect(await ctx.panel.exists(byTestId(TID.baseAlertAction)), 'no second dialog').toBe(false) await ctx.panel.waitFor( async () => !(await ctx.panel.exists(byTestId(TID.dashboardTile(INSTALL_ID)))), diff --git a/e2e/delete-untrack.test.ts b/e2e/delete-untrack.test.ts index cb4e3e1f0..fe885382a 100644 --- a/e2e/delete-untrack.test.ts +++ b/e2e/delete-untrack.test.ts @@ -3,7 +3,7 @@ import path from 'node:path' import { access, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { test, expect } from '@playwright/test' import { launchApp, type AppContext } from './launchApp' -import { expectChooserVisible } from './support/chooserHelpers' +import { expectChooserVisible, uninstallFromBuildsTileMenu } from './support/chooserHelpers' import { closeTitlePopupIfOpen, titlePopupPage, waitForWebContents } from './support/cdpPages' import { byTestId, TID } from './support/testIds' @@ -40,14 +40,6 @@ async function errorShownOnDeletedBuild(): Promise { return ctx.panel.textOf('.base-alert-message-text') } -async function openKebabAndClick(installationId: string, menuItemId: string): Promise { - const kebabClicked = await ctx.panel.click(byTestId(TID.dashboardTileKebab(installationId))) - expect(kebabClicked, `kebab click on ${installationId}`).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem(menuItemId)), { timeout: 5_000 }) - const itemClicked = await ctx.panel.click(byTestId(TID.contextMenuItem(menuItemId))) - expect(itemClicked, `menu item click ${menuItemId}`).toBe(true) -} - test.describe.configure({ mode: 'serial' }) test.beforeAll(async () => { @@ -126,11 +118,7 @@ test('Manage drawer Untrack drops the record but preserves the install directory }) test('kebab Delete drops the record AND removes the install directory @real-comfy', async () => { - await openKebabAndClick(DELETE_ID, 'delete') - - await ctx.panel.waitForVisible(byTestId(TID.baseAlertAction), { timeout: 5_000 }) - const confirmed = await ctx.panel.click(byTestId(TID.baseAlertAction)) - expect(confirmed, 'delete confirm click dispatched').toBe(true) + await uninstallFromBuildsTileMenu(ctx.panel, DELETE_ID) await ctx.panel.waitFor( async () => !(await tileExists(DELETE_ID)) || (await ctx.panel.isVisible(DELETE_ERROR_BADGE)), diff --git a/e2e/migrate-legacy.test.ts b/e2e/migrate-legacy.test.ts index e4f1f1967..f90830d44 100644 --- a/e2e/migrate-legacy.test.ts +++ b/e2e/migrate-legacy.test.ts @@ -6,7 +6,7 @@ import { resolve } from 'node:path' import { test, expect } from '@playwright/test' import { launchApp, type AppContext } from './launchApp' import { closeTitlePopupIfOpen, titlePopupPage, waitForWebContents } from './support/cdpPages' -import { expectChooserVisible } from './support/chooserHelpers' +import { expectChooserVisible, pickFromBuildsTileMenu } from './support/chooserHelpers' import { getIpcInvocations, resetIpcInvocations } from './support/devHooks' import { byTestId, TID } from './support/testIds' @@ -97,12 +97,7 @@ test('chooser kebab Migrate opens the real adoption confirm; Cancel backs out cl expect(legacyInstallId, 'legacyInstallId not captured by the prior test').toBeTruthy() await resetIpcInvocations(ctx.app, 'run-action') - expect( - await ctx.panel.click(byTestId(TID.dashboardTileKebab(legacyInstallId))), - 'kebab click on legacy desktop tile' - ).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('migrate')), { timeout: 5_000 }) - expect(await ctx.panel.click(byTestId(TID.contextMenuItem('migrate')))).toBe(true) + await pickFromBuildsTileMenu(ctx.panel, legacyInstallId, 'migrate') await waitForWebContents(ctx.app, 'comfyTitlePopup.html') const popup = titlePopupPage(ctx.app) diff --git a/e2e/process-ownership.test.ts b/e2e/process-ownership.test.ts index dc0e8ec20..0d8470eb9 100644 --- a/e2e/process-ownership.test.ts +++ b/e2e/process-ownership.test.ts @@ -256,8 +256,9 @@ test('cancelling from the busy check stops nothing and starts nothing @linux', a await crashDesktop(ctx!) const app = await start() await clickInstallTile(app.panel, INSTALL_NAME) - await app.panel.waitForVisible('[data-testid^="chooser-tile-view-logs-"]', { timeout: 15_000 }) - expect(await app.panel.click('[data-testid^="chooser-tile-view-logs-"]')).toBe(true) + const startingTile = '.chooser-tile:has([data-testid^="chooser-tile-progress-"])' + await app.panel.waitForVisible(startingTile, { timeout: 15_000 }) + expect(await app.panel.click(startingTile), 'the starting tile opens its logs').toBe(true) await app.panel.waitFor( async () => (await app.panel.allText('[data-testid="build-progress-steps"]')) diff --git a/e2e/real-comfy.test.ts b/e2e/real-comfy.test.ts index 9ff7d563b..d16348a98 100644 --- a/e2e/real-comfy.test.ts +++ b/e2e/real-comfy.test.ts @@ -8,6 +8,8 @@ import { test, expect } from '@playwright/test' import { keepOnlyComfyHostWindow } from './support/comfyHostWindow' import { launchApp, type AppContext } from './launchApp' import { + pickFromBuildsTileMenu, + uninstallFromBuildsTileMenu, clickInstallTile, clickNewInstallTile, expectChooserVisible, @@ -2300,14 +2302,7 @@ test('cleans up the copy install before the original delete test runs @sec-copy expect(_copyInstallId, 'no copy install id captured to clean up').toBeTruthy() await expectChooserVisible(ctx.panel) - await ctx.panel.waitForVisible(byTestId(TID.dashboardTileKebab(_copyInstallId)), { - timeout: 15_000 - }) - expect(await ctx.panel.click(byTestId(TID.dashboardTileKebab(_copyInstallId)))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('delete')), { timeout: 5_000 }) - expect(await ctx.panel.click(byTestId(TID.contextMenuItem('delete')))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.baseAlertAction), { timeout: 15_000 }) - expect(await ctx.panel.click(byTestId(TID.baseAlertAction))).toBe(true) + await uninstallFromBuildsTileMenu(ctx.panel, _copyInstallId) await expect .poll(() => existsSync(_copyInstallPath), { timeout: 240_000, intervals: [1_000, 2_000] }) @@ -2337,15 +2332,13 @@ test('dashboard kebab "Copy Installation" creates a real ~500MB copy @sec-copy @ test.setTimeout(600_000) await expectChooserVisible(ctx.panel) - await ctx.panel.waitForVisible(byTestId(TID.dashboardTileKebab(_updateInstallId)), { + await ctx.panel.waitForVisible(byTestId(TID.dashboardTile(_updateInstallId)), { timeout: 10_000 }) await resetIpcInvocations(ctx.app, 'run-action') - expect(await ctx.panel.click(byTestId(TID.dashboardTileKebab(_updateInstallId)))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('copy-install')), { timeout: 5_000 }) - expect(await ctx.panel.click(byTestId(TID.contextMenuItem('copy-install')))).toBe(true) + await pickFromBuildsTileMenu(ctx.panel, _updateInstallId, 'copy-install') await waitForWebContents(ctx.app, 'comfyTitlePopup.html') const popup = titlePopupPage(ctx.app) @@ -2398,7 +2391,7 @@ test('Manage drawer "Untrack" removes the install from the registry without touc await waitForWebContents(ctx.app, 'panel.html') await expectChooserVisible(ctx.panel) - await ctx.panel.waitForVisible(byTestId(TID.dashboardTileKebab(_kebabCopyInstallId)), { + await ctx.panel.waitForVisible(byTestId(TID.dashboardTile(_kebabCopyInstallId)), { timeout: 10_000 }) @@ -2893,14 +2886,7 @@ test('real delete wipes the fully-installed ~500MB tree off disk @sec-delete @re test.setTimeout(300_000) expect(_deleteInstallPath, 'install path not captured').toBeTruthy() - await ctx.panel.waitForVisible(byTestId(TID.dashboardTileKebab(_deleteInstallId)), { - timeout: 10_000 - }) - expect(await ctx.panel.click(byTestId(TID.dashboardTileKebab(_deleteInstallId)))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('delete')), { timeout: 5_000 }) - expect(await ctx.panel.click(byTestId(TID.contextMenuItem('delete')))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.baseAlertAction), { timeout: 15_000 }) - expect(await ctx.panel.click(byTestId(TID.baseAlertAction))).toBe(true) + await uninstallFromBuildsTileMenu(ctx.panel, _deleteInstallId) await expect .poll(() => existsSync(_deleteInstallPath), { timeout: 240_000, intervals: [1_000, 2_000] }) diff --git a/e2e/snapshot-share.test.ts b/e2e/snapshot-share.test.ts index 954ff63b9..34a683e0d 100644 --- a/e2e/snapshot-share.test.ts +++ b/e2e/snapshot-share.test.ts @@ -3,7 +3,7 @@ import path from 'node:path' import { mkdir, mkdtemp, readdir, readFile, rm } from 'node:fs/promises' import { test, expect } from '@playwright/test' import { launchApp, type AppContext } from './launchApp' -import { expectChooserVisible } from './support/chooserHelpers' +import { expectChooserVisible, pickFromBuildsTileMenu } from './support/chooserHelpers' import { titlePopupPage, waitForWebContents } from './support/cdpPages' import { evalWithRetry } from './support/evalRetry' import { byTestId, TID } from './support/testIds' @@ -129,9 +129,7 @@ test('dashboard kebab → Share exports the latest snapshot @windows @macos @lin await clearExportDir() await ctx.panel.waitForSelector(byTestId(TID.dashboardTile(INSTALL_ID)), { timeout: 10_000 }) - expect(await ctx.panel.click(byTestId(TID.dashboardTileKebab(INSTALL_ID)))).toBe(true) - await ctx.panel.waitForVisible(byTestId(TID.contextMenuItem('share')), { timeout: 5_000 }) - expect(await ctx.panel.click(byTestId(TID.contextMenuItem('share')))).toBe(true) + await pickFromBuildsTileMenu(ctx.panel, INSTALL_ID, 'share') expectLatestEnvelope(await readSharedEnvelope()) }) diff --git a/e2e/support/chooserHelpers.ts b/e2e/support/chooserHelpers.ts index 4ccf04b4f..a91f1727f 100644 --- a/e2e/support/chooserHelpers.ts +++ b/e2e/support/chooserHelpers.ts @@ -51,14 +51,53 @@ export async function clickInstallTile( const tile = [...document.querySelectorAll('.chooser-tile')].find((candidate) => candidate.querySelector('.chooser-tile-name')?.textContent?.toLowerCase().includes(needle), ) - const launch = tile?.querySelector('.chooser-tile-launch') - if (!launch) return false - launch.click() + if (!tile) return false + tile.click() return true })()`) expect(launched, `Install tile matching "${nameSubstring}" launched`).toBe(true) } +export function buildMenuItem(item: string): string { + return byTestId(`build-menu-${item}`) +} + +export async function openBuildsTileMenu( + panel: WebContentsPage, + installationId: string +): Promise { + await panel.waitForVisible(byTestId(TID.dashboardTile(installationId)), { timeout: 15_000 }) + expect( + await panel.click(byTestId(TID.dashboardTileKebab(installationId))), + `build menu ⋯ clicked on ${installationId}` + ).toBe(true) + await panel.waitForVisible(`[data-testid="build-menu"][data-build-id="${installationId}"]`, { + timeout: 5_000 + }) +} + +export async function pickFromBuildsTileMenu( + panel: WebContentsPage, + installationId: string, + item: string +): Promise { + await openBuildsTileMenu(panel, installationId) + await panel.waitForVisible(buildMenuItem(item), { timeout: 5_000 }) + expect(await panel.click(buildMenuItem(item)), `build menu ${item} picked`).toBe(true) +} + +export async function uninstallFromBuildsTileMenu( + panel: WebContentsPage, + installationId: string +): Promise { + await pickFromBuildsTileMenu(panel, installationId, 'delete') + await panel.waitForVisible(buildMenuItem('confirm-uninstall'), { timeout: 5_000 }) + expect( + await panel.click(buildMenuItem('confirm-uninstall')), + 'uninstall confirmed in the build menu' + ).toBe(true) +} + export async function openTitleMenu(titleBar: WebContentsPage): Promise { await titleBar.waitForVisible('.title-menu-button--icon[aria-haspopup="menu"]') const ok = await titleBar.click('.title-menu-button--icon[aria-haspopup="menu"]') diff --git a/locales/en.json b/locales/en.json index b2c6bcc64..756293c1b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -168,7 +168,10 @@ "nextApp": "Next app", "retry": "Try again", "buildInstalling": "Installing ComfyUI", - "buildStartingComfyUI": "Starting ComfyUI" + "buildStartingComfyUI": "Starting ComfyUI", + "buildClickToStart": "Click to start", + "buildClickToOpen": "Click to open", + "buildClickToViewLogs": "Click to view logs" }, "installType": { "standalone": "Standalone", diff --git a/locales/zh.json b/locales/zh.json index 86d411c03..29fc985ae 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -155,6 +155,9 @@ "buildDidntStart": "未能启动", "buildInstalling": "正在安装 ComfyUI", "buildStartingComfyUI": "正在启动 ComfyUI", + "buildClickToStart": "点击启动", + "buildClickToOpen": "点击打开", + "buildClickToViewLogs": "点击查看日志", "cloudHardware": "RTX 6000 Pro · 96 GB", "exampleWorkflows": "示例工作流", "seeAllApps": "查看全部应用", diff --git a/src/renderer/src/composables/useInstallContextMenu.ts b/src/renderer/src/composables/useInstallContextMenu.ts index 1514ffc0e..b3ed064d5 100644 --- a/src/renderer/src/composables/useInstallContextMenu.ts +++ b/src/renderer/src/composables/useInstallContextMenu.ts @@ -44,6 +44,12 @@ export interface ManageOpenOptions { autoAction?: string | null } +const promotingInstallationIds = ref>(new Set()) + +export function isPromotingToWorkspace(inst: Installation): boolean { + return promotingInstallationIds.value.has(inst.id) +} + export function useInstallContextMenu( opts: { onManage?: (inst: Installation, options?: ManageOpenOptions) => void @@ -68,8 +74,6 @@ export function useInstallContextMenu( y: 0, inst: null as Installation | null }) - const promotingInstallationIds = ref>(new Set()) - function setPromotingToWorkspace(installationId: string, promoting: boolean): void { const next = new Set(promotingInstallationIds.value) if (promoting) next.add(installationId) @@ -77,10 +81,6 @@ export function useInstallContextMenu( promotingInstallationIds.value = next } - function isPromotingToWorkspace(inst: Installation): boolean { - return promotingInstallationIds.value.has(inst.id) - } - function isLocalLikeInstall(inst: Installation): boolean { return inst.sourceCategory !== 'cloud' } diff --git a/src/renderer/src/panel/HomeView.test.ts b/src/renderer/src/panel/HomeView.test.ts index 493a8eca0..d7d02da14 100644 --- a/src/renderer/src/panel/HomeView.test.ts +++ b/src/renderer/src/panel/HomeView.test.ts @@ -433,12 +433,54 @@ describe('Home builds', () => { await flushPromises() expect(wrapper.findAll('[data-testid="home-build"]').map((card) => card.text())).toEqual([ - 'Update availableMy Local 1Standalone', + 'ReadyMy Local 1Standalone · Update', 'RunningVideo LabStandalone', 'Always onComfy CloudRTX 6000 Pro · 96 GB' ]) }) + it('keeps Running on top of a running build with an update, and names the update at the bottom', async () => { + getInstallations.mockResolvedValue([NEWEST]) + const wrapper = await openHome() + useSessionStore().runningInstances.set(NEWEST.id, { + installationId: NEWEST.id, + installationName: NEWEST.name, + mode: 'window' + }) + await flushPromises() + + const card = wrapper.get('[data-testid="home-build"]') + expect(card.get('[data-testid="home-build-status"]').text()).toBe('Running') + expect(card.get('[data-testid="home-build-detail"]').text()).toBe('Standalone · Update') + expect(card.get('[data-testid="home-build-open"]').attributes('aria-label')).toBe( + 'My Local 1, Running' + ) + }) + + it('keeps the update note short so the bottom line fits a narrow card', async () => { + getInstallations.mockResolvedValue([ + { + ...NEWEST, + version: 'v0.3.68', + statusTag: { style: 'update', label: 'Update available: v0.45.4' } + } + ]) + const wrapper = await openHome() + + expect(wrapper.get('[data-testid="home-build-detail"]').text()).toBe('v0.3.68 · Update') + }) + + it('starts a build with an update from its card, saying Ready on top', async () => { + getInstallations.mockResolvedValue([NEWEST]) + const wrapper = await openHome() + + const card = wrapper.get('[data-testid="home-build"]') + expect(card.get('[data-testid="home-build-status"]').text()).toBe('Ready') + await card.get('[data-testid="home-build-open"]').trigger('click') + + expect(wrapper.emitted('pick')?.[0]?.[0]).toMatchObject({ id: NEWEST.id }) + }) + it('keeps only the latest build and Cloud when the window is narrow', async () => { getInstallations.mockResolvedValue([OLDEST, CLOUD, RUNNING, NEWEST]) const wrapper = await openHome() @@ -459,13 +501,11 @@ describe('Home builds', () => { expect(kept).toEqual(['My Local 1', 'Video Lab']) }) - it('shows a stopped local build as ready, with its ComfyUI version and no folder path', async () => { + it('shows a stopped local build as ready, with its version and no folder path', async () => { getInstallations.mockResolvedValue([OLDEST]) const wrapper = await openHome() - expect(wrapper.get('[data-testid="home-build"]').text()).toBe( - 'ReadyFlux SandboxComfyUI v0.42.4' - ) + expect(wrapper.get('[data-testid="home-build"]').text()).toBe('ReadyFlux Sandboxv0.42.4') }) it('shows the address of a remote ComfyUI instead of hardware', async () => { diff --git a/src/renderer/src/panel/HomeView.vue b/src/renderer/src/panel/HomeView.vue index 4ffb25af8..b228d957b 100644 --- a/src/renderer/src/panel/HomeView.vue +++ b/src/renderer/src/panel/HomeView.vue @@ -17,6 +17,7 @@ import { useInstallingBuilds, useViewBuildLogs } from '../composables/useBuildProgress' +import { isPromotingToWorkspace } from '../composables/useInstallContextMenu' import { useProgressStore } from '../stores/progressStore' import { PAGE_SPOTLIGHT_CLASS } from '../lib/pageSpotlight' import { useDashboardScopeStore } from '../stores/dashboardScopeStore' @@ -73,7 +74,9 @@ const narrowBuildIds = computed(() => { const openableBuilds = computed(() => workspaceBuilds.value.filter( (build) => - buildProgressOf(progressStore, build.id) === null && !isBuildOpenBlocked(buildStatus(build)) + buildProgressOf(progressStore, build.id) === null && + !isBuildOpenBlocked(buildStatus(build)) && + !isPromotingToWorkspace(build) ) ) const mostRecentBuild = computed( diff --git a/src/renderer/src/panel/autoStartNarrowLayout.test.ts b/src/renderer/src/panel/autoStartNarrowLayout.test.ts index fbfab8c6c..713759462 100644 --- a/src/renderer/src/panel/autoStartNarrowLayout.test.ts +++ b/src/renderer/src/panel/autoStartNarrowLayout.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest' -import { page as browserPage } from 'vitest/browser' +import { page as browserPage, userEvent } from 'vitest/browser' import { flushPromises, mount, type VueWrapper } from '@vue/test-utils' import { createPinia, setActivePinia } from 'pinia' @@ -7,6 +7,8 @@ import '../assets/main.css' import HomeView from './HomeView.vue' import ChooserFamilyGrid from '../views/chooser/ChooserFamilyGrid.vue' import { TID } from '../../../shared/testIds' +import { useProgressStore, type Operation } from '../stores/progressStore' +import { useSessionStore } from '../stores/sessionStore' import type { Installation } from '../types/ipc' const SMALLEST_WINDOW_WIDTH = 800 @@ -20,7 +22,9 @@ const WIDE_WINDOW_WIDTH = 1280 const BUILDS_GRID_WIDTH_IN_WIDE_WINDOW = WIDE_WINDOW_WIDTH - FRAME_AND_EXPANDED_SIDEBAR_WIDTH - PAGE_SIDE_PADDING const HOME_CARD_SIDE_PADDING_AND_BORDER = 18 + 1 -const BUILDS_TILE_RIGHT_PADDING = 12 +const BUILDS_TILE_MENU_INSET = 10 +const BUILDS_GRID_WIDTH_IN_SMALLEST_WINDOW = + SMALLEST_WINDOW_WIDTH - FRAME_AND_EXPANDED_SIDEBAR_WIDTH - PAGE_SIDE_PADDING const READABLE_NAME_WIDTH = 40 function build(id: string, name: string, lastLaunchedAt: number): Installation { @@ -31,6 +35,12 @@ const STUDIO = build('studio', 'Flux Sandbox for the long weekend render', 400) const PORTRAITS = build('portraits', 'Portrait retouching with the new upscaler', 300) let page: HTMLElement +const mounted: VueWrapper[] = [] + +function track(wrapper: VueWrapper): VueWrapper { + mounted.push(wrapper) + return wrapper +} function boxOf(element: Element): DOMRect { return element.getBoundingClientRect() @@ -67,16 +77,44 @@ beforeEach(() => { document.body.append(page) }) -afterEach(() => page.remove()) +afterEach(() => { + for (const wrapper of mounted.splice(0)) wrapper.unmount() + page.remove() +}) function fullyShown(element: Element): boolean { return element.scrollWidth <= element.clientWidth && element.clientWidth > 0 } +it('keeps the update note visible when build metadata truncates on Home and Builds', async () => { + const studio: Installation = { + ...STUDIO, + sourceLabel: 'Standalone installation with a long name', + version: `v0.3.68+preview.${'weekend-render.'.repeat(4)}7`, + statusTag: { style: 'update', label: 'Update to v0.3.70' } + } + vi.mocked(window.api.getInstallations).mockResolvedValue([studio, PORTRAITS]) + page.style.cssText = `position: absolute; left: 0; top: 0; width: ${LARGE_WINDOW_WIDTH - FRAME_AND_EXPANDED_SIDEBAR_WIDTH}px` + const home = track(mount(HomeView, { attachTo: page })) + const builds = track( + mount(ChooserFamilyGrid, { attachTo: page, props: { installations: [studio, PORTRAITS] } }) + ) + await flushPromises() + + for (const wrapper of [home, builds]) { + const note = onlyIn(wrapper, '[data-testid="build-update-note"]') + const line = note.parentElement! + expect(note.textContent?.trim()).toBe('· Update') + expect(fullyShown(line.firstElementChild!)).toBe(false) + expect(fullyShown(note)).toBe(true) + expect(boxOf(note).right).toBeLessThanOrEqual(boxOf(line).right + 0.5) + } +}) + describe('Auto start on Home build cards in the smallest window with the sidebar open', () => { it('shows the whole status and leaves each name the width the card has after its picture', async () => { page.style.cssText = `position: absolute; left: 0; top: 0; width: ${HOME_WIDTH_IN_SMALLEST_WINDOW}px` - const wrapper = mount(HomeView, { attachTo: page }) + const wrapper = track(mount(HomeView, { attachTo: page })) await flushPromises() const studioStatus = onlyIn( @@ -105,10 +143,12 @@ describe('Auto start on Home build cards in the smallest window with the sidebar async function mountBuildsGrid(width: number): Promise { page.style.cssText = `position: absolute; left: 0; top: 0; width: ${width}px` - const wrapper = mount(ChooserFamilyGrid, { - attachTo: page, - props: { installations: [STUDIO, PORTRAITS], isStoppedActionGated: () => false } - }) + const wrapper = track( + mount(ChooserFamilyGrid, { + attachTo: page, + props: { installations: [STUDIO, PORTRAITS] } + }) + ) await flushPromises() return wrapper } @@ -119,7 +159,7 @@ function buildsTileStatus(wrapper: VueWrapper): Element { } describe('Auto start on Builds page tiles', () => { - it('in a 1024 px window with the sidebar open, keeps the status on one line, the name readable and every button inside the tile', async () => { + it('in a 1024 px window with the sidebar open, keeps the status on one line, the name readable and the ⋯ button inside the tile', async () => { const wrapper = await mountBuildsGrid(BUILDS_GRID_WIDTH_IN_LARGE_WINDOW) const status = buildsTileStatus(wrapper) @@ -136,11 +176,18 @@ describe('Auto start on Builds page tiles', () => { heights.add(tileBox.height) expect(boxOf(name).width, `${id} name width`).toBeGreaterThanOrEqual(READABLE_NAME_WIDTH) - expect(boxOf(kebab).right, `${id} menu button is not cut off`).toBeLessThanOrEqual( - tileBox.right - BUILDS_TILE_RIGHT_PADDING + 0.5 + const kebabBox = boxOf(kebab) + expect(kebabBox.right, `${id} menu button is not cut off`).toBeLessThanOrEqual( + tileBox.right - BUILDS_TILE_MENU_INSET + 0.5 ) + expect(kebabBox.top + kebabBox.height / 2).toBeCloseTo(tileBox.top + tileBox.height / 2, 0) + expect(tile.scrollWidth, `${id} tile does not overflow`).toBeLessThanOrEqual(tile.clientWidth) } expect([...heights]).toEqual([100]) + const [studio, portraits] = [STUDIO, PORTRAITS].map(({ id }) => + boxOf(onlyIn(wrapper, `[data-testid="${TID.dashboardTile(id)}"]`)) + ) + expect(portraits!.top, 'two tiles share a row').toBe(studio!.top) }) it('in a 1280 px window with the sidebar open, shows the whole status', async () => { @@ -151,3 +198,165 @@ describe('Auto start on Builds page tiles', () => { expect(fullyShown(status), 'status is not cut off').toBe(true) }) }) + +type TileState = + | 'ready' + | 'update' + | 'running' + | 'running with an update' + | 'starting' + | 'installing' + | 'uninstalling' + +const TILE_OPERATIONS: Partial>> = { + starting: { opKind: 'launch', flatPercent: 5 }, + installing: { opKind: 'install', flatPercent: 40 }, + uninstalling: { opKind: 'destructive', flatPercent: 18 } +} + +async function buildsGridWithStudioIn(state: TileState, width: number): Promise { + const withUpdate = state === 'update' || state === 'running with an update' + const studio: Installation = withUpdate + ? { ...STUDIO, version: 'v0.3.68', statusTag: { style: 'update', label: 'Update to v0.3.70' } } + : STUDIO + page.style.cssText = `position: absolute; left: 0; top: 0; width: ${width}px` + const wrapper = track( + mount(ChooserFamilyGrid, { + attachTo: page, + props: { installations: [studio, PORTRAITS] } + }) + ) + await flushPromises() + const operation = TILE_OPERATIONS[state] + if (operation) { + useProgressStore().operations.set(STUDIO.id, { + finished: false, + cancelRequested: false, + _globalFloor: 0, + ...operation + } as Operation) + } + if (state.startsWith('running')) { + useSessionStore().runningInstances.set(STUDIO.id, { installationId: STUDIO.id } as never) + } + await flushPromises() + return wrapper +} + +describe('Builds page grid', () => { + it('stacks the tiles one per row in the smallest window, each the full grid width', async () => { + const wrapper = await buildsGridWithStudioIn('ready', BUILDS_GRID_WIDTH_IN_SMALLEST_WINDOW) + const grid = onlyIn(wrapper, '.chooser-family-grid') + const [studio, portraits] = [STUDIO, PORTRAITS].map(({ id }) => + boxOf(onlyIn(wrapper, `[data-testid="${TID.dashboardTile(id)}"]`)) + ) + + expect(getComputedStyle(grid).gridTemplateColumns.split(' ')).toHaveLength(1) + expect(studio!.width).toBe(BUILDS_GRID_WIDTH_IN_SMALLEST_WINDOW) + expect(portraits!.left).toBe(studio!.left) + expect(portraits!.top).toBeGreaterThan(studio!.bottom) + }) + + it.each( + ( + [ + 'ready', + 'update', + 'running', + 'running with an update', + 'starting', + 'installing', + 'uninstalling' + ] as const + ).flatMap((state) => [ + [state, BUILDS_GRID_WIDTH_IN_SMALLEST_WINDOW] as const, + [state, BUILDS_GRID_WIDTH_IN_LARGE_WINDOW] as const + ]) + )('keeps every tile 100 px high when a build is %s, at %ipx', async (state, width) => { + const wrapper = await buildsGridWithStudioIn(state, width) + for (const { id } of [STUDIO, PORTRAITS]) { + const tile = onlyIn(wrapper, `[data-testid="${TID.dashboardTile(id)}"]`) + expect(boxOf(tile).height, `${id} tile height`).toBe(100) + expect(tile.scrollWidth, `${id} tile does not overflow`).toBeLessThanOrEqual(tile.clientWidth) + } + const tile = onlyIn(wrapper, `[data-testid="${TID.dashboardTile(STUDIO.id)}"]`) + expect(tile.querySelector('.chooser-tile-launch')).toBeNull() + expect(tile.querySelectorAll('button:not(.chooser-tile-kebab)')).toHaveLength( + state === 'uninstalling' ? 0 : 1 + ) + if (state === 'running with an update') { + expect(tile.querySelector('.chooser-tile-body .truncate')!.textContent?.trim()).toBe( + 'Running' + ) + expect(tile.querySelector('.chooser-tile-meta-line')!.textContent?.trim()).toBe( + 'Standalone · v0.3.68 · Update' + ) + } + if (state === 'starting') { + expect(tile.querySelector('.chooser-tile-body .truncate')!.textContent?.trim()).toBe( + 'Starting ComfyUI · 5%' + ) + } + if (state === 'installing') { + expect(tile.querySelector('.chooser-tile-body .truncate')!.textContent?.trim()).toBe( + 'Installing ComfyUI · 40%' + ) + } + }) + + it('lets the pointer through the whole tile to its click hint, and keeps the hint shut while the menu is open', async () => { + const wrapper = await buildsGridWithStudioIn('ready', BUILDS_GRID_WIDTH_IN_LARGE_WINDOW) + const tile = onlyIn(wrapper, `[data-testid="${TID.dashboardTile(STUDIO.id)}"]`) + const area = tile.querySelector('[data-testid="chooser-tile-open"]')! + const tileBox = boxOf(tile) + expect(boxOf(area).width).toBeCloseTo(tileBox.width - 2, 0) + expect(boxOf(area).height).toBeCloseTo(tileBox.height - 2, 0) + for (const element of [ + tile.querySelector('.chooser-tile-name')!, + tile.querySelector('.chooser-tile-icon')! + ]) { + const box = boxOf(element) + expect(document.elementFromPoint(box.left + 2, box.top + box.height / 2)).toBe(area) + } + + for (const element of [ + tile.querySelector('.chooser-tile-name')!, + tile.querySelector('.chooser-tile-icon')! + ]) { + await userEvent.hover(element, { force: true }) + await vi.waitFor( + () => + expect(document.querySelector('.tooltip-bubble')?.textContent).toContain( + 'Click to start' + ), + { timeout: 3000 } + ) + await userEvent.unhover(element, { force: true }) + await vi.waitFor(() => expect(document.querySelector('.tooltip-bubble')).toBeNull(), { + timeout: 3000 + }) + } + + await userEvent.click(tile.querySelector('.chooser-tile-kebab')!) + await vi.waitFor(() => + expect(document.querySelector('[data-testid="build-menu"]')).not.toBeNull() + ) + await userEvent.hover(tile.querySelector('.chooser-tile-name')!, { force: true }) + await new Promise((resolve) => setTimeout(resolve, 800)) + expect(document.querySelector('.tooltip-bubble')).toBeNull() + }) + + it('closes the build menu on a second press of the ⋯ button', async () => { + const wrapper = await buildsGridWithStudioIn('ready', BUILDS_GRID_WIDTH_IN_LARGE_WINDOW) + const kebab = onlyIn( + wrapper, + `[data-testid="${TID.dashboardTile(STUDIO.id)}"] .chooser-tile-kebab` + ) as HTMLElement + await userEvent.click(kebab) + await vi.waitFor(() => + expect(document.querySelector('[data-testid="build-menu"]')).not.toBeNull() + ) + await userEvent.click(kebab) + await vi.waitFor(() => expect(document.querySelector('[data-testid="build-menu"]')).toBeNull()) + }) +}) diff --git a/src/renderer/src/panel/home/BuildMenu.test.ts b/src/renderer/src/panel/home/BuildMenu.test.ts index 7b869097d..54fe2d71e 100644 --- a/src/renderer/src/panel/home/BuildMenu.test.ts +++ b/src/renderer/src/panel/home/BuildMenu.test.ts @@ -5,7 +5,10 @@ import { createPinia, setActivePinia } from 'pinia' import AppSidebar from '../AppSidebar.vue' import HomeBuildCard from './HomeBuildCard.vue' +import ChooserInstallTile from '../../views/chooser/ChooserInstallTile.vue' +import Tooltip from '../../components/ui/Tooltip.vue' import { provideBuildMenuHost, type BuildMenuHost } from './useBuildMenu' +import { homeBuildStatus } from './homeBuild' import { provideBuildLogs } from '../../composables/useBuildProgress' import { useAuthStore } from '../../stores/authStore' import { useInstallationStore } from '../../stores/installationStore' @@ -64,7 +67,8 @@ beforeEach(() => { onSettingsChanged: vi.fn(() => () => {}), comfybuilder: { getAuthStatus: vi.fn().mockResolvedValue({ signedIn: false }), - onAuthChanged: vi.fn(() => () => {}) + onAuthChanged: vi.fn(() => () => {}), + promoteLocalInstance: vi.fn() } } host = { launch: vi.fn(), openDetails: vi.fn(), showProgress: vi.fn() } @@ -101,7 +105,13 @@ function putIn(state: State): void { async function mountTile(state: State): Promise { const wrapper = mount( - withHost(() => h(HomeBuildCard, { build: BUILD, status: 'ready', tone: 'ember' })), + withHost(() => + h(HomeBuildCard, { + build: BUILD, + status: homeBuildStatus(BUILD, useSessionStore()), + tone: 'ember' + }) + ), { attachTo: document.body } ) mounted.push(wrapper) @@ -110,6 +120,19 @@ async function mountTile(state: State): Promise { return wrapper } +async function mountBuildsTile(state: State): Promise { + const wrapper = mount( + withHost(() => h(ChooserInstallTile, { installation: BUILD })), + { attachTo: document.body } + ) + mounted.push(wrapper) + putIn(state) + await flushPromises() + return wrapper +} + +const BUILDS_TILE = `[data-testid="dashboard-tile-${BUILD.id}"]` + async function mountSidebar(state: State): Promise { const wrapper = mount( withHost(() => h(AppSidebar, { activePage: 'home' })), @@ -185,9 +208,20 @@ describe('Build menu', () => { const sidebar = await mountSidebar(state) await rightClick(sidebar.get(`[data-testid="app-sidebar-build-${BUILD.id}"]`).element) const fromSidebar = await shownMenu() + await closeMenu() + + const buildsTile = await mountBuildsTile(state) + await buildsTile.get('.chooser-tile-kebab').trigger('click') + const fromBuildsMore = await shownMenu() + await closeMenu() + + await rightClick(buildsTile.get(BUILDS_TILE).element) + const fromBuildsTile = await shownMenu() expect(fromTile).toEqual(fromMore) expect(fromSidebar).toEqual(fromMore) + expect(fromBuildsMore).toEqual(fromMore) + expect(fromBuildsTile).toEqual(fromMore) } ) @@ -210,6 +244,52 @@ describe('Build menu', () => { expect(await shownMenu()).not.toContain('auto-start') }) + it('shows the update beside the version and keeps the whole tile as the primary button', async () => { + const build: Installation = { + ...BUILD, + statusTag: { label: 'Update available', style: 'update' } + } + const wrapper = mount( + withHost(() => h(HomeBuildCard, { build, status: 'update', tone: 'ember' })), + { attachTo: document.body } + ) + mounted.push(wrapper) + await flushPromises() + + expect(wrapper.get('[data-testid="home-build-detail"]').text()).toBe('v0.42.4 · Update') + const buttons = [...wrapper.element.querySelectorAll('button')].map((b) => + b.getAttribute('data-testid') + ) + expect(buttons).toEqual(['home-build-open', 'home-build-more']) + }) + + it('shows upload progress on Home and holds the tile and menu launch actions until it finishes', async () => { + const signedIn = { signedIn: true, workspaceId: 'ws-1' } + vi.mocked(window.api.comfybuilder.getAuthStatus).mockResolvedValue(signedIn) + useAuthStore().status = signedIn + const upload = Promise.withResolvers<{ ok: true }>() + vi.mocked(window.api.comfybuilder.promoteLocalInstance).mockReturnValue(upload.promise) + const tile = await mountTile('ready') + const more = tile.get('[data-testid="home-build-more"]') + await more.trigger('click') + expect(await shownMenu()).toContain('promote-to-workspace') + document.querySelector('[data-testid="build-menu-promote-to-workspace"]')!.click() + + try { + await flushPromises() + expect(tile.get('[data-testid="home-build-status"]').text()).toBe('Creating...') + expect(tile.find('[data-testid="home-build-open"]').exists()).toBe(false) + await more.trigger('click') + expect(await shownMenu()).not.toContain('launch') + } finally { + upload.resolve({ ok: true }) + await flushPromises() + } + + expect(tile.get('[data-testid="home-build-status"]').text()).toBe('Ready') + expect(tile.find('[data-testid="home-build-open"]').exists()).toBe(true) + }) + it('offers Upload build after Restore snapshot when signed in to a workspace, from the ⋯ and a right-click', async () => { const signedIn = { signedIn: true, workspaceId: 'ws-1' } vi.mocked(window.api.comfybuilder.getAuthStatus).mockResolvedValue(signedIn) @@ -356,6 +436,89 @@ describe('Build menu', () => { expect(host.launch).toHaveBeenCalledExactlyOnceWith(BUILD) }) + it.each([ + ['ready', 'pick'], + ['running', 'pick'], + ['starting', 'logs'], + ['installing', 'logs'], + ['uninstalling', 'nothing'] + ] as const)( + 'clicking a %s build card does the same on Home and on the Builds page: %s', + async (state, outcome) => { + const home = await mountTile(state) + await home.get(`[data-build-id="${BUILD.id}"]`).trigger('click') + const homeCard = home.findComponent(HomeBuildCard) + expect(homeCard.emitted('open')?.length ?? 0).toBe(outcome === 'pick' ? 1 : 0) + expect(viewLogs).toHaveBeenCalledTimes(outcome === 'logs' ? 1 : 0) + + const builds = await mountBuildsTile(state) + await builds.get(BUILDS_TILE).trigger('click') + const buildsTile = builds.findComponent(ChooserInstallTile) + expect(buildsTile.emitted('pick')?.length ?? 0).toBe(outcome === 'pick' ? 1 : 0) + expect(viewLogs).toHaveBeenCalledTimes(outcome === 'logs' ? 2 : 0) + expect(buildsTile.emitted('open-details')).toBeUndefined() + expect(host.launch).not.toHaveBeenCalled() + } + ) + + it.each([ + ['ready', 'Click to start'], + ['running', 'Click to open'], + ['starting', 'Click to view logs'], + ['installing', 'Click to view logs'], + ['uninstalling', ''] + ] as const)( + 'hints what a click does on a %s build card, on Home and on the Builds page', + async (state, hint) => { + const home = await mountTile(state) + const homeHint = home.findAllComponents(Tooltip)[0] + if (hint) expect(homeHint?.props('text')).toBe(hint) + else expect(home.find('[data-testid="home-build-open"]').exists()).toBe(false) + + const builds = await mountBuildsTile(state) + const open = builds.find('[data-testid="chooser-tile-open"]') + expect(open.exists()).toBe(Boolean(hint)) + if (hint) expect(builds.findAllComponents(Tooltip)[0]?.props('text')).toBe(hint) + } + ) + + it('hints Click to open on an idle remote build, on Home and on the Builds page', async () => { + const remote: Installation = { ...BUILD, sourceCategory: 'remote' } + const home = mount( + withHost(() => h(HomeBuildCard, { build: remote, status: 'ready', tone: 'ember' })), + { attachTo: document.body } + ) + mounted.push(home) + const builds = mount( + withHost(() => h(ChooserInstallTile, { installation: remote })), + { attachTo: document.body } + ) + mounted.push(builds) + await flushPromises() + + expect(home.findAllComponents(Tooltip)[0]?.props('text')).toBe('Click to open') + expect(builds.findAllComponents(Tooltip)[0]?.props('text')).toBe('Click to open') + }) + + it('names a clipped build in full in the Builds page click hint, and only the action when it fits', async () => { + const builds = await mountBuildsTile('ready') + const label = builds.get('.chooser-tile-name .truncated-text').element + const hint = () => builds.findAllComponents(Tooltip)[0]!.props('text') + + Object.defineProperty(label, 'clientWidth', { configurable: true, value: 120 }) + Object.defineProperty(label, 'scrollWidth', { configurable: true, value: 120 }) + await builds.get(BUILDS_TILE).trigger('pointerenter') + expect(hint()).toBe('Click to start') + + Object.defineProperty(label, 'scrollWidth', { configurable: true, value: 300 }) + await builds.get(BUILDS_TILE).trigger('pointerenter') + expect(hint()).toBe(`${BUILD.name} · Click to start`) + + Object.defineProperty(label, 'scrollWidth', { configurable: true, value: 120 }) + await builds.get('[data-testid="chooser-tile-open"]').trigger('focus') + expect(hint()).toBe('Click to start') + }) + it('opens no menu on a right-click on a page in the sidebar', async () => { const sidebar = await mountSidebar('ready') diff --git a/src/renderer/src/panel/home/HomeBuildCard.vue b/src/renderer/src/panel/home/HomeBuildCard.vue index f9293634b..7cb9e0507 100644 --- a/src/renderer/src/panel/home/HomeBuildCard.vue +++ b/src/renderer/src/panel/home/HomeBuildCard.vue @@ -7,16 +7,19 @@ import { usePointMenu } from '@comfyorg/design-system/lib/menu/usePointMenu' import BuildDeviceArt from './BuildDeviceArt.vue' import BuildMenu, { type BuildMenuAnchor } from './BuildMenu.vue' import BuildProgressBar from './BuildProgressBar.vue' +import Tooltip from '../../components/ui/Tooltip.vue' import { HOME_BUILD_TONES, isBuildOpenBlocked, homeBuildDetail, buildDeviceKind, + isCloudBuild, isComfyCloud, type HomeBuildStatus, type HomeBuildTone } from './homeBuild' import { launchFailed, useBuildProgress } from '../../composables/useBuildProgress' +import { isPromotingToWorkspace } from '../../composables/useInstallContextMenu' import { useProgressStore } from '../../stores/progressStore' import type { Installation } from '../../types/ipc' @@ -40,7 +43,10 @@ const progressStore = useProgressStore() const busy = computed(() => install.progress.value !== null) const starting = computed(() => install.progress.value?.kind === 'launch') const uninstalling = computed(() => install.progress.value?.kind === 'uninstall') -const canOpen = computed(() => !uninstalling.value && !isBuildOpenBlocked(status)) +const promoting = computed(() => isPromotingToWorkspace(build)) +const canOpen = computed( + () => !uninstalling.value && !promoting.value && !isBuildOpenBlocked(status) +) const busyTestId = computed(() => { if (uninstalling.value) return 'home-build-uninstalling' return starting.value ? 'home-build-starting' : 'home-build-installing' @@ -59,6 +65,7 @@ const statusLabel = computed(() => { const percent = install.progress.value?.percent return percent == null ? phase : t('installProgress.detail', { phase, percent }) } + if (promoting.value) return t('devPlatform.workspace.promoting') if (status === 'stopping') return t('chooser.statusStopping') if (status === 'updating') return t('instancePicker.progressUpdating') if (broken.value) return broken.value @@ -67,11 +74,11 @@ const statusLabel = computed(() => { return t('home.buildRunning') case 'starting': return t('home.buildStarting') - case 'update': - return build.statusTag?.label || t('chooser.updatePill') case 'always-on': return t('home.buildAlwaysOn') + case 'update': case 'ready': + if (isCloudBuild(build)) return t('home.buildAlwaysOn') return autoStart ? t('home.autoStartOn') : t('home.buildReady') default: return status satisfies never @@ -80,8 +87,29 @@ const statusLabel = computed(() => { const detail = computed(() => isComfyCloud(build) ? t('home.cloudHardware') : homeBuildDetail(build) ) -const isLive = computed(() => !busy.value && (status === 'running' || status === 'always-on')) +const isLive = computed( + () => + status === 'running' || status === 'always-on' || (status === 'update' && isCloudBuild(build)) +) +const resting = computed(() => status === 'ready' || status === 'update') +const updateNote = computed(() => + !uninstalling.value && status !== 'updating' && build.statusTag?.style === 'update' + ? t('chooser.updatePill') + : '' +) const subtitle = computed(() => (uninstalling.value ? install.detail.value : detail.value)) +const openHint = computed(() => { + if (!canOpen.value) return '' + if ( + busy.value || + (build.statusTag?.style !== 'danger' && launchFailed(progressStore, build.id)) + ) { + return t('home.buildClickToViewLogs') + } + if (broken.value || isLive.value || status === 'starting' || build.sourceCategory === 'remote') + return t('home.buildClickToOpen') + return t('home.buildClickToStart') +}) const testId = computed(() => (busy.value ? busyTestId.value : 'home-build')) function onClick(): void { @@ -125,15 +153,24 @@ function openContextMenu(event: MouseEvent): void { @click="onClick" @contextmenu.prevent="openContextMenu" > -