add JSDoc comments because yes
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Bündelt JSON-Anfragen und verarbeitet Ereignisse gestreamter Chat-Antworten im Browser.
|
||||
*/
|
||||
export async function request(url, data, method = "POST") {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
@@ -60,6 +63,7 @@ export async function stream(url, data, handlers = {}, signal = undefined) {
|
||||
if (done) break;
|
||||
buffer += decoder.decode(value, {stream: true});
|
||||
const parts = buffer.split(/\r?\n\r?\n/);
|
||||
// Das letzte SSE-Ereignis kann unvollständig sein und wird mit dem nächsten Netzwerkblock ergänzt.
|
||||
buffer = parts.pop() || "";
|
||||
for (const part of parts) {
|
||||
const lines = part.split("\n");
|
||||
@@ -81,6 +85,7 @@ export async function stream(url, data, handlers = {}, signal = undefined) {
|
||||
}
|
||||
if (terminal) break;
|
||||
}
|
||||
// Ohne explizites Abschluss- oder Fehlerereignis gilt die Verbindung als vorzeitig abgebrochen.
|
||||
if (!terminal) throw new Error("Response was interrupted. Please try again.");
|
||||
} finally {
|
||||
await reader.cancel().catch(() => {});
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Verwaltet Bildauswahl, Uploads und Vorschauen sowie die Anzeige gespeicherter Anhänge.
|
||||
*/
|
||||
export function appendAttachments(container, attachments = []) {
|
||||
if (!attachments.length) return;
|
||||
const gallery = document.createElement("div");
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert das Chat-Seitenpanel einschließlich Tastaturbedienung und Fokusverwaltung.
|
||||
*/
|
||||
import {chatDrawer, chatDrawerButton, chatDrawerCloseBtn} from "./dom.js?v=20260909-account-controls";
|
||||
|
||||
let lastFocusedElement = null;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Stellt gemeinsame Theme-Daten, Einstiegsvorschläge und die angefragte Chat-ID bereit.
|
||||
*/
|
||||
export const requestedChatId = Number(window.location.pathname.match(/^\/app\/chats\/(\d+)$/)?.[1] || new URLSearchParams(window.location.search).get("chat")) || null;
|
||||
|
||||
export const onboardingPrompts = {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Bündelt Referenzen auf die HTML-Elemente der Chat-Oberfläche.
|
||||
*/
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const chatDiv = $("chat");
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert die Persona-Marktplatzoberfläche mit Suche, Vorschauen und Persona-Verwaltung.
|
||||
*/
|
||||
import { get, post, put } from "./api.js?v=20260909-account-controls";
|
||||
import { initializeAppearance } from "./themeController.js?v=20260909-account-controls";
|
||||
import { clearStatus, setStatus } from "./statusNotice.js?v=20260909-account-controls";
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Ermittelt die Modellfamilie und prüft die Unterstützung des Reasoning-Modus.
|
||||
*/
|
||||
// Conservative allowlist for models supporting the boolean think API.
|
||||
// Unknown models remain usable for normal chat.
|
||||
const reasoningFamilies = new Set(["qwen3", "deepseek-r1", "deepseek-v3.1"]);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Ordnet Modellen Profilinformationen für ihre Darstellung und Auswahl in der Oberfläche zu.
|
||||
*/
|
||||
export const defaultModelProfile = {
|
||||
badge: "General",
|
||||
summary: "Best for general questions, drafting, and everyday conversation. Use a specialized model when you need stronger coding, reasoning, or roleplay behavior."
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert öffentliche Seiten sowie Anmelde- und Registrierungsformulare mit Rückkehr in den Arbeitsbereich.
|
||||
*/
|
||||
import { get, post } from "/js/api.js?v=20260909-account-controls";
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Überträgt Persona-Daten zwischen Formularfeldern und den verwendeten Datenobjekten.
|
||||
*/
|
||||
const personaFieldNames = ["name", "pronouns", "appearance", "background", "details", "exampleDialogues"];
|
||||
|
||||
export function populatePersonaForm(fields, persona = {}) {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert die Reasoning-Auswahl und die aufklappbare Anzeige gestreamter Gedankengänge.
|
||||
*/
|
||||
import {supportsReasoning} from "./modelCapabilities.js?v=20260921-reasoning-capability";
|
||||
|
||||
export function createReasoningToggle(button) {
|
||||
@@ -43,6 +46,7 @@ export function updateReasoning(messageElement, thinking, streaming = false) {
|
||||
}
|
||||
details.querySelector("summary").textContent = streaming ? "Reasoning · Thinking…" : "Reasoning";
|
||||
const content = details.querySelector(".msg-reasoning-content");
|
||||
// Nur automatisch nach unten scrollen, wenn die Ansicht bereits nahe am Ende steht.
|
||||
const follow = content.scrollHeight - content.scrollTop - content.clientHeight < 40;
|
||||
content.textContent = thinking;
|
||||
if (streaming && follow) content.scrollTop = content.scrollHeight;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Ersetzt eine Antwort während der Neugenerierung in ihrer Nachrichtenkarte und stellt sie bei Fehlern wieder her.
|
||||
*/
|
||||
import {stream} from "./api.js";
|
||||
import {updateReasoning, finishReasoning} from "./reasoning.js";
|
||||
import {appendSources} from "./webSearch.js";
|
||||
@@ -46,6 +49,7 @@ export async function regenerateInline({card, scroller, endpoint, payload, rende
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
// Bei Fehler oder Abbruch die ursprünglichen Knoten samt Ereignishandlern wieder einsetzen.
|
||||
if (!committed) update(() => card.replaceChildren(...original));
|
||||
card.removeAttribute("aria-busy");
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert die Chat-Oberfläche mit Gesprächsauswahl, Nachrichteneingabe, Streaming und Persona-Verwaltung.
|
||||
*/
|
||||
import { del, get, post, put, stream } from "./api.js?v=20260909-account-controls";
|
||||
import { regenerateInline } from "./regeneration.js";
|
||||
import { appendSources, createWebSearchToggle } from "./webSearch.js";
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert die Einstellungsoberfläche für Darstellung, Konto, Personas und Diagnosen.
|
||||
*/
|
||||
import { del, get, post, put } from "./api.js?v=20260909-account-controls";
|
||||
import {
|
||||
applyTheme as applySharedTheme,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Zeigt Statusmeldungen an und setzt deren Inhalt und Sichtbarkeit zurück.
|
||||
*/
|
||||
export function setStatus(element, message = "", state = "", baseClass = "status") {
|
||||
if (!element) return;
|
||||
element.textContent = message;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Übernimmt das gespeicherte Theme frühzeitig in das Dokument, bevor die übrige Oberfläche initialisiert wird.
|
||||
*/
|
||||
(() => {
|
||||
const themes = new Set(["fakegpt", "fraud", "germini", "slopilot", "beta-ai", "confusity"]);
|
||||
const storedTheme = localStorage.getItem("krishd-theme");
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Normalisiert, speichert und synchronisiert Theme und Hell-Dunkel-Modus der Oberfläche.
|
||||
*/
|
||||
import {themes} from "./constants.js?v=20260909-account-controls";
|
||||
|
||||
export const THEME_STORAGE_KEY = "krishd-theme";
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Steuert die Websuche-Auswahl und rendert Quellenlinks zu Chat-Antworten.
|
||||
*/
|
||||
/** @typedef {{title: string, url: string, snippet: string}} WebSource */
|
||||
/** @typedef {{message: string, model: string, chatId: number, webSearch?: boolean, reasoning?: boolean}} ChatRequest */
|
||||
/** @typedef {{role: string, content: string, thinking?: string, sources?: WebSource[]}} ChatMessage */
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @file Verbindet die Abmeldeknöpfe des gemeinsamen Seitenkopfs mit der Sitzungsverwaltung.
|
||||
*/
|
||||
import {post} from './api.js?v=20260909-account-controls';
|
||||
|
||||
// Every page gets this control from the same server-rendered header.
|
||||
|
||||
Reference in New Issue
Block a user