fix(group): show all user-created personas in the participant selector (#1770)

_getCharacterList() had two bugs that silently dropped every
user-created persona from the group participant picker:

1. The /api/presets/templates endpoint returns a JSON array directly,
   but the code read `data.templates` (always undefined). The forEach
   over `data.templates || []` iterated over an empty array every time,
   so no user templates were ever added.

2. Even if the array had been read correctly, the `t.isCharacter` guard
   would have filtered them all out — user templates are saved by
   presets.js without that flag, which is only present on built-in
   PROMPT_TEMPLATES entries.

Fix: accept both the direct-array and the {templates:[]} shapes, drop
the isCharacter guard (user_templates are personas by definition), and
use the correct field name (system_prompt, not prompt) so the character
prompt actually reaches the group chat.

Fixes #1656
This commit is contained in:
Lucas Daniel
2026-06-03 01:23:14 -03:00
committed by GitHub
parent bde5f6adb3
commit 12fd8b6570

View File

@@ -299,13 +299,16 @@ async function _getCharacterList() {
}); });
} }
} catch (e) {} } catch (e) {}
// Load user templates and wait for them before returning // Load user templates and wait for them before returning.
// The endpoint returns a JSON array directly (not {templates:[...]}).
// All user templates are personas by definition — no isCharacter filter needed.
try { try {
const r = await fetch(API_BASE + '/api/presets/templates', { credentials: 'same-origin' }); const r = await fetch(API_BASE + '/api/presets/templates', { credentials: 'same-origin' });
const data = await r.json(); const data = await r.json();
(data.templates || []).forEach(t => { const templates = Array.isArray(data) ? data : (data.templates || []);
if (t.isCharacter && !chars.find(c => c.id === t.id)) { templates.forEach(t => {
chars.push({ id: t.id, name: t.name, prompt: t.prompt || '' }); if (t.id && t.name && !chars.find(c => c.id === t.id)) {
chars.push({ id: t.id, name: t.name, prompt: t.system_prompt || t.prompt || '' });
} }
}); });
} catch (e) {} } catch (e) {}