Skip to content

Checkpoint/Lora info menu not being added to Efficient SDXL Loader #477

Open
@druggedhippo

Description

@druggedhippo

This line:

const split = pos === -1 ? [n] : [n.substring(0, pos), n.substring(pos + 1)];

Is incorrect. It assumes that the "." represents a nested object and doesn't work correctly with the text in the default setting:

["CheckpointLoader.ckpt_name", "CheckpointLoaderSimple", "CheckpointLoader|pysssss", "Efficient Loader", "Eff. Loader SDXL"].join(",")

When parsed it results in an array like so:

{"CheckpointLoader":{"ckpt_name":true},"CheckpointLoaderSimple":{"":true},"CheckpointLoader|pysssss":{"":true},"Efficient Loader":{"":true},"Eff":{" Loader SDXL":true}}

Which fails matching the "Eff. Loader SDXL" and the menu is not created. Example of a suggested fix is to check if there a space immediately after the dot, and if there is, assume it is not a nested object.

lookups[type] = value.split(",").reduce((p, n) => {
    n = n.trim();
    const pos = n.indexOf(".");

    // Determine if the string should be split based on the dot.
    // Split only if a dot exists AND the part after the dot contains no spaces.
    // This is a heuristic based on the observed data like "Eff. Loader SDXL".
    const shouldSplit = pos !== -1 && n.substring(pos + 1).indexOf(" ") === -1;

    let mainKey;
    let nestedKey;

    if (shouldSplit) {
        mainKey = n.substring(0, pos);
        nestedKey = n.substring(pos + 1);
    } else {
        // If not splitting, the entire string is the main key
        mainKey = n;
        // Use an empty string as the nested key for items without a clear nested part
        nestedKey = "";
    }

    // Ensure the main key exists as an object
    p[mainKey] ??= {};

    // Set the nested key within the main key's object
    p[mainKey][nestedKey] = true;

    return p;
}, {}); // Added initial value for reduce as an empty object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions