chore: import upstream snapshot with attribution
CI / lint (push) Has been cancelled
CI / js-syntax (push) Successful in 10m24s
CI / deps-audit (push) Has been cancelled
CI / test (push) Failing after 24m55s
CI / sast-bandit (push) Failing after 11m13s
CI / trivy (push) Failing after 9m32s
Docker Publish / build-and-push (push) Failing after 34m3s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:32:09 +08:00
commit 8f10353f0c
135 changed files with 37786 additions and 0 deletions
+247
View File
@@ -0,0 +1,247 @@
{
"name": "stemdeck-desktop",
"version": "0.1.0-alpha.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "stemdeck-desktop",
"version": "0.1.0-alpha.0",
"devDependencies": {
"@tauri-apps/cli": "^2.0.0"
}
},
"node_modules/@tauri-apps/cli": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.11.1.tgz",
"integrity": "sha512-rpEbaJ/HzNb6fwsquwoAbq29/Vt4gADhS423A8fdkwL4edJ0wZmoB8ar7O6JPDL834MUKOCm/rrJ7c9oAaEaYQ==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"bin": {
"tauri": "tauri.js"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "2.11.1",
"@tauri-apps/cli-darwin-x64": "2.11.1",
"@tauri-apps/cli-linux-arm-gnueabihf": "2.11.1",
"@tauri-apps/cli-linux-arm64-gnu": "2.11.1",
"@tauri-apps/cli-linux-arm64-musl": "2.11.1",
"@tauri-apps/cli-linux-riscv64-gnu": "2.11.1",
"@tauri-apps/cli-linux-x64-gnu": "2.11.1",
"@tauri-apps/cli-linux-x64-musl": "2.11.1",
"@tauri-apps/cli-win32-arm64-msvc": "2.11.1",
"@tauri-apps/cli-win32-ia32-msvc": "2.11.1",
"@tauri-apps/cli-win32-x64-msvc": "2.11.1"
}
},
"node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.11.1.tgz",
"integrity": "sha512-6eEKMBXsQPCuM1EmvrjT2+aBuxWQuFdKdW8pzNuNQtpq45nEEpBlD5gr8pUeAyOU1DQKlkFaEc/MPBxb/Pfjtg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.11.1.tgz",
"integrity": "sha512-LQUO7exfRWjWALNhetph5guWpMeHphRpokOLk0OIbTTExaNwJNFu3I4vb+CCM/4G/QGoZe/5XikZOJdNEFP1ig==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.11.1.tgz",
"integrity": "sha512-5i/awiBCRRhOUG8yjn0fMHXIWD5Ez8eEk5LtvOxyQrKuJkRaZDvnbIjZbE183blAwkoA4xN3aO/prJiqscl02Q==",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.11.1.tgz",
"integrity": "sha512-9LrwDw3S9Fygtw/Q6WDhOP+3svJRGAsejeE+GKrc0eO1ThMVhwi2LL6hw4dlKw93IfS7VY1G19sWGxJ/NcU4nA==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.11.1.tgz",
"integrity": "sha512-mNA5dbbqPqDUdTIwdUYYuhO2GvIe9UnB2r0VU2njxBOS3Opbx4gKNC5yP0Iu4rYmEmqdlwry9VzGZQ3wq9dyFg==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-riscv64-gnu": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.11.1.tgz",
"integrity": "sha512-fZj3Gwq+6fUs305T5WQiD5iSGJw+j/4w/HGmk4sHDAcy+rp9zU5eaxB7nOyz5/I/nkNAuKPqfp6uIbiUBXkBCw==",
"cpu": [
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.11.1.tgz",
"integrity": "sha512-XFxGxOvHM7jjeD6ozCKdGfhzJ7lERYDGZl1/Kb4fsvchaJsfLJ981TlyTG8Qy/gFq+f5GitH3bfrX9JAkjPEyw==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.11.1.tgz",
"integrity": "sha512-d5C2/Zm+68v7R9wTuTCjRQEVrWjcdMkJBZ1+rXse+QdMMlTB9+u9PDNDLw9PQflWxYLaYZ7tjxxL9Nb9II6PbA==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.11.1.tgz",
"integrity": "sha512-YdeVWFAR1pTXzUU6NLstPq4G6OLxuDrXCXEBdmBH+5EZIDXUx0D2kJlz3+YjpazkKvAzYpgziTsyRagls0OfRQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.11.1.tgz",
"integrity": "sha512-VBGkuH0eB9K9LLSMv361Gzr5Ou72sCS4+ztpmkWEQ+wd/amhcYOsf3X6qn1RJZDzIhiOYHJEOysZUC3baD01rA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.11.1.tgz",
"integrity": "sha512-b3ORhIAKgp9ZYY+zBt7b7r0kLU2kjvyGF0+MS2SBym3emsweGPybEqocJcmtMuxyBhkOKHP4CiuEJEDuAlTx6A==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"name": "stemdeck-desktop",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"tauri": "tauri",
"dev": "tauri dev",
"build": "tauri build"
},
"devDependencies": {
"@tauri-apps/cli": "^2.0.0"
}
}
+5294
View File
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
[package]
name = "stemdeck"
# Placeholder — stamped from the git tag at build time (Woodpecker / make-app.sh). #169
version = "0.0.0"
description = "StemDeck desktop launcher"
authors = ["StemDeck contributors"]
edition = "2021"
rust-version = "1.88"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
flate2 = "1"
libc = "0.2"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "blocking"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
tar = "0.4"
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
tauri-plugin-store = "2"
zip = { version = "2", default-features = false, features = ["deflate"] }
zstd = "0.13"
[dev-dependencies]
tempfile = "3"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
@@ -0,0 +1,7 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Default StemDeck desktop window permissions",
"windows": ["main"],
"permissions": ["core:default", "dialog:allow-save"]
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 KiB

File diff suppressed because it is too large Load Diff
+50
View File
@@ -0,0 +1,50 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "StemDeck",
"version": "0.0.0",
"identifier": "app.stemdeck.desktop",
"build": {
"frontendDist": "../ui",
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
"app": {
"withGlobalTauri": true,
"windows": [
{
"title": "StemDeck",
"width": 1280,
"height": 820,
"minWidth": 1024,
"minHeight": 720,
"backgroundColor": "#050b10",
"dragDropEnabled": false
}
],
"security": {
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com data:; img-src 'self' data: blob:; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; frame-ancestors 'none'"
}
},
"bundle": {
"active": true,
"targets": ["app"],
"icon": ["icons/icon.icns", "icons/icon.png", "icons/icon.ico"],
"macOS": {
"minimumSystemVersion": "13.0",
"dmg": {
"windowSize": {
"width": 660,
"height": 400
},
"appPosition": {
"x": 180,
"y": 170
},
"applicationFolderPosition": {
"x": 480,
"y": 170
}
}
}
}
}
+40
View File
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>StemDeck Launcher</title>
<link rel="stylesheet" href="./setup.css" />
</head>
<body>
<main class="setup-shell">
<section class="setup-card">
<div class="brand-row">
<h1>StemDeck</h1>
<span>ALPHA</span>
</div>
<p class="subtitle">Preparing the local audio engine, first run will take a while...</p>
<ol class="setup-steps" id="steps">
<li data-step="runtime">Setting up local runtime</li>
<li data-step="workspace">Creating workspace</li>
<li data-step="ffmpeg">Checking FFmpeg</li>
<li data-step="gpu">Configuring compute device</li>
<li data-step="model">Checking AI separation model</li>
<li data-step="backend">Starting backend</li>
</ol>
<p class="status" id="status">Starting setup...</p>
<div class="progress-wrap hidden" id="progress-wrap">
<div class="progress-fill" id="progress-fill"></div>
</div>
<pre class="details hidden" id="details"></pre>
<div class="actions">
<button id="retry" type="button" class="hidden">Retry</button>
</div>
</section>
</main>
<script type="module" src="./setup.js"></script>
</body>
</html>
+8
View File
@@ -0,0 +1,8 @@
{
"version": "0.1.0-alpha.1",
"arch": "arm64",
"runtimeUrl": "",
"runtimeSha256": "",
"runtimeSize": 0,
"archiveName": "StemDeck-runtime-macOS-arm64.tar.zst"
}
+215
View File
@@ -0,0 +1,215 @@
:root {
color-scheme: dark;
--bg: #050b10;
--panel: #101a22;
--line: rgba(148, 163, 184, 0.2);
--ink: #f0f2f5;
--muted: #9aa3ad;
--gold: #d8a84a;
--ok: #54c568;
--err: #ef4f58;
font-family:
"JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* {
box-sizing: border-box;
}
body {
min-height: 100vh;
margin: 0;
background:
radial-gradient(circle at 80% 10%, rgba(216, 168, 74, 0.1), transparent 26rem),
radial-gradient(circle at 12% 92%, rgba(62, 141, 207, 0.09), transparent 24rem),
var(--bg);
color: var(--ink);
}
.setup-shell {
min-height: 100vh;
display: grid;
place-items: center;
padding: 32px;
}
.setup-card {
width: min(760px, 100%);
padding: 32px;
border: 1px solid var(--line);
border-radius: 14px;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent), var(--panel);
box-shadow: 0 20px 90px rgba(0, 0, 0, 0.34);
}
.brand-row {
display: flex;
align-items: center;
gap: 12px;
}
h1 {
margin: 0;
font-size: 32px;
letter-spacing: 0;
}
.brand-row span {
padding: 3px 7px;
border: 1px solid rgba(216, 168, 74, 0.58);
border-radius: 7px;
color: #f1cf82;
font-size: 13px;
}
.subtitle {
margin: 8px 0 26px;
color: var(--muted);
}
.setup-steps {
display: grid;
gap: 12px;
margin: 0;
padding: 0;
list-style: none;
}
.setup-steps li {
display: flex;
align-items: center;
gap: 12px;
min-height: 42px;
padding: 0 14px;
border: 1px solid rgba(148, 163, 184, 0.08);
border-radius: 8px;
background: rgba(3, 10, 15, 0.34);
color: rgba(154, 163, 173, 0.45); /* dimmed — queued */
transition: color 240ms ease, border-color 240ms ease;
}
/* pending: small hollow ring, barely visible */
.setup-steps li::before {
content: "";
flex: 0 0 auto;
width: 12px;
height: 12px;
border: 1.5px solid currentColor;
border-radius: 50%;
opacity: 0.5;
}
/* active: gold spinning ring */
.setup-steps li.active {
color: var(--gold);
border-color: rgba(216, 168, 74, 0.22);
}
.setup-steps li.active::before {
opacity: 1;
border-color: var(--gold);
border-top-color: transparent;
animation: spin 750ms linear infinite;
}
/* done: bright green ✓ */
.setup-steps li.done {
color: var(--ok);
border-color: rgba(84, 197, 104, 0.18);
}
.setup-steps li.done::before {
content: "✓";
width: auto;
height: auto;
border: 0;
opacity: 1;
font-size: 14px;
line-height: 1;
animation: none;
}
/* error: red ✗ */
.setup-steps li.error {
color: var(--err);
border-color: rgba(239, 79, 88, 0.25);
}
.setup-steps li.error::before {
content: "✗";
width: auto;
height: auto;
border: 0;
opacity: 1;
font-size: 14px;
line-height: 1;
animation: none;
}
.status {
margin: 24px 0 0;
color: #cbd2da;
}
.progress-wrap {
height: 4px;
background: rgba(148, 163, 184, 0.15);
border-radius: 2px;
margin-top: 10px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: var(--gold);
border-radius: 2px;
width: 0%;
transition: width 0.15s linear;
}
.progress-fill.indeterminate {
width: 35%;
animation: progress-slide 1.6s ease-in-out infinite;
}
@keyframes progress-slide {
0% { transform: translateX(-200%); }
100% { transform: translateX(400%); }
}
.details {
max-height: 180px;
overflow: auto;
margin: 16px 0 0;
padding: 12px;
border: 1px solid rgba(239, 79, 88, 0.25);
border-radius: 8px;
color: #ffd0d4;
background: rgba(239, 79, 88, 0.08);
white-space: pre-wrap;
}
.actions {
margin-top: 20px;
}
button {
min-height: 42px;
padding: 0 18px;
border: 1px solid rgba(216, 168, 74, 0.4);
border-radius: 8px;
background: rgba(216, 168, 74, 0.14);
color: #f1cf82;
font: inherit;
cursor: pointer;
}
.hidden {
display: none;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
+383
View File
@@ -0,0 +1,383 @@
const { invoke } = window.__TAURI__.core;
let _runtimeUnlisten = null;
// The backend always binds all interfaces; network availability is gated live
// by the backend itself (Settings → "Make StemDeck available on your network").
function startBackend() {
return invoke("start_backend");
}
const statusEl = document.getElementById("status");
const detailsEl = document.getElementById("details");
const retryBtn = document.getElementById("retry");
const steps = [...document.querySelectorAll("[data-step]")];
function setStep(name, state) {
const el = steps.find((item) => item.dataset.step === name);
if (!el) return;
el.classList.remove("active", "done", "error");
if (state) el.classList.add(state);
}
function setStatus(message) {
statusEl.textContent = message;
}
function showError(error, hint) {
for (const el of steps) {
if (el.classList.contains("active")) {
el.classList.replace("active", "error");
}
}
setStatus("Setup could not complete.");
const msg = String(error?.message ?? error);
detailsEl.textContent = hint ? `${msg}\n\n${hint}` : msg;
detailsEl.classList.remove("hidden");
retryBtn.classList.remove("hidden");
}
async function runStep(name, fn) {
setStep(name, "active");
try {
const result = await fn();
setStep(name, "done");
return result;
} catch (err) {
setStep(name, "error");
throw err;
}
}
function minDelay(ms) {
return Promise.all([
new Promise((r) => setTimeout(r, ms)),
new Promise((r) => requestAnimationFrame(r)),
]);
}
function formatElapsed(startedAt) {
const seconds = Math.floor((Date.now() - startedAt) / 1000);
const minutes = Math.floor(seconds / 60);
const rest = seconds % 60;
return minutes > 0 ? `${minutes}m ${rest}s` : `${rest}s`;
}
function startProgressStatus(messages) {
const startedAt = Date.now();
let messageIndex = 0;
const update = () => {
const elapsedSeconds = Math.floor((Date.now() - startedAt) / 1000);
while (
messageIndex + 1 < messages.length &&
elapsedSeconds >= messages[messageIndex + 1].afterSeconds
) {
messageIndex += 1;
}
setStatus(`${messages[messageIndex].text} Elapsed: ${formatElapsed(startedAt)}.`);
};
update();
const timer = window.setInterval(update, 1000);
return () => window.clearInterval(timer);
}
function isMac() {
return /mac/i.test(navigator.userAgentData?.platform ?? navigator.platform ?? "");
}
async function installRuntimePack(appRoot) {
const status = await invoke("runtime_pack_status");
if (!status.manifestReady) {
throw Object.assign(
new Error(`Python runtime not found under ${appRoot}.`),
{ hint: "Try reinstalling StemDeck. If the problem persists, check that your disk has at least 2 GB free." }
);
}
const progressWrap = document.getElementById("progress-wrap");
const progressFill = document.getElementById("progress-fill");
// lastProgressAt is updated by the SSE handler below; only meaningful
// during a network download, so it is reset just before download starts.
let lastReceived = 0;
let lastProgressAt = Date.now();
const STALL_WARN_MS = 30_000;
// Guard against stacked listeners on rapid retry (#146): unlisten any
// previous registration before creating a new one.
if (_runtimeUnlisten) { _runtimeUnlisten(); _runtimeUnlisten = null; }
const unlisten = await window.__TAURI__.event.listen(
"runtime-download-progress",
(event) => {
const { received, total } = event.payload;
if (received !== lastReceived) {
lastReceived = received;
lastProgressAt = Date.now();
}
const mb = (received / 1e6).toFixed(0);
if (total && total > 0) {
const pct = Math.min(100, Math.round((received / total) * 100));
progressFill.style.width = `${pct}%`;
progressFill.classList.remove("indeterminate");
setStatus(`Downloading StemDeck runtime... ${mb} / ${(total / 1e6).toFixed(0)} MB`);
} else {
progressFill.classList.add("indeterminate");
setStatus(`Downloading StemDeck runtime... ${mb} MB received`);
}
}
);
_runtimeUnlisten = unlisten;
progressWrap.classList.remove("hidden");
progressFill.style.width = "0%";
progressFill.classList.remove("indeterminate");
try {
let verified = false;
if (status.archiveReady) {
try {
setStatus("Runtime archive found locally, verifying...");
progressWrap.classList.add("hidden");
await invoke("verify_runtime_pack");
verified = true;
} catch {
// Stale or corrupt archive — fall through to re-download
}
}
if (!verified) {
progressWrap.classList.remove("hidden");
setStatus("Downloading StemDeck runtime...");
// Reset stall baseline when network download is actually about to start (#150).
lastProgressAt = Date.now();
// stallTimer starts here, not at top of function, so it doesn't fire
// during the local verify_runtime_pack path (#150).
// When a stall is detected it stops startProgressStatus first to avoid
// both timers writing setStatus concurrently (#149).
let stopSlowMsg = null;
const stallTimer = window.setInterval(() => {
const stallMs = Date.now() - lastProgressAt;
if (stallMs >= STALL_WARN_MS) {
if (stopSlowMsg) { stopSlowMsg(); stopSlowMsg = null; }
setStatus(
stallMs >= 60_000
? "Download appears unreachable — check your internet connection and click Retry."
: "Download seems slow or stalled — check your internet connection."
);
}
}, 5_000);
// startProgressStatus is assigned after stallTimer creation; the closure
// above captures stopSlowMsg by reference, so it sees the updated value.
stopSlowMsg = startProgressStatus([
{ afterSeconds: 0, text: "Downloading StemDeck runtime..." },
{ afterSeconds: 30, text: "Still downloading runtime... slow connection detected." },
{ afterSeconds: 90, text: "Still downloading... large file on a slow connection can take a few minutes." },
]);
try {
await invoke("download_runtime_pack");
} catch (err) {
throw Object.assign(
new Error(String(err)),
{ hint: "Check your internet connection and click Retry. If the problem persists, try a different network." }
);
} finally {
window.clearInterval(stallTimer);
if (stopSlowMsg) { stopSlowMsg(); }
}
progressWrap.classList.add("hidden");
setStatus("Verifying StemDeck runtime...");
await invoke("verify_runtime_pack");
}
setStatus("Installing StemDeck runtime...");
const installed = await invoke("extract_runtime_pack");
if (!installed.runtimeReady) {
throw Object.assign(
new Error("Runtime install finished but Python/backend files were not found."),
{ hint: "Your disk may be full or the archive may be corrupt. Free up space and click Retry to re-download." }
);
}
} finally {
_runtimeUnlisten = null;
unlisten();
progressWrap.classList.add("hidden");
}
}
async function runSetup() {
detailsEl.classList.add("hidden");
retryBtn.classList.add("hidden");
for (const step of steps) step.classList.remove("active", "done", "error");
try {
setStep("runtime", "active");
setStatus("Checking Python runtime...");
let [runtime] = await Promise.all([
invoke("probe_runtime"),
minDelay(350),
]);
// Compare the installed runtime against the version this app bundle expects.
// On a DMG upgrade the old runtime is still fully "ready", so this MUST be
// checked before the early-return below -- otherwise setup starts the stale
// backend + frontend and the new release (e.g. new features, version) never
// takes effect until the runtime is manually cleared.
const runtimeStatus = await invoke("runtime_pack_status");
const expectedVersion = runtimeStatus.manifest?.version;
const installedVersion = runtimeStatus.installedVersion;
// Mismatch when this build expects a version the installed runtime isn't.
// An unknown installedVersion (a runtime from a build that never recorded
// one) also counts, so an upgrade still refreshes it. Self-heals: after one
// refresh the install records the version and subsequent launches match.
const versionMismatch = Boolean(expectedVersion) && installedVersion !== expectedVersion;
if (runtime.pythonReady && runtime.ffmpegReady && runtime.torchDevice && !versionMismatch) {
for (const step of steps) {
step.classList.remove("active", "error");
if (step.dataset.step === "backend") {
step.classList.remove("done");
} else {
step.classList.add("done");
}
}
await runStep("backend", async () => {
setStatus("Runtime is ready. Starting StemDeck backend...");
const backend = await startBackend();
setStatus("Opening StemDeck...");
window.location.replace(backend.url);
});
return;
}
if (!runtime.pythonReady || versionMismatch) {
if (versionMismatch) {
setStatus(`Updating runtime from ${installedVersion || "an older build"} to ${expectedVersion}...`);
}
await invoke("ensure_workspace");
await installRuntimePack(runtime.appRoot);
runtime = await invoke("probe_runtime");
if (!runtime.pythonReady) {
setStep("runtime", "error");
throw Object.assign(
new Error(`Python runtime setup failed under: ${runtime.dataDir}`),
{ hint: "Check that your disk has at least 2 GB free and click Retry. If it keeps failing, try reinstalling StemDeck." }
);
}
}
setStep("runtime", "done");
setStatus(`Python runtime found at ${runtime.pythonPath}`);
await minDelay(200);
let gpuSummary = "";
await runStep("workspace", () => invoke("ensure_workspace"));
if (runtime.ffmpegReady) {
setStep("ffmpeg", "done");
} else {
await runStep("ffmpeg", async () => {
const stopProgress = startProgressStatus([
{
afterSeconds: 0,
text: "Downloading FFmpeg... this can take a few minutes on first run.",
},
{
afterSeconds: 60,
text: "Still downloading FFmpeg... slow networks or antivirus scans can delay this.",
},
]);
try {
const assets = await invoke("ensure_external_assets");
if (!assets.ffmpegReady) {
throw new Error(
"FFmpeg setup did not complete. Check your internet connection and retry."
);
}
} finally {
stopProgress();
}
});
}
await runStep("gpu", async () => {
const macGPU = isMac();
const stopProgress = startProgressStatus(
macGPU
? [
{
afterSeconds: 0,
text: "Checking Apple Silicon compute support...",
},
{
afterSeconds: 10,
text: "Verifying MPS acceleration for AI models...",
},
]
: [
{
afterSeconds: 0,
text: "Checking NVIDIA GPU and compute support...",
},
{
afterSeconds: 20,
text: "Installing NVIDIA acceleration if needed... first run can take 5-15 minutes.",
},
{
afterSeconds: 120,
text: "Still installing NVIDIA acceleration... CUDA Torch packages are large.",
},
{
afterSeconds: 300,
text: "Still working... setup should finish or time out automatically.",
},
]
);
try {
const gpu = await invoke("ensure_torch_device");
if (macGPU) {
gpuSummary =
gpu.torchDevice === "mps"
? `${gpu.gpuName} acceleration enabled`
: "MPS acceleration unavailable - stem separation will use CPU";
} else {
if (gpu.gpuDetected && !gpu.cudaVerified) {
showError(
`GPU detected (${gpu.gpuName}) but CUDA setup failed - stem separation will use CPU.\nCheck logs/setup.log in the StemDeck data folder for details.`
);
}
gpuSummary = gpu.gpuDetected
? gpu.cudaVerified
? `${gpu.gpuName} - CUDA ${gpu.cudaVersion} enabled`
: `${gpu.gpuName} found - falling back to CPU (CUDA unverified)`
: "No NVIDIA GPU - stem separation will use CPU";
}
return gpu;
} finally {
stopProgress();
}
});
setStep("model", "done");
setStatus("AI separation model will download on first use (~340 MB).");
await runStep("backend", async () => {
setStatus(gpuSummary ? `${gpuSummary} - starting backend...` : "Starting StemDeck backend...");
const backend = await startBackend();
setStatus("Opening StemDeck...");
window.location.replace(backend.url);
});
} catch (error) {
showError(error, error?.hint);
}
}
retryBtn.addEventListener("click", runSetup);
runSetup();