Skip to content

Agent Zero AI framework

Polish Agent Editor profile management

Alessandro7b9f06771f4a
diff --git a/plugins/_agent_editor/AGENTS.md b/plugins/_agent_editor/AGENTS.md
index fcf491b9d..cbf809cd2 100644
--- a/plugins/_agent_editor/AGENTS.md
+++ b/plugins/_agent_editor/AGENTS.md
@@ -55,9 +55,10 @@
editor; Agent Editor persists only the scoped preset reference.
- Manage agents reuses the plugin-settings project vocabulary: Global or one
existing project. The active chat profile appears once above the list; each
- row exposes scoped availability, duplication, icon-only Edit, and Delete for
- profiles owned by that scope. Duplicate materializes the effective source
- profile into the selected writable layer with a collision-free ID and title.
+ row exposes scoped availability, duplication, restore for inherited profiles,
+ icon-only Edit, and Delete for profiles owned by that scope. Duplicate
+ materializes the effective source profile into the selected writable layer
+ with a collision-free ID and title.
Availability changes quietly refresh the adjacent profile switcher catalog
without a success toast.
- The same project selector is available inside Create and Edit. Create keeps
diff --git a/plugins/_agent_editor/webui/agent-editor-store.js b/plugins/_agent_editor/webui/agent-editor-store.js
index 105dfa725..455477c9a 100644
--- a/plugins/_agent_editor/webui/agent-editor-store.js
+++ b/plugins/_agent_editor/webui/agent-editor-store.js
@@ -297,6 +297,33 @@ const model = {
}
},
+ async restoreProfile(profile) {
+ if (!profile?.id || profile.deletable || !profile.scope_has_overrides || this.saving) return;
+ const confirmed = await showConfirmDialog({
+ title: `Restore ${escapeHtml(profile.title || profile.id)}?`,
+ message: `<p>This removes your Agent Editor customizations from ${escapeHtml(this.scopeLabel)}. Other files stay in place.</p>`,
+ confirmText: "Restore original",
+ type: "danger",
+ });
+ if (!confirmed) return;
+ this.saving = true;
+ this.error = "";
+ try {
+ await callJsonApi(API, {
+ action: "remove_changes",
+ profile_id: profile.id,
+ destructive: false,
+ ...this.scopeInput(),
+ });
+ await this.loadProfiles();
+ await modelConfigStore.loadAgentProfiles(true);
+ } catch (error) {
+ this.error = error.message || String(error);
+ } finally {
+ this.saving = false;
+ }
+ },
+
async onScopeChanged() {
const previous = this.intent.projectName || "";
const next = this.projectName || "";
diff --git a/plugins/_agent_editor/webui/main.html b/plugins/_agent_editor/webui/main.html
index f40b7da56..b2d432b61 100644
--- a/plugins/_agent_editor/webui/main.html
+++ b/plugins/_agent_editor/webui/main.html
@@ -66,7 +66,6 @@
<div class="agent-manager-name">
<strong x-text="profile.title || profile.id"></strong>
<span class="agent-origin" x-text="profile.origin"></span>
- <span class="agent-customized-indicator" x-show="profile.scope_has_overrides" title="Customized" aria-label="Customized" role="img"><x-icon name="edit_note"></x-icon></span>
</div>
<p x-text="profile.description || 'No description'"></p>
<button type="button" class="text-button agent-manager-inline-action"
@@ -75,6 +74,13 @@
@click="$store.agentEditor.duplicateProfile(profile)">
<x-icon name="content_copy"></x-icon><span>Duplicate</span>
</button>
+ <button type="button" class="text-button agent-manager-inline-action"
+ x-show="profile.scope_has_overrides && !profile.deletable"
+ :disabled="$store.agentEditor.saving"
+ :aria-label="`Restore original ${profile.title || profile.id}`"
+ @click="$store.agentEditor.restoreProfile(profile)">
+ <x-icon name="restore"></x-icon><span>Restore original</span>
+ </button>
</div>
<div class="agent-manager-actions">
<label class="toggle agent-profile-availability"
@@ -218,7 +224,7 @@
</div>
<small>Use the current preset or choose another setup for this agent.</small>
</div>
- <div class="agent-field wide"><label for="agent-editor-context" class="agent-field-label">When should other agents use this agent?</label><textarea id="agent-editor-context" rows="3" x-model="$store.agentEditor.draft.context" @input="$store.agentEditor.markMetadataSet('context')"></textarea><small>Helps Agent Zero decide when to delegate work to this profile.</small><small class="field-provenance" x-show="$store.agentEditor.metadataProvenance('context')" x-text="$store.agentEditor.metadataProvenance('context')"></small><button type="button" class="text-button" x-show="$store.agentEditor.canResetMetadata('context')" @click="$store.agentEditor.resetMetadata('context')">Reset to inherited</button><small class="field-status" x-show="$store.agentEditor.metadataResetPending('context')">Will reset to inherited on save.</small><span class="field-status" x-show="!$store.agentEditor.draft.context">Delegation quality can be lower while this is empty.</span></div>
+ <div class="agent-field wide"><label for="agent-editor-context" class="agent-field-label">When should other agents use this agent?</label><textarea id="agent-editor-context" rows="3" x-model="$store.agentEditor.draft.context" @input="$store.agentEditor.markMetadataSet('context')"></textarea><small>Helps Agent Zero decide when to delegate work; leaving this empty may reduce delegation quality.</small><button type="button" class="text-button" x-show="$store.agentEditor.canResetMetadata('context')" @click="$store.agentEditor.resetMetadata('context')">Reset to inherited</button><small class="field-status" x-show="$store.agentEditor.metadataResetPending('context')">Will reset to inherited on save.</small></div>
</div>
</div>
</section>
@@ -326,10 +332,9 @@
</div>
</template>
- <div class="modal-footer agent-editor-footer" data-modal-footer x-show="!$store.agentEditor.loading && !($store.agentEditor.view === 'editor' && $store.agentEditor.pendingMutation)">
+ <div class="modal-footer agent-editor-footer" data-modal-footer x-show="!$store.agentEditor.loading && $store.agentEditor.view === 'editor' && !$store.agentEditor.pendingMutation">
<div class="footer-left">
- <button type="button" class="btn btn-cancel" x-show="$store.agentEditor.view === 'manage'" @click="window.closeModal?.()">Close</button>
- <button type="button" class="btn btn-cancel" x-show="$store.agentEditor.view === 'editor'" @click="window.closeModal?.()">Cancel</button>
+ <button type="button" class="btn btn-cancel" @click="window.closeModal?.()">Cancel</button>
</div>
<div class="footer-actions">
<button type="button" class="btn agent-editor-secondary-action" x-show="$store.agentEditor.view === 'editor' && !$store.agentEditor.draft?.creating" @click="$store.agentEditor.save(true)" :disabled="$store.agentEditor.saving || $store.agentEditor.validationIssues().length > 0">Save & test</button>
@@ -380,7 +385,7 @@
.agent-avatar { width:5rem; aspect-ratio:1; position:relative; display:grid; place-items:center; border-radius:16px; overflow:hidden; color:white; font-size:1.35rem; font-weight:700; box-shadow:inset 0 0 0 1px rgba(255,255,255,.15); }
.agent-avatar img { width:100%; height:100%; object-fit:cover; }
.avatar-progress { position:absolute; inset:0; display:grid; place-items:center; background:rgba(0,0,0,.5); }
- .agent-avatar-actions { display:flex; align-items:center; justify-content:center; gap:.35rem; font-size:.76rem; white-space:nowrap; }
+ .agent-avatar-actions { --agent-editor-action:var(--color-primary); display:flex; align-items:center; justify-content:center; gap:.35rem; font-size:.76rem; white-space:nowrap; }
.avatar-color-action,.avatar-upload-action { position:relative; cursor:pointer; }
.avatar-action-icon { display:grid; place-items:center; width:1.75rem; height:1.75rem; border-radius:6px; color:var(--agent-editor-action); }
.avatar-action-icon x-icon { font-size:1.05rem; }
@@ -399,7 +404,7 @@
.agent-editor .text-button { display:inline-flex; align-items:center; min-height:1.5rem; border:0; padding:0; background:transparent; color:var(--agent-editor-action); cursor:pointer; font-size:.82rem; text-align:left; }
.agent-editor .text-button:hover { text-decoration:underline; }
.agent-easy textarea { min-height:11rem; resize:vertical; }
- .restore-action { display:inline-flex; align-items:center; gap:.25rem; margin-top:.4rem; }
+ .restore-action { --agent-editor-action:var(--color-primary); display:inline-flex; align-items:center; gap:.25rem; margin-top:.4rem; }
.easy-tool-list { display:flex; flex-direction:column; padding:.2rem .35rem .2rem 0; }
.easy-tool-list .policy-item { cursor:pointer; }
.easy-skills-hint { margin:.55rem 0 0; color:var(--color-text-secondary); font-size:.79rem; }
@@ -521,16 +526,16 @@
.active-agent-avatar { width:1.5rem; aspect-ratio:1; display:grid; flex:0 0 auto; place-items:center; overflow:hidden; border-radius:6px; color:#fff; font-size:.65rem; font-weight:700; }
.active-agent-avatar img { width:100%; height:100%; object-fit:cover; }
.agent-manager-create { flex:0 0 auto; display:inline-flex; align-items:center; gap:.35rem; }
- .agent-manager-list { display:flex; flex-direction:column; gap:.55rem; }
- .agent-manager-card { display:grid; grid-template-columns:3rem minmax(0,1fr) auto; gap:.75rem; align-items:center; padding:.75rem; border:1px solid var(--color-border); border-radius:10px; }
+ .agent-manager-list { display:flex; flex-direction:column; }
+ .agent-manager-card { display:grid; grid-template-columns:3rem minmax(0,1fr) auto; gap:.75rem; align-items:center; padding:.65rem .25rem; }
+ .agent-manager-card + .agent-manager-card { border-top:1px solid var(--color-border); }
.agent-manager-avatar { width:3rem; aspect-ratio:1; display:grid; place-items:center; border-radius:10px; color:white; font-weight:700; overflow:hidden; }
.agent-manager-avatar img { width:100%; height:100%; object-fit:cover; }
.agent-manager-copy { min-width:0; }
.agent-manager-name { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; }
.agent-manager-name strong,.agent-manager-copy p { overflow-wrap:anywhere; }
- .agent-customized-indicator { display:inline-grid; place-items:center; color:var(--color-text-secondary); }
- .agent-customized-indicator x-icon { font-size:1rem; }
.agent-editor .agent-manager-inline-action { gap:.25rem; margin-top:.15rem; color:var(--color-message-text); opacity:.7; }
+ .agent-editor .agent-manager-inline-action + .agent-manager-inline-action { margin-left:.5rem; }
.agent-editor .agent-manager-inline-action:hover:not(:disabled) { background:transparent; color:var(--color-text); text-decoration:none; opacity:1; }
.agent-manager-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; }
.agent-profile-availability input { width:0; height:0; margin:0; border:0; }
diff --git a/tests/test_agent_editor_webui.py b/tests/test_agent_editor_webui.py
index 72098e1ed..4f53266b6 100644
--- a/tests/test_agent_editor_webui.py
+++ b/tests/test_agent_editor_webui.py
@@ -103,9 +103,7 @@ def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls
assert '<option value="">Global</option>' in modal
assert 'x-for="project in $store.agentEditor.projects"' in modal
assert 'x-show="profile.deletable"' in modal
- assert 'x-show="profile.scope_has_overrides"' in modal
- assert 'class="agent-customized-indicator"' in modal
- assert 'title="Customized"' in modal
+ assert 'class="agent-customized-indicator"' not in modal
assert 'class="button agent-manager-create"' in modal
assert 'class="active-agent-display"' in modal
assert 'class="button icon-button" title="Edit"' in modal
@@ -118,6 +116,9 @@ def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls
assert ':disabled="!!$store.agentEditor.duplicatingProfile"' in modal
assert ':aria-label="`Duplicate ${profile.title || profile.id}`"' in modal
assert "$store.agentEditor.duplicateProfile(profile)" in modal
+ assert 'x-show="profile.scope_has_overrides && !profile.deletable"' in modal
+ assert ':aria-label="`Restore original ${profile.title || profile.id}`"' in modal
+ assert "$store.agentEditor.restoreProfile(profile)" in modal
assert 'class="toggle agent-profile-availability"' in modal
assert ':disabled="$store.agentEditor.profileAvailabilitySaving"' in modal
assert "Default is always available" not in modal
@@ -158,7 +159,7 @@ def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls
assert modal.count('role="alert"') >= 4
assert "Fix ${$store.agentEditor.validationIssues().length}" in modal
assert modal.count("$store.agentEditor.validationIssues().length > 0") == 2
- assert "!($store.agentEditor.view === 'editor' && $store.agentEditor.pendingMutation)" in modal
+ assert "$store.agentEditor.view === 'editor' && !$store.agentEditor.pendingMutation" in modal
assert 'x-show="$store.agentEditor.view === \'editor\' && !$store.agentEditor.draft?.creating"' in modal
assert 'class="btn btn-ok" x-show="$store.agentEditor.view === \'editor\'"' in modal
assert "Delete all customizations in" in modal
@@ -166,8 +167,9 @@ def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls
assert 'promptDisplayState(prompt)' in modal
assert 'promptSourceChain($store.agentEditor.selectedPromptDraft)' in modal
assert "Will reset to inherited on save." in modal
- for key in ("title", "description", "context"):
+ for key in ("title", "description"):
assert f'x-show="$store.agentEditor.metadataProvenance(\'{key}\')"' in modal
+ assert 'metadataProvenance(\'context\')' not in modal
assert ':title="prompt.filename"' not in modal
assert "promptEditPending($store.agentEditor.selectedPromptDraft)" in modal
assert 'aria-label="Discard current edit"' in modal
@@ -210,6 +212,7 @@ def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls
assert "@keydown.ctrl.s.prevent" in modal
assert "@media (max-width: 760px)" in modal
assert modal.count("data-modal-footer") == 1
+ assert ">Close</button>" not in modal
def test_agent_editor_store_has_no_conversational_or_model_builder_path() -> None:
@@ -397,6 +400,16 @@ if (toggleRequest !== 2 || rapidProfiles[1].enabled || store.profileAvailability
setEnabledHandler = null;
await store.duplicateProfile({ id: "researcher", title: "Researcher" });
if (!calls.some(item => item.payload?.action === "duplicate" && item.payload.profile_id === "researcher") || !store.profiles.some(profile => profile.id === "researcher-1")) throw new Error("profile duplication failed");
+calls.length = 0;
+confirmResult = false;
+await store.restoreProfile({ id: "researcher", title: "Researcher", scope_has_overrides: true, deletable: false });
+if (calls.length || confirmations.at(-1)?.title !== "Restore Researcher?") throw new Error("restore cancellation failed");
+confirmResult = true;
+await store.restoreProfile({ id: "researcher", title: "Researcher", scope_has_overrides: true, deletable: false });
+if (!calls.some(item => item.payload?.action === "remove_changes" && item.payload.profile_id === "researcher" && item.payload.destructive === false)) throw new Error("restore original did not use sparse removal");
+if (!calls.some(item => item.endpoint === "loadAgentProfiles" && item.payload === true) || store.saving) throw new Error("restore original did not refresh profile state");
+confirmations.length = 0;
+confirmResult = false;
store.projectName = "other";
if (store.currentChatUsesScope() || store.isProfileActive("default")) throw new Error("foreign project profile appeared active");
store.projectName = "demo";