Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Add per-row busy state to Marketplace plugin actions

Juan Denisf909103656d5
diff --git a/backend/app/plugins/serverkit-tramo/workflow_store.py b/backend/app/plugins/serverkit-tramo/workflow_store.py
index 610c3f7c..aeccc709 100644
--- a/backend/app/plugins/serverkit-tramo/workflow_store.py
+++ b/backend/app/plugins/serverkit-tramo/workflow_store.py
@@ -111,12 +111,19 @@ class WorkflowStore:
@staticmethod
def _empty_doc(slug, name):
- """A minimal valid tramo WorkflowDoc so a new workflow opens cleanly."""
+ """A minimal valid tramo WorkflowDoc so a new workflow opens cleanly.
+
+ Mirrors tramo's own ``emptyDoc()`` — ``version`` and ``meta`` must be
+ present, since the editor's Canvas reads ``doc.meta.mcpServers``
+ unconditionally and crashes on a doc without ``meta``.
+ """
return {
+ 'version': 1,
'id': slug,
'name': name,
'nodes': [],
'edges': [],
+ 'meta': {},
}
# ---------- engine materialization ----------
diff --git a/backend/tests/test_tramo_extension.py b/backend/tests/test_tramo_extension.py
index e60661f5..67c438e1 100644
--- a/backend/tests/test_tramo_extension.py
+++ b/backend/tests/test_tramo_extension.py
@@ -187,6 +187,14 @@ def test_create_slugifies_and_uniquifies(app):
assert a.get_doc().get('nodes') == []
+def test_create_doc_has_meta_and_version(app):
+ """A brand-new workflow doc must carry `meta` (and `version`): the editor's
+ Canvas reads `doc.meta.mcpServers` unconditionally and crashes without it."""
+ doc = WorkflowStore.create('needs-meta').get_doc()
+ assert doc.get('meta') == {}
+ assert doc.get('version') == 1
+
+
def test_create_rejects_blank_name(app):
with pytest.raises(ValueError):
WorkflowStore.create(' ')
diff --git a/builtin-extensions/serverkit-tramo/backend/workflow_store.py b/builtin-extensions/serverkit-tramo/backend/workflow_store.py
index 610c3f7c..aeccc709 100644
--- a/builtin-extensions/serverkit-tramo/backend/workflow_store.py
+++ b/builtin-extensions/serverkit-tramo/backend/workflow_store.py
@@ -111,12 +111,19 @@ class WorkflowStore:
@staticmethod
def _empty_doc(slug, name):
- """A minimal valid tramo WorkflowDoc so a new workflow opens cleanly."""
+ """A minimal valid tramo WorkflowDoc so a new workflow opens cleanly.
+
+ Mirrors tramo's own ``emptyDoc()`` — ``version`` and ``meta`` must be
+ present, since the editor's Canvas reads ``doc.meta.mcpServers``
+ unconditionally and crashes on a doc without ``meta``.
+ """
return {
+ 'version': 1,
'id': slug,
'name': name,
'nodes': [],
'edges': [],
+ 'meta': {},
}
# ---------- engine materialization ----------
diff --git a/builtin-extensions/serverkit-tramo/frontend/components/TramoEditor.jsx b/builtin-extensions/serverkit-tramo/frontend/components/TramoEditor.jsx
index 3cf7f3f7..3801d659 100644
--- a/builtin-extensions/serverkit-tramo/frontend/components/TramoEditor.jsx
+++ b/builtin-extensions/serverkit-tramo/frontend/components/TramoEditor.jsx
@@ -20,7 +20,12 @@ const TramoEditor = ({ slug, onSaveStateChange }) => {
key: slug,
loadDoc: async () => {
const data = await api.request(`/tramo/workflows/${slug}`);
- return data.doc || { name: slug, nodes: [], edges: [] };
+ const doc = data.doc || { version: 1, id: slug, name: slug, nodes: [], edges: [], meta: {} };
+ // The editor's Canvas reads `doc.meta.mcpServers` unconditionally, so a
+ // doc without `meta` crashes it. Guarantee `meta` for brand-new
+ // workflows and any doc persisted by an older version.
+ if (!doc.meta) doc.meta = {};
+ return doc;
},
saveDoc: async (doc) => {
await api.request(`/tramo/workflows/${slug}`, { method: 'PUT', body: { doc } });
diff --git a/builtin-extensions/serverkit-tramo/frontend/styles/tramo-automations.scss b/builtin-extensions/serverkit-tramo/frontend/styles/tramo-automations.scss
index 897bf444..d3def94e 100644
--- a/builtin-extensions/serverkit-tramo/frontend/styles/tramo-automations.scss
+++ b/builtin-extensions/serverkit-tramo/frontend/styles/tramo-automations.scss
@@ -696,6 +696,26 @@
display: flex;
min-height: 0;
+ /* Theme bridge — tramo's editor ships only a light `:root` palette
+ (--tr-*). We don't restyle its .tr-* classes; we feed its documented
+ colour variables from the host design tokens instead. Because custom
+ properties inherit down the DOM, defining them here (an ancestor of the
+ whole editor subtree) overrides tramo's :root values without any
+ specificity battle — and since the host tokens flip with data-theme,
+ the canvas + inspector track dark/light automatically. */
+ --tr-bg: var(--bg-body);
+ --tr-surface: var(--bg-card);
+ --tr-surface-alt: var(--bg-hover);
+ --tr-border: var(--border-default);
+ --tr-border-strong: var(--border-strong);
+ --tr-text: var(--text-primary);
+ --tr-text-muted: var(--text-secondary);
+ --tr-edge: var(--border-strong);
+ --tr-plus: var(--text-tertiary);
+ --tr-accent: var(--accent);
+ --tr-accent-soft: var(--accent-bg);
+ --tr-shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.22);
+
&__canvas {
position: relative;
flex: 1;
diff --git a/frontend/src/pages/Marketplace.jsx b/frontend/src/pages/Marketplace.jsx
index 598a847e..bc656edd 100644
--- a/frontend/src/pages/Marketplace.jsx
+++ b/frontend/src/pages/Marketplace.jsx
@@ -175,6 +175,10 @@ const Marketplace = () => {
const [detailEntry, setDetailEntry] = useState(null);
// Plugin pending uninstall — drives the keep-vs-purge data-policy dialog.
const [uninstallTarget, setUninstallTarget] = useState(null);
+ // Id of the installed plugin whose row action (uninstall/toggle/update) is
+ // in flight. Drives per-row button disabling + live status copy so an
+ // operation can't be double-fired and the operator always sees progress.
+ const [busyPlugin, setBusyPlugin] = useState(null); // { id, action }
// Plugin whose config is being edited (#49) — drives the config dialog.
const [configTarget, setConfigTarget] = useState(null);
@@ -248,28 +252,36 @@ const Marketplace = () => {
const confirmPluginUninstall = async (purge) => {
const plugin = uninstallTarget;
setUninstallTarget(null);
- if (!plugin) return;
+ if (!plugin || busyPlugin) return;
+ setBusyPlugin({ id: plugin.id, action: 'uninstall' });
try {
await api.uninstallPlugin(plugin.id, purge);
toast.success(purge ? 'Extension uninstalled; data purged' : 'Extension uninstalled; data kept');
- loadExtensions();
- } catch (err) { toast.error(err.message); }
+ await loadExtensions();
+ } catch (err) {
+ toast.error(err.message);
+ } finally {
+ setBusyPlugin(null);
+ }
};
const handlePluginUpdate = async (pluginId) => {
- setInstalling(true);
+ if (busyPlugin) return;
+ setBusyPlugin({ id: pluginId, action: 'update' });
try {
const result = await api.updatePlugin(pluginId);
toast.success(`Extension "${result.display_name}" updated to v${result.version}.`);
- loadExtensions();
+ await loadExtensions();
} catch (err) {
toast.error(err.message || 'Extension update failed');
} finally {
- setInstalling(false);
+ setBusyPlugin(null);
}
};
const handlePluginToggle = async (plugin) => {
+ if (busyPlugin) return;
+ setBusyPlugin({ id: plugin.id, action: plugin.status === 'active' ? 'disable' : 'enable' });
try {
if (plugin.status === 'active') {
await api.disablePlugin(plugin.id);
@@ -278,8 +290,12 @@ const Marketplace = () => {
await api.enablePlugin(plugin.id);
toast.success('Extension enabled');
}
- loadExtensions();
- } catch (err) { toast.error(err.message); }
+ await loadExtensions();
+ } catch (err) {
+ toast.error(err.message);
+ } finally {
+ setBusyPlugin(null);
+ }
};
const resetFilters = () => {
@@ -431,7 +447,7 @@ const Marketplace = () => {
key={plugin.id}
plugin={plugin}
update={updatesByKey.get(String(plugin.id))}
- installing={installing}
+ busy={busyPlugin?.id === plugin.id ? busyPlugin.action : null}
onToggle={handlePluginToggle}
onUpdate={handlePluginUpdate}
onUninstall={requestPluginUninstall}
@@ -759,9 +775,12 @@ const PLUGIN_SOURCE_BADGES = {
registry: { label: 'Registry', variant: 'info' },
};
-const PluginRow = ({ plugin, update, installing, onToggle, onUpdate, onUninstall, onConfigure, statusVariant }) => {
+const PluginRow = ({ plugin, update, busy, onToggle, onUpdate, onUninstall, onConfigure, statusVariant }) => {
const updateAvailable = Boolean(update?.update_available);
const compatible = update?.compatible !== false;
+ // A row action is in flight — disable every action on this row so it can't
+ // be double-fired, and surface which one via the button copy.
+ const isBusy = Boolean(busy);
const configurable = plugin.config_schema
&& typeof plugin.config_schema === 'object'
&& Object.keys(plugin.config_schema).length > 0;
@@ -796,28 +815,31 @@ const PluginRow = ({ plugin, update, installing, onToggle, onUpdate, onUninstall
{updateAvailable && (
<Button
size="sm"
- disabled={!compatible || installing}
+ disabled={!compatible || isBusy}
title={compatible ? undefined : 'Panel version is too old for this update'}
onClick={() => onUpdate(plugin.id)}
>
<DownloadCloud aria-hidden="true" />
- Update
+ {busy === 'update' ? 'Updating…' : 'Update'}
</Button>
)}
{configurable && (
- <Button size="sm" variant="outline" onClick={() => onConfigure(plugin)}>
+ <Button size="sm" variant="outline" disabled={isBusy} onClick={() => onConfigure(plugin)}>
Configure
</Button>
)}
<Button
size="sm"
variant={plugin.status === 'active' ? 'outline' : 'default'}
+ disabled={isBusy}
onClick={() => onToggle(plugin)}
>
- {plugin.status === 'active' ? 'Disable' : 'Enable'}
+ {busy === 'enable' ? 'Enabling…'
+ : busy === 'disable' ? 'Disabling…'
+ : plugin.status === 'active' ? 'Disable' : 'Enable'}
</Button>
- <Button size="sm" variant="destructive" onClick={() => onUninstall(plugin)}>
- Uninstall
+ <Button size="sm" variant="destructive" disabled={isBusy} onClick={() => onUninstall(plugin)}>
+ {busy === 'uninstall' ? 'Uninstalling…' : 'Uninstall'}
</Button>
</div>
</article>
diff --git a/frontend/src/plugins/serverkit-tramo/components/TramoEditor.jsx b/frontend/src/plugins/serverkit-tramo/components/TramoEditor.jsx
index 3cf7f3f7..3801d659 100644
--- a/frontend/src/plugins/serverkit-tramo/components/TramoEditor.jsx
+++ b/frontend/src/plugins/serverkit-tramo/components/TramoEditor.jsx
@@ -20,7 +20,12 @@ const TramoEditor = ({ slug, onSaveStateChange }) => {
key: slug,
loadDoc: async () => {
const data = await api.request(`/tramo/workflows/${slug}`);
- return data.doc || { name: slug, nodes: [], edges: [] };
+ const doc = data.doc || { version: 1, id: slug, name: slug, nodes: [], edges: [], meta: {} };
+ // The editor's Canvas reads `doc.meta.mcpServers` unconditionally, so a
+ // doc without `meta` crashes it. Guarantee `meta` for brand-new
+ // workflows and any doc persisted by an older version.
+ if (!doc.meta) doc.meta = {};
+ return doc;
},
saveDoc: async (doc) => {
await api.request(`/tramo/workflows/${slug}`, { method: 'PUT', body: { doc } });
diff --git a/frontend/src/plugins/serverkit-tramo/styles/tramo-automations.scss b/frontend/src/plugins/serverkit-tramo/styles/tramo-automations.scss
index 897bf444..d3def94e 100644
--- a/frontend/src/plugins/serverkit-tramo/styles/tramo-automations.scss
+++ b/frontend/src/plugins/serverkit-tramo/styles/tramo-automations.scss
@@ -696,6 +696,26 @@
display: flex;
min-height: 0;
+ /* Theme bridge — tramo's editor ships only a light `:root` palette
+ (--tr-*). We don't restyle its .tr-* classes; we feed its documented
+ colour variables from the host design tokens instead. Because custom
+ properties inherit down the DOM, defining them here (an ancestor of the
+ whole editor subtree) overrides tramo's :root values without any
+ specificity battle — and since the host tokens flip with data-theme,
+ the canvas + inspector track dark/light automatically. */
+ --tr-bg: var(--bg-body);
+ --tr-surface: var(--bg-card);
+ --tr-surface-alt: var(--bg-hover);
+ --tr-border: var(--border-default);
+ --tr-border-strong: var(--border-strong);
+ --tr-text: var(--text-primary);
+ --tr-text-muted: var(--text-secondary);
+ --tr-edge: var(--border-strong);
+ --tr-plus: var(--text-tertiary);
+ --tr-accent: var(--accent);
+ --tr-accent-soft: var(--accent-bg);
+ --tr-shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.22);
+
&__canvas {
position: relative;
flex: 1;