Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(persona): add persona template picker with guided fields

Steven Enamakelae08a7ea1cbf
diff --git a/app/src/components/settings/panels/PersonaPanel.tsx b/app/src/components/settings/panels/PersonaPanel.tsx
index de5a903a67..79ea56dae4 100644
--- a/app/src/components/settings/panels/PersonaPanel.tsx
+++ b/app/src/components/settings/panels/PersonaPanel.tsx
@@ -1,4 +1,5 @@
import debug from 'debug';
+import { ChevronRight, RotateCcw } from 'lucide-react';
import { useEffect, useState } from 'react';
import { useT } from '../../../lib/i18n/I18nContext';
@@ -17,12 +18,27 @@ import {
setPersonaDescription,
setPersonaDisplayName,
} from '../../../store/personaSlice';
-import Button from '../../ui/Button';
-import { ToggleGroupItem, ToggleGroupRoot } from '../../ui/ToggleGroup';
-import { SettingsRow, SettingsSection, SettingsTextArea, SettingsTextField } from '../controls';
+import {
+ Alert,
+ AlertDescription,
+ AvatarFallback,
+ AvatarRoot,
+ Button,
+ Card,
+ Field,
+ Label,
+ TextArea,
+ TextField,
+ ToggleGroupItem,
+ ToggleGroupRoot,
+} from '../../ui';
import { useSettingsNavigation } from '../hooks/useSettingsNavigation';
import SettingsPanel from '../layout/SettingsPanel';
import PersonaGuidedFields from './persona/PersonaGuidedFields';
+import PersonaTemplatePicker from './persona/PersonaTemplatePicker';
+
+const SEGMENT_CLASS =
+ 'h-auto px-2.5 py-1 text-xs font-medium data-[state=on]:bg-primary-500 data-[state=on]:text-content-inverted';
type SoulMode = 'guided' | 'advanced';
@@ -141,166 +157,210 @@ const PersonaPanel = ({ embedded = false }: PersonaPanelProps) => {
}
};
+ const dirty = identityDirty || soulDirty;
+
+ // One save for the whole page. Identity lives in the store and the character
+ // in SOUL.md on disk, but to the user it is one form; two Save buttons in two
+ // cards made it easy to save half an edit.
+ const onSaveAll = async () => {
+ if (identityDirty) onSaveIdentity();
+ if (soulDirty) await onSaveSoul();
+ };
+
+ const onDiscard = () => {
+ setNameDraft(storedDisplayName);
+ setDescriptionDraft(storedDescription);
+ setSoulDraft(soulSaved);
+ setSoulError(null);
+ };
+
+ const initial = (nameDraft.trim() || 'A').charAt(0).toUpperCase();
+
const body = (
<>
- {/* ── Identity ─────────────────────────────────────────────── */}
- <SettingsSection title={t('settings.persona.identityHeading')}>
- <SettingsRow
- htmlFor="persona-display-name"
- label={t('settings.persona.displayNameLabel')}
- stacked
- control={
- <SettingsTextField
- id="persona-display-name"
- aria-label={t('settings.persona.displayNameLabel')}
- data-testid="persona-display-name-input"
- value={nameDraft}
- maxLength={MAX_PERSONA_DISPLAY_NAME_LEN}
- placeholder={t('settings.persona.displayNamePlaceholder')}
- onChange={e => setNameDraft(e.target.value)}
- />
- }
- />
- <SettingsRow
- htmlFor="persona-description"
- label={t('settings.persona.descriptionLabel')}
- stacked
- control={
- <SettingsTextArea
- id="persona-description"
- aria-label={t('settings.persona.descriptionLabel')}
- data-testid="persona-description-input"
- value={descriptionDraft}
- maxLength={MAX_PERSONA_DESCRIPTION_LEN}
- rows={3}
- placeholder={t('settings.persona.descriptionPlaceholder')}
- onChange={e => setDescriptionDraft(e.target.value)}
- />
- }
- />
- <div className="flex justify-end px-4 py-3">
- <Button
- type="button"
- data-testid="persona-identity-save"
- variant="primary"
- size="xs"
- onClick={onSaveIdentity}
- disabled={!identityDirty}>
- {t('common.save')}
- </Button>
+ {/* ── Identity: who the assistant is, as shown in the app ───────── */}
+ <Card
+ title={t('settings.persona.identityHeading')}
+ description={t('settings.persona.identityDesc')}>
+ <div className="flex flex-col gap-4 p-4 sm:flex-row sm:items-start">
+ <AvatarRoot className="h-14 w-14 shrink-0">
+ <AvatarFallback className="bg-primary-100 text-xl font-semibold text-primary-700 dark:bg-primary-500/15 dark:text-primary-300">
+ {initial}
+ </AvatarFallback>
+ </AvatarRoot>
+ <div className="min-w-0 flex-1 space-y-3">
+ <div>
+ <Label htmlFor="persona-display-name">{t('settings.persona.displayNameLabel')}</Label>
+ <TextField
+ id="persona-display-name"
+ aria-label={t('settings.persona.displayNameLabel')}
+ data-testid="persona-display-name-input"
+ value={nameDraft}
+ maxLength={MAX_PERSONA_DISPLAY_NAME_LEN}
+ placeholder={t('settings.persona.displayNamePlaceholder')}
+ onChange={e => setNameDraft(e.target.value)}
+ className="mt-1.5"
+ />
+ </div>
+ <div>
+ <Label htmlFor="persona-description">{t('settings.persona.descriptionLabel')}</Label>
+ <TextArea
+ id="persona-description"
+ aria-label={t('settings.persona.descriptionLabel')}
+ data-testid="persona-description-input"
+ value={descriptionDraft}
+ maxLength={MAX_PERSONA_DESCRIPTION_LEN}
+ rows={2}
+ placeholder={t('settings.persona.descriptionPlaceholder')}
+ onChange={e => setDescriptionDraft(e.target.value)}
+ className="mt-1.5 resize-none"
+ />
+ </div>
+ </div>
</div>
- </SettingsSection>
- <p className="text-xs text-content-muted leading-relaxed px-1">
- {t('settings.persona.identityDesc')}
- </p>
+ </Card>
- {/* ── Personality (SOUL.md) ────────────────────────────────── */}
- <SettingsSection title={t('settings.persona.soul.heading')}>
- {soulLoading ? (
- <div className="px-4 py-3">
- <p className="text-sm text-content-muted">{t('common.loading')}</p>
- </div>
- ) : (
- <>
- <ToggleGroupRoot
- type="single"
- value={soulMode}
- onValueChange={next => {
- if (next) setSoulMode(next as SoulMode);
- }}
- aria-label={t('settings.persona.builder.modeLabel')}
- variant="secondary"
- size="xs"
- className="px-4 pt-3">
- <ToggleGroupItem value="guided" data-testid="persona-soul-mode-guided">
- {t('settings.persona.builder.modeGuided')}
- </ToggleGroupItem>
- <ToggleGroupItem value="advanced" data-testid="persona-soul-mode-advanced">
- {t('settings.persona.builder.modeAdvanced')}
- </ToggleGroupItem>
- </ToggleGroupRoot>
- {soulMode === 'guided' ? (
- <PersonaGuidedFields value={soulDraft} onChange={setSoulDraft} disabled={soulBusy} />
- ) : (
- <div className="px-4 py-3">
- <SettingsTextArea
+ {soulLoading ? (
+ <Card padded>
+ <p className="text-sm text-content-muted">{t('common.loading')}</p>
+ </Card>
+ ) : (
+ <>
+ {/* ── Templates: one click to a sensible starting point ──────── */}
+ {soulMode === 'guided' && (
+ <Card
+ title={t('settings.persona.templates.heading')}
+ description={t('settings.persona.templates.desc')}>
+ <div className="p-4">
+ <PersonaTemplatePicker
+ value={soulDraft}
+ onChange={setSoulDraft}
+ disabled={soulBusy}
+ />
+ </div>
+ </Card>
+ )}
+
+ {/* ── Character: the SOUL.md sections, as plain fields ────────── */}
+ <Card
+ title={t('settings.persona.characterHeading')}
+ description={t('settings.persona.characterDesc')}
+ headerRight={
+ <ToggleGroupRoot
+ type="single"
+ value={soulMode}
+ onValueChange={next => {
+ if (next) setSoulMode(next as SoulMode);
+ }}
+ aria-label={t('settings.persona.builder.modeLabel')}
+ variant="secondary"
+ size="xs"
+ className="overflow-hidden rounded-lg border border-line gap-0 *:rounded-none *:border-0">
+ <ToggleGroupItem
+ value="guided"
+ data-testid="persona-soul-mode-guided"
+ className={SEGMENT_CLASS}>
+ {t('settings.persona.builder.modeGuided')}
+ </ToggleGroupItem>
+ <ToggleGroupItem
+ value="advanced"
+ data-testid="persona-soul-mode-advanced"
+ className={SEGMENT_CLASS}>
+ {t('settings.persona.builder.modeAdvanced')}
+ </ToggleGroupItem>
+ </ToggleGroupRoot>
+ }>
+ <div className="p-4">
+ {soulMode === 'guided' ? (
+ <PersonaGuidedFields
+ value={soulDraft}
+ onChange={setSoulDraft}
+ disabled={soulBusy}
+ />
+ ) : (
+ <TextArea
aria-label={t('settings.persona.soul.editorLabel')}
data-testid="persona-soul-editor"
value={soulDraft}
- rows={12}
+ rows={14}
spellCheck={false}
className="font-mono text-xs leading-relaxed"
onChange={e => setSoulDraft(e.target.value)}
/>
- </div>
- )}
- <div className="flex flex-wrap items-center gap-2 px-4 pb-3">
- <Button
- type="button"
- data-testid="persona-soul-save"
- variant="primary"
- size="xs"
- onClick={() => void onSaveSoul()}
- disabled={soulBusy || !soulDirty}>
- {t('common.save')}
- </Button>
+ )}
+ </div>
+ <div className="flex flex-wrap items-center justify-between gap-2 px-4 py-3">
+ <span className="text-[11px] text-content-muted">
+ {soulIsDefault ? (
+ <span data-testid="persona-soul-default-badge">
+ {t('settings.persona.soul.usingDefault')}
+ </span>
+ ) : null}
+ </span>
<Button
type="button"
data-testid="persona-soul-reset"
- variant="secondary"
+ variant="tertiary"
size="xs"
+ leadingIcon={<RotateCcw className="h-3.5 w-3.5" aria-hidden />}
onClick={() => void onResetSoul()}
disabled={soulBusy || soulIsDefault}>
{t('settings.persona.soul.reset')}
</Button>
- {soulIsDefault && (
- <span
- data-testid="persona-soul-default-badge"
- className="text-[11px] text-content-muted">
- {t('settings.persona.soul.usingDefault')}
- </span>
- )}
</div>
- </>
- )}
- {soulError && (
- <p
- data-testid="persona-soul-error"
- className="px-4 pb-3 text-xs text-coral-700 dark:text-coral-300">
- {soulError}
- </p>
- )}
- </SettingsSection>
- <p className="text-xs text-content-muted leading-relaxed px-1">
- {t('settings.persona.soul.desc')}
- </p>
+ </Card>
+ </>
+ )}
+
+ {soulError && (
+ <Alert variant="destructive" density="compact" data-testid="persona-soul-error">
+ <AlertDescription>{soulError}</AlertDescription>
+ </Alert>
+ )}
- {/* ── Appearance & Voice (handled in Mascot settings) ──────── */}
- <SettingsSection title={t('settings.persona.appearanceHeading')}>
- <div className="px-4 py-3">
- <Button
- type="button"
- variant="tertiary"
- data-testid="persona-open-mascot"
- onClick={() => navigateToSettings('personality#face')}
- className="w-full justify-between px-0 text-sm text-content hover:bg-transparent hover:text-primary-700 dark:hover:text-primary-300">
- <span>{t('settings.persona.openMascotSettings')}</span>
- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
- </svg>
- </Button>
+ {/* ── Face & voice live on the Face page ──────────────────────────── */}
+ <Card>
+ <Field
+ label={t('settings.persona.appearanceHeading')}
+ description={t('settings.persona.appearanceDesc')}
+ control={
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ data-testid="persona-open-mascot"
+ trailingIcon={<ChevronRight className="h-3.5 w-3.5" aria-hidden />}
+ onClick={() => navigateToSettings('face')}>
+ {t('settings.face.title')}
+ </Button>
+ }
+ />
+ </Card>
+
+ {/* ── One save bar for the page, shown only with unsaved edits ────── */}
+ {dirty && (
+ <div
+ className="sticky bottom-0 z-10 -mx-1 flex items-center justify-between gap-3 rounded-xl border border-line bg-surface/95 px-4 py-3 shadow-float backdrop-blur"
+ data-testid="persona-save-bar">
+ <span className="text-sm text-content-muted">{t('settings.persona.unsavedChanges')}</span>
+ <div className="flex gap-2">
+ <Button variant="secondary" size="sm" onClick={onDiscard} disabled={soulBusy}>
+ {t('settings.persona.discard')}
+ </Button>
+ <Button
+ size="sm"
+ data-testid="persona-save"
+ onClick={() => void onSaveAll()}
+ disabled={soulBusy}>
+ {t('settings.persona.saveChanges')}
+ </Button>
+ </div>
</div>
- </SettingsSection>
- <p className="text-xs text-content-muted leading-relaxed px-1">
- {t('settings.persona.appearanceDesc')}
- </p>
+ )}
</>
);
- // Embedded inside the tabbed Personality & Face page: the parent owns the
- // header AND the page gutter (`SettingsPanel` supplies `p-4` now), so this
- // renders the body flush — a `p-4` here would indent it twice, and the
- // sibling Face tab (MascotPanel) is already flush.
+ // Embedded inside another page: the host owns the header and gutter.
if (embedded) return <div className="space-y-5">{body}</div>;
return <SettingsPanel description={t('settings.personality.menuDesc')}>{body}</SettingsPanel>;
diff --git a/app/src/components/settings/panels/persona/PersonaGuidedFields.tsx b/app/src/components/settings/panels/persona/PersonaGuidedFields.tsx
index 7146b73f1e..b403ed80c3 100644
--- a/app/src/components/settings/panels/persona/PersonaGuidedFields.tsx
+++ b/app/src/components/settings/panels/persona/PersonaGuidedFields.tsx
@@ -1,9 +1,7 @@
import { useT } from '../../../../lib/i18n/I18nContext';
-import Button from '../../../ui/Button';
-import { SettingsRow, SettingsTextArea } from '../../controls';
+import { Button, Label, TextArea } from '../../../ui';
import { useSettingsNavigation } from '../../hooks/useSettingsNavigation';
import { applyPersonaField, parsePersonaFields, type PersonaFieldKey } from './personaSections';
-import PersonaTemplatePicker from './PersonaTemplatePicker';
interface PersonaGuidedFieldsProps {
/** The raw SOUL.md text — the single source of truth this view edits. */
@@ -42,7 +40,8 @@ const FIELDS: readonly FieldDef[] = [
] as const;
/**
- * Structured persona editor (issue #4253, PR1). Presents a few friendly fields
+ * Structured persona editor (issue #4253, PR1). The template picker is a
+ * separate card on the Personality page. Presents a few friendly fields
* that map to named `SOUL.md` sections so non-technical users never touch raw
* markdown. The raw text stays the source of truth: each edit is spliced back
* into `value` via {@link applyPersonaField} and emitted through `onChange`.
@@ -53,40 +52,30 @@ const PersonaGuidedFields = ({ value, onChange, disabled = false }: PersonaGuide
const fields = parsePersonaFields(value);
return (
- <div className="px-4 py-3 space-y-4">
+ <div className="space-y-4">
<p className="text-xs text-content-muted leading-relaxed">
{t('settings.persona.builder.intro')}
</p>
- <PersonaTemplatePicker value={value} onChange={onChange} disabled={disabled} />
-
{FIELDS.map(field => (
- <SettingsRow
- key={field.key}
- htmlFor={field.testId}
- label={t(field.labelKey)}
- stacked
- control={
- <SettingsTextArea
- id={field.testId}
- data-testid={field.testId}
- aria-label={t(field.labelKey)}
- value={fields[field.key]}
- rows={3}
- disabled={disabled}
- placeholder={t(field.placeholderKey)}
- onChange={e => onChange(applyPersonaField(value, field.key, e.target.value))}
- />
- }
- />
+ <div key={field.key}>
+ <Label htmlFor={field.testId}>{t(field.labelKey)}</Label>
+ <TextArea
+ id={field.testId}
+ data-testid={field.testId}
+ aria-label={t(field.labelKey)}
+ value={fields[field.key]}
+ rows={3}
+ disabled={disabled}
+ placeholder={t(field.placeholderKey)}
+ onChange={e => onChange(applyPersonaField(value, field.key, e.target.value))}
+ className="mt-1.5"
+ />
+ </div>
))}
<p className="text-xs text-content-muted leading-relaxed">
- {t('settings.persona.builder.preservedNote')}
- </p>
-
- <p className="text-xs text-content-muted leading-relaxed">
- {t('settings.persona.builder.securityNote')}{' '}
+ {t('settings.persona.builder.preservedNote')} {t('settings.persona.builder.securityNote')}{' '}
<Button
variant="tertiary"
size="xs"
diff --git a/app/src/components/settings/panels/persona/PersonaTemplatePicker.tsx b/app/src/components/settings/panels/persona/PersonaTemplatePicker.tsx
index 75ebc9c83c..20f7405d14 100644
--- a/app/src/components/settings/panels/persona/PersonaTemplatePicker.tsx
+++ b/app/src/components/settings/panels/persona/PersonaTemplatePicker.tsx
@@ -26,15 +26,8 @@ const PersonaTemplatePicker = ({
const { t } = useT();
return (
- <div className="space-y-2">
- <div>
- <p className="text-sm font-medium text-content">
- {t('settings.persona.templates.heading')}
- </p>
- <p className="text-xs text-content-muted leading-relaxed">
- {t('settings.persona.templates.desc')}
- </p>
- </div>
+ // Heading and description come from the host card.
+ <div>
<div className="grid grid-cols-2 gap-2 sm:grid-cols-3">
{PERSONA_TEMPLATES.map(template => (
<Button
@@ -43,7 +36,7 @@ const PersonaTemplatePicker = ({
disabled={disabled}
data-testid={`persona-template-${template.id}`}
onClick={() => onChange(applyTemplate(value, template))}
- className="h-auto w-full flex-col items-start justify-start gap-0.5 rounded-lg border-line-strong px-3 py-2 text-left hover:border-primary-400">
+ className="h-auto w-full flex-col items-start justify-start gap-0.5 rounded-lg border-line px-3 py-2 text-left hover:border-primary-400 hover:bg-surface-hover">
<span className="text-sm font-medium text-content">{t(template.labelKey)}</span>
<span className="text-[11px] font-normal text-content-muted leading-snug">
{t(template.descriptionKey)}
diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.ts
index e129332b13..d93c83867f 100644
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@ -6486,6 +6486,12 @@ const en: TranslationMap = {
'settings.persona.menuDesc':
'Name, personality, avatar, and voice: your assistant as one identity',
'settings.persona.identityHeading': 'Identity',
+ 'settings.persona.characterHeading': 'Character',
+ 'settings.persona.characterDesc':
+ 'How your assistant thinks and talks. Used as its instructions in every conversation.',
+ 'settings.persona.unsavedChanges': 'You have unsaved changes',
+ 'settings.persona.discard': 'Discard',
+ 'settings.persona.saveChanges': 'Save changes',
'settings.persona.identityDesc':
'A display name and short description for your assistant. Shown in the app; does not change how the assistant reasons.',
'settings.persona.displayNameLabel': 'Display name',