make some overall QoL improvements
CI / check (22) (push) Failing after 15m53s
CI / check (24) (push) Failing after 15m50s

This commit is contained in:
Frederik Spirgi
2026-10-12 13:07:59 +02:00
parent f67d918d09
commit 7723125c93
11 changed files with 159 additions and 25 deletions
+7 -3
View File
@@ -5,15 +5,19 @@
/** @typedef {{message: string, model: string, chatId: number, webSearch?: boolean, reasoning?: boolean}} ChatRequest */
/** @typedef {{role: string, content: string, thinking?: string, sources?: WebSource[]}} ChatMessage */
export function createWebSearchToggle(button) {
export function createWebSearchToggle(button, storage = globalThis.localStorage) {
const key = "krishd-web-search-enabled";
let enabled = true;
try { enabled = storage?.getItem(key) !== "false"; } catch { /* Storage may be unavailable. */ }
const render = () => {
button.setAttribute("aria-pressed", String(enabled));
button.title = enabled ? "Automatic web search on - click to disable" : "Web search off - click to enable";
button.title = enabled ? "Web search allowed. The assistant searches when useful. Click to turn off."
: "Web search off. Click to allow the assistant to search when useful.";
button.setAttribute("aria-label", button.title);
};
button.addEventListener("click", () => {
enabled = !enabled;
try { storage?.setItem(key, String(enabled)); } catch { /* Keep this session's choice. */ }
render();
});
render();
@@ -28,7 +32,7 @@ export function appendSources(container, sources) {
section.setAttribute("aria-label", "Sources");
const heading = document.createElement("div");
heading.className = "msg-sources-heading";
heading.textContent = "Sources";
heading.textContent = "Used web results · Sources";
section.appendChild(heading);
sources.slice(0, 5).forEach((source, index) => {
let url;