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.

Studio Desktop: open the OS folder dialog to add a model folder (#13843)

Daniel Han62e063618f47
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.ts
index 3490a2269e6..4bd03b237a7 100644
--- a/studio/frontend/scripts/check-bundle-budget.ts
+++ b/studio/frontend/scripts/check-bundle-budget.ts
@@ -147,8 +147,11 @@ export const BUDGET = {
// transfer (6,773,496 -> 6,774,820 B raw, 2,036,386 -> 2,036,728 B transfer against 59ab069b5, one machine
// and build, Node 24, chunk count unchanged at 95). Lazy-loading it cost more transfer and a 96th startup
// chunk (Rollup split react-dom out), so it is imported statically and the budget raised by that growth.
- transferBytes: 2_036_821,
- rawBytes: 6_774_897,
+ // Opening the OS folder dialog for model folders on Desktop (#13843) adds 235 B raw / 336 B transfer
+ // (6,777,794 -> 6,778,029 B raw, 2,037,725 -> 2,038,061 B transfer against 199987c63, one machine and build,
+ // Node 24, chunk count unchanged at 95). Raised by that growth.
+ transferBytes: 2_037_157,
+ rawBytes: 6_775_132,
};
// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering the
diff --git a/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx b/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx
index cc8229daf22..5cc9e82c335 100644
--- a/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx
+++ b/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx
@@ -17,6 +17,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { useIsAccountOwner } from "@/features/auth";
import {
type ScanFolderInfo,
addScanFolder,
@@ -29,6 +30,7 @@ import { FolderBrowser } from "@/features/model-picker";
import {
openModelsDir,
pickHuggingFaceCacheDir,
+ pickNativeModelFolder,
} from "@/features/native-intents";
import {
type HuggingFaceCacheSettings,
@@ -221,6 +223,13 @@ export function OnDeviceFoldersDialog({
[handleInventoryChanged, pending, recursive],
);
+ const isOwner = useIsAccountOwner();
+ const browseLocations = useCallback(async () => {
+ const picked = await pickNativeModelFolder(isOwner);
+ if (picked === undefined) setBrowserOpen(true);
+ else if (picked) await handleAdd(picked);
+ }, [handleAdd, isOwner]);
+
// Scan folders are arbitrary paths that may be moved or deleted after they
// were registered, so surface the command's failure as a toast.
const handleOpen = useCallback(async (folder: ScanFolderInfo) => {
@@ -381,7 +390,7 @@ export function OnDeviceFoldersDialog({
type="button"
variant="outline"
size="icon-sm"
- onClick={() => setBrowserOpen(true)}
+ onClick={() => void browseLocations()}
aria-label="Browse locations"
className="size-9 rounded-full"
>
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
index 579382c0237..e9ee1a5e99d 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx
@@ -23,6 +23,7 @@ import {
} from "@/components/ui/tooltip";
import { isTouchClick } from "@/components/ui/touch-click";
import { usePlatformStore } from "@/config/env";
+import { useIsAccountOwner } from "@/features/auth";
import { ApiProviderLogo } from "@/features/chat";
import {
type ScanFolderInfo,
@@ -89,6 +90,7 @@ import {
} from "@/features/hub";
import type { HfTaskFilter } from "@/features/hub/hooks/use-hub-model-search";
import { INVENTORY_FRESHNESS_WINDOW_MS } from "@/features/hub/inventory";
+import { pickNativeModelFolder } from "@/features/native-intents";
import {
type NpuModel,
type NpuPickerSource,
@@ -3584,6 +3586,18 @@ export function HubModelPicker({
],
);
+ const isOwner = useIsAccountOwner();
+ const browseForFolder = useCallback(async () => {
+ const picked = await pickNativeModelFolder(isOwner);
+ if (picked === undefined) {
+ setShowFolderBrowser(true);
+ } else if (picked) {
+ setFolderInput(picked);
+ setFolderError(null);
+ void handleAddFolder(picked);
+ }
+ }, [handleAddFolder, isOwner]);
+
const handleRemoveFolder = useCallback(
async (id: number) => {
try {
@@ -7694,7 +7708,7 @@ export function HubModelPicker({
>
<button
type="button"
- onClick={() => setShowFolderBrowser(true)}
+ onClick={() => void browseForFolder()}
title="Browse folders on the server"
className="flex items-center gap-1.5 text-ui-10 font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:text-foreground"
>
@@ -7735,7 +7749,7 @@ export function HubModelPicker({
type="button"
aria-label="Browse for a folder on the server"
title="Browse folders on the server"
- onClick={() => setShowFolderBrowser(true)}
+ onClick={() => void browseForFolder()}
className="shrink-0 rounded p-0.5 text-muted-foreground/80 transition-colors hover:text-foreground"
>
<HugeiconsIcon
@@ -7874,7 +7888,7 @@ export function HubModelPicker({
/>
<button
type="button"
- onClick={() => setShowFolderBrowser(true)}
+ onClick={() => void browseForFolder()}
disabled={folderLoading}
aria-label="Browse for folder"
title="Browse folders on the server"
diff --git a/studio/frontend/src/features/native-intents/api.ts b/studio/frontend/src/features/native-intents/api.ts
index be3edb2fd3b..ab6a34288b3 100644
--- a/studio/frontend/src/features/native-intents/api.ts
+++ b/studio/frontend/src/features/native-intents/api.ts
@@ -47,6 +47,19 @@ export async function pickHuggingFaceCacheDir(): Promise<string | null> {
return invokeNative<string | null>("pick_hugging_face_cache_dir");
}
+/** Desktop owner's OS folder dialog. `undefined` = use the in-app browser (web app,
+ * managed account confined to its workspace, or the dialog failed to open). */
+export async function pickNativeModelFolder(
+ isOwner: boolean,
+): Promise<string | null | undefined> {
+ if (!isTauri || !isOwner) return undefined;
+ try {
+ return await invokeNative<string | null>("pick_native_model_folder");
+ } catch {
+ return undefined;
+ }
+}
+
export async function registerNativeModelPath(
path: string,
): Promise<NativeIntent> {
diff --git a/studio/frontend/src/features/native-intents/index.ts b/studio/frontend/src/features/native-intents/index.ts
index c77c20e1f56..2f903bc70ce 100644
--- a/studio/frontend/src/features/native-intents/index.ts
+++ b/studio/frontend/src/features/native-intents/index.ts
@@ -8,6 +8,7 @@ export {
openModelsDir,
pickNativeDocumentFolder,
pickHuggingFaceCacheDir,
+ pickNativeModelFolder,
readNativeAttachmentFile,
registerNativeAttachmentPath,
registerNativeDatasetPath,
diff --git a/studio/frontend/tests/helpers/tauri-core-stub.mjs b/studio/frontend/tests/helpers/tauri-core-stub.mjs
index babfc98abef..f9f401e8f47 100644
--- a/studio/frontend/tests/helpers/tauri-core-stub.mjs
+++ b/studio/frontend/tests/helpers/tauri-core-stub.mjs
@@ -6,6 +6,7 @@
//
// mode "ok" -> invoke resolves
// mode "rejects" -> invoke rejects, as an older WebView2 runtime would
+// result -> what invoke resolves to in mode "ok"
const control = (globalThis.__TAURI_CORE_STUB__ ??= { calls: [], mode: "ok" });
@@ -14,4 +15,5 @@ export async function invoke(command, args) {
if (control.mode === "rejects") {
throw new Error("command reset_microphone_permission not found");
}
+ return control.result;
}
diff --git a/studio/frontend/tests/native-model-folder-picker.test.ts b/studio/frontend/tests/native-model-folder-picker.test.ts
new file mode 100644
index 00000000000..97729a76cd6
--- /dev/null
+++ b/studio/frontend/tests/native-model-folder-picker.test.ts
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// Issue 6369: Desktop Browse for a model folder opens the OS dialog; the web app, managed
+// accounts and a dialog that fails to open keep the in-app browser.
+
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import test from "node:test";
+
+import { readSrc, readText } from "./helpers/kit.ts";
+
+register("./helpers/tauri-core-resolver.mjs", import.meta.url);
+
+const MODULE = new URL("../src/features/native-intents/api.ts", import.meta.url)
+ .href;
+
+type StubControl = {
+ calls: { command: string }[];
+ mode: "ok" | "rejects";
+ result?: unknown;
+};
+
+let generation = 0;
+
+async function load(options: {
+ tauri: boolean;
+ mode?: "ok" | "rejects";
+ result?: unknown;
+}) {
+ const control: StubControl = {
+ calls: [],
+ mode: options.mode ?? "ok",
+ result: options.result,
+ };
+ const define = (name: string, value: unknown) =>
+ Object.defineProperty(globalThis, name, {
+ value,
+ configurable: true,
+ writable: true,
+ });
+ define("__TAURI_CORE_STUB__", control);
+ define("window", {
+ location: { protocol: options.tauri ? "tauri:" : "https:" },
+ ...(options.tauri ? { __TAURI_INTERNALS__: {} } : {}),
+ });
+
+ generation += 1;
+ const module = (await import(`${MODULE}?bust=${generation}`)) as {
+ pickNativeModelFolder: (
+ isOwner: boolean,
+ ) => Promise<string | null | undefined>;
+ };
+ return { module, control };
+}
+
+test("the desktop owner gets the folder the OS dialog picked", async () => {
+ const { module, control } = await load({ tauri: true, result: "D:\\models" });
+ assert.equal(await module.pickNativeModelFolder(true), "D:\\models");
+ assert.deepEqual(
+ control.calls.map((call) => call.command),
+ ["pick_native_model_folder"],
+ );
+});
+
+test("cancelling the OS dialog adds nothing and opens no other browser", async () => {
+ const { module } = await load({ tauri: true, result: null });
+ assert.equal(await module.pickNativeModelFolder(true), null);
+});
+
+test("the web app keeps the in-app browser and never invokes", async () => {
+ const { module, control } = await load({ tauri: false });
+ assert.equal(await module.pickNativeModelFolder(true), undefined);
+ assert.equal(control.calls.length, 0);
+});
+
+test("a managed account keeps the in-app browser", async () => {
+ const { module, control } = await load({ tauri: true });
+ assert.equal(await module.pickNativeModelFolder(false), undefined);
+ assert.equal(control.calls.length, 0);
+});
+
+test("a native dialog that fails to open falls back to the in-app browser", async () => {
+ const { module } = await load({ tauri: true, mode: "rejects" });
+ assert.equal(await module.pickNativeModelFolder(true), undefined);
+});
+
+test("every model folder Browse button goes through the native picker", () => {
+ const pickers = readSrc(
+ "features/model-picker/components/model-selector/pickers.tsx",
+ );
+ assert.equal(
+ pickers.match(/onClick=\{\(\) => void browseForFolder\(\)\}/g)?.length,
+ 3,
+ );
+ assert.doesNotMatch(
+ pickers,
+ /onClick=\{\(\) => setShowFolderBrowser\(true\)\}/,
+ );
+ assert.match(pickers, /pickNativeModelFolder\(isOwner\)/);
+
+ const hub = readSrc("features/hub/catalog/on-device-folders-dialog.tsx");
+ assert.match(hub, /onClick=\{\(\) => void browseLocations\(\)\}/);
+ assert.doesNotMatch(hub, /onClick=\{\(\) => setBrowserOpen\(true\)\}/);
+ assert.match(hub, /pickNativeModelFolder\(isOwner\)/);
+
+ assert.match(
+ readText("../../src-tauri/src/main.rs"),
+ /native_intents::pick_native_model_folder,/,
+ );
+});
diff --git a/studio/src-tauri/src/main.rs b/studio/src-tauri/src/main.rs
index 6d3fd9003a9..a526843f15b 100644
--- a/studio/src-tauri/src/main.rs
+++ b/studio/src-tauri/src/main.rs
@@ -2364,6 +2364,7 @@ fn main() {
native_intents::read_native_attachment_file,
native_intents::pick_native_model,
native_intents::pick_hugging_face_cache_dir,
+ native_intents::pick_native_model_folder,
native_intents::pick_native_document_folder,
native_intents::consume_native_path_token,
native_intents::register_artifact_path,
diff --git a/studio/src-tauri/src/native_intents.rs b/studio/src-tauri/src/native_intents.rs
index 95b0a59a26e..27b3a20d5d2 100644
--- a/studio/src-tauri/src/native_intents.rs
+++ b/studio/src-tauri/src/native_intents.rs
@@ -485,10 +485,23 @@ pub async fn pick_hugging_face_cache_dir(
app: AppHandle,
) -> Result<Option<String>, String> {
ensure_main_window(&webview)?;
+ pick_local_folder(&app, "Choose model download location").await
+}
+
+#[tauri::command]
+pub async fn pick_native_model_folder(
+ webview: tauri::Webview,
+ app: AppHandle,
+) -> Result<Option<String>, String> {
+ ensure_main_window(&webview)?;
+ pick_local_folder(&app, "Choose a model folder").await
+}
+
+async fn pick_local_folder(app: &AppHandle, title: &str) -> Result<Option<String>, String> {
let (tx, rx) = tokio::sync::oneshot::channel();
app.dialog()
.file()
- .set_title("Choose model download location")
+ .set_title(title)
.pick_folder(move |path| {
let _ = tx.send(path);
});