Skip to content
Closed
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
45 changes: 45 additions & 0 deletions src/services/comfyManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ import { isAbortError } from '@/utils/typeGuardUtil'
const GENERIC_SECURITY_ERR_MSG =
'Forbidden: A security error has occurred. Please check the terminal logs'

// TODO: These types will be auto-generated once ComfyUI-Manager types are updated
// After the ComfyUI-Manager PR is merged and types are generated, replace these with the generated types
interface ImportFailInfoBulkRequest {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] low Priority\n\nIssue: Missing JSDoc documentation for type interfaces\nContext: While the function has good JSDoc, the temporary type interfaces lack documentation explaining their structure and usage\nSuggestion: Add JSDoc comments to ImportFailInfoBulkRequest, ImportFailInfoItem, and ImportFailInfoBulkResponse interfaces

cnr_ids?: string[]
urls?: string[]
}

interface ImportFailInfoItem {
error?: string | null
traceback?: string | null
}

type ImportFailInfoBulkResponse = Record<string, ImportFailInfoItem | null>

/**
* API routes for ComfyUI Manager
*/
Expand All @@ -32,6 +46,7 @@ enum ManagerRoute {
GET_NODES = 'customnode/getmappings',
GET_PACKS = 'customnode/getlist',
IMPORT_FAIL_INFO = 'customnode/import_fail_info',
IMPORT_FAIL_INFO_BULK = 'v2/customnode/import_fail_info_bulk',
REBOOT = 'manager/reboot'
}

Expand Down Expand Up @@ -154,6 +169,35 @@ export const useComfyManagerService = () => {
)
}

/**
* Retrieves import failure information for multiple custom nodes in bulk
* @param params - Object containing arrays of cnr_ids or urls to check
* @param signal - Optional AbortSignal for request cancellation
* @returns Dictionary mapping each cnr_id/url to its import failure info (or null if no failure)
*/
const getImportFailInfoBulk = async (
params: ImportFailInfoBulkRequest,
signal?: AbortSignal
) => {
const errorContext = 'Fetching bulk import failure information'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] medium Priority\n\nIssue: Hard-coded error message violates internationalization requirements\nContext: According to CLAUDE.md line 35, all user-facing strings must use vue-i18n - no hard-coded text in services/utilities\nSuggestion: Replace with i18n key and add translation entry in src/locales/en/main.json

const routeSpecificErrors = {
400: 'Bad Request: Either cnr_ids or urls field is required'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] high Priority\n\nIssue: Hard-coded error message violates internationalization requirements\nContext: According to CLAUDE.md line 35, all user-facing strings must use vue-i18n - no hard-coded text in services/utilities\nSuggestion: Replace with i18n key and add translation entry in src/locales/en/main.json

}

// Validate that at least one field is provided
if (!params.cnr_ids?.length && !params.urls?.length) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[architecture] medium Priority\n\nIssue: Validation logic inconsistency between client and server\nContext: Client throws error before making API call, but the API also handles 400 errors for the same validation. This creates potential race conditions and inconsistent error handling paths\nSuggestion: Either handle all validation on the server side and let the API return 400, or ensure client validation exactly matches server validation rules

throw new Error('Either cnr_ids or urls field is required')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] high Priority\n\nIssue: Hard-coded error message violates internationalization requirements\nContext: According to CLAUDE.md line 35, all user-facing strings must use vue-i18n - no hard-coded text in services/utilities\nSuggestion: Replace with i18n key and add translation entry in src/locales/en/main.json

}

return executeRequest<ImportFailInfoBulkResponse>(
() =>
managerApiClient.post(ManagerRoute.IMPORT_FAIL_INFO_BULK, params, {
signal
}),
{ errorContext, routeSpecificErrors }
)
}

const installPack = async (
params: InstallPackParams,
signal?: AbortSignal
Expand Down Expand Up @@ -260,6 +304,7 @@ export const useComfyManagerService = () => {
// Pack management
listInstalledPacks,
getImportFailInfo,
getImportFailInfoBulk,
installPack,
uninstallPack,
enablePack: installPack, // enable is done via install
Expand Down