Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c4f87b
fix: Replace reactive feature flags with non-reactive approach
viva-jinyi Sep 3, 2025
404585b
fix: Add HelpCenter manager state handling and API version switching
viva-jinyi Sep 3, 2025
f4fae6d
fix: Simplify manager state determination and fix API timing issues
viva-jinyi Sep 3, 2025
6d1d864
fix: Correct manager state determination for non-v4 servers
viva-jinyi Sep 3, 2025
13f156f
chore: Remove debug console.log statements
viva-jinyi Sep 3, 2025
775faa0
test: Update manager state store tests to match new logic
viva-jinyi Sep 3, 2025
6d8ed5c
fix: Remove dynamic API version handling in manager service
viva-jinyi Sep 4, 2025
896eb37
refactor: Add helper functions to managerStateStore for better code r…
viva-jinyi Sep 4, 2025
ad29891
fix: Ensure SystemStats is loaded before conflict detection
viva-jinyi Sep 4, 2025
5b6d6f1
docs: Clarify feature flag default behavior in manager state
viva-jinyi Sep 4, 2025
e5fb47f
fix: Ensure consistent manager state handling for legacy commands
viva-jinyi Sep 4, 2025
2df02e0
refactor: centralize manager opening logic into managerStateStore
viva-jinyi Sep 4, 2025
fe139af
fix: use correct i18n import in managerStateStore
viva-jinyi Sep 4, 2025
abeed2e
feature: initial tab fix
viva-jinyi Sep 4, 2025
4603ca3
test: Fix managerStateStore test failures by adding missing mocks
viva-jinyi Sep 4, 2025
5de7788
refactor: convert managerStateStore to composable
viva-jinyi Sep 5, 2025
4098d34
refactor: use readonly computed properties instead of getter methods
viva-jinyi Sep 5, 2025
dd17988
fix: check isManagerEnabled check to GraphCanvas.vue to avoid the sid…
viva-jinyi Sep 5, 2025
61058a8
chore: console.log to console.debug
viva-jinyi Sep 5, 2025
1bdc990
chore: useConflictDetection().initializeConflictDetection()
viva-jinyi Sep 5, 2025
2386dec
test: add mockManagerDisabled option to disable manager in Playwright…
viva-jinyi Sep 5, 2025
aef2b7b
chore: text modified
viva-jinyi Sep 5, 2025
2cadf05
fix: resolve CI/CD failures by fixing manager initialization timing
viva-jinyi Sep 5, 2025
91c6c87
chore: modified the note
viva-jinyi Sep 5, 2025
75db082
fix: test code modified
viva-jinyi Sep 5, 2025
2b42259
fix: when manager is new manager ui, conflict detectetion should work
viva-jinyi Sep 5, 2025
9634186
fix: ensure fetch system stats before determine manager stats & when …
viva-jinyi Sep 6, 2025
ecbb78d
chore: unnecessary .value deleted & fetch name modified to refetch
viva-jinyi Sep 6, 2025
647a0f2
fix: ref type .value needed
viva-jinyi Sep 6, 2025
c9dd3de
chore: vue use until pattern for waiting initializing
viva-jinyi Sep 6, 2025
3f2ccd8
fix: .value added
viva-jinyi Sep 6, 2025
a363cdc
fix: useManagerState test to properly mock reactive refs
viva-jinyi Sep 6, 2025
1974b1f
fix: when system stats initialized, use until(systemStatsStore.isInit…
viva-jinyi Sep 6, 2025
eda2bf9
fix: test
viva-jinyi Sep 6, 2025
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
Prev Previous commit
Next Next commit
refactor: Add helper functions to managerStateStore for better code r…
…euse

- Add isManagerEnabled(), isNewManagerUI(), isLegacyManagerUI() helpers
- Add shouldShowInstallButton(), shouldShowManagerButtons() for UI logic
- Update components to use helper functions where applicable
- Add comprehensive tests for new helper functions
- Centralize state checking logic to reduce duplication
  • Loading branch information
viva-jinyi committed Sep 6, 2025
commit 896eb37754084d248b40dce4a20c49fffce076a5
4 changes: 2 additions & 2 deletions src/components/dialog/content/LoadWorkflowWarning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ const managerStateStore = useManagerStateStore()

// Show manager buttons unless manager is disabled
const showManagerButtons = computed(() => {
return managerStateStore.getManagerUIState() !== ManagerUIState.DISABLED
return managerStateStore.shouldShowManagerButtons()
})

// Only show Install All button for NEW_UI (new manager with v4 support)
const showInstallAllButton = computed(() => {
return managerStateStore.getManagerUIState() === ManagerUIState.NEW_UI
return managerStateStore.shouldShowInstallButton()
})

const openManager = async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/services/comfyManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { v4 as uuidv4 } from 'uuid'
import { ref } from 'vue'

import { api } from '@/scripts/api'
import {
ManagerUIState,
useManagerStateStore
} from '@/stores/managerStateStore'
import { useManagerStateStore } from '@/stores/managerStateStore'
import { components } from '@/types/generatedManagerTypes'
import { isAbortError } from '@/utils/typeGuardUtil'

Expand Down Expand Up @@ -58,7 +55,7 @@ export const useComfyManagerService = () => {
// Check if manager service should be available
const isManagerServiceAvailable = () => {
const managerStore = useManagerStateStore()
return managerStore.getManagerUIState() === ManagerUIState.NEW_UI
return managerStore.isNewManagerUI()
}

const handleRequestError = (
Expand Down
44 changes: 43 additions & 1 deletion src/stores/managerStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,49 @@ export const useManagerStateStore = defineStore('managerState', () => {
return ManagerUIState.DISABLED
}

/**
* Helper function to check if manager is enabled (not DISABLED)
*/
const isManagerEnabled = (): boolean => {
return getManagerUIState() !== ManagerUIState.DISABLED
}

/**
* Helper function to check if manager UI is in NEW_UI mode
*/
const isNewManagerUI = (): boolean => {
return getManagerUIState() === ManagerUIState.NEW_UI
}

/**
* Helper function to check if manager UI is in LEGACY_UI mode
*/
const isLegacyManagerUI = (): boolean => {
return getManagerUIState() === ManagerUIState.LEGACY_UI
}

/**
* Helper function to check if install button should be shown
* (only in NEW_UI mode)
*/
const shouldShowInstallButton = (): boolean => {
return isNewManagerUI()
}

/**
* Helper function to check if manager buttons should be shown
* (when manager is not disabled)
*/
const shouldShowManagerButtons = (): boolean => {
return isManagerEnabled()
}

return {
getManagerUIState
getManagerUIState,
isManagerEnabled,
isNewManagerUI,
isLegacyManagerUI,
shouldShowInstallButton,
shouldShowManagerButtons
}
})
96 changes: 96 additions & 0 deletions tests-ui/tests/stores/managerStateStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,100 @@ describe('useManagerStateStore', () => {
expect(store.getManagerUIState()).toBe(ManagerUIState.NEW_UI)
})
})

describe('helper functions', () => {
it('isManagerEnabled should return true when state is not DISABLED', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: { system: { argv: ['python', 'main.py'] } }
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({
supports_manager_v4_ui: true
})
vi.mocked(api.getServerFeature).mockReturnValue(true)
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.isManagerEnabled()).toBe(true)
})

it('isManagerEnabled should return false when state is DISABLED', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: {
system: { argv: ['python', 'main.py', '--disable-manager'] }
}
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({})
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.isManagerEnabled()).toBe(false)
})

it('isNewManagerUI should return true when state is NEW_UI', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: { system: { argv: ['python', 'main.py'] } }
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({
supports_manager_v4_ui: true
})
vi.mocked(api.getServerFeature).mockReturnValue(true)
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.isNewManagerUI()).toBe(true)
})

it('isLegacyManagerUI should return true when state is LEGACY_UI', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: {
system: { argv: ['python', 'main.py', '--enable-manager-legacy-ui'] }
}
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({})
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.isLegacyManagerUI()).toBe(true)
})

it('shouldShowInstallButton should return true only for NEW_UI', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: { system: { argv: ['python', 'main.py'] } }
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({
supports_manager_v4_ui: true
})
vi.mocked(api.getServerFeature).mockReturnValue(true)
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.shouldShowInstallButton()).toBe(true)
})

it('shouldShowManagerButtons should return true when not DISABLED', () => {
vi.mocked(useSystemStatsStore).mockReturnValue({
systemStats: { system: { argv: ['python', 'main.py'] } }
} as any)
vi.mocked(api.getClientFeatureFlags).mockReturnValue({
supports_manager_v4_ui: true
})
vi.mocked(api.getServerFeature).mockReturnValue(true)
vi.mocked(useExtensionStore).mockReturnValue({
extensions: []
} as any)

const store = useManagerStateStore()
expect(store.shouldShowManagerButtons()).toBe(true)
})
})
})