Skip to content

Agent Zero AI framework

Use prototype-based context for plugin settings

frdela807e2458bfa
diff --git a/AGENTS.md b/AGENTS.md
index e347564e0..d3fd9adb8 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -128,7 +128,7 @@ Key Files:
- Location: Always develop new plugins in usr/plugins/.
- Manifest: Every plugin requires a plugin.yaml with name, description, version, and optionally settings_sections, per_project_config, per_agent_config, and always_enabled.
- Discovery: Conventions based on folder names (api/, tools/, webui/, extensions/).
-- Settings: Use get_plugin_config(plugin_name, agent=agent) to retrieve settings. Plugins can expose a UI for settings via webui/config.html. For plugins wrapping core settings, set $store.pluginSettings.saveMode = 'core' in x-init.
+- Settings: Use get_plugin_config(plugin_name, agent=agent) to retrieve settings. Plugins can expose a UI for settings via webui/config.html. Plugin settings modals instantiate a local context from $store.pluginSettingsPrototype; bind plugin fields to config.* and use context.* for modal-level state and actions. For plugins wrapping core settings, set context.saveMode = 'core' in x-init.
- Activation: Global and scoped activation rules are stored as .toggle-1 (ON) and .toggle-0 (OFF). Scoped rules are handled via the plugin "Switch" modal.
### Lifecycle Synchronization
diff --git a/docs/agents/AGENTS.plugins.md b/docs/agents/AGENTS.plugins.md
index 1e150fc30..f084583c1 100644
--- a/docs/agents/AGENTS.plugins.md
+++ b/docs/agents/AGENTS.plugins.md
@@ -87,8 +87,9 @@ Core JS hooks can also expose runtime UI surfaces when static HTML breakpoints a
## 4. Plugin Settings
1. Add webui/config.html to your plugin.
-2. Bind fields to $store.pluginSettings.settings.
-3. Settings are scoped per-project and per-agent automatically.
+2. The plugin settings wrapper instantiates a local modal context from $store.pluginSettingsPrototype.
+3. Bind plugin fields to config.* and use context.* for modal-level state and actions.
+4. Settings are scoped per-project and per-agent automatically.
### Resolution Priority (Highest First)
1. project/.a0proj/agents/<profile>/plugins/<name>/config.json
diff --git a/plugins/code_execution/webui/config.html b/plugins/code_execution/webui/config.html
index f6ae0b362..60a542da7 100644
--- a/plugins/code_execution/webui/config.html
+++ b/plugins/code_execution/webui/config.html
@@ -5,7 +5,7 @@
<body>
<div x-data>
- <template x-if="$store.pluginSettings.settings">
+ <template x-if="config">
<div>
<div class="section-title">Code Execution</div>
<div class="section-description">
@@ -22,7 +22,7 @@
</div>
</div>
<div class="field-control">
- <select x-model="$store.pluginSettings.settings.ssh_enabled">
+ <select x-model="config.ssh_enabled">
<option value="auto">Auto</option>
<option value="true">SSH</option>
<option value="false">Local TTY</option>
@@ -31,7 +31,7 @@
</div>
<!-- SSH credentials (shown when SSH or Auto) -->
- <template x-if="$store.pluginSettings.settings.ssh_enabled !== 'false'">
+ <template x-if="config.ssh_enabled !== 'false'">
<div>
<div class="field">
<div class="field-label">
@@ -39,7 +39,7 @@
<div class="field-description">Hostname or IP of the SSH target. Leave empty to use the RFC URL from settings.</div>
</div>
<div class="field-control">
- <input type="text" x-model="$store.pluginSettings.settings.ssh_addr" placeholder="(from RFC URL)" />
+ <input type="text" x-model="config.ssh_addr" placeholder="(from RFC URL)" />
</div>
</div>
@@ -49,7 +49,7 @@
<div class="field-description">SSH port on the target host (default: 55022 for Docker RFC).</div>
</div>
<div class="field-control">
- <input type="number" min="1" max="65535" x-model.number="$store.pluginSettings.settings.ssh_port" />
+ <input type="number" min="1" max="65535" x-model.number="config.ssh_port" />
</div>
</div>
@@ -59,7 +59,7 @@
<div class="field-description">Username for SSH login.</div>
</div>
<div class="field-control">
- <input type="text" x-model="$store.pluginSettings.settings.ssh_user" placeholder="root" />
+ <input type="text" x-model="config.ssh_user" placeholder="root" />
</div>
</div>
@@ -69,7 +69,7 @@
<div class="field-description">Password for SSH login. Leave empty to use the dev root password (via RFC).</div>
</div>
<div class="field-control">
- <input type="password" autocomplete="off" x-model="$store.pluginSettings.settings.ssh_pass" placeholder="(from RFC)" />
+ <input type="password" autocomplete="off" x-model="config.ssh_pass" placeholder="(from RFC)" />
</div>
</div>
</div>
@@ -87,7 +87,7 @@
<div class="field-description">Seconds to wait for the first output before returning control to the agent.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.code_exec_first_output_timeout" />
+ <input type="number" min="1" x-model.number="config.code_exec_first_output_timeout" />
</div>
</div>
@@ -97,7 +97,7 @@
<div class="field-description">Seconds to wait between output chunks before returning control.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.code_exec_between_output_timeout" />
+ <input type="number" min="1" x-model.number="config.code_exec_between_output_timeout" />
</div>
</div>
@@ -107,7 +107,7 @@
<div class="field-description">Hard cap on total execution time in seconds.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.code_exec_max_exec_timeout" />
+ <input type="number" min="1" x-model.number="config.code_exec_max_exec_timeout" />
</div>
</div>
@@ -117,7 +117,7 @@
<div class="field-description">Seconds of idle output before checking for dialog prompts.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.code_exec_dialog_timeout" />
+ <input type="number" min="1" x-model.number="config.code_exec_dialog_timeout" />
</div>
</div>
@@ -133,7 +133,7 @@
<div class="field-description">Seconds to wait for the first output.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.output_first_output_timeout" />
+ <input type="number" min="1" x-model.number="config.output_first_output_timeout" />
</div>
</div>
@@ -143,7 +143,7 @@
<div class="field-description">Seconds to wait between output chunks.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.output_between_output_timeout" />
+ <input type="number" min="1" x-model.number="config.output_between_output_timeout" />
</div>
</div>
@@ -153,7 +153,7 @@
<div class="field-description">Hard cap on total wait time in seconds.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.output_max_exec_timeout" />
+ <input type="number" min="1" x-model.number="config.output_max_exec_timeout" />
</div>
</div>
@@ -163,7 +163,7 @@
<div class="field-description">Seconds of idle output before checking for dialog prompts.</div>
</div>
<div class="field-control">
- <input type="number" min="1" x-model.number="$store.pluginSettings.settings.output_dialog_timeout" />
+ <input type="number" min="1" x-model.number="config.output_dialog_timeout" />
</div>
</div>
@@ -181,7 +181,7 @@
</div>
</div>
<div class="field-control">
- <textarea rows="5" x-model="$store.pluginSettings.settings.prompt_patterns"></textarea>
+ <textarea rows="5" x-model="config.prompt_patterns"></textarea>
</div>
</div>
@@ -193,7 +193,7 @@
</div>
</div>
<div class="field-control">
- <textarea rows="4" x-model="$store.pluginSettings.settings.dialog_patterns"></textarea>
+ <textarea rows="4" x-model="config.dialog_patterns"></textarea>
</div>
</div>
</div>
diff --git a/plugins/infection_check/webui/config.html b/plugins/infection_check/webui/config.html
index a75f466e5..17f675072 100644
--- a/plugins/infection_check/webui/config.html
+++ b/plugins/infection_check/webui/config.html
@@ -2,7 +2,7 @@
<head><title>Infection Check</title></head>
<body>
<div x-data>
- <template x-if="$store.pluginSettings.settings">
+ <template x-if="config">
<div>
<div class="section-title">Infection Check</div>
<div class="section-description">
@@ -19,7 +19,7 @@
</div>
</div>
<div class="field-control">
- <select x-model="$store.pluginSettings.settings.mode">
+ <select x-model="config.mode">
<option value="thoughts">Thoughts (faster)</option>
<option value="complete">Complete (thorough)</option>
</select>
@@ -32,7 +32,7 @@
<div class="field-description">Which model runs the security analysis.</div>
</div>
<div class="field-control">
- <select x-model="$store.pluginSettings.settings.model">
+ <select x-model="config.model">
<option value="utility">Utility model</option>
<option value="main">Main model</option>
</select>
@@ -46,7 +46,7 @@
</div>
<div class="field-control">
<input type="number" min="0" max="10"
- x-model.number="$store.pluginSettings.settings.max_clarifications" />
+ x-model.number="config.max_clarifications" />
</div>
</div>
@@ -57,7 +57,7 @@
</div>
<div class="field-control">
<input type="number" min="0" max="100"
- x-model.number="$store.pluginSettings.settings.history_size" />
+ x-model.number="config.history_size" />
</div>
</div>
@@ -68,7 +68,7 @@
</div>
<div class="field-control" style="width:100%;">
<textarea rows="14" style="width:100%;font-family:monospace;font-size:0.85em;"
- x-model="$store.pluginSettings.settings.prompt"></textarea>
+ x-model="config.prompt"></textarea>
</div>
</div>
diff --git a/plugins/memory/webui/config.html b/plugins/memory/webui/config.html
index 2d6b92cf9..b1e9214aa 100644
--- a/plugins/memory/webui/config.html
+++ b/plugins/memory/webui/config.html
@@ -5,7 +5,7 @@
<body>
<div x-data>
- <template x-if="$store.pluginSettings.settings">
+ <template x-if="config">
<div>
<div class="section-title">Memory</div>
<div class="section-description">
@@ -13,7 +13,7 @@
context awareness.
</div>
- <div class="field" x-show="$store.pluginSettings.projectName">
+ <div class="field" x-show="context.projectName">
<div class="field-label">
<div class="field-title">Project Isolation</div>
<div class="field-description">
@@ -22,7 +22,7 @@
</div>
<div class="field-control">
<label class="toggle">
- <input type="checkbox" x-model="$store.pluginSettings.settings.project_memory_isolation" />
+ <input type="checkbox" x-model="config.project_memory_isolation" />
<span class="toggler"></span>
</label>
</div>
@@ -36,7 +36,7 @@
</div>
</div>
<div class="field-control">
- <input type="text" x-model="$store.pluginSettings.settings.agent_memory_subdir" placeholder="Auto (Project-isolated)" />
+ <input type="text" x-model="config.agent_memory_subdir" placeholder="Auto (Project-isolated)" />
</div>
</div>
@@ -64,7 +64,7 @@
</div>
<div class="field-control">
<label class="toggle">
- <input type="checkbox" x-model="$store.pluginSettings.settings.memory_recall_enabled" />
+ <input type="checkbox" x-model="config.memory_recall_enabled" />
<span class="toggler"></span>
</label>
</div>
@@ -80,7 +80,7 @@
</div>
<div class="field-control">
<label class="toggle">
- <input type="checkbox" x-model="$store.pluginSettings.settings.memory_recall_delayed" />
+ <input type="checkbox" x-model="config.memory_recall_delayed" />
<span class="toggler"></span>
</label>
</div>
@@ -96,7 +96,7 @@
</div>
<div class="field-control">
<label class="toggle">
- <input type="checkbox" x-model="$store.pluginSettings.settings.memory_recall_query_prep" />
+ <input type="checkbox" x-model="config.memory_recall_query_prep" />
<span class="toggler"></span>
</label>
</div>
@@ -113,7 +113,7 @@
<div class="field-control">
<label class="toggle">
<input type="checkbox"
- x-model="$store.pluginSettings.settings.memory_recall_post_filter" />
+ x-model="config.memory_recall_post_filter" />
<span class="toggler"></span>
</label>
</div>
@@ -129,9 +129,9 @@
</div>
<div class="field-control">
<input type="range" min="1" max="10" step="1"
- x-model.number="$store.pluginSettings.settings.memory_recall_interval" />
+ x-model.number="config.memory_recall_interval" />
<span class="range-value"
- x-text="$store.pluginSettings.settings.memory_recall_interval"></span>
+ x-text="config.memory_recall_interval"></span>
</div>
</div>
@@ -144,7 +144,7 @@
</div>
<div class="field-control">
<input type="number"
- x-model.number="$store.pluginSettings.settings.memory_recall_history_len" />
+ x-model.number="config.memory_recall_history_len" />
</div>
</div>
@@ -157,9 +157,9 @@
</div>
<div class="field-control">
<input type="range" min="0" max="1" step="0.01"
- x-model.number="$store.pluginSettings.settings.memory_recall_similarity_threshold" />
+ x-model.number="config.memory_recall_similarity_threshold" />
<span class="range-value"
- x-text="$store.pluginSettings.settings.memory_recall_similarity_threshold"></span>
+ x-text="config.memory_recall_similarity_threshold"></span>
</div>
</div>
@@ -172,7 +172,7 @@
</div>
<div class="field-control">
<input type="number"
- x-model.number="$store.pluginSettings.settings.memory_recall_memories_max_search" />
+ x-model.number="config.memory_recall_memories_max_search" />
</div>
</div>
@@ -185,7 +185,7 @@
</div>
<div class="field-control">
<input type="number"
- x-model.number="$store.pluginSettings.settings.memory_recall_memories_max_result" />
+ x-model.number="config.memory_recall_memories_max_result" />
</div>
</div>
@@ -198,7 +198,7 @@
</div>
<div class="field-control">
<input type="number"
- x-model.number="$store.pluginSettings.settings.memory_recall_solutions_max_search" />
+ x-model.number="config.memory_recall_solutions_max_search" />
</div>
</div>
@@ -211,7 +211,7 @@
</div>
<div class="field-control">
<input type="number"
- x-model.number="$store.pluginSettings.settings.memory_recall_solutions_max_result" />
+ x-model.number="config.memory_recall_solutions_max_result" />
</div>
</div>
@@ -225,7 +225,7 @@
<div class="field-control">
<label class="toggle">
<input type="checkbox"
- x-model="$store.pluginSettings.settings.memory_memorize_enabled" />
+ x-model="config.memory_memorize_enabled" />
<span class="toggler"></span>
</label>
</div>
@@ -242,7 +242,7 @@
<div class="field-control">
<label class="toggle">
<input type="checkbox"
- x-model="$store.pluginSettings.settings.memory_memorize_consolidation" />
+ x-model="config.memory_memorize_consolidation" />
<span class="toggler"></span>
</label>
</div>
@@ -259,9 +259,9 @@
</div>
<div class="field-control">
<input type="range" min="0" max="1" step="0.01"
- x-model.number="$store.pluginSettings.settings.memory_memorize_replace_threshold" />
+ x-model.number="config.memory_memorize_replace_threshold" />
<span class="range-value"
- x-text="$store.pluginSettings.settings.memory_memorize_replace_threshold"></span>
+ x-text="config.memory_memorize_replace_threshold"></span>
</div>
</div>
</div>
diff --git a/plugins/text_editor/webui/config.html b/plugins/text_editor/webui/config.html
index 0ee726298..45943c6b4 100644
--- a/plugins/text_editor/webui/config.html
+++ b/plugins/text_editor/webui/config.html
@@ -5,7 +5,7 @@
<body>
<div x-data>
- <template x-if="$store.pluginSettings.settings">
+ <template x-if="config">
<div>
<div class="section-title">Text Editor</div>
<div class="section-description">
@@ -21,7 +21,7 @@
</div>
<div class="field-control">
<input type="number" min="50" max="5000"
- x-model.number="$store.pluginSettings.settings.max_line_tokens" />
+ x-model.number="config.max_line_tokens" />
</div>
</div>
@@ -34,7 +34,7 @@
</div>
<div class="field-control">
<input type="number" min="10" max="1000"
- x-model.number="$store.pluginSettings.settings.default_line_count" />
+ x-model.number="config.default_line_count" />
</div>
</div>
@@ -47,7 +47,7 @@
</div>
<div class="field-control">
<input type="number" min="500" max="50000"
- x-model.number="$store.pluginSettings.settings.max_total_read_tokens" />
+ x-model.number="config.max_total_read_tokens" />
</div>
</div>
</div>
diff --git a/skills/a0-create-plugin/SKILL.md b/skills/a0-create-plugin/SKILL.md
index d669dc28d..fc1c633da 100644
--- a/skills/a0-create-plugin/SKILL.md
+++ b/skills/a0-create-plugin/SKILL.md
@@ -88,7 +88,7 @@ If your plugin needs user-configurable settings, add `webui/config.html`. The sy
### Settings modal contract
-The modal provides Project + Agent profile context selectors. Your config.html binds to `$store.pluginSettings.settings`:
+The modal provides Project + Agent profile context selectors. The plugin settings wrapper instantiates a local modal context from `$store.pluginSettingsPrototype`. Inside `config.html`, bind plugin fields to `config.*` and use `context.*` for modal-level state and actions:
```html
<html>
@@ -100,14 +100,14 @@ The modal provides Project + Agent profile context selectors. Your config.html b
</head>
<body>
<div x-data>
- <input x-model="$store.pluginSettings.settings.my_key" />
- <input type="checkbox" x-model="$store.pluginSettings.settings.feature_enabled" />
+ <input x-model="config.my_key" />
+ <input type="checkbox" x-model="config.feature_enabled" />
</div>
</body>
</html>
```
-The modal's Save button persists `$store.pluginSettings.settings` to `config.json` in the correct scope (project/agent/global).
+The modal's Save button persists `config` to `config.json` in the correct scope (project/agent/global).
### Surfacing core settings (e.g. memory pattern)
@@ -115,7 +115,7 @@ If your plugin exposes existing core settings rather than plugin-specific ones,
```html
<div x-data x-init="
- $store.pluginSettings.saveMode = 'core';
+ context.saveMode = 'core';
if ($store.settings && !$store.settings.settings) $store.settings.onOpen();
">
<x-component path="settings/agent/memory.html"></x-component>
diff --git a/webui/components/plugins/list/pluginListStore.js b/webui/components/plugins/list/pluginListStore.js
index 9b583fdfa..6426e4d91 100644
--- a/webui/components/plugins/list/pluginListStore.js
+++ b/webui/components/plugins/list/pluginListStore.js
@@ -63,7 +63,7 @@ const model = {
const pluginToggleStore = Alpine.store("pluginToggle");
if (pluginToggleStore?.open) await pluginToggleStore.open(plugin);
- const pluginSettingsStore = Alpine.store("pluginSettings");
+ const pluginSettingsStore = Alpine.store("pluginSettingsPrototype");
if (!pluginSettingsStore?.open) {
throw new Error("Plugin settings store is unavailable.");
}
diff --git a/webui/components/plugins/plugin-configs.html b/webui/components/plugins/plugin-configs.html
index 4daac6641..5715d73c0 100644
--- a/webui/components/plugins/plugin-configs.html
+++ b/webui/components/plugins/plugin-configs.html
@@ -6,47 +6,53 @@
</script>
</head>
<body>
- <div x-data>
- <template x-if="$store.pluginSettings">
- <div x-create="$store.pluginSettings.loadConfigList()" class="plugin-configs-container">
-
- <div x-show="$store.pluginSettings.configsError" class="plugin-configs-error">
+ <div x-data="(() => {
+ const modals = Array.from(document.querySelectorAll('.modal.show'));
+ const parentModal = /** @type {HTMLElement & { __pluginSettingsContext?: object }} */ (modals[modals.length - 2] || null);
+ return {
+ context: parentModal?.__pluginSettingsContext || null,
+ };
+ })()">
+ <template x-if="context">
+ <div x-create="context.loadConfigList()" class="plugin-configs-container">
+
+ <div x-show="context.configsError" class="plugin-configs-error">
<span class="material-symbols-outlined">error</span>
- <span x-text="$store.pluginSettings.configsError"></span>
+ <span x-text="context.configsError"></span>
</div>
- <div x-show="$store.pluginSettings.isListingConfigs" class="plugin-configs-loading">
+ <div x-show="context.isListingConfigs" class="plugin-configs-loading">
<span class="material-symbols-outlined spinning">progress_activity</span>
<span>Loading configurations...</span>
</div>
- <div x-show="!$store.pluginSettings.isListingConfigs" class="plugin-configs-list">
- <template x-if="($store.pluginSettings.configs || []).length === 0">
+ <div x-show="!context.isListingConfigs" class="plugin-configs-list">
+ <template x-if="(context.configs || []).length === 0">
<div class="plugin-configs-empty">No configurations found.</div>
</template>
- <template x-for="cfg in ($store.pluginSettings.configs || [])" :key="(cfg.project_name || '') + '|' + (cfg.agent_profile || '')">
+ <template x-for="cfg in (context.configs || [])" :key="(cfg.project_name || '') + '|' + (cfg.agent_profile || '')">
<div class="plugin-configs-row">
<div class="plugin-configs-scope">
<div class="plugin-configs-scope-top">
<div class="plugin-configs-scope-line">
<span class="plugin-configs-scope-key">Project:</span>
- <span x-text="$store.pluginSettings.projectLabel(cfg.project_name || '')"></span>
+ <span x-text="context.projectLabel(cfg.project_name || '')"></span>
</div>
<div class="plugin-configs-scope-line">
<span class="plugin-configs-scope-key">Agent profile:</span>
- <span x-text="$store.pluginSettings.agentProfileLabel(cfg.agent_profile || '')"></span>
+ <span x-text="context.agentProfileLabel(cfg.agent_profile || '')"></span>
</div>
</div>
<div class="plugin-configs-scope-sub" x-text="cfg.path || ''"></div>
</div>
<div class="plugin-configs-actions">
- <button type="button" class="button" @click="$store.pluginSettings.switchToConfig(cfg.project_name || '', cfg.agent_profile || '')">
+ <button type="button" class="button" @click="context.switchToConfig(cfg.project_name || '', cfg.agent_profile || '')">
<span class="icon material-symbols-outlined">list</span>
Show
</button>
- <button type="button" class="button cancel icon-button" title="Delete" @click="$confirmClick($event, () => $store.pluginSettings.deleteConfig(cfg.project_name || '', cfg.agent_profile || ''))">
+ <button type="button" class="button cancel icon-button" title="Delete" @click="$confirmClick($event, () => context.deleteConfig(cfg.project_name || '', cfg.agent_profile || ''))">
<span class="icon material-symbols-outlined">delete</span>
</button>
</div>
diff --git a/webui/components/plugins/plugin-settings-store.js b/webui/components/plugins/plugin-settings-store.js
index dd017f3d5..2bd43eed2 100644
--- a/webui/components/plugins/plugin-settings-store.js
+++ b/webui/components/plugins/plugin-settings-store.js
@@ -355,4 +355,4 @@ const model = {
},
};
-export const store = createStore("pluginSettings", model);
+export const store = createStore("pluginSettingsPrototype", model);
diff --git a/webui/components/plugins/plugin-settings.html b/webui/components/plugins/plugin-settings.html
index 3444dd91d..d6c446334 100644
--- a/webui/components/plugins/plugin-settings.html
+++ b/webui/components/plugins/plugin-settings.html
@@ -6,14 +6,23 @@
</script>
</head>
<body>
- <div x-data>
- <template x-if="$store.pluginSettings">
- <div x-create="$store.pluginSettings.onModalOpen()"
- x-destroy="$store.pluginSettings.cleanup(); $store.pluginListStore?.refresh()">
+ <div x-data="(() => {
+ const context = $instantiate($store.pluginSettingsPrototype);
+ return {
+ context,
+ get config() {
+ return this.context.settings;
+ },
+ };
+ })()">
+ <template x-if="context">
+ <div>
+ <div x-create="context.onModalOpen(); (() => { const modal = $el.closest('.modal'); if (modal) modal.__pluginSettingsContext = context; })()"
+ x-destroy="context.cleanup(); $store.pluginListStore?.refresh()">
<!-- Context toolbar: Project + Agent profile (only when at least one scope is configurable) -->
<div class="plugin-settings-scope-section"
- x-show="$store.pluginSettings.perProjectConfig || $store.pluginSettings.perAgentConfig">
+ x-show="context.perProjectConfig || context.perAgentConfig">
<div class="plugin-settings-scope-header">
<div class="plugin-settings-scope-title">Settings scope</div>
<div class="plugin-settings-scope-desc">This plugin supports settings per project or agent profile.</div>
@@ -23,12 +32,12 @@
<label class="plugin-settings-toolbar-item">
<span class="plugin-settings-toolbar-label">Project</span>
- <select x-model="$store.pluginSettings.projectName"
- x-init="$nextTick(() => $el.value = $store.pluginSettings.projectName)"
- @change="$store.pluginSettings.onScopeChanged()"
- :disabled="!$store.pluginSettings.perProjectConfig">
+ <select x-model="context.projectName"
+ x-init="$nextTick(() => $el.value = context.projectName)"
+ @change="context.onScopeChanged()"
+ :disabled="!context.perProjectConfig">
<option value="">Global</option>
- <template x-for="project in $store.pluginSettings.projects" :key="project.key">
+ <template x-for="project in context.projects" :key="project.key">
<option :value="project.key" x-text="project.label"></option>
</template>
</select>
@@ -36,18 +45,18 @@
<label class="plugin-settings-toolbar-item">
<span class="plugin-settings-toolbar-label">Agent profile</span>
- <select x-model="$store.pluginSettings.agentProfileKey"
- x-init="$nextTick(() => $el.value = $store.pluginSettings.agentProfileKey)"
- @change="$store.pluginSettings.onScopeChanged()"
- :disabled="!$store.pluginSettings.perAgentConfig">
+ <select x-model="context.agentProfileKey"
+ x-init="$nextTick(() => $el.value = context.agentProfileKey)"
+ @change="context.onScopeChanged()"
+ :disabled="!context.perAgentConfig">
<option value="">All profiles</option>
- <template x-for="profile in $store.pluginSettings.agentProfiles" :key="profile.key">
+ <template x-for="profile in context.agentProfiles" :key="profile.key">
<option :value="profile.key" x-text="profile.label"></option>
</template>
</select>
</label>
- <button type="button" class="button plugin-settings-toolbar-button" title="Show existing configurations" @click="$store.pluginSettings.openConfigListModal()">
+ <button type="button" class="button plugin-settings-toolbar-button" title="Show existing configurations" @click="context.openConfigListModal()">
<span class="icon material-symbols-outlined">list</span>
</button>
@@ -70,50 +79,51 @@
</div>
</div>
- <div x-show="$store.pluginSettings.scopeMismatchMessage" class="plugin-settings-scope-info">
+ <div x-show="context.scopeMismatchMessage" class="plugin-settings-scope-info">
<span class="material-symbols-outlined">info</span>
- <span x-text="$store.pluginSettings.scopeMismatchMessage"></span>
+ <span x-text="context.scopeMismatchMessage"></span>
</div>
</div>
<!-- Error -->
- <div x-show="$store.pluginSettings.error" class="plugin-settings-error">
+ <div x-show="context.error" class="plugin-settings-error">
<span class="material-symbols-outlined">error</span>
- <span x-text="$store.pluginSettings.error"></span>
+ <span x-text="context.error"></span>
</div>
<!-- Loading -->
- <div x-show="$store.pluginSettings.isLoading" class="plugin-settings-loading">
+ <div x-show="context.isLoading" class="plugin-settings-loading">
<span class="material-symbols-outlined spinning">progress_activity</span>
<span>Loading settings...</span>
</div>
<!-- Plugin settings body: plugin provides /plugins/<name>/webui/config.html -->
- <div x-show="!$store.pluginSettings.isLoading"
+ <div x-show="!context.isLoading"
class="plugin-settings-body"
- x-html="$store.pluginSettings.settingsComponentHtml">
+ x-html="context.settingsComponentHtml">
</div>
</div>
- </template>
- </div>
- <!-- Footer (pinned outside scroll area) -->
- <div class="modal-footer" data-modal-footer>
- <button class="btn btn-ok"
- @click="$store.pluginSettings.save()"
- :disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
- Save
- </button>
- <button class="btn"
- @click="$store.pluginSettings.resetToDefault()"
- :disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
- Default
- </button>
- <button class="btn btn-cancel"
- @click="window.closeModal?.()">
- Cancel
- </button>
+ <!-- Footer (pinned outside scroll area) -->
+ <div class="modal-footer" data-modal-footer>
+ <button class="btn btn-ok"
+ @click="context.save()"
+ :disabled="context?.isSaving || context?.isLoading">
+ Save
+ </button>
+ <button class="btn"
+ @click="context.resetToDefault()"
+ :disabled="context?.isSaving || context?.isLoading">
+ Default
+ </button>
+ <button class="btn btn-cancel"
+ @click="window.closeModal?.()">
+ Cancel
+ </button>
+ </div>
+ </div>
+ </template>
</div>
<style>
diff --git a/webui/js/initFw.js b/webui/js/initFw.js
index 15e915ecb..d8d67a655 100644
--- a/webui/js/initFw.js
+++ b/webui/js/initFw.js
@@ -150,3 +150,30 @@ Alpine.directive(
cleanup(() => clearInterval(intervalId));
}
);
+
+
+ // clone existing global store into standalone instance
+ globalThis.Alpine.magic('instantiate', () => (src) => {
+ const out = {};
+ const desc = Object.getOwnPropertyDescriptors(src);
+
+ for (const k in desc) {
+ const d = desc[k];
+
+ if (d.get || d.set || typeof d.value === "function") {
+ Object.defineProperty(out, k, d);
+ } else {
+ const v = d.value;
+ Object.defineProperty(out, k, {
+ ...d,
+ value: Array.isArray(v)
+ ? v.map(i => (i && typeof i === "object" ? { ...i } : i))
+ : v && typeof v === "object"
+ ? { ...v }
+ : v
+ });
+ }
+ }
+
+ return out;
+});
\ No newline at end of file