Implementation:AUTOMATIC1111 Stable diffusion webui Extensions Tab JS
| Knowledge Sources | |
|---|---|
| Domains | UI_Frontend, Extensions, Configuration |
| Last Updated | 2025-05-15 00:00 GMT |
Overview
Provides client-side JavaScript functions for the Extensions tab, handling extension enable/disable toggling, update checking, installation, and configuration state restoration.
Description
This module contains several functions that support the Extensions management UI. The extensions_apply function collects the state of all extension checkboxes (enable/disable and update flags), triggers a UI restart/reload, and returns the serialized lists. The extensions_check function similarly collects disabled extensions, sets all status indicators to "Loading...", and initiates a progress-tracked check operation. The install_extension_from_index function handles one-click installation from the extension index by setting the URL in the install textarea and clicking the install button. The config_state_confirm_restore function prompts the user for confirmation before restoring a saved configuration state (extensions, webui version, or both), with appropriate warning messages. The toggle_all_extensions and toggle_extension functions manage the "select all" checkbox behavior, keeping it in sync with individual extension toggles.
Usage
These functions are called by Gradio event handlers in the Extensions tab. Users interact with them through the Extensions UI: toggling extension checkboxes, clicking Apply/Check/Install buttons, and using the configuration state restore feature.
Code Reference
Source Location
- Repository: AUTOMATIC1111_Stable_diffusion_webui
- File: javascript/extensions.js
- Lines: 1-95
Signature
function extensions_apply(_disabled_list, _update_list, disable_all)
function extensions_check()
function install_extension_from_index(button, url)
function config_state_confirm_restore(_, config_state_name, config_restore_type)
function toggle_all_extensions(event)
function toggle_extension()
Import
// Loaded automatically by the web UI as part of the javascript/ directory
// Functions are called by Gradio component event bindings
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| _disabled_list | any | No | Placeholder parameter (actual values are collected from DOM checkboxes) |
| _update_list | any | No | Placeholder parameter (actual values are collected from DOM checkboxes) |
| disable_all | bool | Yes | Whether to disable all extensions |
| button | HTMLElement | Yes | The install button element that was clicked |
| url | string | Yes | The URL of the extension repository to install |
| config_state_name | string | Yes | Name of the configuration state to restore |
| config_restore_type | string | Yes | Type of restore: "extensions", "webui", or "both" |
Outputs
| Name | Type | Description |
|---|---|---|
| extensions_apply result | array | JSON-serialized disabled list, update list, and disable_all flag |
| extensions_check result | array | Random task ID and JSON-serialized disabled extensions list |
| config_state_confirm_restore result | array | Confirmed boolean, state name, and restore type |
Usage Examples
// These functions are typically called by Gradio's JavaScript function bindings:
// Apply extension changes (called by Apply button)
var result = extensions_apply(null, null, false);
// Returns: ['["ext1","ext2"]', '["ext3"]', false]
// Check for updates (called by Check for updates button)
var result = extensions_check();
// Returns: ['task(abc123)', '["disabled_ext"]']
// Install from index (called by Install button in available extensions list)
install_extension_from_index(buttonElement, 'https://github.com/user/extension.git');
// Toggle all extensions checkbox
toggle_all_extensions({ target: { checked: true } });