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
3 changes: 0 additions & 3 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,6 @@
"currentVersion": "Current Version",
"variant": "Hardware",
"comfyVersion": "Version",
"starterTemplate": "Starter template",
"starterTemplateNone": "None",
"starterTemplateNoneDesc": "Start with a blank canvas",
"templatePickerTitle": "Choose a starter workflow",
"templateModelsDownloaded": "Downloaded",
"templateTabsAria": "Filter starter workflows by type",
Expand Down
3 changes: 0 additions & 3 deletions locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,6 @@
"currentVersion": "当前版本",
"variant": "硬件",
"comfyVersion": "ComfyUI 版本",
"starterTemplate": "入门模板",
"starterTemplateNone": "无",
"starterTemplateNoneDesc": "从空白画布开始",
"templatePickerTitle": "选择入门工作流",
"templateModelsDownloaded": "已下载",
"templateTabsAria": "按类型筛选入门工作流",
Expand Down
21 changes: 2 additions & 19 deletions src/main/host/attach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ import {
deactivateFirebaseAuthReporter
} from '../lib/firebaseAuthIdentity'
import { convertLevelToZoomPercent } from '../lib/zoom'
import {
clearPendingTemplateOpen,
installationEvents,
type InstallationRecord
} from '../installations'
import { buildTemplateDeeplink } from '../sources/standalone/curatedTemplates'
import { abortTemplateDownload } from '../sources/standalone/templateDownloadTask'
import { installationEvents, type InstallationRecord } from '../installations'
import { abortModelStaging } from '../sources/comfybuilder/modelStagingTask'
import {
dropInstallationIndex,
Expand Down Expand Up @@ -423,17 +417,7 @@ export function attachInstall(entry: ComfyWindowEntry, opts: AttachInstallOpts):

attachSessionDownloadHandler(comfyContents.session)

let urlToLoad = comfyUrl
const pendingTemplate =
typeof installation.pendingTemplateOpen === 'string' ? installation.pendingTemplateOpen : null
if (isLocal && pendingTemplate) {
urlToLoad = buildTemplateDeeplink(comfyUrl, pendingTemplate)
void clearPendingTemplateOpen(installationId).catch((err) => {
console.warn(`[templates] Failed to clear pendingTemplateOpen for ${installationId}:`, err)
})
}

comfyContents.loadURL(urlToLoad)
comfyContents.loadURL(comfyUrl)

entry._installCleanup = (): void => {
if (entry._installCleanup === null) return
Expand All @@ -457,7 +441,6 @@ export function attachInstall(entry: ComfyWindowEntry, opts: AttachInstallOpts):
inFlight.abort()
_operationAborts.delete(id)
}
abortTemplateDownload(id)
abortModelStaging(id)
const relaunch = fx.relaunchStates.get(id) as
{ navBlocker: (...args: unknown[]) => void } | undefined
Expand Down
24 changes: 1 addition & 23 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
import {
registerTitlePopupIpc,
triggerPickerSnapshotBroadcast,
openDownloadsTrayForInstall,
type InstancePickerInstall
} from './popups/titlePopup'
import { registerPickerSettingsIpc } from './popups/pickerSettingsHandlers'
Expand Down Expand Up @@ -74,11 +73,7 @@ import {
} from './lib/comfyDownloadManager'
import { stopAgentPrefetches } from './lib/agentRequirementsLaunch'
import { prefetchEnrolledAgents } from './lib/agentPrefetch'
import {
hasActiveTemplateDownloads,
getTemplateDownloadState
} from './sources/standalone/templateDownloadTask'
import { isTerminal as isTemplateDownloadTerminal } from './sources/standalone/templateDownloadCore'
import { hasActiveTemplateDownloads } from './sources/standalone/templateDownloadTask'
import { registerAssetDownloadHandlers } from './lib/ipc/registerAssetDownloadHandlers'
import { registerDownloadHandlers } from './lib/ipc/registerDownloadHandlers'
import { registerTemplateInputAssetHandlers } from './lib/ipc/registerTemplateInputAssetHandlers'
Expand Down Expand Up @@ -518,7 +513,6 @@ function onLaunch({
if (proc) {
proc.on('exit', () => {})
}
scheduleTemplateTrayAutoOpen(installationId)
return
}

Expand All @@ -534,7 +528,6 @@ function onLaunch({
if (proc) {
proc.on('exit', () => {})
}
scheduleTemplateTrayAutoOpen(installationId)
return
}
}
Expand Down Expand Up @@ -573,21 +566,6 @@ function onLaunch({
if (proc) {
proc.on('exit', () => {})
}

scheduleTemplateTrayAutoOpen(installationId)
}

const TEMPLATE_TRAY_AUTO_OPEN_MS = 2500

function scheduleTemplateTrayAutoOpen(installationId: string): void {
const state = getTemplateDownloadState(installationId)
if (!state || isTemplateDownloadTerminal(state.status)) return
setTimeout(() => {
const cur = getTemplateDownloadState(installationId)
if (cur && !isTemplateDownloadTerminal(cur.status)) {
openDownloadsTrayForInstall(installationId)
}
}, TEMPLATE_TRAY_AUTO_OPEN_MS)
}

ipcMain.handle('quit-app', () => quitApp())
Expand Down
53 changes: 24 additions & 29 deletions src/main/installations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,40 +782,35 @@ describe('installations.enforceCloudName', () => {
})
})

describe('installations.clearPendingTemplateOpen', () => {
it('clears the one-shot flag once, then is a no-op on the cleared record', async () => {
describe('installations.load (a build made when first run offered a starter workflow)', () => {
it('lists, finds and updates a record that still carries the starter-template fields', async () => {
fs.writeFileSync(
path.join(userDataPath, 'installations.json'),
JSON.stringify([
{
id: 'starter-build',
name: 'Starter Build',
installPath: path.join(tmpRoot, 'starter'),
sourceId: 'standalone',
status: 'installed',
createdAt: new Date().toISOString(),
bundledTemplateId: 'image_z_image_turbo',
bundledTemplateSizeBytes: 5_000_000_000,
pendingTemplateOpen: 'image_z_image_turbo',
downloadTemplateModels: true
}
])
)
const installations = await loadInstallations()
const entry = await installations.add({
name: 'With Template',
installPath: path.join(tmpRoot, 't'),
sourceId: 'standalone',
status: 'installed',
bundledTemplateId: 'flux_schnell',
pendingTemplateOpen: 'flux_schnell',
downloadTemplateModels: true
})

expect(await installations.clearPendingTemplateOpen(entry.id)).toBe(true)
expect((await installations.get(entry.id))!.pendingTemplateOpen).toBeNull()
expect(await installations.clearPendingTemplateOpen(entry.id)).toBe(false)
})

it('is a no-op for a legacy record with no template fields (migration-safe)', async () => {
const installations = await loadInstallations()
const entry = await installations.add({
name: 'Legacy',
installPath: path.join(tmpRoot, 'legacy'),
sourceId: 'standalone',
expect((await installations.list()).map((record) => record.id)).toEqual(['starter-build'])
expect(await installations.get('starter-build')).toMatchObject({
name: 'Starter Build',
status: 'installed'
})
expect(entry.pendingTemplateOpen).toBeUndefined()
expect(entry.bundledTemplateId).toBeUndefined()
expect(await installations.clearPendingTemplateOpen(entry.id)).toBe(false)
})

it('returns false when the install is gone', async () => {
const installations = await loadInstallations()
expect(await installations.clearPendingTemplateOpen('does-not-exist')).toBe(false)
await installations.update('starter-build', { name: 'Renamed' })
expect((await installations.get('starter-build'))!.name).toBe('Renamed')
})
})

Expand Down
17 changes: 0 additions & 17 deletions src/main/installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export interface InstallationRecord {
modelDirsPrimary?: string | null
inputDir?: string
outputDir?: string
bundledTemplateId?: string
bundledTemplateSizeBytes?: number
pendingTemplateOpen?: string | null
downloadTemplateModels?: boolean
[key: string]: unknown
}

Expand Down Expand Up @@ -362,19 +358,6 @@ export async function markLaunched(
return updated
}

export async function clearPendingTemplateOpen(installationId: string): Promise<boolean> {
return enqueue(async () => {
const list = await loadForWrite()
const index = list.findIndex((i) => i.id === installationId)
if (index === -1) return false
const existing = list[index]!
if (existing.pendingTemplateOpen == null) return false
list[index] = { ...existing, pendingTemplateOpen: null } as InstallationRecord
await save(list)
return true
})
}

export async function getRecent(): Promise<InstallationRecord | null> {
const list = await load()
let best: InstallationRecord | null = null
Expand Down
10 changes: 0 additions & 10 deletions src/main/lib/ipc/registerInstallationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ import { restoreSnapshotIntoInstallation } from '../standaloneMigration'
import * as mainTelemetry from '../telemetry'
import { buildErrorFields } from '../../../shared/errorEvent'
import { invalidateModelDownloadStartupPass } from '../comfyDownloadManager'
import {
startTemplateDownload,
abortTemplateDownload
} from '../../sources/standalone/templateDownloadTask'
import { abortModelStaging } from '../../sources/comfybuilder/modelStagingTask'
import { recordIpcInvocation } from '../e2eOverrides'
import { DEFAULT_INSTALL_NAME } from '../../../shared/defaultInstallName'
Expand Down Expand Up @@ -279,11 +275,6 @@ export function registerInstallationHandlers(): void {

let snapshotRestoreError: string | null = null

if (inst.bundledTemplateId && inst.downloadTemplateModels && inst.pendingTemplateOpen) {
const sizeBytes = inst.bundledTemplateSizeBytes ?? 0
startTemplateDownload(inst, sizeBytes, { sendOutput })
}

const cache = createCache(
settings.get('cacheDir') as string,
settings.get('maxCachedDownloads') as number
Expand Down Expand Up @@ -327,7 +318,6 @@ export function registerInstallationHandlers(): void {
if (!snapshotRestoreError) sendProgress('done', { percent: 100, status: 'Complete' })
} catch (err) {
_operationAborts.delete(installationId)
abortTemplateDownload(installationId)
abortModelStaging(installationId)
if (abort.signal.aborted) {
if (isComfyUpdate) {
Expand Down
Loading
Loading