mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-08-16 10:43:21 -03:00
feat(autocomplete): replace /af and /ac toggle abbreviations with full command names
This commit is contained in:
@@ -1667,7 +1667,7 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
expect(input.value).toBe('looking_to_the_side,');
|
expect(input.value).toBe('looking_to_the_side,');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows /af command for loras when active-filters autocomplete is off (default)', async () => {
|
it('shows /activefilters command for loras when active-filters autocomplete is off (default)', async () => {
|
||||||
const input = document.createElement('textarea');
|
const input = document.createElement('textarea');
|
||||||
input.value = '/';
|
input.value = '/';
|
||||||
input.selectionStart = input.value.length;
|
input.selectionStart = input.value.length;
|
||||||
@@ -1682,8 +1682,6 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
const commandNames = autoComplete.items.map((item) => item.command);
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
expect(commandNames).toContain('/af');
|
|
||||||
expect(commandNames).not.toContain('/noaf');
|
|
||||||
expect(commandNames).toContain('/activefilters');
|
expect(commandNames).toContain('/activefilters');
|
||||||
expect(commandNames).not.toContain('/noactivefilters');
|
expect(commandNames).not.toContain('/noactivefilters');
|
||||||
});
|
});
|
||||||
@@ -1710,11 +1708,11 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
|
|
||||||
const commandNames = autoComplete.items.map((item) => item.command);
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
expect(commandNames).toContain('/af');
|
expect(commandNames).toContain('/activefilters');
|
||||||
expect(previewTooltipMock.show).not.toHaveBeenCalled();
|
expect(previewTooltipMock.show).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows /noaf command for loras when active-filters autocomplete is on', async () => {
|
it('shows /noactivefilters command for loras when active-filters autocomplete is on', async () => {
|
||||||
settingGetMock.mockImplementation((key) => {
|
settingGetMock.mockImplementation((key) => {
|
||||||
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
if (key === 'loramanager.lora_active_filters_autocomplete') {
|
||||||
return true;
|
return true;
|
||||||
@@ -1736,8 +1734,6 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
const commandNames = autoComplete.items.map((item) => item.command);
|
const commandNames = autoComplete.items.map((item) => item.command);
|
||||||
expect(commandNames).toContain('/noaf');
|
|
||||||
expect(commandNames).not.toContain('/af');
|
|
||||||
expect(commandNames).toContain('/noactivefilters');
|
expect(commandNames).toContain('/noactivefilters');
|
||||||
expect(commandNames).not.toContain('/activefilters');
|
expect(commandNames).not.toContain('/activefilters');
|
||||||
});
|
});
|
||||||
@@ -1766,7 +1762,7 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
expect(settingSetMock).toHaveBeenCalledWith('loramanager.lora_active_filters_autocomplete', true);
|
expect(settingSetMock).toHaveBeenCalledWith('loramanager.lora_active_filters_autocomplete', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggles the active-filters setting when /af is accepted', async () => {
|
it('toggles the active-filters setting when /activefilters is accepted', async () => {
|
||||||
const input = document.createElement('textarea');
|
const input = document.createElement('textarea');
|
||||||
input.value = '/';
|
input.value = '/';
|
||||||
input.selectionStart = input.value.length;
|
input.selectionStart = input.value.length;
|
||||||
@@ -1782,7 +1778,7 @@ describe('AutoComplete widget interactions', () => {
|
|||||||
|
|
||||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
|
||||||
const afItem = autoComplete.items.find((item) => item.command === '/af');
|
const afItem = autoComplete.items.find((item) => item.command === '/activefilters');
|
||||||
expect(afItem).toBeDefined();
|
expect(afItem).toBeDefined();
|
||||||
|
|
||||||
// Simulate the input being cleared after the command is accepted so the
|
// Simulate the input being cleared after the command is accepted so the
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ const TAG_COMMANDS = {
|
|||||||
'/embedding': { type: 'embedding', label: 'Embeddings' },
|
'/embedding': { type: 'embedding', label: 'Embeddings' },
|
||||||
...WILDCARD_COMMANDS,
|
...WILDCARD_COMMANDS,
|
||||||
// Autocomplete toggle commands - only show one based on current state
|
// Autocomplete toggle commands - only show one based on current state
|
||||||
'/ac': {
|
'/autocomplete': {
|
||||||
type: 'toggle_setting',
|
type: 'toggle_setting',
|
||||||
settingId: 'loramanager.prompt_tag_autocomplete',
|
settingId: 'loramanager.prompt_tag_autocomplete',
|
||||||
value: true,
|
value: true,
|
||||||
label: 'Autocomplete: ON',
|
label: 'Autocomplete: ON',
|
||||||
condition: () => !getPromptTagAutocompletePreference()
|
condition: () => !getPromptTagAutocompletePreference()
|
||||||
},
|
},
|
||||||
'/noac': {
|
'/noautocomplete': {
|
||||||
type: 'toggle_setting',
|
type: 'toggle_setting',
|
||||||
settingId: 'loramanager.prompt_tag_autocomplete',
|
settingId: 'loramanager.prompt_tag_autocomplete',
|
||||||
value: false,
|
value: false,
|
||||||
@@ -50,26 +50,7 @@ const TAG_COMMANDS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Command definitions for LoRA active-filters search
|
// Command definitions for LoRA active-filters search
|
||||||
// Aliases (/activefilters, /noactivefilters) mirror /emb ↔ /embedding
|
|
||||||
const LORAS_COMMANDS = {
|
const LORAS_COMMANDS = {
|
||||||
'/af': {
|
|
||||||
type: 'toggle_setting',
|
|
||||||
settingId: 'loramanager.lora_active_filters_autocomplete',
|
|
||||||
value: true,
|
|
||||||
label: 'Active Filters: ON',
|
|
||||||
feedbackSummary: 'Active Filters Search: ON',
|
|
||||||
feedbackDetail: 'LoRA autocomplete now searches within the active filters of the LoRA Manager page.',
|
|
||||||
condition: () => !getLoraActiveFiltersAutocompletePreference()
|
|
||||||
},
|
|
||||||
'/noaf': {
|
|
||||||
type: 'toggle_setting',
|
|
||||||
settingId: 'loramanager.lora_active_filters_autocomplete',
|
|
||||||
value: false,
|
|
||||||
label: 'Active Filters: OFF',
|
|
||||||
feedbackSummary: 'Active Filters Search: OFF',
|
|
||||||
feedbackDetail: 'LoRA autocomplete searches the full library again.',
|
|
||||||
condition: () => getLoraActiveFiltersAutocompletePreference()
|
|
||||||
},
|
|
||||||
'/activefilters': {
|
'/activefilters': {
|
||||||
type: 'toggle_setting',
|
type: 'toggle_setting',
|
||||||
settingId: 'loramanager.lora_active_filters_autocomplete',
|
settingId: 'loramanager.lora_active_filters_autocomplete',
|
||||||
@@ -761,7 +742,7 @@ class AutoComplete {
|
|||||||
searchTerm = (match[1] || '').trim();
|
searchTerm = (match[1] || '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For loras model type, check if we're in command mode (/af, /noaf)
|
// For loras model type, check if we're in command mode (/activefilters, /noactivefilters)
|
||||||
if (this.modelType === 'loras') {
|
if (this.modelType === 'loras') {
|
||||||
const commandResult = this._parseCommandInput(rawSearchTerm);
|
const commandResult = this._parseCommandInput(rawSearchTerm);
|
||||||
|
|
||||||
@@ -773,7 +754,7 @@ class AutoComplete {
|
|||||||
this._showCommandList(commandResult.commandFilter);
|
this._showCommandList(commandResult.commandFilter);
|
||||||
return;
|
return;
|
||||||
} else if (commandResult.command?.type === 'toggle_setting') {
|
} else if (commandResult.command?.type === 'toggle_setting') {
|
||||||
// Handle toggle setting command (/af, /noaf)
|
// Handle toggle setting command (/activefilters, /noactivefilters)
|
||||||
this._handleToggleSettingCommand(commandResult.command);
|
this._handleToggleSettingCommand(commandResult.command);
|
||||||
return;
|
return;
|
||||||
} else if (commandResult.command) {
|
} else if (commandResult.command) {
|
||||||
@@ -813,7 +794,7 @@ class AutoComplete {
|
|||||||
this._showCommandList(commandResult.commandFilter);
|
this._showCommandList(commandResult.commandFilter);
|
||||||
return;
|
return;
|
||||||
} else if (commandResult.command?.type === 'toggle_setting') {
|
} else if (commandResult.command?.type === 'toggle_setting') {
|
||||||
// Handle toggle setting command (/ac, /noac)
|
// Handle toggle setting command (/autocomplete, /noautocomplete)
|
||||||
this._handleToggleSettingCommand(commandResult.command);
|
this._handleToggleSettingCommand(commandResult.command);
|
||||||
return;
|
return;
|
||||||
} else if (commandResult.command) {
|
} else if (commandResult.command) {
|
||||||
@@ -2866,7 +2847,7 @@ class AutoComplete {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle toggle setting command (/ac, /noac)
|
* Handle toggle setting command (e.g., /autocomplete, /activefilters)
|
||||||
* @param {Object} command - The toggle command with settingId and value
|
* @param {Object} command - The toggle command with settingId and value
|
||||||
*/
|
*/
|
||||||
async _handleToggleSettingCommand(command) {
|
async _handleToggleSettingCommand(command) {
|
||||||
|
|||||||
Reference in New Issue
Block a user