@simplexai/localmodels-win32-x64 0.1.0-dev.63 → 0.1.0-dev.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +140 -130
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/__main__.py +2 -2
- package/modules/localmodels/app.py +15 -2
- package/modules/localmodels/approval.py +5 -3
- package/modules/localmodels/bifrost_checks.py +2 -1
- package/modules/localmodels/catalog.json +36 -0
- package/modules/localmodels/catalog.py +28 -5
- package/modules/localmodels/catalog_recipes.py +40 -1
- package/modules/localmodels/component.py +1 -1
- package/modules/localmodels/context_policy.py +7 -2
- package/modules/localmodels/custom_probe.py +5 -5
- package/modules/localmodels/debug_mode.py +85 -103
- package/modules/localmodels/deploy.py +129 -18
- package/modules/localmodels/deployment_lifecycle.py +167 -0
- package/modules/localmodels/download-mirrors.json +126 -6
- package/modules/localmodels/draft_spec.py +164 -0
- package/modules/localmodels/engine_adapters/__init__.py +4 -0
- package/modules/localmodels/engine_adapters/auxiliary.py +27 -0
- package/modules/localmodels/engine_adapters/base.py +40 -0
- package/modules/localmodels/engine_adapters/strata_poly.py +57 -0
- package/modules/localmodels/engine_adapters/suite_plan.py +394 -0
- package/modules/localmodels/engines-prism-b12178-03ec600.json +7 -7
- package/modules/localmodels/gateway.py +124 -13
- package/modules/localmodels/gateway_accept.py +1 -6
- package/modules/localmodels/gateway_cli.py +13 -24
- package/modules/localmodels/gateway_ops.py +185 -0
- package/modules/localmodels/gateway_server.py +3 -2
- package/modules/localmodels/harness.py +13 -16
- package/modules/localmodels/harness_core.py +4 -9
- package/modules/localmodels/harness_gateway.py +4 -3
- package/modules/localmodels/hosts.py +22 -34
- package/modules/localmodels/install.py +15 -0
- package/modules/localmodels/library_convert.py +5 -11
- package/modules/localmodels/library_custom.py +6 -6
- package/modules/localmodels/library_elastic.py +24 -127
- package/modules/localmodels/library_jobs.py +14 -5
- package/modules/localmodels/library_order.py +4 -3
- package/modules/localmodels/library_poly.py +5 -4
- package/modules/localmodels/library_pricing.py +80 -255
- package/modules/localmodels/library_serve.py +13 -14
- package/modules/localmodels/library_smoke.py +8 -1
- package/modules/localmodels/library_status.py +16 -16
- package/modules/localmodels/llm_rank.py +1 -1
- package/modules/localmodels/magpie_legacy.py +160 -0
- package/modules/localmodels/magpie_setup.py +6 -1
- package/modules/localmodels/memcalc_cli.py +2 -2
- package/modules/localmodels/pi_profile.py +3 -7
- package/modules/localmodels/plan_envelope.py +1 -1
- package/modules/localmodels/planning/__init__.py +3 -0
- package/modules/localmodels/{budget.py → planning/budget.py} +48 -30
- package/modules/localmodels/{stack_llm_ram.py → planning/llm_ram.py} +11 -1
- package/modules/localmodels/{memcalc_load.py → planning/memcalc_load.py} +1 -1
- package/modules/localmodels/planning/memory_pools.py +403 -0
- package/modules/localmodels/{sizecalc.py → planning/sizecalc.py} +1 -1
- package/modules/localmodels/recommend.py +1 -1
- package/modules/localmodels/recommend_cli.py +3 -4
- package/modules/localmodels/residency_host.py +1 -1
- package/modules/localmodels/service_control.py +4 -4
- package/modules/localmodels/service_deployment.py +3 -2
- package/modules/localmodels/service_wiring.py +17 -19
- package/modules/localmodels/setup_inspection.py +1 -1
- package/modules/localmodels/setup_inspection_harness.py +1 -1
- package/modules/localmodels/setup_upgrade.py +3 -12
- package/modules/localmodels/sizecalc_cli.py +10 -2
- package/modules/localmodels/speech_admission.py +1 -1
- package/modules/localmodels/speech_jobs.py +2 -1
- package/modules/localmodels/speech_model.py +2 -0
- package/modules/localmodels/speech_server.py +130 -9
- package/modules/localmodels/speech_state.py +11 -0
- package/modules/localmodels/speech_worker_sensevoice.py +38 -0
- package/modules/localmodels/speech_workers.py +5 -1
- package/modules/localmodels/stack.py +4 -9
- package/modules/localmodels/stack_arena.py +2 -2
- package/modules/localmodels/stack_auto.py +5 -5
- package/modules/localmodels/stack_aux_gpu.py +5 -3
- package/modules/localmodels/stack_binding.py +24 -143
- package/modules/localmodels/stack_capacity.py +1 -1
- package/modules/localmodels/stack_card.py +3 -3
- package/modules/localmodels/stack_cleanup.py +6 -5
- package/modules/localmodels/stack_client_settings.py +9 -2
- package/modules/localmodels/stack_compose.py +43 -6
- package/modules/localmodels/stack_console.py +2 -2
- package/modules/localmodels/stack_debug.py +1 -1
- package/modules/localmodels/stack_decision.py +1 -1
- package/modules/localmodels/stack_doctor.py +10 -7
- package/modules/localmodels/stack_down.py +3 -3
- package/modules/localmodels/stack_gpu_memory.py +1 -1
- package/modules/localmodels/stack_hardware.py +3 -3
- package/modules/localmodels/stack_hardware_text.py +1 -1
- package/modules/localmodels/stack_ledger.py +2 -1
- package/modules/localmodels/stack_lifecycle.py +7 -7
- package/modules/localmodels/stack_mcp.py +1 -1
- package/modules/localmodels/stack_memory.py +4 -4
- package/modules/localmodels/stack_mlx.py +1 -1
- package/modules/localmodels/stack_plan.py +18 -13
- package/modules/localmodels/stack_ports.py +2 -2
- package/modules/localmodels/stack_preflight.py +4 -3
- package/modules/localmodels/stack_remove.py +13 -6
- package/modules/localmodels/stack_review.py +3 -5
- package/modules/localmodels/stack_rollback.py +1 -1
- package/modules/localmodels/stack_route.py +5 -4
- package/modules/localmodels/stack_run.py +16 -0
- package/modules/localmodels/stack_suite.py +14 -6
- package/modules/localmodels/stack_summary.py +1 -1
- package/modules/localmodels/stack_try.py +10 -14
- package/modules/localmodels/stack_up.py +25 -39
- package/modules/localmodels/stack_update.py +2 -1
- package/modules/localmodels/stack_verify.py +4 -30
- package/modules/localmodels/stack_view.py +6 -4
- package/modules/localmodels/stack_view_apply.py +2 -2
- package/modules/localmodels/stack_view_llm.py +12 -7
- package/modules/localmodels/stack_view_text.py +2 -6
- package/modules/localmodels/stack_view_tick.py +2 -2
- package/modules/localmodels/stack_view_words.py +5 -2
- package/modules/localmodels/stack_warm.py +7 -4
- package/modules/localmodels/stack_whatif.py +1 -1
- package/modules/localmodels/suite.py +6 -334
- package/modules/localmodels/tui_views.py +28 -7
- package/modules/localmodels/web/index.html +595 -226
- package/modules/localmodels/web/sizecalc/app.js +34 -40
- package/modules/localmodels/web/sizecalc/calc.js +3 -3
- package/modules/localmodels/web/sizecalc/page.html +4 -3
- package/modules/localmodels/web/view/fleet.html +18 -3
- package/modules/localmodels/web/view/fleet.js +135 -14
- package/modules/localmodels/web/view/i18n.js +4 -0
- package/modules/localmodels/web/view/index.html +16 -0
- package/modules/localmodels/web/view/nav.js +49 -0
- package/modules/localmodels/web/view/theme.js +1 -1
- package/modules/localmodels/web/view/view.css +51 -15
- package/modules/localmodels/web/view/view.js +22 -4
- package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/RECORD +137 -127
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/library_vram.py +0 -123
- /package/modules/localmodels/{memcalc.py → planning/memcalc.py} +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev63.dist-info → simplex_localmodels-0.1.0.dev65.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -601,21 +601,21 @@ if (typeof document !== "undefined") (() => {
|
|
|
601
601
|
parts.push(`<line x1="${x}" x2="${x}" y1="${top - 6}" y2="${H - 22}" stroke="var(--line)" stroke-width="1"/>`);
|
|
602
602
|
if (major || !narrow) parts.push(`<text x="${x}" y="${H - 6}" text-anchor="middle">${g >= 1024 ? `${g / 1024}T` : `${g}G`}</text>`);
|
|
603
603
|
}
|
|
604
|
-
// tier baselines
|
|
604
|
+
// tier baselines
|
|
605
605
|
const rows = r.devices;
|
|
606
|
-
D.tiers.forEach((
|
|
606
|
+
D.tiers.forEach((_t, idx) => {
|
|
607
607
|
const y = top + idx * rowH + rowH / 2 + (narrow ? 8 : 0);
|
|
608
|
-
const [label] = TIER_ZH[tier];
|
|
609
608
|
parts.push(`<line x1="${x0}" x2="${x1}" y1="${y}" y2="${y}" stroke="var(--line-2)" stroke-width="1"/>`);
|
|
610
|
-
if (narrow) parts.push(`<text class="tl" x="${x0}" y="${y - 24}">${esc(label)}</text>`);
|
|
611
|
-
else parts.push(`<text class="tl" x="0" y="${y + 4}">${esc(label)}</text>`);
|
|
612
609
|
});
|
|
613
|
-
// vertical reference lines drawn below device dots & haloed labels
|
|
610
|
+
// vertical reference lines drawn below tier labels, device dots & haloed labels
|
|
614
611
|
parts.push(`<line x1="${xw}" x2="${xw}" y1="${top - 4}" y2="${H - 22}" stroke="var(--muted)" stroke-width="1.5" stroke-dasharray="4 3"/>`);
|
|
615
612
|
parts.push(`<line x1="${xn}" x2="${xn}" y1="${top - 10}" y2="${H - 22}" stroke="var(--ink)" stroke-width="2"/>`);
|
|
616
|
-
// devices of each tier, merged when their usable memory is within 4%
|
|
613
|
+
// tier labels & devices of each tier, merged when their usable memory is within 4%
|
|
617
614
|
D.tiers.forEach(([tier], idx) => {
|
|
618
615
|
const y = top + idx * rowH + rowH / 2 + (narrow ? 8 : 0);
|
|
616
|
+
const [label] = TIER_ZH[tier];
|
|
617
|
+
if (narrow) parts.push(`<text class="tl halo" x="${x0}" y="${y - 24}">${esc(label)}</text>`);
|
|
618
|
+
else parts.push(`<text class="tl" x="0" y="${y + 4}">${esc(label)}</text>`);
|
|
619
619
|
const mine = rows.filter((d) => d.tier === tier).sort((a, b) => a.usable_bytes - b.usable_bytes);
|
|
620
620
|
const groups = [];
|
|
621
621
|
for (const d of mine) {
|
|
@@ -951,43 +951,45 @@ if (typeof document !== "undefined") (() => {
|
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
953
|
|
|
954
|
+
const THEME_KEY = "localmodels.theme";
|
|
955
|
+
const THEME_LEGACY_KEYS = ["lm-sizecalc-theme", "lm-theme"];
|
|
956
|
+
const THEME_ORDER = ["auto", "light", "dark"];
|
|
957
|
+
const THEME_LABEL = { auto: "外观:跟随系统", light: "外观:浅色", dark: "外观:深色" };
|
|
958
|
+
const THEME_NEXT = { auto: "浅色", light: "深色", dark: "跟随系统" };
|
|
959
|
+
|
|
954
960
|
function readSavedTheme() {
|
|
955
961
|
try {
|
|
956
962
|
if (typeof localStorage !== "undefined" && typeof localStorage.getItem === "function") {
|
|
957
|
-
const
|
|
958
|
-
|
|
963
|
+
for (const key of [THEME_KEY, ...THEME_LEGACY_KEYS]) {
|
|
964
|
+
const saved = localStorage.getItem(key);
|
|
965
|
+
if (THEME_ORDER.includes(saved)) return saved;
|
|
966
|
+
}
|
|
959
967
|
}
|
|
960
968
|
} catch { /* ignore storage errors on file:// or private browsing */ }
|
|
961
|
-
return
|
|
969
|
+
return "auto";
|
|
962
970
|
}
|
|
963
971
|
|
|
964
972
|
function saveTheme(mode) {
|
|
965
973
|
try {
|
|
966
974
|
if (typeof localStorage !== "undefined" && typeof localStorage.setItem === "function") {
|
|
967
|
-
localStorage.setItem(
|
|
975
|
+
localStorage.setItem(THEME_KEY, mode);
|
|
976
|
+
for (const key of THEME_LEGACY_KEYS) localStorage.setItem(key, mode);
|
|
968
977
|
}
|
|
969
978
|
} catch { /* ignore */ }
|
|
970
979
|
}
|
|
971
980
|
|
|
972
|
-
function
|
|
973
|
-
const
|
|
974
|
-
if (
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
return typeof matchMedia === "function" && Boolean(matchMedia("(prefers-color-scheme: dark)").matches);
|
|
978
|
-
} catch {
|
|
979
|
-
return false;
|
|
981
|
+
function applyTheme(mode) {
|
|
982
|
+
const m = THEME_ORDER.includes(mode) ? mode : "auto";
|
|
983
|
+
if (document.documentElement?.dataset) {
|
|
984
|
+
if (m === "auto") delete document.documentElement.dataset.theme;
|
|
985
|
+
else document.documentElement.dataset.theme = m;
|
|
980
986
|
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
function syncThemeButton() {
|
|
984
987
|
const btn = $("theme");
|
|
985
988
|
if (!btn) return;
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
btn.
|
|
990
|
-
btn.setAttribute("aria-label", label);
|
|
989
|
+
btn.textContent = THEME_LABEL[m];
|
|
990
|
+
const tip = `当前${THEME_LABEL[m]},点击切换为${THEME_NEXT[m]}`;
|
|
991
|
+
btn.title = tip;
|
|
992
|
+
btn.setAttribute("aria-label", tip);
|
|
991
993
|
}
|
|
992
994
|
|
|
993
995
|
function selectLadderFormat(fmt, restoreFocus = false) {
|
|
@@ -1174,20 +1176,12 @@ if (typeof document !== "undefined") (() => {
|
|
|
1174
1176
|
failLabel: "请复制地址栏",
|
|
1175
1177
|
failAnnounce: "未能自动复制链接,请直接复制浏览器地址栏",
|
|
1176
1178
|
});
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
document.documentElement.dataset.theme = savedTheme;
|
|
1180
|
-
}
|
|
1181
|
-
syncThemeButton();
|
|
1182
|
-
try {
|
|
1183
|
-
const mq = typeof matchMedia === "function" ? matchMedia("(prefers-color-scheme: dark)") : null;
|
|
1184
|
-
if (mq && typeof mq.addEventListener === "function") mq.addEventListener("change", syncThemeButton);
|
|
1185
|
-
} catch { /* ignore */ }
|
|
1179
|
+
let themeMode = readSavedTheme();
|
|
1180
|
+
applyTheme(themeMode);
|
|
1186
1181
|
$("theme").addEventListener("click", () => {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
saveTheme(
|
|
1190
|
-
syncThemeButton();
|
|
1182
|
+
themeMode = THEME_ORDER[(THEME_ORDER.indexOf(themeMode) + 1) % THEME_ORDER.length];
|
|
1183
|
+
applyTheme(themeMode);
|
|
1184
|
+
saveTheme(themeMode);
|
|
1191
1185
|
});
|
|
1192
1186
|
$("pin-btn")?.addEventListener("click", () => {
|
|
1193
1187
|
if (pinned) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// The sizing model of localmodels/sizecalc.py, line for line. Every table (formats,
|
|
2
|
-
// devices with their usable memory, constants) comes from sizecalc.page_data(), which the
|
|
3
|
-
// inlines as SIZECALC_DATA; tests/test_sizecalc.py runs this file under Node and compares its
|
|
1
|
+
// The sizing model of localmodels/planning/sizecalc.py, line for line. Every table (formats,
|
|
2
|
+
// engines, devices with their usable memory, constants) comes from sizecalc.page_data(), which the
|
|
3
|
+
// CLI inlines as SIZECALC_DATA; tests/test_sizecalc.py runs this file under Node and compares its
|
|
4
4
|
// reports with Python's. Every number is an estimate for sizing, not a measurement.
|
|
5
5
|
const SizeCalc = (data) => {
|
|
6
6
|
const C = data.constants;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<meta name="color-scheme" content="light dark">
|
|
7
7
|
<title>模型体量计算器</title>
|
|
8
|
+
<script>try{var t=localStorage.getItem("localmodels.theme")||localStorage.getItem("lm-sizecalc-theme")||localStorage.getItem("lm-theme");if(t==="light"||t==="dark")document.documentElement.dataset.theme=t;}catch(e){}</script>
|
|
8
9
|
<style>
|
|
9
10
|
/* Layout: a control rail on the left, the answer on the right. The answer leads with the class
|
|
10
11
|
of device (the magnitude), then the memory ruler that shows why, then the selected device's
|
|
@@ -68,7 +69,7 @@ p { margin: 0; }
|
|
|
68
69
|
code, .mono { font-family: var(--f-mono); font-size: 0.9em; }
|
|
69
70
|
a { color: var(--accent); }
|
|
70
71
|
.mast { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 22px; }
|
|
71
|
-
.eyebrow { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); font-weight: 500; }
|
|
72
|
+
.eyebrow { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); font-weight: 500; text-wrap: pretty; }
|
|
72
73
|
.lede { color: var(--ink-2); font-size: 14.5px; max-width: 76ch; }
|
|
73
74
|
.mast-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
|
|
74
75
|
.mast-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
|
|
@@ -313,11 +314,11 @@ tbody tr.dev:focus-visible { outline: 2px solid var(--accent); outline-offset: -
|
|
|
313
314
|
<div id="live-status" class="sr-only" role="status" aria-live="polite"></div>
|
|
314
315
|
<header class="mast">
|
|
315
316
|
<div class="mast-row">
|
|
316
|
-
<div class="eyebrow">LOCALMODELS · SIZECALC ·
|
|
317
|
+
<div class="eyebrow">LOCALMODELS · SIZECALC · <span style="white-space:nowrap">估算,不是实测</span></div>
|
|
317
318
|
<div class="mast-actions">
|
|
318
319
|
<button class="theme" id="share-btn" type="button">复制链接</button>
|
|
319
320
|
<button class="theme" id="pin-btn" type="button" aria-pressed="false">固定当前方案作对比</button>
|
|
320
|
-
<button class="theme" id="theme" type="button"
|
|
321
|
+
<button class="theme" id="theme" type="button">外观:跟随系统</button>
|
|
321
322
|
</div>
|
|
322
323
|
</div>
|
|
323
324
|
<h1>模型体量计算器</h1>
|
|
@@ -12,22 +12,37 @@
|
|
|
12
12
|
<body class="fleet">
|
|
13
13
|
<main>
|
|
14
14
|
<div class="top">
|
|
15
|
-
<div class="crumb"><span>View hub</span> / <b>Computers</b></div>
|
|
15
|
+
<div class="crumb"><svg class="crumb-mark" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" aria-hidden="true"><path d="M12 3 3 7.5 12 12l9-4.5L12 3Z"/><path d="m3 12 9 4.5 9-4.5" opacity=".7"/><path d="m3 16.5 9 4.5 9-4.5" opacity=".45"/></svg><span>View hub</span> / <b>Computers</b></div>
|
|
16
16
|
<span class="tag" id="fleet-sum" aria-live="polite"></span>
|
|
17
17
|
<div class="grow"></div>
|
|
18
|
-
<
|
|
18
|
+
<div class="fl-top-actions">
|
|
19
|
+
<span class="fleet-updated num" id="fleet-updated"></span>
|
|
20
|
+
<button class="icon-btn" id="fleet-notify" type="button" hidden aria-pressed="false" title="Alert notifications: off" aria-label="notifications"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"><path d="M4 11V7.5a4 4 0 0 1 8 0V11l1 1.5H3L4 11Z"/><path d="M6.5 14a1.6 1.6 0 0 0 3 0"/></svg></button>
|
|
21
|
+
<button class="icon-btn" id="fleet-refresh" type="button" title="Refresh (r)" aria-label="Refresh"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M13.5 8a5.5 5.5 0 1 1-1.35-3.6"/><path d="M13.5 2.5v2.75h-2.75"/></svg></button>
|
|
22
|
+
<button class="icon-btn" id="theme" type="button" title="Appearance: system / light / dark (t)" aria-label="theme"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4"><circle cx="8" cy="8" r="5.5"/><path d="M8 2.5v11" /><path d="M8 2.5a5.5 5.5 0 0 1 0 11Z" fill="currentColor"/></svg></button>
|
|
23
|
+
</div>
|
|
19
24
|
</div>
|
|
20
25
|
<section class="card">
|
|
21
26
|
<header><h2>Computers</h2><span class="sub">read-only · each one's view agent sends its stack here</span></header>
|
|
22
27
|
<p class="explain">One row per computer added with <code>stack view-hub add</code>. Open one to see its whole board, or switch computers from the list in its top bar. Several stacks sharing a GPU each show it; the total above counts each card once.</p>
|
|
23
28
|
<div class="fl-bar">
|
|
24
|
-
<input id="fleet-q" type="search" placeholder="Filter computers, models or GPUs
|
|
29
|
+
<input id="fleet-q" type="search" placeholder="Filter computers, models or GPUs (/)" aria-label="Filter computers">
|
|
25
30
|
<div class="seg" role="group" aria-label="Filter by status">
|
|
26
31
|
<button type="button" class="chip fl-filter" data-filter="all" aria-pressed="true">All</button>
|
|
27
32
|
<button type="button" class="chip fl-filter" data-filter="attention" aria-pressed="false">Needs attention</button>
|
|
28
33
|
<button type="button" class="chip fl-filter" data-filter="live" aria-pressed="false">Live</button>
|
|
34
|
+
<button type="button" class="chip fl-filter" data-filter="stale" aria-pressed="false">Stale</button>
|
|
29
35
|
<button type="button" class="chip fl-filter" data-filter="waiting" aria-pressed="false">Waiting</button>
|
|
30
36
|
</div>
|
|
37
|
+
<div class="fl-sort">
|
|
38
|
+
<label for="fl-sort-select" class="sub">Sort:</label>
|
|
39
|
+
<select id="fl-sort-select" class="fl-select" aria-label="Sort computers">
|
|
40
|
+
<option value="status" selected>Problem first</option>
|
|
41
|
+
<option value="name">Name (A-Z)</option>
|
|
42
|
+
<option value="vram_free">VRAM free</option>
|
|
43
|
+
<option value="gpus">GPUs (High to Low)</option>
|
|
44
|
+
</select>
|
|
45
|
+
</div>
|
|
31
46
|
</div>
|
|
32
47
|
<div id="fleet-rows"></div>
|
|
33
48
|
</section>
|
|
@@ -67,10 +67,9 @@ const FLEET = (function () {
|
|
|
67
67
|
el("span", { class: "fl-num" }, `${gb(g.used_bytes)} / ${gb(g.total_bytes)} GB`));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function
|
|
70
|
+
function hasAlert(c) {
|
|
71
71
|
return Boolean(
|
|
72
72
|
c && (
|
|
73
|
-
c.state === "stale" ||
|
|
74
73
|
(Array.isArray(c.problems) && c.problems.length > 0) ||
|
|
75
74
|
(Array.isArray(c.down) && c.down.length > 0) ||
|
|
76
75
|
Number(c.alerts) > 0 ||
|
|
@@ -79,24 +78,41 @@ const FLEET = (function () {
|
|
|
79
78
|
);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
function
|
|
81
|
+
function hasProblem(c) {
|
|
82
|
+
return Boolean(c && (c.state === "stale" || hasAlert(c)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function freeVramBytes(c) {
|
|
86
|
+
return ((c && c.gpus) || []).reduce((sum, g) => sum + Math.max(0, ((g && g.total_bytes) || 0) - ((g && g.used_bytes) || 0)), 0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function sortAndFilter(rows, query, filter, sortBy = "status") {
|
|
83
90
|
const f = String(filter || "all").toLowerCase();
|
|
84
91
|
const q = String(query || "").trim().toLowerCase();
|
|
92
|
+
const s = String(sortBy || "status").toLowerCase();
|
|
85
93
|
const rank = (c) => (hasProblem(c) ? 0 : c && c.state === "live" ? 1 : 2);
|
|
94
|
+
const byName = (a, b) => String(a.c.name || "").localeCompare(String(b.c.name || ""));
|
|
86
95
|
return (rows || [])
|
|
87
96
|
.map((c, idx) => ({ c, idx }))
|
|
88
97
|
.filter(({ c }) => {
|
|
89
98
|
if (!c) return false;
|
|
90
99
|
if (f === "attention" && !hasProblem(c)) return false;
|
|
100
|
+
if (f === "alerts" && !hasAlert(c)) return false;
|
|
91
101
|
if (f === "live" && c.state !== "live") return false;
|
|
102
|
+
if (f === "stale" && c.state !== "stale") return false;
|
|
92
103
|
if (f === "waiting" && c.state !== "waiting") return false;
|
|
93
104
|
if (!q) return true;
|
|
94
105
|
const llmText = typeof c.llm === "string" ? c.llm : c.llm && (c.llm.model || c.llm.id || "");
|
|
95
106
|
const gpus = (c.gpus || []).map((g) => (g && g.name) || "").join(" ");
|
|
96
|
-
const hay = `${c.name || ""} ${c.hostname || ""} ${llmText} ${c.state || ""} ${gpus}`.toLowerCase();
|
|
107
|
+
const hay = `${c.name || ""} ${c.hostname || ""} ${c.tier || ""} ${llmText} ${c.state || ""} ${gpus}`.toLowerCase();
|
|
97
108
|
return hay.includes(q);
|
|
98
109
|
})
|
|
99
|
-
.sort((a, b) =>
|
|
110
|
+
.sort((a, b) => {
|
|
111
|
+
if (s === "gpus") return (((b.c.gpus && b.c.gpus.length) || 0) - ((a.c.gpus && a.c.gpus.length) || 0)) || byName(a, b);
|
|
112
|
+
if (s === "vram_free") return (freeVramBytes(b.c) - freeVramBytes(a.c)) || byName(a, b);
|
|
113
|
+
if (s === "name") return byName(a, b) || a.idx - b.idx;
|
|
114
|
+
return rank(a.c) - rank(b.c) || a.idx - b.idx;
|
|
115
|
+
})
|
|
100
116
|
.map(({ c }) => c);
|
|
101
117
|
}
|
|
102
118
|
|
|
@@ -125,7 +141,10 @@ const FLEET = (function () {
|
|
|
125
141
|
: null;
|
|
126
142
|
const meta = c.state === "waiting"
|
|
127
143
|
? null
|
|
128
|
-
: el("span", { class: "fl-meta" },
|
|
144
|
+
: el("span", { class: "fl-meta" },
|
|
145
|
+
spark,
|
|
146
|
+
el("span", { class: `fl-age is-${c.state}` }, `${STATE[c.state]} · ${ago(c.age_s)}`),
|
|
147
|
+
el("span", { class: "fl-chevron", "aria-hidden": "true" }, "→"));
|
|
129
148
|
const head = el("div", { class: "fl-head" },
|
|
130
149
|
el("span", { class: `fl-dot is-${c.state}`, title: STATE[c.state] || c.state }),
|
|
131
150
|
c.state === "waiting" ? el("b", {}, c.name) : el("a", { href }, el("b", {}, c.name)),
|
|
@@ -155,25 +174,88 @@ const FLEET = (function () {
|
|
|
155
174
|
for (const c of rows) for (const g of c.gpus || []) cards.set(g.card, g);
|
|
156
175
|
let used = 0, total = 0;
|
|
157
176
|
for (const g of cards.values()) { used += g.used_bytes || 0; total += g.total_bytes || 0; }
|
|
158
|
-
const live = rows.filter((c) => c.state === "live").length;
|
|
159
|
-
|
|
177
|
+
const live = rows.filter((c) => c && c.state === "live").length;
|
|
178
|
+
const stale = rows.filter((c) => c && c.state === "stale").length;
|
|
179
|
+
const alerts = rows.reduce((n, c) => n + (c ? (c.alerts ?? (c.down ? c.down.length : 0)) : 0), 0);
|
|
180
|
+
return { computers: rows.length, live, stale, alerts, cards: cards.size, used, total };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function summaryText(sum) {
|
|
184
|
+
const parts = [`${sum.live} of ${sum.computers} reporting`];
|
|
185
|
+
if (sum.stale) parts.push(`+ ${sum.stale} stale`);
|
|
186
|
+
if (sum.alerts) parts.push(`${sum.alerts} alert${sum.alerts === 1 ? "" : "s"}`);
|
|
187
|
+
parts.push(`${sum.cards} GPU${sum.cards === 1 ? "" : "s"}`, `${gb(sum.used)} / ${gb(sum.total)} GB VRAM in use`);
|
|
188
|
+
return parts.join(" · ");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function fleetAlertKeys(rows) {
|
|
192
|
+
const keys = new Map();
|
|
193
|
+
for (const c of rows || []) {
|
|
194
|
+
if (!c) continue;
|
|
195
|
+
if (c.state === "stale") keys.set(`stale:${c.name}`, `${c.name}: no recent report`);
|
|
196
|
+
for (const comp of c.down || []) keys.set(`down:${c.name}:${comp}`, `${c.name}: ${comp} is down`);
|
|
197
|
+
if (c.calls && c.failed * 2 > c.calls) keys.set(`failed:${c.name}`, `${c.name}: ${c.failed} of ${c.calls} recent calls failed`);
|
|
198
|
+
}
|
|
199
|
+
return keys;
|
|
160
200
|
}
|
|
161
201
|
|
|
162
202
|
function overview() {
|
|
163
203
|
const box = document.getElementById("fleet-rows");
|
|
164
204
|
if (!box) return;
|
|
165
205
|
const sumEl = document.getElementById("fleet-sum");
|
|
206
|
+
const updatedEl = document.getElementById("fleet-updated");
|
|
166
207
|
const qInput = document.getElementById("fleet-q");
|
|
208
|
+
const sortSelect = document.getElementById("fl-sort-select");
|
|
167
209
|
const filterBtns = [...document.querySelectorAll(".fl-filter")];
|
|
168
210
|
const filterLabels = new Map(filterBtns.map((btn) => [btn, String(btn.textContent || "").trim()]));
|
|
211
|
+
const stamp = (d = new Date()) => [d.getHours(), d.getMinutes(), d.getSeconds()].map((n) => String(n).padStart(2, "0")).join(":");
|
|
169
212
|
const historyMap = new Map();
|
|
170
213
|
let query = qInput ? qInput.value : "";
|
|
171
214
|
let filter = "all";
|
|
215
|
+
let sortBy = sortSelect ? (sortSelect.value || "status") : "status";
|
|
172
216
|
let lastFound = null;
|
|
173
217
|
let lastSig = null;
|
|
174
218
|
let lastSum = null;
|
|
175
219
|
let lastCounts = null;
|
|
176
220
|
|
|
221
|
+
// Optional browser alert notifications when a computer goes stale or a component drops.
|
|
222
|
+
const notifyBtn = document.getElementById("fleet-notify");
|
|
223
|
+
const note = {
|
|
224
|
+
on: false,
|
|
225
|
+
seen: null,
|
|
226
|
+
init() {
|
|
227
|
+
if (!notifyBtn || typeof Notification === "undefined" || typeof window === "undefined" || !window.isSecureContext) return;
|
|
228
|
+
notifyBtn.hidden = false;
|
|
229
|
+
try { this.on = localStorage.getItem("lm-fleet-notify") === "1" && Notification.permission === "granted"; } catch (e) { /* not kept */ }
|
|
230
|
+
this.say();
|
|
231
|
+
notifyBtn.addEventListener("click", () => {
|
|
232
|
+
if (this.on) return this.set(false);
|
|
233
|
+
if (Notification.permission === "granted") return this.set(true);
|
|
234
|
+
Notification.requestPermission().then((p) => this.set(p === "granted"));
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
set(on) {
|
|
238
|
+
this.on = on;
|
|
239
|
+
try { localStorage.setItem("lm-fleet-notify", on ? "1" : "0"); } catch (e) { /* not kept */ }
|
|
240
|
+
this.say();
|
|
241
|
+
},
|
|
242
|
+
say() {
|
|
243
|
+
if (!notifyBtn) return;
|
|
244
|
+
notifyBtn.setAttribute("aria-pressed", String(this.on));
|
|
245
|
+
notifyBtn.title = this.on ? "Alert notifications: on" : Notification.permission === "denied"
|
|
246
|
+
? "The browser blocked notifications; allow them in site settings, then click"
|
|
247
|
+
: "Alert notifications: off (the browser asks for permission)";
|
|
248
|
+
},
|
|
249
|
+
check(rows) {
|
|
250
|
+
const keys = fleetAlertKeys(rows);
|
|
251
|
+
const fresh = this.seen ? [...keys].filter(([k]) => !this.seen.has(k)) : [];
|
|
252
|
+
this.seen = new Set(keys.keys());
|
|
253
|
+
if (!this.on) return;
|
|
254
|
+
for (const [key, body] of fresh) new Notification("localmodels · view hub", { body, tag: key });
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
note.init();
|
|
258
|
+
|
|
177
259
|
const recordHistory = (found) => {
|
|
178
260
|
const rows = Array.isArray(found && found.computers) ? found.computers : [];
|
|
179
261
|
const seen = new Set();
|
|
@@ -191,29 +273,38 @@ const FLEET = (function () {
|
|
|
191
273
|
for (const name of historyMap.keys()) if (!seen.has(name)) historyMap.delete(name);
|
|
192
274
|
};
|
|
193
275
|
|
|
194
|
-
const setSum = (
|
|
276
|
+
const setSum = (sum) => {
|
|
277
|
+
const text = summaryText(sum);
|
|
195
278
|
if (sumEl && lastSum !== text) {
|
|
196
279
|
lastSum = text;
|
|
197
280
|
sumEl.textContent = text;
|
|
198
281
|
}
|
|
282
|
+
if (sumEl && sumEl.classList) {
|
|
283
|
+
sumEl.classList.toggle("bad", sum.alerts > 0);
|
|
284
|
+
sumEl.classList.toggle("warn", sum.alerts === 0 && sum.stale > 0);
|
|
285
|
+
}
|
|
199
286
|
};
|
|
200
287
|
|
|
201
288
|
const draw = (found) => {
|
|
202
289
|
lastFound = found;
|
|
203
290
|
if (!found) {
|
|
291
|
+
if (updatedEl) updatedEl.textContent = "Offline";
|
|
204
292
|
if (lastSig === "offline") return;
|
|
205
293
|
lastSig = "offline";
|
|
206
294
|
box.replaceChildren(el("div", { class: "empty" }, "Cannot reach the hub."));
|
|
207
295
|
return;
|
|
208
296
|
}
|
|
209
297
|
const rows = Array.isArray(found.computers) ? found.computers : [];
|
|
298
|
+
note.check(rows);
|
|
210
299
|
const sum = totals(rows);
|
|
211
|
-
setSum(
|
|
300
|
+
setSum(sum);
|
|
301
|
+
if (updatedEl) updatedEl.textContent = `Updated ${stamp()}`;
|
|
212
302
|
if (filterBtns.length) {
|
|
213
303
|
const counts = {
|
|
214
304
|
all: rows.length,
|
|
215
305
|
attention: rows.filter(hasProblem).length,
|
|
216
306
|
live: rows.filter((c) => c && c.state === "live").length,
|
|
307
|
+
stale: rows.filter((c) => c && c.state === "stale").length,
|
|
217
308
|
waiting: rows.filter((c) => c && c.state === "waiting").length,
|
|
218
309
|
};
|
|
219
310
|
const countSig = JSON.stringify(counts);
|
|
@@ -224,15 +315,16 @@ const FLEET = (function () {
|
|
|
224
315
|
const n = counts[mode];
|
|
225
316
|
if (n === undefined) continue;
|
|
226
317
|
const label = filterLabels.get(btn) || "";
|
|
227
|
-
btn.replaceChildren(label, " ", el("small", mode === "attention" && n > 0 ? { class: "bad" } : {}, String(n)));
|
|
318
|
+
btn.replaceChildren(label, " ", el("small", (mode === "attention" || mode === "stale") && n > 0 ? { class: "bad" } : {}, String(n)));
|
|
228
319
|
}
|
|
229
320
|
}
|
|
230
321
|
}
|
|
231
|
-
const shown = sortAndFilter(rows, query, filter);
|
|
322
|
+
const shown = sortAndFilter(rows, query, filter, sortBy);
|
|
232
323
|
const sig = JSON.stringify({
|
|
233
324
|
total: rows.length,
|
|
234
325
|
query,
|
|
235
326
|
filter,
|
|
327
|
+
sortBy,
|
|
236
328
|
rows: shown.map((c) => ({
|
|
237
329
|
name: c.name,
|
|
238
330
|
state: c.state,
|
|
@@ -293,6 +385,12 @@ const FLEET = (function () {
|
|
|
293
385
|
if (lastFound !== null) draw(lastFound);
|
|
294
386
|
});
|
|
295
387
|
}
|
|
388
|
+
if (sortSelect) {
|
|
389
|
+
sortSelect.addEventListener("change", () => {
|
|
390
|
+
sortBy = sortSelect.value || "status";
|
|
391
|
+
if (lastFound !== null) draw(lastFound);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
296
394
|
for (const btn of filterBtns) {
|
|
297
395
|
btn.addEventListener("click", () => {
|
|
298
396
|
filter = btn.getAttribute("data-filter") || "all";
|
|
@@ -305,6 +403,8 @@ const FLEET = (function () {
|
|
|
305
403
|
if (found) recordHistory(found);
|
|
306
404
|
draw(found);
|
|
307
405
|
});
|
|
406
|
+
const refresh = document.getElementById("fleet-refresh");
|
|
407
|
+
if (refresh) refresh.addEventListener("click", () => { tick(); });
|
|
308
408
|
tick();
|
|
309
409
|
setInterval(tick, 3000);
|
|
310
410
|
const theme = document.getElementById("theme");
|
|
@@ -313,13 +413,34 @@ const FLEET = (function () {
|
|
|
313
413
|
const next = { auto: "light", light: "dark", dark: "auto" }[now];
|
|
314
414
|
if (next === "auto") delete document.documentElement.dataset.theme;
|
|
315
415
|
else document.documentElement.dataset.theme = next;
|
|
316
|
-
try {
|
|
416
|
+
try {
|
|
417
|
+
localStorage.setItem("localmodels.theme", next);
|
|
418
|
+
localStorage.setItem("lm-theme", next);
|
|
419
|
+
} catch (e) { /* not kept */ }
|
|
317
420
|
});
|
|
421
|
+
if (typeof document.addEventListener === "function") {
|
|
422
|
+
document.addEventListener("keydown", (e) => {
|
|
423
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
424
|
+
const a = document.activeElement;
|
|
425
|
+
if (a && (["INPUT", "TEXTAREA", "SELECT"].includes(a.tagName) || a.isContentEditable)) {
|
|
426
|
+
if (e.key === "Escape" && a === qInput) {
|
|
427
|
+
qInput.value = "";
|
|
428
|
+
query = "";
|
|
429
|
+
qInput.blur();
|
|
430
|
+
if (lastFound !== null) draw(lastFound);
|
|
431
|
+
}
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (e.key === "/" && qInput) { e.preventDefault(); qInput.focus(); qInput.select(); }
|
|
435
|
+
else if (e.key === "r" || e.key === "R") { e.preventDefault(); tick(); }
|
|
436
|
+
else if ((e.key === "t" || e.key === "T") && theme) { e.preventDefault(); theme.click(); }
|
|
437
|
+
});
|
|
438
|
+
}
|
|
318
439
|
}
|
|
319
440
|
|
|
320
441
|
if (typeof document !== "undefined") {
|
|
321
442
|
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => { switcher(); overview(); });
|
|
322
443
|
else { switcher(); overview(); }
|
|
323
444
|
}
|
|
324
|
-
return { current, totals, optionText, ago, sortAndFilter, sparkPoints };
|
|
445
|
+
return { current, totals, summaryText, optionText, ago, sortAndFilter, sparkPoints, fleetAlertKeys };
|
|
325
446
|
})();
|
|
@@ -7,6 +7,10 @@ const WORDS = {
|
|
|
7
7
|
"nav.concepts": "Concepts", "nav.jev": "Jev decision", "nav.embedding": "Embedding", "nav.rerank": "Reranker", "nav.stt": "Speech-to-text",
|
|
8
8
|
"crumb.host": "This computer", "crumb.stack": "Stack",
|
|
9
9
|
"theme": "Appearance: system / light / dark", "nav.rail": "Collapse the menu", "nav.expand": "Expand the menu",
|
|
10
|
+
"nav.console": "Single-model console (requires localmodels serve on :8765)",
|
|
11
|
+
"keys.h": "Keyboard shortcuts (?)", "keys.title": "Keyboard shortcuts", "keys.jump": "Jump to a section",
|
|
12
|
+
"keys.step": "Next / previous section", "keys.rail": "Collapse or expand sidebar", "keys.theme": "Cycle appearance",
|
|
13
|
+
"keys.help": "Toggle this guide", "keys.close": "Close dialog or menu", "keys.ok": "Done",
|
|
10
14
|
"live.connecting": "Connecting…", "live.demo": "Demo data", "live.on": "Live · this computer", "live.on.remote": "Live · {host}", "live.empty": "No stack here",
|
|
11
15
|
"live.off": "Disconnected, retrying…", "live.fail": "Cannot read this computer",
|
|
12
16
|
"flow.h": "Request flow",
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
<button class="icon-btn" id="notify" type="button" hidden aria-pressed="false" data-i18n-title="notify.off" title="Alert notifications: off" aria-label="notifications"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"><path d="M4 11V7.5a4 4 0 0 1 8 0V11l1 1.5H3L4 11Z"/><path d="M6.5 14a1.6 1.6 0 0 0 3 0"/></svg></button>
|
|
47
47
|
<div class="snap"><button class="icon-btn" id="snap" type="button" aria-haspopup="menu" aria-expanded="false" data-i18n-title="snap.h" title="Snapshot" aria-label="snapshot"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"><path d="M2.5 5.5h2l1-1.5h5l1 1.5h2v7h-11z"/><circle cx="8" cy="8.8" r="2.2"/></svg></button>
|
|
48
48
|
<div class="menu" id="snap-menu" role="menu" hidden><button type="button" role="menuitem" id="snap-json" data-i18n="snap.json">Download the JSON document</button><button type="button" role="menuitem" id="snap-text" data-i18n="snap.text">Copy a text summary</button><small data-i18n="snap.note"></small></div></div>
|
|
49
|
+
<a class="icon-btn" id="link-console" hidden href="http://127.0.0.1:8765/" target="_blank" rel="noopener noreferrer" data-i18n-title="nav.console" title="Single-model console" aria-label="Single-model console"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4"><rect x="2" y="3" width="12" height="10" rx="2"/><path d="M5 7h6M5 10h3"/></svg></a>
|
|
50
|
+
<button class="icon-btn" id="keys-btn" type="button" data-i18n-title="keys.h" title="Keyboard shortcuts (?)" aria-label="keyboard shortcuts"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><circle cx="8" cy="8" r="5.5"/><path d="M6.4 6.3a1.7 1.7 0 0 1 3.2.7c0 1.1-1.6 1.4-1.6 2.3"/><circle cx="8" cy="11.5" r=".4" fill="currentColor"/></svg></button>
|
|
49
51
|
<button class="icon-btn" id="theme" type="button" data-i18n-title="theme" title="Appearance: system / light / dark" aria-label="theme"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4"><circle cx="8" cy="8" r="5.5"/><path d="M8 2.5v11A5.5 5.5 0 0 0 8 2.5Z" fill="currentColor"/></svg></button>
|
|
50
52
|
</div>
|
|
51
53
|
<nav class="tabs" id="tabs" aria-label="sections"></nav>
|
|
@@ -126,6 +128,20 @@
|
|
|
126
128
|
</div>
|
|
127
129
|
</main>
|
|
128
130
|
<div class="hint" id="hint" role="tooltip"></div>
|
|
131
|
+
<dialog class="keys-dialog" id="keys-dialog" aria-labelledby="keys-title">
|
|
132
|
+
<header class="keys-head"><b id="keys-title" tabindex="-1" data-i18n="keys.title">Keyboard shortcuts</b><button class="icon-btn" id="keys-close" type="button" aria-label="close">×</button></header>
|
|
133
|
+
<table class="keys-table">
|
|
134
|
+
<tbody>
|
|
135
|
+
<tr><td><kbd>1</kbd> – <kbd>8</kbd></td><td data-i18n="keys.jump">Jump to a section</td></tr>
|
|
136
|
+
<tr><td><kbd>j</kbd> / <kbd>k</kbd></td><td data-i18n="keys.step">Next / previous section</td></tr>
|
|
137
|
+
<tr><td><kbd>[</kbd> / <kbd>]</kbd></td><td data-i18n="keys.rail">Collapse or expand sidebar</td></tr>
|
|
138
|
+
<tr><td><kbd>t</kbd></td><td data-i18n="keys.theme">Cycle appearance</td></tr>
|
|
139
|
+
<tr><td><kbd>?</kbd></td><td data-i18n="keys.help">Toggle this guide</td></tr>
|
|
140
|
+
<tr><td><kbd>Esc</kbd></td><td data-i18n="keys.close">Close dialog or menu</td></tr>
|
|
141
|
+
</tbody>
|
|
142
|
+
</table>
|
|
143
|
+
<footer class="keys-foot"><button class="keys-ok" id="keys-ok" type="button" data-i18n="keys.ok">Done</button></footer>
|
|
144
|
+
</dialog>
|
|
129
145
|
<script src="nav.js"></script>
|
|
130
146
|
<script src="view.js"></script>
|
|
131
147
|
<script src="fleet.js"></script>
|
|
@@ -45,15 +45,64 @@ const NAV = {
|
|
|
45
45
|
try { localStorage.setItem("lm-rail", on ? "1" : "0"); } catch (e) { /* not kept */ }
|
|
46
46
|
setTimeout(() => this.place(), 260);
|
|
47
47
|
};
|
|
48
|
+
this.setRail = setRail;
|
|
48
49
|
rail.addEventListener("click", () => setRail(!document.body.classList.contains("rail")));
|
|
49
50
|
let saved = null;
|
|
50
51
|
try { saved = localStorage.getItem("lm-rail"); } catch (e) { /* not kept */ }
|
|
51
52
|
setRail(saved === "1");
|
|
53
|
+
this.initKeys();
|
|
52
54
|
const start = location.hash.slice(1);
|
|
53
55
|
if (start && document.getElementById(start)) requestAnimationFrame(() => this.mark(start, true));
|
|
54
56
|
else this.spy();
|
|
55
57
|
},
|
|
56
58
|
|
|
59
|
+
initKeys() {
|
|
60
|
+
const dlg = document.getElementById("keys-dialog");
|
|
61
|
+
const btn = document.getElementById("keys-btn");
|
|
62
|
+
const toggleDlg = (open) => {
|
|
63
|
+
if (!dlg) return;
|
|
64
|
+
const show = open === undefined ? !dlg.open : open;
|
|
65
|
+
if (show && !dlg.open) {
|
|
66
|
+
dlg.showModal?.();
|
|
67
|
+
document.getElementById("keys-title")?.focus?.();
|
|
68
|
+
} else if (!show && dlg.open) {
|
|
69
|
+
dlg.close?.();
|
|
70
|
+
btn?.focus?.();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
btn?.addEventListener?.("click", () => toggleDlg());
|
|
74
|
+
document.getElementById("keys-close")?.addEventListener?.("click", () => toggleDlg(false));
|
|
75
|
+
document.getElementById("keys-ok")?.addEventListener?.("click", () => toggleDlg(false));
|
|
76
|
+
dlg?.addEventListener?.("click", (e) => { if (e.target === dlg) toggleDlg(false); });
|
|
77
|
+
dlg?.addEventListener?.("cancel", (e) => { e.preventDefault(); toggleDlg(false); });
|
|
78
|
+
addEventListener("keydown", (e) => {
|
|
79
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
80
|
+
const el = document.activeElement;
|
|
81
|
+
if (el && (["INPUT", "TEXTAREA", "SELECT"].includes(el.tagName) || el.isContentEditable)) return;
|
|
82
|
+
if (dlg?.open) {
|
|
83
|
+
if (e.key === "?" || e.key === "Escape") { e.preventDefault(); toggleDlg(false); }
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (e.key === "?") { e.preventDefault(); return void toggleDlg(true); }
|
|
87
|
+
if (e.key === "[") { e.preventDefault(); return void this.setRail?.(true); }
|
|
88
|
+
if (e.key === "]") { e.preventDefault(); return void this.setRail?.(false); }
|
|
89
|
+
if (e.key === "t" || e.key === "T") { e.preventDefault(); return void document.getElementById("theme")?.click?.(); }
|
|
90
|
+
const visible = this.links.filter((a) => {
|
|
91
|
+
const s = document.getElementById(a.dataset.nav);
|
|
92
|
+
return s && !s.hidden;
|
|
93
|
+
});
|
|
94
|
+
if (!visible.length) return;
|
|
95
|
+
if (e.key >= "1" && e.key <= "9") {
|
|
96
|
+
const target = visible[Number(e.key) - 1];
|
|
97
|
+
if (target) this.go(e, target.dataset.nav);
|
|
98
|
+
} else if (e.key === "j" || e.key === "k") {
|
|
99
|
+
const idx = visible.findIndex((a) => a.dataset.nav === this.active);
|
|
100
|
+
const next = e.key === "j" ? Math.min(visible.length - 1, idx + 1) : Math.max(0, (idx < 0 ? 0 : idx) - 1);
|
|
101
|
+
this.go(e, visible[next].dataset.nav);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
|
|
57
106
|
go(event, id) {
|
|
58
107
|
event.preventDefault();
|
|
59
108
|
const target = document.getElementById(id);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
var asked = new URLSearchParams(location.search).get("theme");
|
|
6
6
|
if (asked === "light" || asked === "dark") return void (document.documentElement.dataset.theme = asked);
|
|
7
7
|
try {
|
|
8
|
-
var picked = localStorage.getItem("lm-theme");
|
|
8
|
+
var picked = localStorage.getItem("localmodels.theme") || localStorage.getItem("lm-theme") || localStorage.getItem("lm-sizecalc-theme");
|
|
9
9
|
if (picked === "light" || picked === "dark") document.documentElement.dataset.theme = picked;
|
|
10
10
|
} catch (e) {
|
|
11
11
|
/* storage may be off: follow the system */
|