KaranocaVe (#858): History expands a saved run in place (results, cancel and
export for that run, by id) instead of replacing the current run; a new About
tab links the project and lm-detector (anchors standalone, copy buttons in
magpie's frame); the desktop launcher shows the local service address after
4s if navigation stalls; integration.md documents Windows' excluded port
ranges. Version 0.2.3.
Reviewed at d272d0c14fed1c1b654f970f358fabea4b2fe210, run on mote (macOS) in
a copy of the PR tree with a temp HOME in the run folder:
- packages/fingerprint: bun install --frozen-lockfile, typecheck ok, bun test
37 pass 0 fail, bun run build. diff -r of the PR's dist against the rebuild:
identical (dist/ui, plugin.js, cli.js).
- bun scripts/check.mjs fingerprint: registry.json ok, fingerprint ok.
- Bundle: the only new URL strings are the two About links
(github.com/KaranocaVe/magpie-fingerprint, github.com/Ikaleio/lm-detector);
no new fetch/eval/Function/WebSocket/sendBeacon; CSS has only the existing
data: SVG.
- Playwright 1.62.0, Chromium and WebKit, en and zh-CN, 1100px and 380px,
standalone and inside a parent frame, with the API stubbed from the demo
server's /api/bootstrap (a running, a completed and a failed run): History
expands a row (aria-expanded true), cancel from an expanded running row sends
one cancel and the row shows Cancelled, About shows 2 anchors standalone and
2 copy buttons framed (copy shows Copied in both engines), ArrowRight/Left
wrap across the three tabs, no horizontal overflow, no request off the stub
origin. 48 screenshots checked.
- The one page error, standalone only ("Cannot destructure property 'context'"
from the vendored bridge's hello), is the same on main 03ab6d66f (same load
harness on main's dist).
Not tried: the launcher fallback in a real Windows magpie window (covered by
the new boot test only). src/service-identity.ts VERSION still says 0.2.2
(health/bootstrap report it; nothing compares it), filed separately.
126 lines
5.1 KiB
JavaScript
126 lines
5.1 KiB
JavaScript
(() => {
|
|
const messages = {
|
|
en: {
|
|
title: 'Fingerprint',
|
|
connecting: 'Connecting to Fingerprint…',
|
|
remote:
|
|
'Upgrade Magpie for remote plugin services, or forward the service port to this computer over SSH.',
|
|
invalidPort: 'Invalid Fingerprint service port.',
|
|
failed: 'Could not connect',
|
|
fallback: 'If the page does not open, copy this address into a browser on this computer:',
|
|
},
|
|
'zh-Hans': {
|
|
title: '模型指纹',
|
|
connecting: '正在连接模型指纹服务…',
|
|
remote: '请升级 Magpie 以支持远程插件服务,或将服务器的服务端口通过 SSH 转发到本机。',
|
|
invalidPort: '模型指纹服务端口无效。',
|
|
failed: '连接失败',
|
|
fallback: '如果页面未打开,请将此地址复制到本机浏览器:',
|
|
},
|
|
'zh-Hant': {
|
|
title: '模型指紋',
|
|
connecting: '正在連線至模型指紋服務…',
|
|
remote: '請升級 Magpie 以支援遠端外掛服務,或透過 SSH 將伺服器的服務連接埠轉送至本機。',
|
|
invalidPort: '模型指紋服務連接埠無效。',
|
|
failed: '連線失敗',
|
|
fallback: '如果頁面未開啟,請將此網址複製到本機瀏覽器:',
|
|
},
|
|
ja: {
|
|
title: 'モデル指紋',
|
|
connecting: 'モデル指紋サービスに接続中…',
|
|
remote:
|
|
'リモートプラグインサービスを利用するには、Magpie を更新するか、SSH でサービスポートをこのコンピューターに転送してください。',
|
|
invalidPort: 'モデル指紋サービスのポートが無効です。',
|
|
failed: '接続できませんでした',
|
|
fallback:
|
|
'ページが開かない場合は、このアドレスをこのコンピューターのブラウザーにコピーしてください:',
|
|
},
|
|
de: {
|
|
title: 'Modell-Fingerabdruck',
|
|
connecting: 'Verbindung zum Fingerabdruck-Dienst wird hergestellt…',
|
|
remote:
|
|
'Aktualisieren Sie Magpie für entfernte Plugin-Dienste oder leiten Sie den Dienstport per SSH an diesen Computer weiter.',
|
|
invalidPort: 'Ungültiger Port für den Fingerabdruck-Dienst.',
|
|
failed: 'Verbindung fehlgeschlagen',
|
|
fallback:
|
|
'Falls sich die Seite nicht öffnet, diese Adresse im Browser auf diesem Computer öffnen:',
|
|
},
|
|
};
|
|
let text = messages.en;
|
|
const status = document.getElementById('status');
|
|
function followLanguage(theme) {
|
|
const language = String(theme?.lang || 'en')
|
|
.toLowerCase()
|
|
.replaceAll('_', '-');
|
|
const parts = language.split('-');
|
|
const key =
|
|
parts[0] === 'zh'
|
|
? parts.includes('hant') ||
|
|
(!parts.includes('hans') && parts.some((part) => ['tw', 'hk', 'mo'].includes(part)))
|
|
? 'zh-Hant'
|
|
: 'zh-Hans'
|
|
: parts[0];
|
|
text = messages[key] || messages.en;
|
|
document.documentElement.lang = messages[key] ? key : 'en';
|
|
document.title = text.title;
|
|
document.getElementById('title').textContent = text.title;
|
|
status.textContent = text.connecting;
|
|
}
|
|
return (async () => {
|
|
const theme = await window.magpie?.ready;
|
|
followLanguage(theme);
|
|
window.magpie?.onTheme?.(followLanguage);
|
|
const config = (await window.magpie?.options?.get?.()) || {};
|
|
const port = Number(config.port ?? 3488);
|
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(text.invalidPort);
|
|
let service = window.magpie?.service;
|
|
let localFallback = '';
|
|
if (!service) {
|
|
// This computer's window: wails://localhost on macOS and Linux,
|
|
// http://wails.localhost on Windows (Wails v3, WebView2).
|
|
const host = String(location.hostname || '')
|
|
.toLowerCase()
|
|
.replace(/^\[|\]$/g, '');
|
|
const local =
|
|
!host ||
|
|
host === 'localhost' ||
|
|
host.endsWith('.localhost') ||
|
|
host === '::1' ||
|
|
/^127\./.test(host);
|
|
if (!local) {
|
|
status.textContent = text.remote;
|
|
return;
|
|
}
|
|
service = `http://127.0.0.1:${port}/`;
|
|
localFallback = service;
|
|
}
|
|
const url = new URL(service, location.href);
|
|
// Opaque Magpie web frames need the concrete proxy origin in connect-src.
|
|
url.searchParams.set('uiOrigin', url.origin);
|
|
if (theme) {
|
|
url.searchParams.set('theme', theme.dark ? 'dark' : 'light');
|
|
if (theme.lang) url.searchParams.set('lang', theme.lang);
|
|
}
|
|
const context = window.magpie?.context?.provider;
|
|
if (context?.id) url.searchParams.set('provider', context.id);
|
|
window.magpie?.onAction((action) => {
|
|
if (action?.provider?.id) {
|
|
url.searchParams.set('provider', action.provider.id);
|
|
location.replace(url.href);
|
|
}
|
|
});
|
|
if (localFallback) {
|
|
setTimeout(() => {
|
|
status.textContent = text.fallback;
|
|
const field = document.getElementById('service-url');
|
|
field.value = localFallback;
|
|
field.onclick = () => field.select();
|
|
document.getElementById('fallback').hidden = false;
|
|
}, 4000);
|
|
}
|
|
location.replace(url.href);
|
|
})().catch((error) => {
|
|
status.textContent = `${text.failed}: ${String(error?.message || error)}`;
|
|
});
|
|
})();
|