From 86789ceb9de53528377bca5ae7d3d96f918af230 Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Sat, 18 Jan 2025 12:25:04 -0700 Subject: [PATCH] Show changelog on new version --- src/assets/changelog.json | 1 + src/components/graph/GraphCanvas.vue | 40 ++++++++++++++++++++++++++++ src/constants/coreSettings.ts | 15 +++++++++++ src/utils/envUtil.ts | 24 +++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 src/assets/changelog.json diff --git a/src/assets/changelog.json b/src/assets/changelog.json new file mode 100644 index 000000000..a575e19de --- /dev/null +++ b/src/assets/changelog.json @@ -0,0 +1 @@ +{"last_node_id":16,"last_link_id":10,"nodes":[{"id":16,"type":"MarkdownNote","pos":[630,60],"size":[930,945],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[],"title":"Changelog","properties":{},"widgets_values":["# v0.3.11 (Pre-release)\n\n## What's Changed\n\n* Nvidia Cosmos 7B and 14B: text to video and image to video diffusion model support.\n \n\n\n* New sampler: res_multistep\n* ckpt/pt/etc.. files are now always loaded safely on pytorch 2.4 and above.\n* Fix some cases of ancestral samplers not being deterministic.\n* Support ascend npu by @ji-huazhong [#5436](https://github.com/comfyanonymous/ComfyUI/pull/5436)\n* Add option to log non-error output to stdout by @webfiltered [#6243](https://github.com/comfyanonymous/ComfyUI/pull/6243)\n* serve workflow templates from custom_nodes by @bezo97 [#6193](https://github.com/comfyanonymous/ComfyUI/pull/6193)\n* Remove duplicate calls to INPUT_TYPES by @catboxanon [#6249](https://github.com/comfyanonymous/ComfyUI/pull/6249)\n* Fix Hook Keyframe 'guarantee_steps' behavior and add 'sigmas' by @Kosinkadink [#6273](https://github.com/comfyanonymous/ComfyUI/pull/6273)\n* Add kl_optimal scheduler by @blepping [#6206](https://github.com/comfyanonymous/ComfyUI/pull/6206)\n* (fix): \"verbose\" argument by @bigcat88 [#6289](https://github.com/comfyanonymous/ComfyUI/pull/6289)\n* Fix custom node type-hinting examples by @webfiltered [#6281](https://github.com/comfyanonymous/ComfyUI/pull/6281)\n* Add missing model_options param to finalize_default_conds call by @Kosinkadink [#6296](https://github.com/comfyanonymous/ComfyUI/pull/6296)\n* Fix unknown scheduler error handling in calculate_sigmas function by @blepping [#6280](https://github.com/comfyanonymous/ComfyUI/pull/6280)\n* Fix temporal tiling for Tiled VAE decoder, remove redundant tiles. by @kvochko [#6306](https://github.com/comfyanonymous/ComfyUI/pull/6306)\n* Update web content to release v1.6.14 by @huchenlei [#6312](https://github.com/comfyanonymous/ComfyUI/pull/6312)\n* add fov and mask for load 3d node by @jtydhr88 [#6308](https://github.com/comfyanonymous/ComfyUI/pull/6308)\n* Update web content to release v1.6.15 by @huchenlei [#6324](https://github.com/comfyanonymous/ComfyUI/pull/6324)\n* Update web content to release v1.6.16 by @huchenlei [#6335](https://github.com/comfyanonymous/ComfyUI/pull/6335)\n* Update web content to release v1.6.17 by @huchenlei [#6337](https://github.com/comfyanonymous/ComfyUI/pull/6337)\n* Add update-frontend github action by @huchenlei [#6336](https://github.com/comfyanonymous/ComfyUI/pull/6336)\n* Update CODEOWNERS by @yoland68 [#6338](https://github.com/comfyanonymous/ComfyUI/pull/6338)\n* In inner_sample, change \"sigmas\" to \"sample_sigmas\" by @Kosinkadink [#6360](https://github.com/comfyanonymous/ComfyUI/pull/6360)\n* Frontend Update: v1.6.18 by @huchenlei [#6368](https://github.com/comfyanonymous/ComfyUI/pull/6368)\n* Document get_attr and get_model_object by @huchenlei [#6357](https://github.com/comfyanonymous/ComfyUI/pull/6357)\n* fixed: robust loading \\`comfy.settings.json\\` by @ltdrdata [#6383](https://github.com/comfyanonymous/ComfyUI/pull/6383)\n* Add pyproject.toml by @huchenlei [#6386](https://github.com/comfyanonymous/ComfyUI/pull/6386)\n* Hooks Part 2 - TransformerOptionsHook and AdditionalModelsHook by @Kosinkadink [#6377](https://github.com/comfyanonymous/ComfyUI/pull/6377)\n* Merge ruff.toml into pyproject.toml by @huchenlei [#6431](https://github.com/comfyanonymous/ComfyUI/pull/6431)\n* (fix): load_extra_path_config: relative path not converted to a full path by @bigcat88 [#6395](https://github.com/comfyanonymous/ComfyUI/pull/6395)\n* Rewrite res_multistep sampler and implement res_multistep_cfg_pp sampler by @pamparamm [#6462](https://github.com/comfyanonymous/ComfyUI/pull/6462)\n* Add SetFirstSigma node by @catboxanon [#6459](https://github.com/comfyanonymous/ComfyUI/pull/6459)\n\n**Full Changelog**: [\\`v0.3.10...v0.3.11\\`](https://github.com/comfyanonymous/ComfyUI/compare/v0.3.10...v0.3.11)\n\n----\n\n> To disable showing changelog on new releases, go the the Changelog section in settings\n"],"color":"#222","bgcolor":"#000"}],"links":[],"groups":[],"config":{},"extra":{"ds":{"scale":1.503752370924104,"offset":[-489.9627968865069,158.59081129748483]}},"version":0.4} \ No newline at end of file diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 1e513546c..b1ee27945 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -43,6 +43,7 @@ import { } from '@comfyorg/litegraph' import { computed, onMounted, ref, watch, watchEffect } from 'vue' +import changelog from '@/assets/changelog.json' import LiteGraphCanvasSplitterOverlay from '@/components/LiteGraphCanvasSplitterOverlay.vue' import BottomPanel from '@/components/bottomPanel/BottomPanel.vue' import GraphCanvasMenu from '@/components/graph/GraphCanvasMenu.vue' @@ -56,6 +57,7 @@ import { CORE_SETTINGS } from '@/constants/coreSettings' import { usePragmaticDroppable } from '@/hooks/dndHooks' import { api } from '@/scripts/api' import { app as comfyApp } from '@/scripts/app' +import { app } from '@/scripts/app' import { ChangeTracker } from '@/scripts/changeTracker' import { getStorageValue, setStorageValue } from '@/scripts/utils' import { IS_CONTROL_WIDGET, updateControlWidgetLabel } from '@/scripts/widgets' @@ -71,10 +73,12 @@ import { } from '@/stores/modelToNodeStore' import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore' import { useSettingStore } from '@/stores/settingStore' +import { useSystemStatsStore } from '@/stores/systemStatsStore' import { useWorkflowStore } from '@/stores/workflowStore' import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore' import { useWorkspaceStore } from '@/stores/workspaceStore' import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes' +import { electronAPI, isElectron, isVersionLessThan } from '@/utils/envUtil' const emit = defineEmits(['ready']) const canvasRef = ref(null) @@ -278,6 +282,42 @@ const persistCurrentWorkflow = () => { } } +const getComfyVersion = () => { + if (isElectron()) return electronAPI().getComfyUIVersion() + return useSystemStatsStore()?.systemStats?.system?.comfyui_version ?? '' +} + +const stopWatchChangeLog = watch( + () => workflowStore.activeWorkflow, + () => { + if (!comfyAppReady.value) return + + const isDisabled = settingStore.get('Comfy.ShowChangeLog') === false + if (isDisabled || !changelog) { + stopWatchChangeLog() + return + } + + const workflow = workflowStore.activeWorkflow + const activeState = workflow?.activeState + const comfyVersion = getComfyVersion() + if (!workflow || !activeState || !comfyVersion) return + + // Just checking if temporary is not enough bc doesn't account for duplicate feature + const isBlank = !workflow.isPersisted && activeState.nodes?.length === 0 + if (!isBlank) return + + const lastShown = settingStore.get('Comfy.LastChangelogVersion') + const isSeen = lastShown && !isVersionLessThan(lastShown, comfyVersion) + if (!isSeen) { + app.loadGraphData(changelog) + settingStore.set('Comfy.LastChangelogVersion', comfyVersion) + } + + stopWatchChangeLog() + } +) + watchEffect(() => { if (workflowStore.activeWorkflow) { const workflow = workflowStore.activeWorkflow diff --git a/src/constants/coreSettings.ts b/src/constants/coreSettings.ts index f0d29012e..636d9376d 100644 --- a/src/constants/coreSettings.ts +++ b/src/constants/coreSettings.ts @@ -708,5 +708,20 @@ export const CORE_SETTINGS: SettingParams[] = [ defaultValue: 'after', options: ['before', 'after'], versionModified: '1.6.10' + }, + { + id: 'Comfy.ShowChangeLog', + category: ['Comfy', 'Changelog'], + name: 'Show changelog on new release', + type: 'boolean', + defaultValue: true, + versionAdded: '1.7.15' + }, + { + id: 'Comfy.LastChangelogVersion', + name: 'The version of ComfyUI on which the last changelog was shown', + type: 'hidden', + defaultValue: '0.0.0', + versionAdded: '1.7.15' } ] diff --git a/src/utils/envUtil.ts b/src/utils/envUtil.ts index b5b987ca7..08abb5446 100644 --- a/src/utils/envUtil.ts +++ b/src/utils/envUtil.ts @@ -14,3 +14,27 @@ export function electronAPI() { export function showNativeMenu(options?: ElectronContextMenuOptions) { electronAPI()?.showContextMenu(options) } + +const normalizeVersion = (version: string) => { + return version + .split('.') + .map(Number) + .filter((v) => !Number.isNaN(v)) +} + +export function isVersionLessThan(versionA: string, versionB: string) { + versionA ??= '0.0.0' + versionB ??= '0.0.0' + + const normalizedA = normalizeVersion(versionA) + const normalizedB = normalizeVersion(versionB) + + for (let i = 0; i < Math.max(normalizedA.length, normalizedB.length); i++) { + const a = normalizedA[i] ?? 0 + const b = normalizedB[i] ?? 0 + if (a < b) return true + if (a > b) return false + } + + return false +}