feat: Add update_theme functionality with UI support

Backend:
- Add PUT /api/themes/:id endpoint for updating existing themes

Store:
- Add updateTheme method to theme store

MCP:
- Add update_theme tool to modify name, description, or save current variables

UI:
- Add edit button to ThemeListItem (custom themes only)
- Add edit modal with name and description fields
- Support editing from both desktop sidebar and mobile dropdown
This commit is contained in:
2026-02-13 05:50:13 -06:00
parent d5518cb6d1
commit 2e64dceb1e
6 changed files with 263 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ const showNewThemeModal = ref(false)
const showCloneModal = ref(false)
const cloneSourceId = ref<string | null>(null)
const cloneName = ref('')
const showEditModal = ref(false)
const editingTheme = ref<any>(null)
const editName = ref('')
const editDescription = ref('')
const fileInput = ref<HTMLInputElement | null>(null)
const currentCategoryVariables = computed(() => {
@@ -58,6 +62,26 @@ async function confirmClone() {
}
}
function handleEditTheme(theme: any) {
editingTheme.value = theme
editName.value = theme.name
editDescription.value = theme.description || ''
showEditModal.value = true
}
async function confirmEdit() {
if (editingTheme.value && editName.value.trim()) {
await store.updateTheme(editingTheme.value.id, {
name: editName.value.trim(),
description: editDescription.value.trim() || undefined
})
showEditModal.value = false
editingTheme.value = null
editName.value = ''
editDescription.value = ''
}
}
function handleSetDefault(id: string) {
store.setDefaultTheme(id)
}
@@ -171,6 +195,7 @@ onMounted(() => {
@select="(t) => { handleSelectTheme(t); mobileDropdownOpen = false }"
@clone="handleCloneTheme"
@setDefault="handleSetDefault"
@edit="handleEditTheme"
/>
</div>
<div v-if="store.userThemes.length > 0" class="dropdown-section">
@@ -184,6 +209,7 @@ onMounted(() => {
@delete="handleDeleteTheme"
@clone="handleCloneTheme"
@setDefault="handleSetDefault"
@edit="handleEditTheme"
/>
</div>
</div>
@@ -208,6 +234,7 @@ onMounted(() => {
@delete="handleDeleteTheme"
@clone="handleCloneTheme"
@setDefault="handleSetDefault"
@edit="handleEditTheme"
/>
</section>
@@ -222,6 +249,7 @@ onMounted(() => {
@delete="handleDeleteTheme"
@clone="handleCloneTheme"
@setDefault="handleSetDefault"
@edit="handleEditTheme"
/>
</section>
</div>
@@ -366,6 +394,33 @@ onMounted(() => {
</div>
</div>
</div>
<!-- Edit Modal -->
<div v-if="showEditModal" class="modal-overlay" @click="showEditModal = false">
<div class="modal" @click.stop>
<h3>Edit Theme</h3>
<div class="form-group">
<label>Name</label>
<input
v-model="editName"
type="text"
placeholder="Theme name"
/>
</div>
<div class="form-group">
<label>Description</label>
<textarea
v-model="editDescription"
placeholder="Theme description (optional)"
rows="3"
></textarea>
</div>
<div class="modal-actions">
<button class="btn-secondary" @click="showEditModal = false">Cancel</button>
<button class="btn-primary" @click="confirmEdit">Save</button>
</div>
</div>
</div>
</div>
</template>
@@ -820,6 +875,35 @@ onMounted(() => {
border-color: var(--accent);
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
font-size: 0.8rem;
font-weight: 500;
color: var(--text-secondary);
margin-bottom: 0.375rem;
}
.modal textarea {
width: 100%;
padding: 0.75rem 1rem;
background: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: 8px;
color: var(--text-primary);
font-size: 0.95rem;
font-family: inherit;
resize: vertical;
}
.modal textarea:focus {
outline: none;
border-color: var(--accent);
}
.modal-actions {
display: flex;
gap: 0.75rem;