Update SPEC.md with hierarchical autocomplete design
This commit is contained in:
9
SPEC.md
9
SPEC.md
@@ -163,16 +163,15 @@ else:
|
||||
### Responsibilities
|
||||
1. **Register Extension:** Use `app.registerExtension({ name: "CompassImageLoader", ... })`.
|
||||
2. **Dynamic Combo Refresh:** Listen for the `fresh-node-defs` event fired by ComfyUI's `api.js` (which happens on startup and when the user clicks Refresh). When received, update the `directory` combo widget on existing node instances with the latest values from the node's definition.
|
||||
3. **Autocomplete / Filtering:** Override the `directory` combo widget behavior to allow the user to type and filter the dropdown list in real-time (rgthree-style). The filtered list should be case-insensitive.
|
||||
4. **State Preservation:** Ensure the user's selected `directory` value is preserved across page reloads and workflow loads. Do not reset the value when refreshing the combo list unless the previously selected value is no longer in the new list.
|
||||
3. **Hierarchical Directory Autocomplete:** The `directory` field is driven by a text input that builds a path segment-by-segment. As the user types, the dropdown shows only **direct child directories** of the currently-typed prefix. When the user selects a child, it is appended with a trailing `/`, and the next focus/input shows only the children of that new prefix. This continues recursively, allowing the user to drill down into arbitrarily-deep directory trees.
|
||||
4. **Stop on Direction Detection:** The autocomplete filters are applied against the **full list of eligible parent paths** discovered by the backend. For each level, only the immediate next segment is shown — not any deeper paths. This means the user naturally stops at the level where they intend to set the `direction` widget.
|
||||
5. **State Preservation:** Ensure the user's selected `directory` value is preserved across page reloads and workflow loads.
|
||||
|
||||
---
|
||||
|
||||
## Backend API for Frontend Refresh
|
||||
|
||||
To support the frontend refreshing the directory list without reloading the page, the backend exposes a lightweight HTTP endpoint. However, the standard ComfyUI pattern is to rely on the node definition refresh (clicking the Refresh button in the UI), which re-fetches `api.getNodeDefs()`. Therefore, the node must ensure its `INPUT_TYPES` classmethod dynamically rebuilds the directory list every time it is called.
|
||||
|
||||
No custom API endpoint is required. The frontend simply refreshes the combo values from the re-fetched node definition.
|
||||
The frontend extension works by maintaining the **full list** of eligible directory paths (discovered by `INPUT_TYPES`) in `_all_values`. It does not need to call any custom endpoint — it simply filters that full list to show only the next level down on each interaction. The `_discover_children` helper function is defined in the backend for completeness but is not currently called by the frontend.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user