Skip to content
Draft
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/settings-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export type Settings = {
'Comfy.Canvas.LeftMouseClickBehavior': string
'Comfy.Canvas.MouseWheelScroll': string
'Comfy.VueNodes.Enabled': boolean
'Comfy.VueNodes.HideSafeModelExtensions': boolean
'Comfy.AppBuilder.VueNodeSwitchDismissed': boolean
'Comfy.PartnerNodesEducation.Dismissed': boolean
'Comfy.ModelLibrary.UseAssetBrowser': boolean
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@
"name": "Modern Node Design (Nodes 2.0)",
"tooltip": "Modern: DOM-based rendering with enhanced interactivity, native browser features, and updated visual design. Classic: Traditional canvas rendering."
},
"Comfy_VueNodes_HideSafeModelExtensions": {
"name": "Hide .safetensors and .sft extensions",
"tooltip": "Hide these extensions in closed model widgets. Other extensions remain visible; dropdown options and saved values keep full filenames."
},
"Comfy_WidgetControlMode": {
"name": "Widget control mode",
"tooltip": "Controls when widget values are updated (randomize/increment/decrement), either before the prompt is queued or after.",
Expand Down
9 changes: 9 additions & 0 deletions src/platform/settings/constants/coreSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,15 @@ export const CORE_SETTINGS: SettingParams[] = [
experimental: true,
versionAdded: '1.27.1'
},
{
id: 'Comfy.VueNodes.HideSafeModelExtensions',
category: ['Comfy', 'Nodes 2.0', 'HideSafeModelExtensions'],
name: 'Hide .safetensors and .sft extensions',
type: 'boolean',
defaultValue: false,
tooltip:
'Hide these extensions in closed model widgets. Other extensions remain visible; dropdown options and saved values keep full filenames.'
},
{
id: 'Comfy.AppBuilder.VueNodeSwitchDismissed',
name: 'App Builder Vue Node switch dismissed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { nextTick } from 'vue'
import { createI18n } from 'vue-i18n'

import { useSettingStore } from '@/platform/settings/settingStore'
import type { SimplifiedWidget, WidgetValue } from '@/types/simplifiedWidget'
import { toNodeId } from '@comfyorg/graph-model/nodeId'
import { widgetId } from '@comfyorg/graph-model/widgetId'
Expand Down Expand Up @@ -128,6 +129,80 @@ describe('WidgetSelectDefault', () => {
expect(screen.getByRole('combobox')).not.toHaveAttribute('title')
})

it.for([
{ filename: 'portrait.safetensors', summary: 'portrait' },
{ filename: 'portrait.SFT', summary: 'portrait' },
{ filename: 'portrait.SAFETENSORS', summary: 'portrait' },
{ filename: 'portrait.ckpt', summary: 'portrait.ckpt' },
{ filename: 'portrait.pt', summary: 'portrait.pt' },
{ filename: 'portrait.pth', summary: 'portrait.pth' },
{ filename: 'portrait.bin', summary: 'portrait.bin' },
{
filename: 'portrait.safetensors.ckpt',
summary: 'portrait.safetensors.ckpt'
},
{ filename: '.sft', summary: '.sft' }
])('optionally summarizes $filename as $summary', ({ filename, summary }) => {
useSettingStore().settingValues['Comfy.VueNodes.HideSafeModelExtensions'] =
true
const raw = `studio/models/${filename}`
renderComponent(createWidget([raw]), raw, undefined, true)

expect(screen.getByRole('combobox').textContent.trim()).toBe(summary)
})

it.for([
{ filenameSummary: false, options: {}, expected: 'studio/model.sft' },
{
filenameSummary: true,
options: { getOptionLabel: () => 'Custom.sft' },
expected: 'Custom.sft'
}
])(
'preserves $expected with extension hiding enabled',
({ filenameSummary, options, expected }) => {
useSettingStore().settingValues[
'Comfy.VueNodes.HideSafeModelExtensions'
] = true
const raw = 'studio/model.sft'
renderComponent(
createWidget([raw], options),
raw,
undefined,
filenameSummary
)

expect(screen.getByRole('combobox').textContent.trim()).toBe(expected)
}
)

it('updates summaries live without hiding option extensions or changing raw selections', async () => {
const settings = useSettingStore()
const first = 'studio/model.safetensors'
const second = 'studio/model.sft'
const { user, onUpdate, rerender } = renderComponent(
createWidget([first, second]),
first,
undefined,
true
)
settings.settingValues['Comfy.VueNodes.HideSafeModelExtensions'] = true
await nextTick()
expect(screen.getByRole('combobox').textContent.trim()).toBe('model')

await openDropdown(user)
expect(
screen.getByRole('option', { name: 'model.safetensors' })
).toBeVisible()
await user.click(screen.getByRole('option', { name: 'model.sft' }))
expect(onUpdate).toHaveBeenCalledWith(second)
await rerender({ modelValue: second })

settings.settingValues['Comfy.VueNodes.HideSafeModelExtensions'] = false
await nextTick()
expect(screen.getByRole('combobox').textContent.trim()).toBe('model.sft')
})

it.for([
{ current: 42, action: 'Next', expected: -7 },
{ current: 42, action: 'Previous', expected: 11 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { countBy } from 'es-toolkit'
import { computed, ref, toRef } from 'vue'
import type { Ref } from 'vue'

import { useSettingStore } from '@/platform/settings/settingStore'
import { useComboStepping } from '@/renderer/extensions/vueNodes/widgets/composables/useComboStepping'
import type { WidgetValue } from '@comfyorg/graph-model/widgetValue'
import type { IWidgetOptions } from '@comfyorg/graph-model/widgets'
Expand Down Expand Up @@ -32,6 +33,7 @@ export function useComboOptions(
onSelect: (option: ComboOption) => void
}
) {
const settings = useSettingStore()
const options = toRef(getOptions)
const searchQuery = ref('')
const directory = ref<string[]>([])
Expand Down Expand Up @@ -60,20 +62,27 @@ export function useComboOptions(
const selectedOption = computed(() =>
normalized.value.find((option) => option.value === selectedValue.value)
)
const summarizeFilename = computed(
() => config.filenameSummary() && !options.value?.getOptionLabel
)
const selection = computed(() => {
const option = selectedOption.value
const invalid =
options.value?.values !== undefined &&
Boolean(selectedValue.value) &&
!option
const label = option ? option.label : invalid ? String(value.value) : ''
const summary = summarizeFilename.value
? label.split(/[/\\]/).at(-1)
: label
return {
option,
invalid,
summary:
config.filenameSummary() && !options.value?.getOptionLabel
? label.split(/[/\\]/).at(-1)
: label
summarizeFilename.value &&
settings.get('Comfy.VueNodes.HideSafeModelExtensions')
? summary?.replace(/^(.+)\.(?:safetensors|sft)$/i, '$1')
: summary
}
})
const longestLabel = computed(() =>
Expand Down
Loading