plugins default config helper and frontend

Alessandro committed Mar 2, 2026 at 11:05 UTC 809771807e13becb0278e83b98adf85883a5d9e6
4 files changed +44
python/api/plugins.py
+7
@@ -151,6 +151,13 @@ class Plugins(ApiHandler):
151
152 return {"ok": True}
153
154 + if action == "get_default_config":
155 + plugin_name = input.get("plugin_name", "")
156 + if not plugin_name:
157 + return Response(status=400, response="Missing plugin_name")
158 + settings = plugins.get_default_plugin_config(plugin_name)
159 + return {"ok": True, "data": settings or {}}
160 +
161 if action == "save_config":
162 plugin_name = input.get("plugin_name", "")
163 project_name = input.get("project_name", "")
python/helpers/plugins.py
+9
@@ -386,6 +386,15 @@ def get_plugin_config(
386 return None
387
388
389 +def get_default_plugin_config(plugin_name: str):
390 + file_path = files.get_abs_path(find_plugin_dir(plugin_name), CONFIG_DEFAULT_FILE_NAME)
391 + if file_path and files.exists(file_path):
392 + return (
393 + json.loads if file_path.lower().endswith(".json") else yaml_helper.loads
394 + )(files.read_file(file_path))
395 + return None
396 +
397 +
398 def save_plugin_config(
399 plugin_name: str, project_name: str, agent_profile: str, settings: dict
400 ):
webui/components/plugins/plugin-settings-store.js
+23
@@ -1,6 +1,8 @@
1 import { createStore } from "/js/AlpineStore.js";
2 +import { showConfirmDialog } from "/js/confirmDialog.js";
3
4 const fetchApi = globalThis.fetchApi;
5 +const justToast = globalThis.justToast;
6
7 const model = {
8 // which plugin this modal is showing
@@ -264,6 +266,27 @@ const model = {
266 }
267 },
268
269 + async resetToDefault() {
270 + if (!this.pluginName) return;
271 + const confirmed = await showConfirmDialog({
272 + title: "Reset to Default",
273 + message: "This will replace the current settings with the plugin defaults. Any unsaved changes will be lost.",
274 + confirmText: "Reset",
275 + type: "warning",
276 + });
277 + if (!confirmed) return;
278 + const response = await fetchApi("/plugins", {
279 + method: "POST",
280 + headers: { "Content-Type": "application/json" },
281 + body: JSON.stringify({ action: "get_default_config", plugin_name: this.pluginName }),
282 + });
283 + const result = await response.json().catch(() => ({}));
284 + if (result.ok) {
285 + this.settings = result.data || {};
286 + justToast("Settings reset to default.", "info");
287 + }
288 + },
289 +
290 async save() {
291 if (!this.pluginName) return;
292
webui/components/plugins/plugin-settings.html
+5
@@ -105,6 +105,11 @@
105 :disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
106 Save
107 </button>
108 + <button class="btn"
109 + @click="$store.pluginSettings.resetToDefault()"
110 + :disabled="$store.pluginSettings?.isSaving || $store.pluginSettings?.isLoading">
111 + Default
112 + </button>
113 <button class="btn btn-cancel"
114 @click="window.closeModal?.()">
115 Cancel