mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 14:54:37 +00:00
feat: add dynamic Fuse.js options loading for template filtering (#7822)
## Summary PRD: https://www.notion.so/comfy-org/Implement-Move-search-config-to-templates-repo-for-template-owner-adjustability-2c76d73d365081ad81c4ed33332eda09 Move search config to templates repo for template owner adjustability ## Changes - **What**: - Made `fuseOptions` reactive in `useTemplateFiltering` composable to support dynamic updates - Added `getFuseOptions()` API method to fetch Fuse.js configuration from `/templates/fuse_options.json` - Added `loadFuseOptions()` function to `useTemplateFiltering` that fetches and applies server-provided options - Removed unused `templateFuse` computed property from `workflowTemplatesStore` - Added comprehensive unit tests covering success, null response, error handling, and Fuse instance recreation scenarios - **Breaking**: None - **Dependencies**: None (uses existing `fuse.js` and `axios` dependencies) ## Review Focus - Verify that the API endpoint path `/templates/fuse_options.json` is correct and accessible - Confirm that the reactive `fuseOptions` properly triggers Fuse instance recreation when updated - Check that error handling gracefully falls back to default options when server fetch fails - Ensure the watch on `fuseOptions` is necessary or can be removed (currently just recreates Fuse via computed) - Review test coverage to ensure all edge cases are handled ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7822-feat-add-dynamic-Fuse-js-options-loading-for-template-filtering-2db6d73d365081828103d8ee70844b2e) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -10,7 +10,10 @@ import type {
|
||||
} from '@/platform/assets/schemas/assetSchema'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||
import { type WorkflowTemplates } from '@/platform/workflow/templates/types/template'
|
||||
import {
|
||||
type TemplateInfo,
|
||||
type WorkflowTemplates
|
||||
} from '@/platform/workflow/templates/types/template'
|
||||
import type {
|
||||
ComfyApiWorkflow,
|
||||
ComfyWorkflowJSON,
|
||||
@@ -51,6 +54,7 @@ import type { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||
import type { AuthHeader } from '@/types/authTypes'
|
||||
import type { NodeExecutionId } from '@/types/nodeIdentification'
|
||||
import { fetchHistory } from '@/platform/remote/comfyui/history'
|
||||
import type { IFuseOptions } from 'fuse.js'
|
||||
|
||||
interface QueuePromptRequestBody {
|
||||
client_id: string
|
||||
@@ -1269,6 +1273,29 @@ export class ComfyApi extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Fuse options from the server.
|
||||
*
|
||||
* @returns The Fuse options, or null if not found or invalid
|
||||
*/
|
||||
async getFuseOptions(): Promise<IFuseOptions<TemplateInfo> | null> {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
this.fileURL('/templates/fuse_options.json'),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
const contentType = res.headers['content-type']
|
||||
return contentType?.includes('application/json') ? res.data : null
|
||||
} catch (error) {
|
||||
console.error('Error loading fuse options:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom nodes i18n data from the server.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user