Skip to content

add installedVersion #4337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 4, 2025
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
4 changes: 4 additions & 0 deletions src/components/graph/GraphCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import { app as comfyApp } from '@/scripts/app'
import { ChangeTracker } from '@/scripts/changeTracker'
import { IS_CONTROL_WIDGET, updateControlWidgetLabel } from '@/scripts/widgets'
import { useColorPaletteService } from '@/services/colorPaletteService'
import { newUserService } from '@/services/newUserService'
import { useWorkflowService } from '@/services/workflowService'
import { useCommandStore } from '@/stores/commandStore'
import { useExecutionStore } from '@/stores/executionStore'
Expand Down Expand Up @@ -302,6 +303,9 @@ onMounted(async () => {
CORE_SETTINGS.forEach((setting) => {
settingStore.addSetting(setting)
})

await newUserService().initializeIfNewUser(settingStore)

// @ts-expect-error fixme ts strict error
await comfyApp.setup(canvasRef.value)
canvasStore.canvas = comfyApp.canvas
Expand Down
7 changes: 7 additions & 0 deletions src/constants/coreSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,13 @@ export const CORE_SETTINGS: SettingParams[] = [
defaultValue: false,
versionAdded: '1.8.7'
},
{
id: 'Comfy.InstalledVersion',
name: 'The frontend version that was running when the user first installed ComfyUI',
type: 'hidden',
defaultValue: null,
versionAdded: '1.24.0'
},
{
id: 'LiteGraph.ContextMenu.Scaling',
name: 'Scale node combo widget menus (lists) when zoomed in',
Expand Down
1 change: 1 addition & 0 deletions src/schemas/apiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ const zSettings = z.object({
'Comfy.Toast.DisableReconnectingToast': z.boolean(),
'Comfy.Workflow.Persist': z.boolean(),
'Comfy.TutorialCompleted': z.boolean(),
'Comfy.InstalledVersion': z.string().nullable(),
'Comfy.Node.AllowImageSizeDraw': z.boolean(),
'Comfy-Desktop.AutoUpdate': z.boolean(),
'Comfy-Desktop.SendStatistics': z.boolean(),
Expand Down
74 changes: 74 additions & 0 deletions src/services/newUserService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import type { useSettingStore } from '@/stores/settingStore'

let pendingCallbacks: Array<() => Promise<void>> = []
let isNewUserDetermined = false
let isNewUserCached: boolean | null = null

export const newUserService = () => {
function checkIsNewUser(
settingStore: ReturnType<typeof useSettingStore>
): boolean {
const isNewUserSettings =
Object.keys(settingStore.settingValues).length === 0 ||
!settingStore.get('Comfy.TutorialCompleted')
const hasNoWorkflow = !localStorage.getItem('workflow')
const hasNoPreviousWorkflow = !localStorage.getItem(
'Comfy.PreviousWorkflow'
)

return isNewUserSettings && hasNoWorkflow && hasNoPreviousWorkflow
}

async function registerInitCallback(callback: () => Promise<void>) {
if (isNewUserDetermined) {
if (isNewUserCached) {
try {
await callback()
} catch (error) {
console.error('New user initialization callback failed:', error)
}
}
} else {
pendingCallbacks.push(callback)
}
}

async function initializeIfNewUser(
settingStore: ReturnType<typeof useSettingStore>
) {
if (isNewUserDetermined) return

isNewUserCached = checkIsNewUser(settingStore)
isNewUserDetermined = true

if (!isNewUserCached) {
pendingCallbacks = []
return
}

await settingStore.set(
'Comfy.InstalledVersion',
__COMFYUI_FRONTEND_VERSION__
)

for (const callback of pendingCallbacks) {
try {
await callback()
} catch (error) {
console.error('New user initialization callback failed:', error)
}
}

pendingCallbacks = []
}

function isNewUser(): boolean | null {
return isNewUserDetermined ? isNewUserCached : null
}

return {
registerInitCallback,
initializeIfNewUser,
isNewUser
}
}
Loading