Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

feat(install): use pre-built Tauri icon for macOS .app bundle (#7628)

Arjun B Divecha2cf903e64dcc
diff --git a/install.sh b/install.sh
index 5ab0282328b..cb9bb9aab19 100755
--- a/install.sh
+++ b/install.sh
@@ -1431,6 +1431,32 @@ LAUNCHER_EOF
rm -f "$_css_gem_png"
fi
+ # Also try to find the pre-built Tauri icon.icns (1024×1024, professionally
+ # built with all required sizes). Prefer it over the sips-generated icon
+ # for the macOS .app bundle — it ships in the pip package at
+ # studio/src-tauri/icons/icon.icns and is higher quality with @2x variants.
+ _css_tauri_icns=""
+ for _sp in "$_css_venv_dir"/lib/python*/site-packages/studio/src-tauri/icons; do
+ if [ -f "$_sp/icon.icns" ]; then
+ _css_tauri_icns="$_sp/icon.icns"
+ fi
+ done
+ if [ -z "$_css_tauri_icns" ] && [ -n "$_css_script_dir" ] && [ -f "$_css_script_dir/studio/src-tauri/icons/icon.icns" ]; then
+ _css_tauri_icns="$_css_script_dir/studio/src-tauri/icons/icon.icns"
+ fi
+
+ # Also look for the higher-resolution Tauri icon.png (1024×1024) for
+ # the Linux .desktop icon — better than the 512px rounded variant.
+ _css_tauri_png=""
+ for _sp in "$_css_venv_dir"/lib/python*/site-packages/studio/src-tauri/icons; do
+ if [ -f "$_sp/icon.png" ]; then
+ _css_tauri_png="$_sp/icon.png"
+ fi
+ done
+ if [ -z "$_css_tauri_png" ] && [ -n "$_css_script_dir" ] && [ -f "$_css_script_dir/studio/src-tauri/icons/icon.png" ]; then
+ _css_tauri_png="$_css_script_dir/studio/src-tauri/icons/icon.png"
+ fi
+
# ── Platform-specific shortcuts ──
# Env-mode installs are workspace-scoped: skip persistent desktop /
# Start-Menu / dock launchers that may point at a deleted workspace.
@@ -1450,7 +1476,19 @@ LAUNCHER_EOF
_css_desktop="$_css_app_dir/unsloth-studio.desktop"
# Escape backslashes and double-quotes for .desktop Exec= field
_css_exec_escaped=$(printf '%s' "$_css_launcher" | sed 's/\\/\\\\/g; s/"/\\"/g')
- _css_icon_escaped=$(printf '%s' "$_css_icon_png" | sed 's/\\/\\\\/g; s/"/\\"/g')
+ # Prefer the higher-resolution Tauri icon.png, but persist it under the
+ # installed data directory so local-checkout shortcuts survive repo moves.
+ _css_desktop_icon="$_css_icon_png"
+ if [ -f "$_css_tauri_png" ]; then
+ _css_desktop_icon_tmp="${_css_icon_png}.tmp"
+ if cp "$_css_tauri_png" "$_css_desktop_icon_tmp" 2>/dev/null \
+ && mv "$_css_desktop_icon_tmp" "$_css_icon_png" 2>/dev/null; then
+ :
+ else
+ rm -f "$_css_desktop_icon_tmp"
+ fi
+ fi
+ _css_icon_escaped=$(printf '%s' "$_css_desktop_icon" | sed 's/\\/\\\\/g; s/"/\\"/g')
cat > "$_css_desktop" << DESKTOP_EOF
[Desktop Entry]
Version=1.0
@@ -1542,8 +1580,14 @@ STUB_EOF
&& mv "$_css_macos_dir/launch-studio.tmp" "$_css_macos_dir/launch-studio"
chmod +x "$_css_macos_dir/launch-studio"
- # Build AppIcon.icns from unsloth-gem.png (2240x2240)
- if [ -f "$_css_gem_png" ] && command -v sips >/dev/null 2>&1 && command -v iconutil >/dev/null 2>&1; then
+ # ── AppIcon ──
+ # Prefer the pre-built Tauri icon.icns (1024×1024, professionally built
+ # with all sizes). Fall back to generating one from the gem PNG via
+ # sips+iconutil, then to a plain PNG copy.
+ if [ -f "$_css_tauri_icns" ] \
+ && cp "$_css_tauri_icns" "$_css_res_dir/AppIcon.icns" 2>/dev/null; then
+ :
+ elif [ -f "$_css_gem_png" ] && command -v sips >/dev/null 2>&1 && command -v iconutil >/dev/null 2>&1; then
_css_tmpdir=$(mktemp -d 2>/dev/null)
if [ -d "$_css_tmpdir" ]; then
_css_iconset="$_css_tmpdir/AppIcon.iconset"
@@ -1560,7 +1604,7 @@ STUB_EOF
rm -rf "$_css_tmpdir"
fi
fi
- # Fallback: copy PNG as icon
+ # Last-resort fallback: copy PNG as icon
if [ ! -f "$_css_res_dir/AppIcon.icns" ] && [ -f "$_css_icon_png" ]; then
cp "$_css_icon_png" "$_css_res_dir/AppIcon.icns" 2>/dev/null || true
fi
diff --git a/pyproject.toml b/pyproject.toml
index 8e55926c508..aa9e52cc18d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,6 +59,8 @@ studio = [
"*.ps1",
"*.bat",
"node_prebuilt_pins.json",
+ "src-tauri/icons/icon.icns",
+ "src-tauri/icons/icon.png",
"frontend/dist/**/*",
"frontend/*.json",
"frontend/*.ts",
diff --git a/studio/src-tauri/icons/icon.png b/studio/src-tauri/icons/icon.png
index 7837ab40ddc..8a9ab5dbb1f 100644
Binary files a/studio/src-tauri/icons/icon.png and b/studio/src-tauri/icons/icon.png differ
diff --git a/tests/test_installer_shortcut_icons.py b/tests/test_installer_shortcut_icons.py
new file mode 100644
index 00000000000..fde6797e29d
--- /dev/null
+++ b/tests/test_installer_shortcut_icons.py
@@ -0,0 +1,128 @@
+"""Regression tests for installer shortcut icon selection and fallback behavior."""
+
+from __future__ import annotations
+
+import shlex
+import shutil
+import struct
+import subprocess
+import sys
+import textwrap
+from pathlib import Path
+
+import pytest
+
+REPO_ROOT = Path(__file__).resolve().parents[1]
+INSTALL_SH = REPO_ROOT / "install.sh"
+PYPROJECT = REPO_ROOT / "pyproject.toml"
+TAURI_ICON_PNG = REPO_ROOT / "studio" / "src-tauri" / "icons" / "icon.png"
+
+
+def test_linux_tauri_icon_is_1024_square():
+ data = TAURI_ICON_PNG.read_bytes()
+ assert data[:8] == b"\x89PNG\r\n\x1a\n"
+ assert data[12:16] == b"IHDR"
+ assert struct.unpack(">II", data[16:24]) == (1024, 1024)
+
+
+def test_tauri_icons_are_declared_as_package_data():
+ tomllib = pytest.importorskip("tomllib" if sys.version_info >= (3, 11) else "tomli")
+ data = tomllib.loads(PYPROJECT.read_text(encoding = "utf-8"))
+ package_data = data["tool"]["setuptools"]["package-data"]["studio"]
+ assert "src-tauri/icons/icon.icns" in package_data
+ assert "src-tauri/icons/icon.png" in package_data
+
+
[email protected](shutil.which("bash") is None, reason = "bash is unavailable")
+def test_linux_tauri_icon_is_copied_into_installed_data(tmp_path):
+ source = INSTALL_SH.read_text(encoding = "utf-8")
+ marker = source.index("# Prefer the higher-resolution Tauri icon.png")
+ start = source.index(' _css_desktop_icon="$_css_icon_png"', marker)
+ end = source.index(' cat > "$_css_desktop"', start)
+ block = textwrap.dedent(source[start:end])
+
+ checkout_icon = tmp_path / "checkout" / "icon.png"
+ installed_icon = tmp_path / "data" / "unsloth-studio.png"
+ checkout_icon.parent.mkdir()
+ installed_icon.parent.mkdir()
+ checkout_icon.write_text("high-resolution")
+ installed_icon.write_text("fallback")
+ script = "\n".join(
+ [
+ f"_css_tauri_png={shlex.quote(str(checkout_icon))}",
+ f"_css_icon_png={shlex.quote(str(installed_icon))}",
+ block,
+ 'printf "%s" "$_css_icon_escaped"',
+ ]
+ )
+ result = subprocess.run(
+ ["bash", "-c", script],
+ env = {"PATH": "/usr/bin:/bin"},
+ check = True,
+ capture_output = True,
+ text = True,
+ )
+ assert result.stdout == str(installed_icon)
+ assert installed_icon.read_text() == "high-resolution"
+
+
[email protected](shutil.which("bash") is None, reason = "bash is unavailable")
+def test_macos_prebuilt_copy_failure_runs_generated_icns_fallback(tmp_path):
+ source = INSTALL_SH.read_text(encoding = "utf-8")
+ marker = source.index("# ── AppIcon ──")
+ start = source.index(' if [ -f "$_css_tauri_icns"', marker)
+ end = source.index(" # Touch so Finder indexes it", start)
+ block = textwrap.dedent(source[start:end])
+
+ tauri_icns = tmp_path / "source.icns"
+ gem_png = tmp_path / "gem.png"
+ fallback_png = tmp_path / "fallback.png"
+ resources = tmp_path / "Resources"
+ fake_bin = tmp_path / "bin"
+ resources.mkdir()
+ fake_bin.mkdir()
+ tauri_icns.write_text("prebuilt")
+ gem_png.write_text("gem")
+ fallback_png.write_text("raw-png")
+
+ (fake_bin / "cp").write_text(
+ "#!/bin/sh\n"
+ f'if [ "${{1:-}}" = {shlex.quote(str(tauri_icns))} ]; then exit 1; fi\n'
+ 'exec /bin/cp "$@"\n'
+ )
+ (fake_bin / "sips").write_text(
+ "#!/bin/sh\n"
+ 'while [ "$#" -gt 0 ]; do\n'
+ ' if [ "$1" = --out ]; then shift; out=$1; fi\n'
+ " shift\n"
+ "done\n"
+ 'mkdir -p "$(dirname "$out")"; printf resized > "$out"\n'
+ )
+ (fake_bin / "iconutil").write_text(
+ "#!/bin/sh\n"
+ 'while [ "$#" -gt 0 ]; do\n'
+ ' if [ "$1" = -o ]; then shift; out=$1; fi\n'
+ " shift\n"
+ "done\n"
+ 'printf generated > "$out"\n'
+ )
+ for command in ("cp", "sips", "iconutil"):
+ (fake_bin / command).chmod(0o755)
+
+ script = "\n".join(
+ [
+ f"_css_tauri_icns={shlex.quote(str(tauri_icns))}",
+ f"_css_gem_png={shlex.quote(str(gem_png))}",
+ f"_css_icon_png={shlex.quote(str(fallback_png))}",
+ f"_css_res_dir={shlex.quote(str(resources))}",
+ block,
+ ]
+ )
+ result = subprocess.run(
+ ["bash", "-c", script],
+ env = {"PATH": f"{fake_bin}:/usr/bin:/bin", **{"TMPDIR": str(tmp_path)}},
+ capture_output = True,
+ text = True,
+ )
+ assert result.returncode == 0, result.stderr
+ assert (resources / "AppIcon.icns").read_text() == "generated"