diff --git a/src/renderer/src/components/settings/ComfyUISettingsContent.test.ts b/src/renderer/src/components/settings/ComfyUISettingsContent.test.ts index d66082a1e..b294267c3 100644 --- a/src/renderer/src/components/settings/ComfyUISettingsContent.test.ts +++ b/src/renderer/src/components/settings/ComfyUISettingsContent.test.ts @@ -48,7 +48,11 @@ vi.mock('../../views/comfyUISettings/SnapshotsView.vue', () => ({ } })) vi.mock('../../views/comfyUISettings/SettingsSectionList.vue', () => ({ - default: { template: '
' } + default: { + name: 'SettingsSectionList', + props: ['columns'], + template: '
' + } })) vi.mock('../../views/comfyUISettings/StatusFactPanel.vue', () => ({ default: { template: '
' } @@ -732,6 +736,58 @@ describe('ComfyUISettingsContent', () => { }) }) + describe('Startup Args two-column layout', () => { + let priorSections: unknown[] + let target: HTMLElement + + beforeEach(() => { + priorSections = useComfyUISettingsState.sections.value + useComfyUISettingsState.sections.value = [ + { tab: 'update', fields: [] }, + { tab: 'settings', fields: [] }, + { tab: 'status', fields: [] } + ] + target = document.createElement('div') + target.id = 'page-actions' + document.body.append(target) + }) + + afterEach(() => { + useComfyUISettingsState.sections.value = priorSections + target.remove() + }) + + async function columnsFor(props: Record): Promise { + const w = await mountContent({ initialTab: 'config', ...props }) + const columns = w.findComponent({ name: 'SettingsSectionList' }).props('columns') + w.unmount() + return columns + } + + it('lays out the Startup Args tab in two columns on the build page', async () => { + expect(await columnsFor({ pageActionsTarget: '#page-actions' })).toBe(true) + }) + + it('keeps the settings modal single-column', async () => { + expect(await columnsFor({})).toBe(false) + }) + + it('keeps a cloud build single-column, where that tab is labelled Storage', async () => { + expect( + await columnsFor({ + pageActionsTarget: '#page-actions', + installation: { ...SAMPLE_INSTALL, sourceCategory: 'cloud' } + }) + ).toBe(false) + }) + + it('keeps the Update tab single-column on the build page', async () => { + expect(await columnsFor({ pageActionsTarget: '#page-actions', initialTab: 'update' })).toBe( + false + ) + }) + }) + describe('Update-tab auto-refresh staleness gate', () => { async function checkUpdateFireCount(lastCheckedAt?: number): Promise { const priorSections = useComfyUISettingsState.sections.value diff --git a/src/renderer/src/components/settings/ComfyUISettingsContent.vue b/src/renderer/src/components/settings/ComfyUISettingsContent.vue index 0719859d2..2419080bb 100644 --- a/src/renderer/src/components/settings/ComfyUISettingsContent.vue +++ b/src/renderer/src/components/settings/ComfyUISettingsContent.vue @@ -292,16 +292,21 @@ const showConsoleTab = computed( isTabAllowedForCategory('console', installation.value.sourceCategory) ) -const tabs = computed(() => { - const isCloud = installation.value?.sourceCategory === 'cloud' - return ALL_TABS.filter((tab) => +const isCloud = computed(() => installation.value?.sourceCategory === 'cloud') + +const tabs = computed(() => + ALL_TABS.filter((tab) => tab.key === 'console' ? showConsoleTab.value : sectionsForTab(tab.sectionTab).value.length > 0 ).map((tab) => - isCloud && tab.key === 'config' + isCloud.value && tab.key === 'config' ? { ...tab, label: t('comfyUISettings.tabStorage'), icon: HardDrive } : tab ) -}) +) + +const isStartupArgsPage = computed( + () => isPage.value && activeTab.value === 'config' && !isCloud.value +) const showUpdateBadge = computed(() => { const inst = installation.value @@ -1085,6 +1090,7 @@ defineExpose({ > { expect(wrapper.emitted('update-field')![0]![1]).toBe(true) }) }) + + describe('two-column layout', () => { + const TWO_COLUMN_GRID = '@2xl/build-settings:grid' + const launchField: DetailField = { + id: 'launchArgs', + label: 'Startup arguments', + value: '--listen', + editable: true, + editType: 'text' + } + + function mountSections(sections: DetailSection[], columns: boolean) { + return mount(SettingsSectionList, { props: { sections, columns } }) + } + + it('shows a titled section as a heading beside its fields', () => { + const wrapper = mountSections( + [{ title: 'Launch Settings', description: 'How the build starts.', fields: [launchField] }], + true + ) + expect(wrapper.find('h3').text()).toBe('Launch Settings') + expect(wrapper.find('.settings-v2-section').classes()).toContain(TWO_COLUMN_GRID) + expect(wrapper.find('.settings-v2-section-body').classes()).toContain('max-w-xl') + expect(wrapper.find('.settings-v2-section-body').text()).toContain('Startup arguments') + }) + + it('shows the section description once, under the heading', () => { + const wrapper = mountSections( + [{ title: 'Launch Settings', description: 'How the build starts.', fields: [launchField] }], + true + ) + const descriptions = wrapper.findAll('.settings-v2-section-desc') + expect(descriptions).toHaveLength(1) + expect(descriptions[0]!.element.closest('header')).not.toBeNull() + }) + + it('leaves the layout unchanged when columns is off', () => { + const wrapper = mountSections( + [{ title: 'Launch Settings', description: 'How the build starts.', fields: [launchField] }], + false + ) + expect(wrapper.find('h3').exists()).toBe(false) + expect(wrapper.find('.settings-v2-section').classes()).not.toContain(TWO_COLUMN_GRID) + expect(wrapper.find('.settings-v2-section-body').classes()).toContain('contents') + expect(wrapper.find('.settings-v2-section-desc').text()).toBe('How the build starts.') + }) + + it('keeps an untitled section stacked so its rows do not split across columns', () => { + const wrapper = mountSections([{ fields: [launchField, { ...launchField, id: 'b' }] }], true) + expect(wrapper.find('.settings-v2-section').classes()).not.toContain(TWO_COLUMN_GRID) + expect(wrapper.find('.settings-v2-section-body').classes()).toContain('contents') + }) + + it('keeps a collapsible section stacked with its toggle and description', () => { + const wrapper = mountSections( + [ + { + title: 'Advanced', + description: 'Rarely needed flags.', + collapsed: false, + fields: [launchField] + } + ], + true + ) + expect(wrapper.find('h3').exists()).toBe(false) + expect(wrapper.find('.settings-v2-section').classes()).not.toContain(TWO_COLUMN_GRID) + expect(wrapper.find('button[aria-expanded]').text()).toContain('Advanced') + expect(wrapper.find('.settings-v2-section-desc').text()).toBe('Rarely needed flags.') + }) + }) }) diff --git a/src/renderer/src/views/comfyUISettings/SettingsSectionList.vue b/src/renderer/src/views/comfyUISettings/SettingsSectionList.vue index 4c19f2ef3..3c33a3963 100644 --- a/src/renderer/src/views/comfyUISettings/SettingsSectionList.vue +++ b/src/renderer/src/views/comfyUISettings/SettingsSectionList.vue @@ -27,6 +27,7 @@ import type { interface Props { sections: DetailSection[] readonly?: boolean + columns?: boolean installationId?: string runningActionIds?: Set pendingRestartFieldIds?: Set @@ -35,6 +36,7 @@ interface Props { const props = withDefaults(defineProps(), { readonly: false, + columns: false, installationId: undefined, runningActionIds: () => new Set(), pendingRestartFieldIds: () => new Set(), @@ -119,6 +121,10 @@ function toggleCollapsed(section: { title?: string }): void { } } +function isTwoColumn(section: { title?: string; collapsed?: boolean }): boolean { + return props.columns && Boolean(section.title) && !isCollapsible(section) +} + const visibleSections = computed(() => props.sections) function isNestedField(field: DetailField): boolean { @@ -202,7 +208,10 @@ function actionVariantClass(action: ActionDef, directStyle = true): string {