make some overall QoL improvements
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user