Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(personas): edit custom personas (GH #55)

purplead9498f00a10
diff --git a/src/components/personas/PersonaPanel.tsx b/src/components/personas/PersonaPanel.tsx
index 0400ee24..730f2275 100644
--- a/src/components/personas/PersonaPanel.tsx
+++ b/src/components/personas/PersonaPanel.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react'
-import { Plus, Trash2 } from 'lucide-react'
+import { Plus, Trash2, Pencil } from 'lucide-react'
import { useSettingsStore } from '../../stores/settingsStore'
import { PersonaCard } from './PersonaCard'
import { SystemPromptEditor } from './SystemPromptEditor'
@@ -9,6 +9,9 @@ export function PersonaPanel() {
const personasEnabled = useSettingsStore((s) => s.settings.personasEnabled)
const updateSettings = useSettingsStore((s) => s.updateSettings)
const [showEditor, setShowEditor] = useState(false)
+ const [editingId, setEditingId] = useState<string | null>(null)
+
+ const editingPersona = editingId ? personas.find((p) => p.id === editingId) : undefined
return (
<div className="w-full max-w-2xl">
@@ -60,17 +63,27 @@ export function PersonaPanel() {
onClick={() => setActivePersona(persona.id)}
/>
{!persona.isBuiltIn && (
- <button
- onClick={() => removePersona(persona.id)}
- className="absolute -top-1 -right-1 w-5 h-5 rounded-full bg-red-500/80 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"
- >
- <Trash2 size={10} />
- </button>
+ <div className="absolute -top-1 -right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button
+ onClick={() => { setEditingId(persona.id); setShowEditor(false) }}
+ title="Edit persona"
+ className="w-5 h-5 rounded-full bg-gray-600/90 text-white flex items-center justify-center hover:bg-gray-500"
+ >
+ <Pencil size={10} />
+ </button>
+ <button
+ onClick={() => { removePersona(persona.id); if (editingId === persona.id) setEditingId(null) }}
+ title="Delete persona"
+ className="w-5 h-5 rounded-full bg-red-500/80 text-white flex items-center justify-center hover:bg-red-500"
+ >
+ <Trash2 size={10} />
+ </button>
+ </div>
)}
</div>
))}
<button
- onClick={() => setShowEditor(!showEditor)}
+ onClick={() => { setShowEditor(!showEditor); setEditingId(null) }}
className="flex flex-col items-center gap-2 p-4 rounded-xl bg-gray-50 dark:bg-white/[0.02] border border-gray-300 dark:border-white/10 hover:border-gray-400 dark:hover:border-white/15 transition-all cursor-pointer"
>
<div className="w-10 h-10 rounded-lg flex items-center justify-center bg-gray-100 dark:bg-white/5">
@@ -80,7 +93,19 @@ export function PersonaPanel() {
</button>
</div>
- {showEditor && <SystemPromptEditor />}
+ {/* Edit mode (GitHub #55) takes precedence over create mode. The `key`
+ remounts the editor per persona so its seeded fields refresh. */}
+ {editingPersona ? (
+ <SystemPromptEditor
+ key={editingPersona.id}
+ editingId={editingPersona.id}
+ initialName={editingPersona.name}
+ initialPrompt={editingPersona.systemPrompt}
+ onDone={() => setEditingId(null)}
+ />
+ ) : showEditor ? (
+ <SystemPromptEditor onDone={() => setShowEditor(false)} />
+ ) : null}
</div>
)
}
diff --git a/src/components/personas/SystemPromptEditor.tsx b/src/components/personas/SystemPromptEditor.tsx
index 956d1dba..f903a9e6 100644
--- a/src/components/personas/SystemPromptEditor.tsx
+++ b/src/components/personas/SystemPromptEditor.tsx
@@ -3,22 +3,46 @@ import { v4 as uuid } from 'uuid'
import { GlowButton } from '../ui/GlowButton'
import { useSettingsStore } from '../../stores/settingsStore'
-export function SystemPromptEditor() {
- const { addPersona } = useSettingsStore()
- const [name, setName] = useState('')
- const [prompt, setPrompt] = useState('')
+interface SystemPromptEditorProps {
+ /** When set, the editor updates this persona in place instead of adding a
+ * new one (GitHub #55 — edit custom personas). The parent remounts the
+ * editor with a `key` so the seeded fields below refresh per persona. */
+ editingId?: string | null
+ initialName?: string
+ initialPrompt?: string
+ /** Called after a successful save/update or a cancel, so the parent can
+ * close the editor. */
+ onDone?: () => void
+}
+
+export function SystemPromptEditor({
+ editingId,
+ initialName = '',
+ initialPrompt = '',
+ onDone,
+}: SystemPromptEditorProps) {
+ const { addPersona, updatePersona } = useSettingsStore()
+ const [name, setName] = useState(initialName)
+ const [prompt, setPrompt] = useState(initialPrompt)
+ const isEditing = !!editingId
const handleSave = () => {
if (!name.trim() || !prompt.trim()) return
- addPersona({
- id: uuid(),
- name: name.trim(),
- icon: 'User',
- systemPrompt: prompt.trim(),
- isBuiltIn: false,
- })
- setName('')
- setPrompt('')
+ if (isEditing) {
+ // Only the user-editable fields — keep id/icon/isBuiltIn untouched.
+ updatePersona(editingId!, { name: name.trim(), systemPrompt: prompt.trim() })
+ } else {
+ addPersona({
+ id: uuid(),
+ name: name.trim(),
+ icon: 'User',
+ systemPrompt: prompt.trim(),
+ isBuiltIn: false,
+ })
+ setName('')
+ setPrompt('')
+ }
+ onDone?.()
}
return (
@@ -36,9 +60,19 @@ export function SystemPromptEditor() {
rows={4}
className="w-full px-3 py-2 rounded-lg bg-white/5 border border-white/10 text-white placeholder-gray-500 focus:outline-none focus:border-white/20 text-sm resize-none"
/>
- <GlowButton onClick={handleSave} disabled={!name.trim() || !prompt.trim()} className="w-full">
- Save Persona
- </GlowButton>
+ <div className="flex gap-2">
+ <GlowButton onClick={handleSave} disabled={!name.trim() || !prompt.trim()} className="flex-1">
+ {isEditing ? 'Update Persona' : 'Save Persona'}
+ </GlowButton>
+ {onDone && (
+ <button
+ onClick={onDone}
+ className="px-4 py-2 rounded-lg text-sm text-gray-500 hover:text-gray-300 border border-white/10 hover:border-white/20 transition-colors"
+ >
+ Cancel
+ </button>
+ )}
+ </div>
</div>
)
}