Skip to content

Commit 38fb53d

Browse files
authored
feat: LOD setting for LG and Vue (#6755)
## Summary Create a composable for useRenderModeSetting that lets you set a setting for either vue or litegraph and once set remembers each state respectively. ``` useRenderModeSetting( { setting: 'LiteGraph.Canvas.MinFontSizeForLOD', vue: 0, litegraph: 8 }, shouldRenderVueNodes ) ``` ## Screenshots (if applicable) <img width="1611" height="997" alt="image" src="https://github.com/user-attachments/assets/621930f2-2d21-4c86-a46d-e3e292d4e012" /> <img width="1611" height="997" alt="chrome_Gr1V3P6sJi" src="https://github.com/user-attachments/assets/eb63b747-487f-4f5e-8fcf-f0d2ff97b976" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6755-feat-LOD-setting-for-LG-and-Vue-2b16d73d365081cbbf09c292ee3c0e96) by [Unito](https://www.unito.io)
1 parent a832141 commit 38fb53d

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

browser_tests/tests/vueNodes/interactions/canvas/zoom.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
test.describe('Vue Nodes Zoom', () => {
77
test.beforeEach(async ({ comfyPage }) => {
88
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
9+
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
910
await comfyPage.vueNodes.waitForNodes()
1011
})
1112

browser_tests/tests/vueNodes/nodeStates/lod.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test.beforeEach(async ({ comfyPage }) => {
99
test.describe('Vue Nodes - LOD', () => {
1010
test.beforeEach(async ({ comfyPage }) => {
1111
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
12+
await comfyPage.setSetting('LiteGraph.Canvas.MinFontSizeForLOD', 8)
1213
await comfyPage.setup()
1314
await comfyPage.loadWorkflow('default')
1415
})

src/composables/graph/useVueNodeLifecycle.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { shallowRef, watch } from 'vue'
33

44
import { useGraphNodeManager } from '@/composables/graph/useGraphNodeManager'
55
import type { GraphNodeManager } from '@/composables/graph/useGraphNodeManager'
6+
import { useRenderModeSetting } from '@/composables/settings/useRenderModeSetting'
67
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
78
import { useVueNodesMigrationDismissed } from '@/composables/useVueNodesMigrationDismissed'
89
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
@@ -18,15 +19,18 @@ function useVueNodeLifecycleIndividual() {
1819
const canvasStore = useCanvasStore()
1920
const layoutMutations = useLayoutMutations()
2021
const { shouldRenderVueNodes } = useVueFeatureFlags()
21-
2222
const nodeManager = shallowRef<GraphNodeManager | null>(null)
23-
2423
const { startSync } = useLayoutSync()
2524

2625
const isVueNodeToastDismissed = useVueNodesMigrationDismissed()
2726

2827
let hasShownMigrationToast = false
2928

29+
useRenderModeSetting(
30+
{ setting: 'LiteGraph.Canvas.MinFontSizeForLOD', vue: 0, litegraph: 8 },
31+
shouldRenderVueNodes
32+
)
33+
3034
const initializeNodeManager = () => {
3135
// Use canvas graph if available (handles subgraph contexts), fallback to app graph
3236
const activeGraph = comfyApp.canvas?.graph
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { ComputedRef } from 'vue'
2+
import { ref, watch } from 'vue'
3+
4+
import { useSettingStore } from '@/platform/settings/settingStore'
5+
import type { Settings } from '@/schemas/apiSchema'
6+
7+
interface RenderModeSettingConfig<TSettingKey extends keyof Settings> {
8+
setting: TSettingKey
9+
vue: Settings[TSettingKey]
10+
litegraph: Settings[TSettingKey]
11+
}
12+
13+
export function useRenderModeSetting<TSettingKey extends keyof Settings>(
14+
config: RenderModeSettingConfig<TSettingKey>,
15+
isVueMode: ComputedRef<boolean>
16+
) {
17+
const settingStore = useSettingStore()
18+
const vueValue = ref(config.vue)
19+
const litegraphValue = ref(config.litegraph)
20+
const lastWasVue = ref<boolean | null>(null)
21+
22+
const load = async (vue: boolean) => {
23+
if (lastWasVue.value === vue) return
24+
25+
if (lastWasVue.value !== null) {
26+
const currentValue = settingStore.get(config.setting)
27+
if (lastWasVue.value) {
28+
vueValue.value = currentValue
29+
} else {
30+
litegraphValue.value = currentValue
31+
}
32+
}
33+
34+
await settingStore.set(
35+
config.setting,
36+
vue ? vueValue.value : litegraphValue.value
37+
)
38+
lastWasVue.value = vue
39+
}
40+
41+
watch(isVueMode, load, { immediate: true })
42+
}

0 commit comments

Comments
 (0)