Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ vi.mock('../../views/comfyUISettings/SnapshotsView.vue', () => ({
}
}))
vi.mock('../../views/comfyUISettings/SettingsSectionList.vue', () => ({
default: { template: '<div data-testid="settings-section-list-stub"></div>' }
default: {
name: 'SettingsSectionList',
props: ['columns'],
template: '<div data-testid="settings-section-list-stub"></div>'
}
}))
vi.mock('../../views/comfyUISettings/StatusFactPanel.vue', () => ({
default: { template: '<div />' }
Expand Down Expand Up @@ -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<string, unknown>): Promise<unknown> {
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<number> {
const priorSections = useComfyUISettingsState.sections.value
Expand Down
16 changes: 11 additions & 5 deletions src/renderer/src/components/settings/ComfyUISettingsContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,21 @@ const showConsoleTab = computed(
isTabAllowedForCategory('console', installation.value.sourceCategory)
)

const tabs = computed<TabDef[]>(() => {
const isCloud = installation.value?.sourceCategory === 'cloud'
return ALL_TABS.filter((tab) =>
const isCloud = computed(() => installation.value?.sourceCategory === 'cloud')

const tabs = computed<TabDef[]>(() =>
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
Expand Down Expand Up @@ -1085,6 +1090,7 @@ defineExpose({
>
<SettingsSectionList
:sections="visibleSections"
:columns="isStartupArgsPage"
:installation-id="installation?.id"
:running-action-ids="runningActionIds"
:pending-restart-field-ids="pendingRestartFieldIds"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,75 @@ describe('SettingsSectionList', () => {
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.')
})
})
})
Loading
Loading