feat: Chat-Kopf und Seitenleiste nach Auftrag v1.1 (A1, #1195); Version 0.1.18-rc1
Kopf nur mit Persona, Stimme und Einstellungen; Max. Tokens, Sprachausgabe und Live vorlesen im Popover; Neuer Chat und Einklappen in der Seitenleiste, Öffnen im Kopf; Popover legen sich über den Verlauf, höchstens eines offen, Klick daneben und Escape schließen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -132,8 +132,8 @@ pub(super) async fn page(State(state): State<Arc<AppState>>, headers: HeaderMap)
|
||||
.map(|m| format!("<option value=\"{0}\">{0}</option>", esc(m)))
|
||||
.collect();
|
||||
format!(
|
||||
"<label>Sprachausgabe <select id=\"chat-sprache\"><option value=\"\">aus</option>{options}</select></label>\
|
||||
<label><input type=\"checkbox\" id=\"chat-live\"> Live vorlesen</label>"
|
||||
"<label class=\"feld\">Sprachausgabe <select id=\"chat-sprache\"><option value=\"\">aus</option>{options}</select></label>\
|
||||
<label class=\"feld check\"><input type=\"checkbox\" id=\"chat-live\"> Live vorlesen</label>"
|
||||
)
|
||||
};
|
||||
// CHAT-04: Mini-Player über dem Eingabefeld. Der Platz bleibt, der Knopf ist ausgegraut, wenn nichts läuft.
|
||||
@ -148,19 +148,21 @@ pub(super) async fn page(State(state): State<Arc<AppState>>, headers: HeaderMap)
|
||||
let stimme_kopf = if sprachmodelle.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
"<details class=\"stimmen-popover\" id=\"chat-stimmen-popover\"><summary>Stimme</summary>\
|
||||
<label>Stimme <select id=\"chat-stimme\"><option value=\"\">(zuerst Sprachausgabe wählen)</option></select></label>\
|
||||
<button class=\"sm\" type=\"button\" id=\"chat-stimme-vorschau\">Vorschau</button></details>".to_string()
|
||||
"<details class=\"popover stimmen-popover\" id=\"chat-stimmen-popover\"><summary>Stimme</summary><div class=\"popover-box\">\
|
||||
<label class=\"feld\">Stimme <select id=\"chat-stimme\"><option value=\"\">(zuerst Sprachausgabe wählen)</option></select></label>\
|
||||
<button class=\"sm\" type=\"button\" id=\"chat-stimme-vorschau\">Vorschau</button></div></details>".to_string()
|
||||
};
|
||||
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><div id=\"chat-sync\" class=\"klein chat-sync\" role=\"status\" aria-live=\"polite\" hidden></div><ul id=\"chat-liste\"></ul></aside>\
|
||||
"<div class=\"chat-rahmen\" id=\"chat-rahmen\"><aside class=\"chat-seite\" aria-label=\"Verlauf\"><div class=\"chat-seite-kopf\"><button class=\"primary\" type=\"button\" id=\"chat-neu\">Neuer Chat</button>\
|
||||
<button class=\"sm icon\" type=\"button\" id=\"chat-seite-knopf\" aria-expanded=\"true\" aria-controls=\"chat-rahmen\" aria-label=\"Seitenleiste einklappen\" title=\"Seitenleiste einklappen\">{ICON_PANEL}</button></div><div class=\"zeile\"><input type=\"search\" id=\"chat-suche\" placeholder=\"Suchen …\" aria-label=\"Verläufe durchsuchen\"></div><div id=\"chat-sync\" class=\"klein chat-sync\" role=\"status\" aria-live=\"polite\" hidden></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>\
|
||||
<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>\
|
||||
<div class=\"chat-kopf\" id=\"chat-kopf\"><button class=\"sm icon chat-oeffnen\" type=\"button\" id=\"chat-seite-oeffnen\" aria-expanded=\"true\" aria-controls=\"chat-rahmen\" aria-label=\"Seitenleiste öffnen\" title=\"Seitenleiste öffnen\">{ICON_PANEL}</button>\
|
||||
<label class=\"chat-chip\"><span class=\"vh\">Persona</span><select id=\"chat-persona\"><option value=\"\">aus</option>{persona_options}</select></label>\
|
||||
<details class=\"popover persona-popover\" id=\"chat-persona-popover\"><summary>Details</summary><div class=\"popover-box\">\
|
||||
<div class=\"klein\" id=\"chat-persona-details\" aria-live=\"polite\">Keine Persona gewählt.</div></div></details>{stimme_kopf}\
|
||||
<details class=\"popover einst-popover rechts\" id=\"chat-einst-popover\"><summary aria-label=\"Erweiterte Einstellungen\" title=\"Erweiterte Einstellungen\">{ICON_REGLER}</summary><div class=\"popover-box\">\
|
||||
<strong>Erweiterte Einstellungen</strong>\
|
||||
<label class=\"feld\">Max. Tokens <input id=\"chat-max\" type=\"number\" min=\"1\" max=\"{MAX_TOKENS_LIMIT}\" value=\"{DEFAULT_MAX_TOKENS}\"></label>{sprache}</div></details></div>\
|
||||
<p class=\"klein\" id=\"chat-persona-hinweis\" data-kontexte=\"{contexts}\" data-laengen=\"{lengths}\" role=\"status\"></p>\
|
||||
<div class=\"verlauf\" id=\"chat-verlauf\" aria-live=\"polite\"></div><button type=\"button\" class=\"sm chat-nach-unten\" id=\"chat-nach-unten\" hidden>Zur aktuellen Antwort ↓</button>\
|
||||
{player}\
|
||||
@ -696,6 +698,10 @@ pub(super) async fn script() -> Response {
|
||||
|
||||
/// Skript des Playgrounds. Schreibt Texte nur über `textContent`, nie als
|
||||
/// HTML: Antworten eines Modells können nichts in die Seite einschleusen.
|
||||
/// Linienbilder (Lucide, Strichstärke wie `button.icon svg`), nehmen die Textfarbe an.
|
||||
const ICON_PANEL: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><path d=\"M9 3v18\"/></svg>";
|
||||
const ICON_REGLER: &str = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M20 7h-9M14 17H5\"/><circle cx=\"17\" cy=\"17\" r=\"3\"/><circle cx=\"7\" cy=\"7\" r=\"3\"/></svg>";
|
||||
|
||||
const CHAT_JS: &str = r#"(function () {
|
||||
var box = document.getElementById("chat");
|
||||
if (!box) { return; }
|
||||
@ -1789,12 +1795,29 @@ const CHAT_JS: &str = r#"(function () {
|
||||
zeichneListe();
|
||||
text.focus();
|
||||
}
|
||||
if (seiteKnopf) {
|
||||
seiteKnopf.addEventListener("click", function () {
|
||||
var zu = rahmen.classList.toggle("zu");
|
||||
seiteKnopf.setAttribute("aria-expanded", zu ? "false" : "true");
|
||||
});
|
||||
// Einklappen steht in der Seitenleiste, das Öffnen im Kopf (nur sichtbar, solange die Leiste zu ist).
|
||||
var seiteOeffnen = document.getElementById("chat-seite-oeffnen");
|
||||
function seiteUmschalten() {
|
||||
var zu = rahmen.classList.toggle("zu");
|
||||
if (seiteKnopf) { seiteKnopf.setAttribute("aria-expanded", zu ? "false" : "true"); }
|
||||
if (seiteOeffnen) { seiteOeffnen.setAttribute("aria-expanded", zu ? "false" : "true"); }
|
||||
if (zu && seiteOeffnen) { seiteOeffnen.focus(); } else if (!zu && seiteKnopf) { seiteKnopf.focus(); }
|
||||
}
|
||||
if (seiteKnopf) { seiteKnopf.addEventListener("click", seiteUmschalten); }
|
||||
if (seiteOeffnen) { seiteOeffnen.addEventListener("click", seiteUmschalten); }
|
||||
// Popover im Kopf: höchstens einer offen; Klick daneben oder Escape schließt.
|
||||
var popovers = Array.prototype.slice.call(document.getElementById("chat-kopf").querySelectorAll("details.popover"));
|
||||
popovers.forEach(function (p) {
|
||||
p.addEventListener("toggle", function () {
|
||||
if (p.open) { popovers.forEach(function (q) { if (q !== p) { q.open = false; } }); }
|
||||
});
|
||||
});
|
||||
document.addEventListener("click", function (e) {
|
||||
popovers.forEach(function (p) { if (p.open && !p.contains(e.target)) { p.open = false; } });
|
||||
});
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Escape") { popovers.forEach(function (p) { if (p.open) { p.open = false; p.querySelector("summary").focus(); } }); }
|
||||
});
|
||||
suche.addEventListener("input", zeichneListe);
|
||||
zeichneListe();
|
||||
verlaufVomServer();
|
||||
|
||||
Reference in New Issue
Block a user