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.

Desktop and Windows installer: browser-panel capture prompt, private ACL for a custom Studio home (#14464)

Daniel Han491d3dc433f7
diff --git a/install.ps1 b/install.ps1
index 3fb4c319c11..8679bbe27a3 100644
--- a/install.ps1
+++ b/install.ps1
@@ -3253,9 +3253,10 @@ function Install-UnslothStudio {
Restore-StudioTempEnvironment
throw "$envOverrideVar=$StudioHome is not writable."
}
- # A new desktop-chosen root would inherit its drive's ACL (often writable by every
- # account): give it the profile's access instead. An existing folder keeps its ACL.
- if ($tauriChosenRoot -and -not $script:StudioEnvRootExisted) {
+ # A new custom root would inherit its drive's ACL (often writable by every account, so
+ # another user could swap the installed executables): give it the profile's access
+ # instead. An existing folder keeps its ACL.
+ if (-not $script:StudioEnvRootExisted) {
try {
$rootAcl = New-Object System.Security.AccessControl.DirectorySecurity
$rootAcl.SetAccessRuleProtection($true, $false)
diff --git a/studio/src-tauri/src/browser_webview.rs b/studio/src-tauri/src/browser_webview.rs
index 710fd4338da..d6a0e584cda 100644
--- a/studio/src-tauri/src/browser_webview.rs
+++ b/studio/src-tauri/src/browser_webview.rs
@@ -13,7 +13,9 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::time::{Duration, Instant};
-use tauri::webview::{DownloadEvent, NewWindowResponse, PageLoadEvent};
+use tauri::webview::{
+ DownloadEvent, NewWindowResponse, PageLoadEvent, PermissionKind, PermissionResponse,
+};
use tauri::{
AppHandle, Emitter, LogicalPosition, LogicalSize, Manager, Rect, Runtime, State, Url, Webview,
WebviewBuilder, WebviewUrl,
@@ -859,11 +861,21 @@ fn macos_at_least(major: isize) -> bool {
})
}
-/// Pages' own profile, proxied via `browser_proxy` (macOS: set on first load).
+/// Pages ask before using a capture device. With no handler wry grants every WKWebView capture
+/// request on macOS without a prompt, so any page could open the microphone the app holds for
+/// dictation. `Default` is WebKit's own per-site prompt there and the platform default elsewhere
+/// (WebView2's prompt, WebKitGTK's deny), so only the silent grant goes away.
+fn page_permission(_kind: PermissionKind) -> PermissionResponse {
+ PermissionResponse::Default
+}
+
+/// Pages' own profile, proxied via `browser_proxy` (macOS: set on first load). Every
+/// browser-panel webview is built through here, so none can miss the permission handler.
fn with_page_profile<R: Runtime>(
builder: WebviewBuilder<R>,
app: &AppHandle<R>,
) -> Result<WebviewBuilder<R>, String> {
+ let builder = builder.on_permission_request(|_, kind| page_permission(kind));
let proxy = crate::browser_proxy::address()?;
#[cfg(target_os = "macos")]
{
@@ -2257,6 +2269,42 @@ fn take_finished(
#[cfg(test)]
mod tests {
+ #[test]
+ fn page_capture_requests_are_never_granted_silently() {
+ for kind in [
+ PermissionKind::Microphone,
+ PermissionKind::Camera,
+ PermissionKind::DisplayCapture,
+ PermissionKind::Other,
+ ] {
+ assert!(
+ !matches!(page_permission(kind), PermissionResponse::Allow),
+ "{kind:?} must not be granted without asking"
+ );
+ }
+ }
+
+ #[test]
+ fn every_page_webview_gets_the_permission_handler() {
+ // A Windows checkout may carry CRLF line endings.
+ let source = include_str!("browser_webview.rs").replace("\r\n", "\n");
+ let code = &source[..source.find("#[cfg(test)]\nmod tests").unwrap()];
+ let start = code.find("fn with_page_profile").unwrap();
+ let body = &code[start..start + code[start..].find("\n}\n").unwrap()];
+ assert!(
+ body.contains(".on_permission_request("),
+ "with_page_profile must install the page permission handler"
+ );
+ let builders = code.matches("WebviewBuilder::new(").count();
+ let profiled = code.matches("with_page_profile(").count();
+ assert!(builders > 0);
+ assert_eq!(
+ builders,
+ profiled,
+ "every page WebviewBuilder must go through with_page_profile"
+ );
+ }
+
#[test]
fn a_finished_path_matching_no_reservation_settles_only_a_sole_one() {
let (a, b) = (PathBuf::from("/s/a.zip"), PathBuf::from("/s/b.zip"));
diff --git a/tests/python/test_custom_studio_home_acl.py b/tests/python/test_custom_studio_home_acl.py
new file mode 100644
index 00000000000..1f7e8805f1b
--- /dev/null
+++ b/tests/python/test_custom_studio_home_acl.py
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""install.ps1: a new custom UNSLOTH_STUDIO_HOME gets the private ACL (current user, SYSTEM,
+Administrators), not only the desktop-chosen one, and an existing folder keeps its ACL."""
+
+from __future__ import annotations
+
+import os
+import shutil
+import sys
+import tempfile
+from pathlib import Path
+
+import pytest
+
+from unsloth_pwsh_runner import run_pwsh
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+INSTALL_PS1 = REPO_ROOT / "install.ps1"
+PWSH = shutil.which("pwsh") or shutil.which("powershell")
+
+
+def _env_root_block() -> str:
+ source = INSTALL_PS1.read_text(encoding = "utf-8")
+ start = source.index(" if ($envOverride) {\n try {\n # BEFORE the create")
+ end = source.index(' $StudioDataDir = Join-Path $StudioHome "share"', start)
+ return source[start:end] + " }\n"
+
+
+def _run(root: Path, *, tauri_chosen: bool) -> str:
+ # Reports whether the root ended up protected (Windows) or whether the ACL write was tried
+ # (elsewhere .NET has no Windows ACLs, so the attempt lands in the warning).
+ script = f"""
+$ErrorActionPreference = "Stop"
+$script:lines = @()
+function Write-StudioLine {{ param([string]$Text, $ForegroundColor) $script:lines += $Text }}
+function Restore-StudioTempEnvironment {{ }}
+$envOverride = $env:TEST_ROOT
+$envOverrideVar = "UNSLOTH_STUDIO_HOME"
+$tauriChosenRoot = ${"true" if tauri_chosen else "false"}
+{_env_root_block()}
+if ($IsWindows -or $env:OS -eq "Windows_NT") {{
+ if ((Get-Acl -LiteralPath $StudioHome).AreAccessRulesProtected) {{ "restricted" }} else {{ "inherited" }}
+}} elseif ($script:lines -match "Could not restrict access") {{ "restricted" }} else {{ "inherited" }}
+"""
+ env = os.environ.copy()
+ env["TEST_ROOT"] = str(root)
+ handle, name = tempfile.mkstemp(suffix = ".ps1")
+ os.close(handle)
+ try:
+ Path(name).write_text(script, encoding = "utf-8-sig")
+ result = run_pwsh(
+ [PWSH, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", name],
+ check = False,
+ capture_output = True,
+ text = True,
+ env = env,
+ )
+ finally:
+ os.unlink(name)
+ assert result.returncode == 0, result.stderr
+ return result.stdout.strip().splitlines()[-1]
+
+
[email protected](PWSH is None, reason = "PowerShell is required")
+def test_new_custom_root_gets_the_private_acl(tmp_path: Path):
+ assert _run(tmp_path / "custom" / "studio", tauri_chosen = False) == "restricted"
+
+
[email protected](PWSH is None, reason = "PowerShell is required")
+def test_new_desktop_chosen_root_still_gets_the_private_acl(tmp_path: Path):
+ assert _run(tmp_path / "chosen" / "studio", tauri_chosen = True) == "restricted"
+
+
[email protected](PWSH is None, reason = "PowerShell is required")
+def test_existing_custom_root_keeps_its_acl(tmp_path: Path):
+ root = tmp_path / "existing"
+ root.mkdir()
+ assert _run(root, tauri_chosen = False) == "inherited"