cleanup, simpler toggling logic

Alessandro committed Feb 26, 2026 at 11:15 UTC ec5842ace39964104e1e2faa0c23ab8887728b63
4 files changed +11 -41
plugins/example_agent/plugin.yaml
+2 -1
@@ -3,4 +3,5 @@ description: Example agent plugin demonstrating the Agent Zero plugin system.
3 version: 1.0.0
4 settings_sections: []
5 per_project_config: true
6 -per_agent_config: false
\ No newline at end of file
6 +per_agent_config: false
7 +always_enabled: true
webui/components/plugins/plugin-settings-store.js
+1 -1
@@ -58,7 +58,7 @@ const model = {
58 if (toggleStore) {
59 toggleStore.projectName = nextProject;
60 toggleStore.agentProfileKey = nextProfile;
61 - toggleStore.calculateStatus();
61 + await toggleStore.loadToggleStatus();
62 }
63 },
64
webui/components/plugins/toggle/plugin-toggle-advanced.html
+1 -26
@@ -60,18 +60,10 @@
60 </label>
61
62 <div class="plugin-settings-toolbar-item plugin-status-toggle-item">
63 - <template x-if="!$store.pluginToggle.hasExplicitRuleForScope && !$store.pluginToggle.alwaysEnabled">
64 - <button type="button"
65 - class="button icon-button"
66 - title="Add explicit rule for this scope"
67 - @click="$store.pluginToggle.addRule()">
68 - <span class="icon material-symbols-outlined">add</span>
69 - </button>
70 - </template>
63 <label class="toggle" :class="{ 'disabled-appearance': !$store.pluginToggle.hasExplicitRuleForScope && !$store.pluginToggle.alwaysEnabled }">
64 <input type="checkbox"
65 :checked="$store.pluginToggle.status === 'enabled'"
74 - :disabled="$store.pluginToggle.alwaysEnabled || $store.pluginToggle.isSaving || !$store.pluginToggle.hasExplicitRuleForScope"
66 + :disabled="$store.pluginToggle.alwaysEnabled || $store.pluginToggle.isSaving"
67 @change="$store.pluginToggle.setEnabled($event.target.checked)">
68 <span class="toggler"></span>
69 </label>
@@ -189,11 +181,6 @@
181 font-size: var(--font-size-small);
182 }
183
192 - .plugin-settings-body {
193 - padding: 1rem;
194 - min-height: 4rem;
195 - }
196 -
184 @media (max-width: 640px) {
185 .plugin-settings-toolbar-item {
186 flex-basis: 100%;
@@ -238,18 +225,6 @@
225 flex: 0 0 auto;
226 }
227
241 - .plugin-status-toggle-item .button {
242 - padding: 0.3rem 0.5rem;
243 - height: 2.2rem;
244 - display: flex;
245 - align-items: center;
246 - justify-content: center;
247 - }
248 -
249 - .plugin-status-toggle-item .button .icon {
250 - font-size: 1.1rem;
251 - }
252 -
228 .disabled-appearance {
229 opacity: 0.6;
230 }
webui/components/plugins/toggle/plugin-toggle-store.js
+7 -13
@@ -23,6 +23,7 @@ const model = {
23 perProjectConfig: true,
24 perAgentConfig: true,
25 hasExplicitRuleForScope: false,
26 + hasConfigScreen: false,
27
28 // Where the effective toggle was actually resolved (mirrors plugin-settings-store loadedXxx fields)
29 loadedPath: "",
@@ -39,6 +40,8 @@ const model = {
40 this.projectName = "";
41 this.agentProfileKey = "";
42 this.configs = [];
43 + this.status = 'enabled';
44 + this.hasExplicitRuleForScope = false;
45 this.loadedPath = "";
46 this.loadedProjectName = "";
47 this.loadedAgentProfile = "";
@@ -72,6 +75,8 @@ const model = {
75 this.loadedPath = "";
76 this.loadedProjectName = "";
77 this.loadedAgentProfile = "";
78 + this.isLoading = false;
79 + this.isSaving = false;
80 },
81
82 async loadProjects() {
@@ -176,27 +181,20 @@ const model = {
181 });
182 } else {
183 // Same plugin — push current scope explicitly.
179 - // onScopeChanged() syncs on @change events, but if the user never touched
180 - // the scope selectors after the modal opened the settings store may still
181 - // hold a stale scope from a prior session.
184 settingsStore.projectName = this.projectName || "";
185 settingsStore.agentProfileKey = this.agentProfileKey || "";
186 }
185 - await window.openModal?.("components/plugins/plugin-settings.html");
187 + await window.openModal?.("/components/plugins/plugin-settings.html");
188 },
189
190 async openConfigListModal() {
191 await window.openModal?.("/components/plugins/toggle/plugin-toggles.html");
192 },
193
192 - async loadConfigList() {
193 - await this.loadConfigs();
194 - },
195 -
194 async switchToConfig(projectName, agentProfile) {
195 this.projectName = projectName || "";
196 this.agentProfileKey = agentProfile || "";
199 - this.onScopeChanged();
197 + await this.onScopeChanged();
198 await window.closeModal?.();
199 },
200
@@ -258,10 +256,6 @@ const model = {
256 await settingsStore.loadSettings();
257 },
258
261 - async addRule() {
262 - await this.setEnabled(this.status === 'enabled');
263 - },
264 -
259 projectLabel(key) {
260 if (!key) return "Global";
261 const found = (this.projects || []).find(p => p.key === key);