Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Merge f-027-int2 into f-027-gh-app
Niko12210d0ec83b7dda
diff --cc apps/host/src/lib/i18n.tsindex 628f1f372,0c398be83..8a429c46e--- a/apps/host/src/lib/i18n.ts+++ b/apps/host/src/lib/i18n.ts@@@ -23,15 -25,7 +25,17 @@@ import fix_es from '../locales/fix-es.jimport fix_ru from '../locales/fix-ru.json';import fix_pt from '../locales/fix-pt.json';import fix_ko from '../locales/fix-ko.json';+ import fix_fr from '../locales/fix-fr.json';+/* The strings of the 0.2.7 GitHub items (gh-<lang>.json, scripts/make-gh-locales.py). */+import gh_en from '../locales/gh-en.json';+import gh_zh from '../locales/gh-zh.json';+import gh_ja from '../locales/gh-ja.json';+import gh_de from '../locales/gh-de.json';+import gh_es from '../locales/gh-es.json';+import gh_ru from '../locales/gh-ru.json';+import gh_pt from '../locales/gh-pt.json';+import gh_ko from '../locales/gh-ko.json';++import gh_fr from '../locales/gh-fr.json';import base_zh from '../locales/zh.json';import base_ja from '../locales/ja.json';import base_de from '../locales/de.json';@@@ -45,9 -40,9 +50,9 @@@ export type Language=typeof LANGUAGES[n/* The Tune model dialog's strings live in tune-<lang>.json (apps/host/scripts/make-tune-locales.py) so other interface work does not collide with them. *//* The tool-server, picture and agent-result strings of the tools and images fixes live in tools-<lang>.json for the same reason. *//* The strings that had no key in the files above (#3479, #3825) and the 0.2.4.3 fixes live in fix-<lang>.json (scripts/make-fix-locales.py). */-const english:Record<string,string>={...baseEnglish,...tune_en,...tools_en,...fix_en};-const [zh,ja,de,es,ru,pt,ko,fr]=[{...base_zh,...tune_zh,...tools_zh,...fix_zh},{...base_ja,...tune_ja,...tools_ja,...fix_ja},{...base_de,...tune_de,...tools_de,...fix_de},{...base_es,...tune_es,...tools_es,...fix_es},{...base_ru,...tune_ru,...tools_ru,...fix_ru},{...base_pt,...tune_pt,...tools_pt,...fix_pt},{...base_ko,...tune_ko,...tools_ko,...fix_ko},{...base_fr,...tune_fr,...tools_fr,...fix_fr}] as Record<string,string>[];+const english:Record<string,string>={...baseEnglish,...tune_en,...tools_en,...fix_en,...gh_en};- const [zh,ja,de,es,ru,pt,ko]=[{...base_zh,...tune_zh,...tools_zh,...fix_zh,...gh_zh},{...base_ja,...tune_ja,...tools_ja,...fix_ja,...gh_ja},{...base_de,...tune_de,...tools_de,...fix_de,...gh_de},{...base_es,...tune_es,...tools_es,...fix_es,...gh_es},{...base_ru,...tune_ru,...tools_ru,...fix_ru,...gh_ru},{...base_pt,...tune_pt,...tools_pt,...fix_pt,...gh_pt},{...base_ko,...tune_ko,...tools_ko,...fix_ko,...gh_ko}] as Record<string,string>[];- const catalogs:Record<Language,Record<string,string>>={en:english,zh,ja,de,es,ru,pt,ko};++const [zh,ja,de,es,ru,pt,ko,fr]=[{...base_zh,...tune_zh,...tools_zh,...fix_zh,...gh_zh},{...base_ja,...tune_ja,...tools_ja,...fix_ja,...gh_ja},{...base_de,...tune_de,...tools_de,...fix_de,...gh_de},{...base_es,...tune_es,...tools_es,...fix_es,...gh_es},{...base_ru,...tune_ru,...tools_ru,...fix_ru,...gh_ru},{...base_pt,...tune_pt,...tools_pt,...fix_pt,...gh_pt},{...base_ko,...tune_ko,...tools_ko,...fix_ko,...gh_ko},{...base_fr,...tune_fr,...tools_fr,...fix_fr,...gh_fr}] as Record<string,string>[];+ const catalogs:Record<Language,Record<string,string>>={en:english,zh,ja,de,fr,es,ru,pt,ko};const entities:Record<string,string>={amp:'&',lt:'<',gt:'>',quot:'"',apos:"'",nbsp:'\u00a0'};const decode=(text:string)=>text.replace(/&(#x[\da-f]+|#\d+|amp|lt|gt|quot|apos|nbsp);/gi,(whole,key:string)=>key[0]==='#'?String.fromCodePoint(key[1].toLowerCase()==='x'?parseInt(key.slice(2),16):parseInt(key.slice(1),10)):entities[key]??whole);const ids=new Map(Object.entries(english).map(([id,value])=>[decode(value),id]));diff --cc docs/DETAILS.mdindex bd5b7f4c5,92360d808..8013aab04--- a/docs/DETAILS.md+++ b/docs/DETAILS.md@@@ -768,9 -815,8 +818,9 @@@ after a changeneeded for `npx` servers. An **address** (`url`, optional `headers`) uses MCP's Streamable HTTP transport (the older SSE-onlytransport is not supported). `"disabled": true` leaves an entry out.- Servers start with Strata. The server window says what each offers or why it did not start. The Monitor tab lists them, and- the Sampling drawer has **Use tools from MCP servers** (on by default). A server that stops later is started again at its next call.+ Chat settings has **Use tools from MCP servers** (on by default). A server that stops later is started again at its next call.-- In the chat each call shows as a small block. The model reads the result and goes on, up to `max_rounds` calls in a row. A tool+- In the chat each call shows as a small block. The model reads the result and goes on, up to `max_rounds` rounds of calls (one round can hold several calls). At the limit+ the model gets one final reply with no tools, using the results already found, so the answer is not cut off. A toolthat fails or takes longer than `timeout_s` gives the model an `error: ...` result. Results longer than `max_result_chars` arecut with a note. Stop stops a running tool too.- Only the chat page uses them. API clients see the API exactly as before and keep their own tools. A request todiff --cc serve/web/app.cssindex de457cc70,0873b2694..18f1c9061--- a/serve/web/app.css+++ b/serve/web/app.css@@@ -198,8 -238,100 +238,106 @@@ main { flex: 1; min-height: 0; display.img-results img{max-width:100%;border-radius:var(--st-r-lg);display:block}.img-results figcaption{font-size:var(--st-fs-sm, 13px);color:var(--st-ink-2, inherit);margin-top:4px}+/* Raster MCP results remain visible outside the collapsed tool details. */+.tool-image { margin: 16px 0; max-width: 100%; }+.tool-image img { display: block; width: 100%; max-width: 640px; height: auto; border-radius: var(--st-r-md); }+.tool-image figcaption { margin-top: 10px; }+.tool-image a:not([href]) { opacity: .5; pointer-events: none; }+++ /* Math (serve/web/math.js): a formula never widens the chat; a long display formula scrolls inside its own box. */+ .chat-math { overflow-wrap: normal; }+ .chat-math--display { display: block; text-align: center; overflow-x: auto; max-width: 100%; margin: .6em 0; padding: .25em 0; }+ .chat-math--display > * { margin: 0 !important; }+ .chat-math[data-math-error] { white-space: pre-wrap; }+ .chat-math .katex { font-size: 1.08em; }++ /* svg/html preview (serve/web/preview.js): the frame is sandboxed and carries the page's colours, so it is transparent on the+ theme's surface; the code and the preview swap places inside the same box. */+ .st-code__btns { display: flex; gap: 4px; }+ .st-code .st-btn--icon[aria-pressed="true"] { background: rgba(255, 255, 255, .12); color: #fff; }+ .st-code__preview { display: none; }+ .st-code[data-preview="true"] > pre { display: none; }+ .st-code[data-preview="true"] .st-code__preview { display: block; height: min(340px, 60vh); background: var(--st-surface-2); }+ .st-code [data-preview-scripts] { display: none; }+ .st-code[data-preview="true"] [data-preview-scripts] { display: inline-flex; }+ .st-code .st-btn--icon[data-preview-scripts][aria-pressed="true"] { background: var(--st-warn-tint); color: var(--st-warn-text); }+ .st-code--run .st-code__preview { outline: 2px solid var(--st-warn-text); outline-offset: -2px; }+ .st-code__preview iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }++ /* ---------------------------------------------------------------- chat history (chats-ui.js)+ The saved-chats list (PR #1787 by Scotty-Hudson), edit / regenerate / rewind (PR #2615 by uppet) and the Chat settings button. */+ .view--chat { flex-direction: row; }+ .chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }+ .chat-sidebar { flex: none; width: 260px; display: flex; flex-direction: column; gap: var(--st-s-3);+ padding: var(--st-s-4); background: var(--st-surface); border-right: 1px solid var(--st-line); }+ .sidebar-head { display: flex; align-items: center; gap: var(--st-s-2); }+ .sidebar-head .card-title { flex: 1; }+ #sidebar-toggle .st-icon { transform: rotate(90deg); transition: transform var(--st-dur) var(--st-ease); }+ .chat-sidebar[data-open="false"] { width: 60px; }+ .chat-sidebar[data-open="false"] .sidebar-head { flex-direction: column; }+ .chat-sidebar[data-open="false"] #sidebar-toggle .st-icon { transform: rotate(-90deg); }+ .chat-sidebar[data-open="false"] .sidebar-title, .chat-sidebar[data-open="false"] .sidebar-search,+ .chat-sidebar[data-open="false"] .sidebar-list, .chat-sidebar[data-open="false"] .sidebar-foot { display: none; }+ .sidebar-search { height: 36px; font-size: var(--st-fs-sm); }+ .sidebar-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }+ .sidebar-group { margin: 0; padding: var(--st-s-3) 8px var(--st-s-1); font-size: var(--st-fs-xs);+ font-weight: var(--st-fw-bold); letter-spacing: .04em; text-transform: uppercase; color: var(--st-ink-muted); }+ .chat-item { display: flex; align-items: center; gap: 2px; border-radius: var(--st-r-md); }+ .chat-item.on { background: var(--st-surface-2); }+ .chat-item__title { flex: 1; min-width: 0; border: 0; background: transparent; cursor: pointer; text-align: left;+ padding: 8px; color: var(--st-ink-soft); font: 500 var(--st-fs-sm)/1.35 var(--st-font);+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .chat-item:hover .chat-item__title { color: var(--st-ink); }+ .chat-item.on .chat-item__title { color: var(--st-ink); font-weight: var(--st-fw-bold); }+ .chat-item__actions { display: flex; gap: 2px; flex: none; opacity: 0; } /* the buttons come up on hover or focus */+ .chat-item:hover .chat-item__actions, .chat-item:focus-within .chat-item__actions { opacity: 1; }+ .chat-item__actions .st-btn--icon { width: 30px; height: 30px; }+ .chat-item__actions .st-btn--icon .st-icon { width: 16px; height: 16px; }+ .chat-item__input { flex: 1; min-width: 0; height: 34px; font-size: var(--st-fs-sm); }+ .sidebar-empty { margin: 0; padding: var(--st-s-2) 8px; }+ .sidebar-foot { margin: 0; }+ .chat-parent { display: flex; align-items: center; justify-content: center; gap: var(--st-s-3); flex-wrap: wrap; padding: var(--st-s-2) var(--st-s-4);+ border-bottom: 1px solid var(--st-line-soft); font-size: var(--st-fs-sm); }+ .chat-parent .st-btn { height: 30px; padding: 0 12px; font-size: var(--st-fs-xs); }++ /* the buttons under a message, the open panel / editor, and the bars above the box (Undo, a waiting message) */+ .history-actions, .history-editor__actions, .history-undo, .pending { display: flex; flex-wrap: wrap; gap: var(--st-s-2); align-items: center; }+ .history-actions .st-btn, .history-undo .st-btn, .pending .st-btn, .history-panel .st-btn { height: 30px; padding: 0 10px; font-size: var(--st-fs-xs); }+ .history-actions { margin-top: var(--st-s-1); }+ .st-msg--user .history-actions { justify-content: flex-end; }+ .history-panel, .history-editor { width: 100%; display: flex; flex-direction: column; gap: var(--st-s-2); padding: var(--st-s-3);+ border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface-2); }+ .history-choice { display: flex; align-items: center; gap: var(--st-s-3); flex-wrap: wrap; }+ .history-choice > .muted { flex: 1 1 14rem; min-width: 0; }+ .history-panel > .st-btn { align-self: flex-start; }+ .history-editor textarea { width: 100%; min-height: 140px; max-height: 50vh; resize: vertical; font: inherit; height: auto; padding: 10px 14px; }+ .history-editor p, .history-panel p { margin: 0; }+ .st-msg[data-editing="true"] > .st-bubble { display: none; }+ .history-undo, .pending { max-width: min(100%, 1100px); margin: 0 auto var(--st-s-2); color: var(--st-ink-muted); font-size: var(--st-fs-sm); }+ .pending { justify-content: space-between; padding: 6px 10px; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface); }+ .pending__text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; color: var(--st-ink-soft); }+ .pending__actions { display: flex; gap: var(--st-s-2); }++ /* Chat settings: the button says what it is, and the drawer groups the chat switches */+ .chat-settings-button { height: 36px; padding: 0 10px; gap: 6px; white-space: nowrap; font-size: var(--st-fs-sm); }+ .chat-settings-short { display: none; }+ .drawer-group { display: flex; flex-direction: column; gap: var(--st-s-4); padding-top: var(--st-s-4); border-top: 1px solid var(--st-line); }+ .drawer-group__title { margin: 0; font-size: var(--st-fs-base); font-weight: var(--st-fw-bold); color: var(--st-ink); }+ .seg--3 { grid-template-columns: repeat(3, 1fr); }+ .seg--3 button { padding: 0 4px; }+ #lang { width: 100%; }+ @media (max-width: 640px) {+ .chat-settings-label, .composer-hint { display: none; }+ .chat-settings-short { display: inline; }+ .st-btn--send { margin-left: auto; }+ }+ @media (max-width: 760px) {+ /* the list is an overlay here: the chat keeps the whole width when it is closed to its rail */+ .view--chat { position: relative; }+ .chat-sidebar[data-open="true"] { position: absolute; top: 0; left: 0; bottom: 0; z-index: 30; box-shadow: var(--st-sh-pop); }+ .chat-sidebar { padding: var(--st-s-3); }+ }++ /* a message may use the room a wide window gives the chat column (#3176 widened the column; the kit's 720px kept the messages narrow in it) */+ .st-msg { max-width: min(100%, 900px); }+ .st-toast .st-btn { white-space: nowrap; }diff --cc serve/web/app.jsindex 86fb16a8c,46d79bea4..6c7d51846--- a/serve/web/app.js+++ b/serve/web/app.js@@@ -658,49 -870,21 +871,53 @@@ function toolHtml(t, k)`<span class="st-badge ${cls}">${esc(label)}</span>${t.ms != null && t.state !== "skipped" ? `<span class="muted small">${fmt(t.ms / 1000, 1)} s</span>` : ""}` +`${icon("chevron", "st-icon st-icon--sm st-chev")}</summary><div class="st-collapse__body">${body}</div></details>`;}+// Raster tool results are same-origin cached files; credentials stay in request headers.+const mediaBlobs = new Map();+let mediaEpoch = 0;+function clearToolMedia() {+ mediaEpoch++;+ for (const pending of mediaBlobs.values()) pending.then((url) => URL.revokeObjectURL(url), () => {});+ mediaBlobs.clear();+}+window.addEventListener("pagehide", clearToolMedia);+window.addEventListener("pageshow", (event) => { if (event.persisted) hydrateToolImages(document); });+function safeToolMedia(url) { return typeof url === "string" && /^tool-media\/[0-9a-f]{64}\.(png|jpg|webp)$/.test(url); }+function toolImages(t) {+ return (t.images || []).filter((im) => safeToolMedia(im.url)).map((im) =>+ `<figure class="tool-image"><img data-tool-image="${esc(im.url)}" alt="Tool image" loading="lazy">` ++ `<figcaption><a class="st-btn" data-tool-download="${esc(im.url)}" download="${esc(im.name || "generated-image.png")}">Download image</a></figcaption></figure>`).join("");+}+function hydrateToolImages(root) {+ root.querySelectorAll("[data-tool-image]").forEach((img) => {+ const url = img.dataset.toolImage, epoch = mediaEpoch;+ if (!safeToolMedia(url)) return;+ if (!mediaBlobs.has(url)) mediaBlobs.set(url, fetch(url, {headers: headers()}).then((r) => {+ if (!r.ok) throw new Error("Image unavailable");+ return r.blob();+ }).then((b) => URL.createObjectURL(b)).catch((e) => {if (epoch === mediaEpoch) mediaBlobs.delete(url); throw e;}));+ mediaBlobs.get(url).then((blob) => {+ if (epoch !== mediaEpoch || !img.isConnected) return;+ img.src = blob;+ const a = img.closest("figure").querySelector("[data-tool-download]");+ a.href = blob;+ }).catch(() => { img.alt = "Image unavailable; try refreshing"; });+ });+}// the answer's text with the tool blocks where the model called them+ // math (opt-in, serve/web/math.js): formulas become placeholders before the Markdown runs and are drawn after it+ function answerMarkdown(text) {+ return settings.math ? StrataMath.markdown(text, markdown) : markdown(text);+ }function answerHtml(m) {- if (!m.tools || !m.tools.length) return markdown(m.text || "");+ if (!m.tools || !m.tools.length) return answerMarkdown(m.text || "");let html = "", pos = 0;m.tools.forEach((t, k) => {const at = Math.min(Math.max(t.at || 0, pos), m.text.length);- if (at > pos) html += markdown(m.text.slice(pos, at));+ if (at > pos) html += answerMarkdown(m.text.slice(pos, at));pos = at;- html += toolHtml(t, k);+ html += toolHtml(t, k) + toolImages(t);});- return html + markdown(m.text.slice(pos));+ return html + answerMarkdown(m.text.slice(pos));}// a tool event from the stream (the `strata_mcp` field of a chunk)function onTool(m, x) {@@@ -737,10 -921,10 +954,11 @@@ function updateAssistant(el, m, streamibubble.innerHTML = m.reasoning ? `<span class="muted cursor">Writing</span>` : `<span class="cursor"></span>`;} else {bubble.innerHTML = answerHtml(m);+ hydrateToolImages(bubble);+ if (settings.math) StrataMath.hydrate(bubble);if (streaming) bubble.classList.add("cursor"); else bubble.classList.remove("cursor");}- el.querySelector(".meta-text").textContent = m.meta || (streaming ? "" : m.stopped ? "Stopped" : "");+ el.querySelector(".meta-text").textContent = m.meta || (streaming ? "" : m.stopped ? tr("chat.stopped", "Stopped") : "");el.querySelector("[data-msg-copy]").hidden = streaming || !m.text;}function renderChat() {@@@ -748,38 -932,13 +966,41 @@@chat.querySelectorAll(".st-msg").forEach((e) => e.remove());$("chat-empty").hidden = messages.length > 0;messages.forEach((m, i) => chat.appendChild(msgEl(m, i)));+ renderSidebar();+ renderParent();+ renderUndoBar();scrollDown(true);}-function nearBottom() { const s = $("chat-scroll"); return s.scrollHeight - s.scrollTop - s.clientHeight < 120; }-function scrollDown(force) { const s = $("chat-scroll"); if (force || nearBottom()) s.scrollTop = s.scrollHeight; }+// Follow the answer while the reader has not left (#4014). Asking "am I within 120 px of the bottom?" on every frame pulled+// the view back after every wheel notch (a notch is about 100 px), so scrolling up during a long answer only worked by+// dragging the scrollbar. Now the reader's own input lets go (wheel up, a finger or a key moving up, the scrollbar), and a+// scroll back to the bottom follows again.+let stickToBottom = true, lastReaderInput = 0;+const FOLLOW_SLACK = 24, FAR_AWAY = 400, INPUT_WINDOW_MS = 400;+function followAfterScroll(distance, wasFollowing, msSinceInput) {+ if (distance <= FOLLOW_SLACK) return true;+ if (msSinceInput <= INPUT_WINDOW_MS || distance > FAR_AWAY) return false;+ return wasFollowing;+}+function scrollDown(force) {+ const s = $("chat-scroll");+ if (force) stickToBottom = true;+ if (stickToBottom) s.scrollTop = s.scrollHeight;+}+(function watchReader() {+ const s = $("chat-scroll");+ const touch = () => { lastReaderInput = Date.now(); };+ s.addEventListener("wheel", (e) => { touch(); if (e.deltaY < 0 && s.scrollTop > 0) stickToBottom = false; }, {passive: true});+ s.addEventListener("touchmove", touch, {passive: true});+ s.addEventListener("pointerdown", touch, {passive: true});+ s.addEventListener("keydown", (e) => {+ touch();+ if (["PageUp", "ArrowUp", "Home"].includes(e.key) && e.target === s && s.scrollTop > 0) stickToBottom = false;+ });+ s.addEventListener("scroll", () => {+ stickToBottom = followAfterScroll(s.scrollHeight - s.scrollTop - s.clientHeight, stickToBottom, Date.now() - lastReaderInput);+ }, {passive: true});+})();$("chat").addEventListener("click", (e) => {const cc = e.target.closest("[data-code-copy]");@@@ -965,11 -1245,14 +1312,15 @@@ $("input").addEventListener("keydown",function autosize() { const t = $("input"); t.style.height = "auto"; t.style.height = `${Math.min(t.scrollHeight, innerHeight * 0.4)}px`; }$("input").addEventListener("input", autosize);+ // one chat, as before: New chat clears it, with an Undo (with the saved-chats list on, its own New chat button does this job)$("new-btn").onclick = () => {- if (busy) { toast("warn", "Still writing", "Stop the answer first."); return; }+ if (busy) { stillWriting(); return; }+ if (panel) { closePanel(); }+ clearUndo();+ releasePending();if (!messages.length) return;const backup = messages;+ clearToolMedia();messages = [];saveChat();renderChat();