feat: Persona-Detail-Popover im Chat-Kopf (#1122)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 10:41:11 +01:00
parent 023fff607a
commit f9e1dcfd32
3 changed files with 32 additions and 3 deletions

View File

@ -61,9 +61,19 @@ pub(super) async fn page(State(state): State<Arc<AppState>>, headers: HeaderMap)
}
}
let personas = state.store().personas(&viewer.user).unwrap_or_default();
// CHAT-01/Persona-Popover: Angaben je Persona für die Detailansicht (nur Angaben, kein Prompt-Text).
let persona_options: String = personas
.iter()
.map(|p| format!("<option value=\"{}\">{}</option>", p.id, esc(&p.name)))
.map(|p| {
format!(
"<option value=\"{}\" data-version=\"{}\" data-stimme=\"{}\" data-zeichen=\"{}\">{}</option>",
p.id,
p.version,
esc(p.voice.as_deref().unwrap_or("")),
p.systemprompt.chars().count() + p.style.chars().count(),
esc(&p.name)
)
})
.collect();
let model_context: Vec<_> = models
.iter()
@ -131,7 +141,9 @@ pub(super) async fn page(State(state): State<Arc<AppState>>, headers: HeaderMap)
format!(
"<div class=\"chat-rahmen\" id=\"chat-rahmen\"><aside class=\"chat-seite\" aria-label=\"Verlauf\"><div class=\"zeile\"><input type=\"search\" id=\"chat-suche\" placeholder=\"Suchen …\" aria-label=\"Verläufe durchsuchen\"></div><ul id=\"chat-liste\"></ul></aside>\
<section class=\"card\" id=\"chat\">\
<div class=\"zeile chat-kopf\" id=\"chat-kopf\"><label>Persona <select id=\"chat-persona\"><option value=\"\">aus</option>{persona_options}</select></label>{stimme_kopf}</div>\
<div class=\"zeile chat-kopf\" id=\"chat-kopf\"><label>Persona <select id=\"chat-persona\"><option value=\"\">aus</option>{persona_options}</select></label>\
<details class=\"persona-popover\" id=\"chat-persona-popover\"><summary>Details</summary>\
<div class=\"klein\" id=\"chat-persona-details\" aria-live=\"polite\">Keine Persona gewählt.</div></details>{stimme_kopf}</div>\
<div class=\"zeile\">\
<label>Max. Tokens <input id=\"chat-max\" type=\"number\" min=\"1\" max=\"{MAX_TOKENS_LIMIT}\" value=\"{DEFAULT_MAX_TOKENS}\"></label>{sprache}\
<span class=\"rechts\"><button class=\"sm\" type=\"button\" id=\"chat-seite-knopf\" aria-expanded=\"true\" aria-controls=\"chat-rahmen\">Verlauf ein/aus</button><button class=\"sm\" type=\"button\" id=\"chat-neu\">Neuer Chat</button></span></div>\
@ -652,6 +664,17 @@ const CHAT_JS: &str = r#"(function () {
}
modell.addEventListener("change", laengePruefen);
persona.addEventListener("change", laengePruefen);
// Persona-Popover: Name, Version, Stimme und Umfang der gewählten Persona.
var personaDetails = document.getElementById("chat-persona-details");
function personaDetailsZeigen() {
if (!personaDetails) { return; }
var o = persona.options[persona.selectedIndex];
if (!persona.value || !o) { personaDetails.textContent = "Keine Persona gewählt."; return; }
var stimme = o.getAttribute("data-stimme") || "keine";
personaDetails.textContent = o.textContent + " · Version " + o.getAttribute("data-version") + " · Stimme: " + stimme + " · Umfang " + o.getAttribute("data-zeichen") + " Zeichen";
}
persona.addEventListener("change", personaDetailsZeigen);
personaDetailsZeigen();
laengePruefen();
var sprache = document.getElementById("chat-sprache");
var stimme = document.getElementById("chat-stimme");