Skip to content

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++

Copy feedback: one helper (lib/clipboard.ts copyText with a toast); Markdown and Serving use it, lib/copy-text.ts is gone (the toast store is loaded only when a code block is copied)

Niko1221536460c3d83b
diff --git a/apps/host/src/components/Markdown.tsx b/apps/host/src/components/Markdown.tsx
index fe65886f0..f10cca543 100644
--- a/apps/host/src/components/Markdown.tsx
+++ b/apps/host/src/components/Markdown.tsx
@@ -1,5 +1,5 @@
import { tr } from '../lib/i18n';
-import { copyAndTell } from '../lib/copy-text';
+import { copyText } from '../lib/clipboard';
/** Safe, dependency-free rendering of the Markdown structures used in answers. */
import { Fragment, type ReactNode } from 'react';
import { Btn, IconBtn } from './ui';
@@ -57,6 +57,11 @@ export function continuesParagraph(lines: string[], at: number): boolean {
return false;
return !displayBlock(lines, at);
}
+/** Copy a code block. The toast store needs a browser, so it is loaded here, when someone copies: the renderer itself must render without one. */
+async function copyCode(text: string) {
+ const { pushToast } = await import('../lib/store');
+ await copyText(text, 'Code', { toast: pushToast });
+}
export function Markdown({ text, onOpenLink, onPreviewHtml, imageSession }: {
text: string;
onOpenLink?: (url: string) => void;
@@ -79,7 +84,7 @@ export function Markdown({ text, onOpenLink, onPreviewHtml, imageSession }: {
while (i < lines.length && !/^\s*```/.test(lines[i]))
body.push(lines[i++]);
i++;
- nodes.push(<div className="st-code" key={key}><div className="st-code__head"><span>{language || tr('code')}</span>{tr(/^html$/i.test(language) && onPreviewHtml ? <Btn size="sm" onClick={() => onPreviewHtml(body.join('\n'))}>{tr("Open preview")}</Btn> : null)}<IconBtn name="copy" title={tr("Copy code")} onClick={() => void copyAndTell(body.join('\n'), 'Code')}/></div><SyntaxCode text={body.join('\n')} language={language}/></div>);
+ nodes.push(<div className="st-code" key={key}><div className="st-code__head"><span>{language || tr('code')}</span>{tr(/^html$/i.test(language) && onPreviewHtml ? <Btn size="sm" onClick={() => onPreviewHtml(body.join('\n'))}>{tr("Open preview")}</Btn> : null)}<IconBtn name="copy" title={tr("Copy code")} onClick={() => void copyCode(body.join('\n'))}/></div><SyntaxCode text={body.join('\n')} language={language}/></div>);
continue;
}
const block = displayBlock(lines, i);
diff --git a/apps/host/src/lib/copy-text.ts b/apps/host/src/lib/copy-text.ts
deleted file mode 100644
index c48819369..000000000
--- a/apps/host/src/lib/copy-text.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Put text on the clipboard. The browser clipboard call can be refused inside the app window (WebView2 asks no one and says no),
- * so a hidden text field and the older copy command are the second try. Resolves true when one of them worked.
- */
-export async function copyText(value: string): Promise<boolean> {
- try {
- await navigator.clipboard.writeText(value);
- return true;
- }
- catch {
- // fall through to the older route
- }
- try {
- const field = document.createElement('textarea');
- field.value = value;
- field.setAttribute('readonly', '');
- field.style.cssText = 'position:fixed;left:-9999px;top:0;opacity:0';
- document.body.appendChild(field);
- field.select();
- const ok = document.execCommand('copy');
- field.remove();
- return ok;
- }
- catch {
- return false;
- }
-}
-
-/** Copy and say so: "Copied", or "Couldn't copy" with what to do instead. */
-export async function copyAndTell(value: string, label: string): Promise<void> {
- // loaded here, not at the top: the store needs a browser, and the Markdown renderer (which copies code) is also rendered without one
- const { pushToast } = await import('./store');
- if (await copyText(value))
- pushToast('success', 'Copied', label);
- else
- pushToast('warn', 'Couldn’t copy', 'Select the text and copy it manually.');
-}
diff --git a/apps/host/src/screens/Serving.tsx b/apps/host/src/screens/Serving.tsx
index e2b0ce9cf..0eb86676d 100644
--- a/apps/host/src/screens/Serving.tsx
+++ b/apps/host/src/screens/Serving.tsx
@@ -1,4 +1,4 @@
-import { copyAndTell } from '../lib/copy-text';
+import { copyText } from '../lib/clipboard';
import { tr } from '../lib/i18n';
import { appBaseUrl } from '../lib/connect-urls';
import { deviceLabel, instanceLabel } from '../lib/runtime-models';
@@ -9,7 +9,7 @@ import { useEffect, useRef, useState } from 'react';
import { Btn, Dialog, Empty, Icon, IconBtn, Seg, Select, ErrorNotice } from '../components/ui';
import { Screen, SectionHead } from '../components/layout';
import { clockTime, duration, tokens } from '../lib/format';
-import { cancelRequest, setLocalSharing, setServingAccess, useStore } from '../lib/store';
+import { cancelRequest, setLocalSharing, setServingAccess, useStore, pushToast } from '../lib/store';
export function ServingScreen() {
const serving = useStore(s => s.serving);
const storedRuntime = useStore(s => s.runtime), hardware = useStore(s => s.hardware);
@@ -74,7 +74,7 @@ export function ServingScreen() {
}
}
async function copyConnectionValue(value: string, label: string) {
- await copyAndTell(value, label);
+ await copyText(value, label, { toast: pushToast });
}
const code = `curl ${serving.baseUrl}${protocol === 'responses' ? '/responses' : protocol === 'openai' ? serving.endpoints.openai : serving.endpoints.anthropic} \\\n -H 'Content-Type: application/json'${serving.access.apiKeySet ? " \\\n -H 'Authorization: Bearer YOUR_API_KEY'" : ''} \\\n -d '${JSON.stringify({ model: loaded?.apiModelId ?? 'YOUR_MODEL_ID', ...(protocol === 'responses' ? { input: 'Hello', store: false } : { ...(protocol === 'anthropic' ? { max_tokens: 256 } : {}), messages: [{ role: 'user', content: 'Hello' }] }) }, null, 2)}'`;
return <Screen title={tr("Serving")} actions={<><Btn icon="link" onClick={() => setCloudflareOpen(true)}>{tr("Cloudflare tunnel")}</Btn><IconBtn name="info" title={tr("Connection guide")} onClick={() => setGuide(true)}/></>}><div className="stack stack--lg">