diff --git a/apps/host/src/components/DropZone.tsx b/apps/host/src/components/DropZone.tsx index c0b1f976..cecf20f9 100644 --- a/apps/host/src/components/DropZone.tsx +++ b/apps/host/src/components/DropZone.tsx @@ -9,7 +9,14 @@ export const DROP_EVENT = 'strata:drop-files'; /** The pictures on the clipboard, named so each one is told apart in the composer (a pasted screenshot arrives as "image.png"). */ export function pastedFiles(data: DataTransfer | null | undefined): File[] { const out: File[] = []; - for (const file of Array.from(data?.files ?? [])) { + // `files` is empty for some screenshot tools (Win+Shift+S in WebView2): the same picture is then only in `items`. + const found = Array.from(data?.files ?? []); + if (!found.some(f => f.type.startsWith('image/'))) + for (const item of Array.from(data?.items ?? [])) { + const file = item.kind === 'file' && item.type.startsWith('image/') ? item.getAsFile() : null; + if (file) found.push(file); + } + for (const file of found) { if (!file.type.startsWith('image/')) continue; const extension = file.type.split('/')[1]?.replace('jpeg', 'jpg').replace(/[+].*/, '') || 'png'; out.push(new File([file], `Pasted picture ${new Date().toLocaleTimeString().replace(/[^0-9]+/g, '-').replace(/-$/, '')}${out.length ? `-${out.length + 1}` : ''}.${extension}`, { type: file.type })); diff --git a/apps/host/src/components/Markdown.tsx b/apps/host/src/components/Markdown.tsx index 996b191f..e771dccd 100644 --- a/apps/host/src/components/Markdown.tsx +++ b/apps/host/src/components/Markdown.tsx @@ -1,4 +1,5 @@ import { tr } from '../lib/i18n'; +import { copyAndTell } from '../lib/copy-text'; /** Safe, dependency-free rendering of the Markdown structures used in answers. */ import { Fragment, type ReactNode } from 'react'; import { Btn, IconBtn } from './ui'; @@ -69,7 +70,7 @@ export function Markdown({ text, onOpenLink, onPreviewHtml, imageSession }: { while (i < lines.length && !/^\s*```/.test(lines[i])) body.push(lines[i++]); i++; - nodes.push(
{tr(m.tokens ? `${tokens(m.tokens)} tokens` : '')}{tr(m.tps ? ` · ${tps(m.tps)} tok/s` : '')}{tr(m.durationMs ? ` · ${duration(m.durationMs)}` : '')}{tr(m.demo ? ' · Example' : '')}
: null)} diff --git a/apps/host/src/screens/Serving.tsx b/apps/host/src/screens/Serving.tsx index ebe6609a..e2b0ce9c 100644 --- a/apps/host/src/screens/Serving.tsx +++ b/apps/host/src/screens/Serving.tsx @@ -1,3 +1,4 @@ +import { copyAndTell } from '../lib/copy-text'; import { tr } from '../lib/i18n'; import { appBaseUrl } from '../lib/connect-urls'; import { deviceLabel, instanceLabel } from '../lib/runtime-models'; @@ -8,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, pushToast } from '../lib/store'; +import { cancelRequest, setLocalSharing, setServingAccess, useStore } from '../lib/store'; export function ServingScreen() { const serving = useStore(s => s.serving); const storedRuntime = useStore(s => s.runtime), hardware = useStore(s => s.hardware); @@ -73,13 +74,7 @@ export function ServingScreen() { } } async function copyConnectionValue(value: string, label: string) { - try { - await navigator.clipboard.writeText(value); - pushToast('success', 'Copied', label); - } - catch { - pushToast('warn', 'Couldn’t copy', 'Select the value and copy it manually.'); - } + await copyAndTell(value, label); } 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