Merge remote-tracking branch 'origin/main' into feat/new-workflow-templates

This commit is contained in:
Johnpaul
2025-09-05 20:22:26 +01:00
614 changed files with 37783 additions and 9017 deletions

View File

@@ -12,7 +12,7 @@ This directory contains the service layer for the ComfyUI frontend application.
## Overview
Services in ComfyUI provide organized modules that implement the application's functionality and logic. They handle operations such as API communication, workflow management, user settings, and other essential features.
Services in ComfyUI provide organized modules that implement the application's functionality and logic. They handle operations such as API communication, workflow management, user settings, and other essential features.
The term "business logic" in this context refers to the code that implements the core functionality and behavior of the application - the rules, processes, and operations that make ComfyUI work as expected, separate from the UI display code.
@@ -57,21 +57,25 @@ While services can interact with both UI components and stores (centralized stat
## Core Services
The following table lists ALL services in the system as of 2025-01-30:
The following table lists ALL services in the system as of 2025-09-01:
### Main Services
| Service | Description | Category |
|---------|-------------|----------|
| audioService.ts | Manages audio recording and WAV encoding functionality | Media |
| autoQueueService.ts | Manages automatic queue execution | Execution |
| colorPaletteService.ts | Handles color palette management and customization | UI |
| comfyManagerService.ts | Manages ComfyUI application packages and updates | Manager |
| comfyRegistryService.ts | Handles registration and discovery of ComfyUI extensions | Registry |
| customerEventsService.ts | Handles customer event tracking and audit logs | Analytics |
| dialogService.ts | Provides dialog and modal management | UI |
| extensionService.ts | Manages extension registration and lifecycle | Extensions |
| keybindingService.ts | Handles keyboard shortcuts and keybindings | Input |
| litegraphService.ts | Provides utilities for working with the LiteGraph library | Graph |
| load3dService.ts | Manages 3D model loading and visualization | 3D |
| mediaCacheService.ts | Manages media file caching with blob storage and cleanup | Media |
| newUserService.ts | Handles new user initialization and onboarding | System |
| nodeHelpService.ts | Provides node documentation and help | Nodes |
| nodeOrganizationService.ts | Handles node organization and categorization | Nodes |
| nodeSearchService.ts | Implements node search functionality | Search |
@@ -105,47 +109,82 @@ For complex services with state management and multiple methods, class-based ser
```typescript
export class NodeSearchService {
// Service state
private readonly nodeFuseSearch: FuseSearch<ComfyNodeDefImpl>
private readonly filters: Record<string, FuseFilter<ComfyNodeDefImpl, string>>
public readonly nodeFuseSearch: FuseSearch<ComfyNodeDefImpl>
public readonly inputTypeFilter: FuseFilter<ComfyNodeDefImpl, string>
public readonly outputTypeFilter: FuseFilter<ComfyNodeDefImpl, string>
public readonly nodeCategoryFilter: FuseFilter<ComfyNodeDefImpl, string>
public readonly nodeSourceFilter: FuseFilter<ComfyNodeDefImpl, string>
constructor(data: ComfyNodeDefImpl[]) {
// Initialize state
this.nodeFuseSearch = new FuseSearch(data, { /* options */ })
// Setup filters
this.filters = {
inputType: new FuseFilter<ComfyNodeDefImpl, string>(/* options */),
category: new FuseFilter<ComfyNodeDefImpl, string>(/* options */)
}
// Initialize search index
this.nodeFuseSearch = new FuseSearch(data, {
fuseOptions: {
keys: ['name', 'display_name'],
includeScore: true,
threshold: 0.3,
shouldSort: false,
useExtendedSearch: true
},
createIndex: true,
advancedScoring: true
})
// Setup individual filters
const fuseOptions = { includeScore: true, threshold: 0.3, shouldSort: true }
this.inputTypeFilter = new FuseFilter<ComfyNodeDefImpl, string>(data, {
id: 'input',
name: 'Input Type',
invokeSequence: 'i',
getItemOptions: (node) => Object.values(node.inputs).map((input) => input.type),
fuseOptions
})
// Additional filters initialized similarly...
}
public searchNode(query: string, filters: FuseFilterWithValue[] = []): ComfyNodeDefImpl[] {
// Implementation
return results
public searchNode(
query: string,
filters: FuseFilterWithValue<ComfyNodeDefImpl, string>[] = []
): ComfyNodeDefImpl[] {
const matchedNodes = this.nodeFuseSearch.search(query)
return matchedNodes.filter((node) => {
return filters.every((filterAndValue) => {
const { filterDef, value } = filterAndValue
return filterDef.matches(node, value, { wildcard: '*' })
})
})
}
get nodeFilters(): FuseFilter<ComfyNodeDefImpl, string>[] {
return [
this.inputTypeFilter,
this.outputTypeFilter,
this.nodeCategoryFilter,
this.nodeSourceFilter
]
}
}
```
### 2. Composable-style Services
For simpler services or those that need to integrate with Vue's reactivity system, we prefer using composable-style services:
For services that need to integrate with Vue's reactivity system or handle API interactions, we use composable-style services:
```typescript
export function useNodeSearchService(initialData: ComfyNodeDefImpl[]) {
// State (reactive if needed)
const data = ref(initialData)
// Search functionality
function searchNodes(query: string) {
// Implementation
return results
}
// Additional methods
function refreshData(newData: ComfyNodeDefImpl[]) {
data.value = newData
}
// Return public API
return {
searchNodes,
@@ -154,12 +193,35 @@ export function useNodeSearchService(initialData: ComfyNodeDefImpl[]) {
}
```
When deciding between these approaches, consider:
### Service Pattern Comparison
1. **Stateful vs. Stateless**: For stateful services, classes often provide clearer encapsulation
2. **Reactivity needs**: If the service needs to be reactive, composable-style services integrate better with Vue's reactivity system
3. **Complexity**: For complex services with many methods and internal state, classes can provide better organization
4. **Testing**: Both approaches can be tested effectively, but composables may be simpler to test with Vue Test Utils
| Aspect | Class-Based Services | Composable-Style Services | Bootstrap Services | Shared State Services |
|--------|---------------------|---------------------------|-------------------|---------------------|
| **Count** | 4 services | 18+ services | 1 service | 1 service |
| **Export Pattern** | `export class ServiceName` | `export function useServiceName()` | `export function setupX()` | `export function serviceFactory()` |
| **Instantiation** | `new ServiceName(data)` | `useServiceName()` | Direct function call | Direct function call |
| **Best For** | Complex data structures, search algorithms, expensive initialization | Vue integration, API calls, reactive state | One-time app initialization | Singleton-like shared state |
| **State Management** | Encapsulated private/public properties | External stores + reactive refs | Event listeners, side effects | Module-level state |
| **Vue Integration** | Manual integration needed | Native reactivity support | N/A | Varies |
| **Examples** | `NodeSearchService`, `Load3dService` | `workflowService`, `dialogService` | `autoQueueService` | `newUserService` |
### Decision Criteria
When choosing between these approaches, consider:
1. **Data Structure Complexity**: Classes work well for services managing multiple related data structures (search indices, filters, complex state)
2. **Initialization Cost**: Classes are ideal when expensive setup should happen once and be controlled by instantiation
3. **Vue Integration**: Composables integrate seamlessly with Vue's reactivity system and stores
4. **API Interactions**: Composables handle async operations and API calls more naturally
5. **State Management**: Classes provide strong encapsulation; composables work better with external state management
6. **Application Bootstrap**: Bootstrap services handle one-time app initialization, event listener setup, and side effects
7. **Singleton Behavior**: Shared state services provide module-level state that persists across multiple function calls
**Current Usage Patterns:**
- **Class-based services (4)**: Complex data processing, search algorithms, expensive initialization
- **Composable-style services (18+)**: UI interactions, API calls, store integration, reactive state management
- **Bootstrap services (1)**: One-time application initialization and event handler setup
- **Shared state services (1)**: Singleton-like behavior with module-level state management
### Service Template
@@ -172,7 +234,7 @@ Here's a template for creating a new composable-style service:
export function useExampleService() {
// Private state/functionality
const cache = new Map()
/**
* Description of what this method does
* @param param1 Description of parameter
@@ -188,7 +250,7 @@ export function useExampleService() {
throw error
}
}
// Return public API
return {
performOperation
@@ -206,16 +268,16 @@ Services in ComfyUI frequently use the following design patterns:
export function useCachedService() {
const cache = new Map()
const pendingRequests = new Map()
async function fetchData(key: string) {
// Check cache first
if (cache.has(key)) return cache.get(key)
// Check if request is already in progress
if (pendingRequests.has(key)) {
return pendingRequests.get(key)
}
// Perform new request
const requestPromise = fetch(`/api/${key}`)
.then(response => response.json())
@@ -224,11 +286,11 @@ export function useCachedService() {
pendingRequests.delete(key)
return data
})
pendingRequests.set(key, requestPromise)
return requestPromise
}
return { fetchData }
}
```
@@ -248,7 +310,7 @@ export function useNodeFactory() {
throw new Error(`Unknown node type: ${type}`)
}
}
return { createNode }
}
```
@@ -267,11 +329,243 @@ export function useWorkflowService(
const storagePath = await storageService.getPath(name)
return apiService.saveData(storagePath, graphData)
}
return { saveWorkflow }
}
```
## Testing Services
Services in ComfyUI can be tested effectively using different approaches depending on their implementation pattern.
### Testing Class-Based Services
**Setup Requirements:**
```typescript
// Manual instantiation required
const mockData = [/* test data */]
const service = new NodeSearchService(mockData)
```
**Characteristics:**
- Requires constructor argument preparation
- State is encapsulated within the class instance
- Direct method calls on the instance
- Good isolation - each test gets a fresh instance
**Example:**
```typescript
describe('NodeSearchService', () => {
let service: NodeSearchService
beforeEach(() => {
const mockNodes = [/* mock node definitions */]
service = new NodeSearchService(mockNodes)
})
test('should search nodes by query', () => {
const results = service.searchNode('test query')
expect(results).toHaveLength(2)
})
test('should apply filters correctly', () => {
const filters = [{ filterDef: service.inputTypeFilter, value: 'IMAGE' }]
const results = service.searchNode('*', filters)
expect(results.every(node => /* has IMAGE input */)).toBe(true)
})
})
```
### Testing Composable-Style Services
**Setup Requirements:**
```typescript
// Direct function call, no instantiation
const { saveWorkflow, loadWorkflow } = useWorkflowService()
```
**Characteristics:**
- No instantiation needed
- Integrates naturally with Vue Test Utils
- Easy mocking of reactive dependencies
- External store dependencies need mocking
**Example:**
```typescript
describe('useWorkflowService', () => {
beforeEach(() => {
// Mock external dependencies
vi.mock('@/stores/settingStore', () => ({
useSettingStore: () => ({
get: vi.fn().mockReturnValue(true),
set: vi.fn()
})
}))
vi.mock('@/stores/toastStore', () => ({
useToastStore: () => ({
add: vi.fn()
})
}))
})
test('should save workflow with prompt', async () => {
const { saveWorkflow } = useWorkflowService()
await saveWorkflow('test-workflow')
// Verify interactions with mocked dependencies
expect(mockSettingStore.get).toHaveBeenCalledWith('Comfy.PromptFilename')
})
})
```
### Testing Bootstrap Services
**Focus on Setup Behavior:**
```typescript
describe('autoQueueService', () => {
beforeEach(() => {
// Mock global dependencies
vi.mock('@/scripts/api', () => ({
api: {
addEventListener: vi.fn()
}
}))
vi.mock('@/scripts/app', () => ({
app: {
queuePrompt: vi.fn()
}
}))
})
test('should setup event listeners', () => {
setupAutoQueueHandler()
expect(mockApi.addEventListener).toHaveBeenCalledWith('graphChanged', expect.any(Function))
})
test('should handle graph changes when auto-queue enabled', () => {
setupAutoQueueHandler()
// Simulate graph change event
const graphChangeHandler = mockApi.addEventListener.mock.calls[0][1]
graphChangeHandler()
expect(mockApp.queuePrompt).toHaveBeenCalled()
})
})
```
### Testing Shared State Services
**Focus on Shared State Behavior:**
```typescript
describe('newUserService', () => {
beforeEach(() => {
// Reset module state between tests
vi.resetModules()
})
test('should return consistent API across calls', () => {
const service1 = newUserService()
const service2 = newUserService()
// Same functions returned (shared behavior)
expect(service1.isNewUser).toBeDefined()
expect(service2.isNewUser).toBeDefined()
})
test('should share state between service instances', async () => {
const service1 = newUserService()
const service2 = newUserService()
// Initialize through one instance
const mockSettingStore = { set: vi.fn() }
await service1.initializeIfNewUser(mockSettingStore)
// State should be shared
expect(service2.isNewUser()).toBe(true) // or false, depending on mock
})
})
```
### Common Testing Patterns
**Mocking External Dependencies:**
```typescript
// Mock stores
vi.mock('@/stores/settingStore', () => ({
useSettingStore: () => ({
get: vi.fn(),
set: vi.fn()
})
}))
// Mock API calls
vi.mock('@/scripts/api', () => ({
api: {
get: vi.fn().mockResolvedValue({ data: 'mock' }),
post: vi.fn().mockResolvedValue({ success: true })
}
}))
// Mock Vue composables
vi.mock('vue', () => ({
ref: vi.fn((val) => ({ value: val })),
reactive: vi.fn((obj) => obj)
}))
```
**Async Testing:**
```typescript
test('should handle async operations', async () => {
const service = useMyService()
const result = await service.performAsyncOperation()
expect(result).toBeTruthy()
})
test('should handle concurrent requests', async () => {
const service = useMyService()
const promises = [
service.loadData('key1'),
service.loadData('key2')
]
const results = await Promise.all(promises)
expect(results).toHaveLength(2)
})
```
**Error Handling:**
```typescript
test('should handle service errors gracefully', async () => {
const service = useMyService()
// Mock API to throw error
mockApi.get.mockRejectedValue(new Error('Network error'))
await expect(service.fetchData()).rejects.toThrow('Network error')
})
test('should provide meaningful error messages', async () => {
const service = useMyService()
const consoleSpy = vi.spyOn(console, 'error').mockImplementation()
await service.handleError('test error')
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('test error'))
})
```
### Testing Best Practices
1. **Isolate Dependencies**: Always mock external dependencies (stores, APIs, DOM)
2. **Reset State**: Use `beforeEach` to ensure clean test state
3. **Test Error Paths**: Don't just test happy paths - test error scenarios
4. **Mock Timers**: Use `vi.useFakeTimers()` for time-dependent services
5. **Test Async Properly**: Use `async/await` and proper promise handling
For more detailed information about the service layer pattern and its applications, refer to:
- [Service Layer Pattern](https://en.wikipedia.org/wiki/Service_layer_pattern)
- [Service-Orientation](https://en.wikipedia.org/wiki/Service-orientation)

View File

@@ -1,17 +1,18 @@
import axios, { AxiosError, AxiosResponse } from 'axios'
import { v4 as uuidv4 } from 'uuid'
import { ref } from 'vue'
import { api } from '@/scripts/api'
import {
type InstallPackParams,
type InstalledPacksResponse,
type ManagerPackInfo,
type ManagerQueueStatus,
SelectedVersion,
type UpdateAllPacksParams
} from '@/types/comfyManagerTypes'
import { components } from '@/types/generatedManagerTypes'
import { isAbortError } from '@/utils/typeGuardUtil'
type ManagerQueueStatus = components['schemas']['QueueStatus']
type InstallPackParams = components['schemas']['InstallPackParams']
type InstalledPacksResponse = components['schemas']['InstalledPacksResponse']
type UpdateAllPacksParams = components['schemas']['UpdateAllPacksParams']
type ManagerTaskHistory = components['schemas']['HistoryResponse']
type QueueTaskItem = components['schemas']['QueueTaskItem']
const GENERIC_SECURITY_ERR_MSG =
'Forbidden: A security error has occurred. Please check the terminal logs'
@@ -22,21 +23,19 @@ enum ManagerRoute {
START_QUEUE = 'manager/queue/start',
RESET_QUEUE = 'manager/queue/reset',
QUEUE_STATUS = 'manager/queue/status',
INSTALL = 'manager/queue/install',
UPDATE = 'manager/queue/update',
UPDATE_ALL = 'manager/queue/update_all',
UNINSTALL = 'manager/queue/uninstall',
DISABLE = 'manager/queue/disable',
FIX_NODE = 'manager/queue/fix',
LIST_INSTALLED = 'customnode/installed',
GET_NODES = 'customnode/getmappings',
GET_PACKS = 'customnode/getlist',
IMPORT_FAIL_INFO = 'customnode/import_fail_info',
REBOOT = 'manager/reboot'
IMPORT_FAIL_INFO_BULK = 'customnode/import_fail_info_bulk',
REBOOT = 'manager/reboot',
IS_LEGACY_MANAGER_UI = 'manager/is_legacy_manager_ui',
TASK_HISTORY = 'manager/queue/history',
QUEUE_TASK = 'manager/queue/task'
}
const managerApiClient = axios.create({
baseURL: api.apiURL(''),
baseURL: api.apiURL('/v2/'),
headers: {
'Content-Type': 'application/json'
}
@@ -49,7 +48,6 @@ const managerApiClient = axios.create({
export const useComfyManagerService = () => {
const isLoading = ref(false)
const error = ref<string | null>(null)
const didStartQueue = ref(false)
const handleRequestError = (
err: unknown,
@@ -110,28 +108,21 @@ export const useComfyManagerService = () => {
201: 'Created: ComfyUI-Manager job queue is already running'
}
didStartQueue.value = true
return executeRequest<null>(
() => managerApiClient.get(ManagerRoute.START_QUEUE, { signal }),
{ errorContext, routeSpecificErrors }
)
}
const getQueueStatus = async (signal?: AbortSignal) => {
const getQueueStatus = async (client_id?: string, signal?: AbortSignal) => {
const errorContext = 'Getting ComfyUI-Manager queue status'
return executeRequest<ManagerQueueStatus>(
() => managerApiClient.get(ManagerRoute.QUEUE_STATUS, { signal }),
{ errorContext }
)
}
const resetQueue = async (signal?: AbortSignal) => {
const errorContext = 'Resetting ComfyUI-Manager queue'
return executeRequest<null>(
() => managerApiClient.get(ManagerRoute.RESET_QUEUE, { signal }),
() =>
managerApiClient.get(ManagerRoute.QUEUE_STATUS, {
params: client_id ? { client_id } : undefined,
signal
}),
{ errorContext }
)
}
@@ -154,73 +145,81 @@ export const useComfyManagerService = () => {
)
}
const installPack = async (
params: InstallPackParams,
const getImportFailInfoBulk = async (
params: components['schemas']['ImportFailInfoBulkRequest'] = {},
signal?: AbortSignal
) => {
const errorContext = `Installing pack ${params.id}`
const errorContext = 'Fetching bulk import failure information'
return executeRequest<components['schemas']['ImportFailInfoBulkResponse']>(
() =>
managerApiClient.post(ManagerRoute.IMPORT_FAIL_INFO_BULK, params, {
signal
}),
{ errorContext }
)
}
const queueTask = async (
kind: QueueTaskItem['kind'],
params: QueueTaskItem['params'],
ui_id?: string,
signal?: AbortSignal
) => {
const task: QueueTaskItem = {
kind,
params,
ui_id: ui_id || uuidv4(),
client_id: api.clientId ?? api.initialClientId ?? 'unknown'
}
const errorContext = `Queueing ${task.kind} task`
const routeSpecificErrors = {
403: GENERIC_SECURITY_ERR_MSG,
404:
params.selected_version === SelectedVersion.NIGHTLY
? `Not Found: Node pack ${params.id} does not provide nightly version`
: GENERIC_SECURITY_ERR_MSG
404: `Not Found: Task could not be queued`
}
return executeRequest<null>(
() => managerApiClient.post(ManagerRoute.INSTALL, params, { signal }),
() => managerApiClient.post(ManagerRoute.QUEUE_TASK, task, { signal }),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
}
const installPack = async (
params: InstallPackParams,
ui_id?: string,
signal?: AbortSignal
) => {
return queueTask('install', params, ui_id, signal)
}
const uninstallPack = async (
params: ManagerPackInfo,
params: components['schemas']['UninstallPackParams'],
ui_id?: string,
signal?: AbortSignal
) => {
const errorContext = `Uninstalling pack ${params.id}`
const routeSpecificErrors = {
403: GENERIC_SECURITY_ERR_MSG
}
return executeRequest<null>(
() => managerApiClient.post(ManagerRoute.UNINSTALL, params, { signal }),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
return queueTask('uninstall', params, ui_id, signal)
}
const disablePack = async (
params: ManagerPackInfo,
params: components['schemas']['DisablePackParams'],
ui_id?: string,
signal?: AbortSignal
): Promise<null> => {
const errorContext = `Disabling pack ${params.id}`
const routeSpecificErrors = {
404: `Pack ${params.id} not found or not installed`,
409: `Pack ${params.id} is already disabled`
}
return executeRequest<null>(
() => managerApiClient.post(ManagerRoute.DISABLE, params, { signal }),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
return queueTask('disable', params, ui_id, signal)
}
const updatePack = async (
params: ManagerPackInfo,
params: components['schemas']['UpdatePackParams'],
ui_id?: string,
signal?: AbortSignal
): Promise<null> => {
const errorContext = `Updating pack ${params.id}`
const routeSpecificErrors = {
403: GENERIC_SECURITY_ERR_MSG
}
return executeRequest<null>(
() => managerApiClient.post(ManagerRoute.UPDATE, params, { signal }),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
return queueTask('update', params, ui_id, signal)
}
const updateAllPacks = async (
params?: UpdateAllPacksParams,
params: UpdateAllPacksParams = {},
ui_id?: string,
signal?: AbortSignal
) => {
const errorContext = 'Updating all packs'
@@ -229,8 +228,18 @@ export const useComfyManagerService = () => {
401: 'Unauthorized: ComfyUI-Manager job queue is busy'
}
const queryParams = {
mode: params.mode,
client_id: api.clientId ?? api.initialClientId ?? 'unknown',
ui_id: ui_id || uuidv4()
}
return executeRequest<null>(
() => managerApiClient.get(ManagerRoute.UPDATE_ALL, { params, signal }),
() =>
managerApiClient.get(ManagerRoute.UPDATE_ALL, {
params: queryParams,
signal
}),
{ errorContext, routeSpecificErrors, isQueueOperation: true }
)
}
@@ -247,6 +256,36 @@ export const useComfyManagerService = () => {
)
}
const isLegacyManagerUI = async (signal?: AbortSignal) => {
const errorContext = 'Checking if user set Manager to use the legacy UI'
return executeRequest<{ is_legacy_manager_ui: boolean }>(
() => managerApiClient.get(ManagerRoute.IS_LEGACY_MANAGER_UI, { signal }),
{ errorContext }
)
}
const getTaskHistory = async (
options: {
ui_id?: string
max_items?: number
client_id?: string
offset?: number
} = {},
signal?: AbortSignal
) => {
const errorContext = 'Getting ComfyUI-Manager task history'
return executeRequest<ManagerTaskHistory>(
() =>
managerApiClient.get(ManagerRoute.TASK_HISTORY, {
params: options,
signal
}),
{ errorContext }
)
}
return {
// State
isLoading,
@@ -254,12 +293,13 @@ export const useComfyManagerService = () => {
// Queue operations
startQueue,
resetQueue,
getQueueStatus,
getTaskHistory,
// Pack management
listInstalledPacks,
getImportFailInfo,
getImportFailInfoBulk,
installPack,
uninstallPack,
enablePack: installPack, // enable is done via install
@@ -268,6 +308,7 @@ export const useComfyManagerService = () => {
updateAllPacks,
// System operations
rebootComfyUI
rebootComfyUI,
isLegacyManagerUI
}
}

View File

@@ -359,6 +359,55 @@ export const useComfyRegistryService = () => {
)
}
/**
* Get multiple pack versions in a single bulk request.
* This is more efficient than making individual requests for each pack version.
*
* @param nodeVersions - Array of node ID and version pairs to retrieve
* @param signal - Optional AbortSignal for request cancellation
* @returns Bulk response containing the requested node versions or null on error
*
* @example
* ```typescript
* const versions = await getBulkNodeVersions([
* { node_id: 'ComfyUI-Manager', version: '1.0.0' },
* { node_id: 'ComfyUI-Impact-Pack', version: '2.0.0' }
* ])
* if (versions) {
* versions.node_versions.forEach(result => {
* if (result.status === 'success' && result.node_version) {
* console.log(`Retrieved ${result.identifier.node_id}@${result.identifier.version}`)
* }
* })
* }
* ```
*/
const getBulkNodeVersions = async (
nodeVersions: components['schemas']['NodeVersionIdentifier'][],
signal?: AbortSignal
) => {
const endpoint = '/bulk/nodes/versions'
const errorContext = 'Failed to get bulk node versions'
const routeSpecificErrors = {
400: 'Bad request: Invalid node version identifiers provided'
}
const requestBody: components['schemas']['BulkNodeVersionsRequest'] = {
node_versions: nodeVersions
}
return executeApiRequest(
() =>
registryApiClient.post<
components['schemas']['BulkNodeVersionsResponse']
>(endpoint, requestBody, {
signal
}),
errorContext,
routeSpecificErrors
)
}
return {
isLoading,
error,
@@ -372,6 +421,7 @@ export const useComfyRegistryService = () => {
listPacksForPublisher,
getNodeDefs,
postPackReview,
inferPackFromNodeName
inferPackFromNodeName,
getBulkNodeVersions
}
}

View File

@@ -5,7 +5,6 @@ import WorkflowTemplateSelector from '@/components/custom/widget/WorkflowTemplat
import ApiNodesSignInContent from '@/components/dialog/content/ApiNodesSignInContent.vue'
import ConfirmationDialogContent from '@/components/dialog/content/ConfirmationDialogContent.vue'
import ErrorDialogContent from '@/components/dialog/content/ErrorDialogContent.vue'
import IssueReportDialogContent from '@/components/dialog/content/IssueReportDialogContent.vue'
import LoadWorkflowWarning from '@/components/dialog/content/LoadWorkflowWarning.vue'
import ManagerProgressDialogContent from '@/components/dialog/content/ManagerProgressDialogContent.vue'
import MissingModelsWarning from '@/components/dialog/content/MissingModelsWarning.vue'
@@ -16,6 +15,9 @@ import TopUpCreditsDialogContent from '@/components/dialog/content/TopUpCreditsD
import UpdatePasswordContent from '@/components/dialog/content/UpdatePasswordContent.vue'
import ManagerDialogContent from '@/components/dialog/content/manager/ManagerDialogContent.vue'
import ManagerHeader from '@/components/dialog/content/manager/ManagerHeader.vue'
import NodeConflictDialogContent from '@/components/dialog/content/manager/NodeConflictDialogContent.vue'
import NodeConflictFooter from '@/components/dialog/content/manager/NodeConflictFooter.vue'
import NodeConflictHeader from '@/components/dialog/content/manager/NodeConflictHeader.vue'
import ManagerProgressFooter from '@/components/dialog/footer/ManagerProgressFooter.vue'
import ComfyOrgHeader from '@/components/dialog/header/ComfyOrgHeader.vue'
import ManagerProgressHeader from '@/components/dialog/header/ManagerProgressHeader.vue'
@@ -29,6 +31,7 @@ import {
type ShowDialogOptions,
useDialogStore
} from '@/stores/dialogStore'
import type { ConflictDetectionResult } from '@/types/conflictDetectionTypes'
export type ConfirmationDialogType =
| 'default'
@@ -152,16 +155,6 @@ export const useDialogService = () => {
})
}
function showIssueReportDialog(
props: InstanceType<typeof IssueReportDialogContent>['$props']
) {
dialogStore.showDialog({
key: 'global-issue-report',
component: IssueReportDialogContent,
props
})
}
function showManagerDialog(
props: InstanceType<typeof ManagerDialogContent>['$props'] = {}
) {
@@ -178,9 +171,9 @@ export const useDialogService = () => {
'bg-gray-500 dark-theme:bg-neutral-700 w-9 h-9 p-1.5 rounded-full text-white'
}
},
header: { class: '!py-0 px-6 !m-0 h-[68px]' },
header: { class: 'py-0! px-6 m-0! h-[68px]' },
content: {
class: '!p-0 h-full w-[90vw] max-w-full flex-1 overflow-hidden'
class: 'p-0! h-full w-[90vw] max-w-full flex-1 overflow-hidden'
},
root: { class: 'manager-dialog' }
}
@@ -205,70 +198,14 @@ export const useDialogService = () => {
position: 'bottom',
pt: {
root: { class: 'w-[80%] max-w-2xl mx-auto border-none' },
content: { class: '!p-0' },
header: { class: '!p-0 border-none' },
footer: { class: '!p-0 border-none' }
content: { class: 'p-0!' },
header: { class: 'p-0! border-none' },
footer: { class: 'p-0! border-none' }
}
}
})
}
function parseError(error: Error) {
const filename =
'fileName' in error
? (error.fileName as string)
: error.stack?.match(/(\/extensions\/.*\.js)/)?.[1]
const extensionFile = filename
? filename.substring(filename.indexOf('/extensions/'))
: undefined
return {
errorMessage: error.toString(),
stackTrace: error.stack,
extensionFile
}
}
/**
* Show a error dialog to the user when an error occurs.
* @param error The error to show
* @param options The options for the dialog
*/
function showErrorDialog(
error: unknown,
options: {
title?: string
reportType?: string
} = {}
) {
const errorProps: {
errorMessage: string
stackTrace?: string
extensionFile?: string
} =
error instanceof Error
? parseError(error)
: {
errorMessage: String(error)
}
const props: InstanceType<typeof ErrorDialogContent>['$props'] = {
error: {
exceptionType: options.title ?? 'Unknown Error',
exceptionMessage: errorProps.errorMessage,
traceback: errorProps.stackTrace ?? t('errorDialog.noStackTrace'),
reportType: options.reportType
}
}
dialogStore.showDialog({
key: 'global-error',
component: ErrorDialogContent,
props
})
}
/**
* Shows a dialog requiring sign in for API nodes
* @returns Promise that resolves to true if user clicks login, false if cancelled
@@ -400,7 +337,7 @@ export const useDialogService = () => {
props: options,
dialogComponentProps: {
pt: {
header: { class: '!p-3' }
header: { class: 'p-3!' }
}
}
})
@@ -474,10 +411,10 @@ export const useDialogService = () => {
class: 'rounded-2xl overflow-hidden'
},
header: {
class: '!p-0 hidden'
class: 'p-0! hidden'
},
content: {
class: '!p-0 !m-0'
class: 'p-0! m-0!'
}
}
}
@@ -491,6 +428,54 @@ export const useDialogService = () => {
})
}
function showNodeConflictDialog(
options: {
showAfterWhatsNew?: boolean
conflictedPackages?: ConflictDetectionResult[]
dialogComponentProps?: DialogComponentProps
buttonText?: string
onButtonClick?: () => void
} = {}
) {
const {
dialogComponentProps,
buttonText,
onButtonClick,
showAfterWhatsNew,
conflictedPackages
} = options
return dialogStore.showDialog({
key: 'global-node-conflict',
headerComponent: NodeConflictHeader,
footerComponent: NodeConflictFooter,
component: NodeConflictDialogContent,
dialogComponentProps: {
closable: true,
pt: {
header: { class: '!p-0 !m-0' },
content: { class: '!p-0 overflow-y-hidden' },
footer: { class: '!p-0' },
pcCloseButton: {
root: {
class:
'!w-7 !h-7 !border-none !outline-none !p-2 !m-1.5 bg-gray-500 dark-theme:bg-neutral-700 text-white'
}
}
},
...dialogComponentProps
},
props: {
showAfterWhatsNew,
conflictedPackages
},
footerProps: {
buttonText,
onButtonClick
}
})
}
return {
showLoadWorkflowWarning,
showMissingModelsWarning,
@@ -499,10 +484,8 @@ export const useDialogService = () => {
showExecutionErrorDialog,
showTemplateWorkflowsDialog,
showWorkflowTemplateSelectorDialog,
showIssueReportDialog,
showManagerDialog,
showManagerProgressDialog,
showErrorDialog,
showApiNodesSignInDialog,
showSignInDialog,
showTopUpCreditsDialog,
@@ -512,6 +495,7 @@ export const useDialogService = () => {
confirm,
toggleManagerDialog,
toggleManagerProgressDialog,
showLayoutDialog
showLayoutDialog,
showNodeConflictDialog
}
}