From 7aa16eb77a61ddcfece7b4a7176d6e7307dab2cd Mon Sep 17 00:00:00 2001 From: Sofian Mejjoute Date: Wed, 15 Jul 2026 04:10:06 -0600 Subject: [PATCH 1/2] fix: decode file:// URIs from the macOS app file picker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit saucer's macOS picker returns NSURL.absoluteString — a percent-encoded file:// URI (e.g. file:///Users/.../my%20model.gguf), not a POSIX path — so the app's fs::exists() check rejected every picked model with "backbone model not found". WebKitGTK returns a plain path, so the Linux container smoke never caught it (macOS-only). Add file_uri_to_path(): strip the file:// scheme and percent-decode. Apply it in pick_file (clean path in the setup textbox), in launch (before fs::exists and before save_config), and in load_config (so a config saved with a bad URI self-heals on next boot / auto-launch). Plain paths have no scheme and pass through untouched. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 1f26503..574fc37 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -40,6 +40,40 @@ using json = nlohmann::json; static fs::path exe_dir() { return zonos2_exe_dir(); } +// macOS's saucer file picker returns NSURL.absoluteString — a percent-encoded +// file:// URI (e.g. file:///Users/.../my%20model.gguf), not a POSIX path — so a +// filesystem lookup on it fails. Normalize any file:// URI to a native path; +// plain paths (Linux/Windows pickers, hand-typed) have no scheme and pass through. +static std::string file_uri_to_path(const std::string & s) { + constexpr const char * scheme = "file://"; + if (s.rfind(scheme, 0) != 0) return s; + // Drop scheme (+ optional empty authority: file://host/path -> /path); percent-decode. + std::string rest = s.substr(7); + std::string out; + out.reserve(rest.size()); + auto unhex = [](char c) -> int { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + return -1; + }; + for (size_t i = 0; i < rest.size(); ++i) { + int hi, lo; + if (rest[i] == '%' && i + 2 < rest.size() && + (hi = unhex(rest[i + 1])) >= 0 && (lo = unhex(rest[i + 2])) >= 0) { + out.push_back(static_cast(hi * 16 + lo)); + i += 2; + } else { + out.push_back(rest[i]); + } + } +#ifdef _WIN32 + // A Windows file URI decodes to "/C:/path"; strip the spurious leading slash. + if (out.size() >= 3 && out[0] == '/' && out[2] == ':') out.erase(0, 1); +#endif + return out; +} + static fs::path config_path() { #ifdef _WIN32 const char * base = getenv("APPDATA"); @@ -78,7 +112,11 @@ static json load_config() { std::ifstream f(config_path()); if (!f) return json::object(); json j = json::parse(f, nullptr, false); - return j.is_object() ? j : json::object(); + if (!j.is_object()) return json::object(); + // Repair configs written before the file://-URI fix (macOS picker); harmless on plain paths. + for (const char * k : {"model", "dac", "spk"}) + if (j.contains(k) && j[k].is_string()) j[k] = file_uri_to_path(j[k].get()); + return j; } static std::string save_config(const json & j) { // returns error message or "" @@ -365,13 +403,17 @@ coco::stray start(saucer::application * app) { webview->expose("pick_file", [&desktop](const std::string & /*kind*/) -> std::string { auto r = desktop.pick({.filters = {"*.gguf"}}); - return r ? r->string() : std::string{}; + return r ? file_uri_to_path(r->string()) : std::string{}; }); webview->expose("get_config", []() -> std::string { return load_config().dump(); }); - webview->expose("launch", [webview](const std::string & model, const std::string & dac, - const std::string & spk, bool gpu) -> std::string { + webview->expose("launch", [webview](const std::string & model_in, const std::string & dac_in, + const std::string & spk_in, bool gpu) -> std::string { + // Self-heal file:// URIs (macOS picker, or a config saved before this fix). + const std::string model = file_uri_to_path(model_in); + const std::string dac = file_uri_to_path(dac_in); + const std::string spk = file_uri_to_path(spk_in); std::error_code ec; if (!fs::exists(model, ec)) return "backbone model not found: " + model; if (!fs::exists(dac, ec)) return "DAC decoder not found: " + dac; From a8dd0e37edceb3a0b1855348a880c5f437799787 Mon Sep 17 00:00:00 2001 From: Sofian Mejjoute Date: Wed, 15 Jul 2026 06:02:38 -0600 Subject: [PATCH 2/2] feat: download models from the setup page in zonos2-app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The desktop app could only *pick* existing .gguf files, so a user without models was stuck — while the start-zonos2 launchers download-if-missing. Add the same one-click path to the app's setup page: choose a quant and hit "Download & Launch" to fetch backbone + dac + (optional) spk-encoder from the public HF GGUF repo into /models, with a live progress bar; then it launches as usual. "I already have the model files" still reveals the native pickers. Implementation mirrors the launcher and the app's existing ffmpeg fetch: system curl to a .part with resume + rc-33 (416) handling, ZONOS2_BASE_URL override, spk-encoder failure non-fatal (voice cloning disabled). Download runs on a background thread; the page polls a new download_status() exposed fn (byte count from the .part, denominator from a curl -sIL HEAD, falling back to a size table). A ZONOS2_APP_SELFTEST_DOWNLOAD= seam runs the download headlessly for tests/app-download-smoke.sh, wired into the linux-app CI job. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/build.yml | 1 + README.md | 13 ++- src/app-pages.h | 138 ++++++++++++++++++++++----- src/app.cpp | 185 ++++++++++++++++++++++++++++++++++++ tests/app-download-smoke.sh | 70 ++++++++++++++ 5 files changed, 376 insertions(+), 31 deletions(-) create mode 100755 tests/app-download-smoke.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7343ff..7c186d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -200,6 +200,7 @@ jobs: bin=$(find build -name zonos2-app -type f | head -1) out=$("$bin" --help 2>&1 || true) echo "$out" | grep -q "usage:" || { echo "app smoke failed:"; echo "$out"; exit 1; } + bash tests/app-download-smoke.sh "$bin" - name: Package if: startsWith(github.ref, 'refs/tags/v') shell: bash diff --git a/README.md b/README.md index adf373d..f29fb72 100644 --- a/README.md +++ b/README.md @@ -148,11 +148,14 @@ curl -s http://localhost:1919/tts/generate \ ## Desktop App (zonos2-app) The same server and web UI, packaged as a native window (a [saucer](https://github.com/saucer/saucer) -webview: WebView2 / WKWebView / WebKitGTK). First launch opens a setup page to pick your `.gguf` -files with native file dialogs; the choice is saved (`~/.config/zonos2/app.json`, or the platform -equivalent) and later launches boot straight into the UI. The embedded server binds an ephemeral -`127.0.0.1` port and its whole HTTP API stays reachable while the app runs; closing the window -shuts it down. Release tags ship prebuilt bundles: `zonos2-linux-x64-app.tar.gz`, +webview: WebView2 / WKWebView / WebKitGTK). First launch opens a setup page: pick a model quality +and click **Download & Launch** and it fetches the model files for you (into +`~/.config/zonos2/models`, or the platform equivalent) — same one-click path as the launcher +scripts, no terminal needed. If you already have the `.gguf` files, "I already have the model files" +reveals native file pickers instead. The choice is saved (`~/.config/zonos2/app.json`, or the +platform equivalent) and later launches boot straight into the UI. The embedded server binds an +ephemeral `127.0.0.1` port and its whole HTTP API stays reachable while the app runs; closing the +window shuts it down. Release tags ship prebuilt bundles: `zonos2-linux-x64-app.tar.gz`, `zonos2-macos-arm64-app.zip` (a `Zonos2.app`), and `zonos2-app.exe` inside the Windows `zonos2-windows-x64-vulkan.zip`. diff --git a/src/app-pages.h b/src/app-pages.h index 1d646a9..ebbcfa7 100644 --- a/src/app-pages.h +++ b/src/app-pages.h @@ -23,6 +23,14 @@ static const char * ZONOS2_APP_STYLE = R"html( input[type=text] { flex: 1; background: #0d0f13; color: #e6e8ee; border: 1px solid #2a3040; border-radius: 7px; padding: 8px 10px; font-size: 13px; min-width: 0; } input[type=text]:focus { outline: none; border-color: #5b7fd4; } + select { width: 100%; background: #0d0f13; color: #e6e8ee; border: 1px solid #2a3040; + border-radius: 7px; padding: 8px 10px; font-size: 13px; } + select:focus { outline: none; border-color: #5b7fd4; } + a { color: #7fa0ff; text-decoration: none; } + a:hover { text-decoration: underline; } + .bar { height: 8px; background: #0d0f13; border: 1px solid #2a3040; border-radius: 6px; + overflow: hidden; margin: 4px 0 14px; } + .barfill { height: 100%; width: 0; background: #3b5bd6; transition: width .3s ease; } button { background: #222836; color: #e6e8ee; border: 1px solid #323a4d; border-radius: 7px; padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; } button:hover { background: #2a3242; } @@ -46,49 +54,127 @@ static const char * ZONOS2_APP_STYLE = R"html( static const char * ZONOS2_APP_SETUP_PAGE = R"html(
-

Zonos2

-

Pick the model files to use. They are saved for the next launch.

+
+

Zonos2

+

Download the model files to get started, or point to files you already have.

- -
-
+
+ + +
+
+
- -
-
+ - -
-
+
+
-
+
+ + +

I already have the model files

+
-
- +