From 9ff3bbfac697d1e56e5bdb3903ba97148e43564a Mon Sep 17 00:00:00 2001
From: Sreeram Sreedhar
Date: Tue, 23 Jun 2026 22:54:49 -0700
Subject: [PATCH] Require folder selection for SMFS onboarding
---
apps/desktop/app/onboarding/page.tsx | 72 ++++++++++--
apps/desktop/lib/smfs.ts | 9 +-
apps/desktop/src-tauri/Cargo.lock | 163 +++++++++++++++++++++++++++
apps/desktop/src-tauri/Cargo.toml | 1 +
apps/desktop/src-tauri/src/lib.rs | 14 ++-
apps/desktop/src-tauri/src/smfs.rs | 76 ++++++++++++-
6 files changed, 321 insertions(+), 14 deletions(-)
diff --git a/apps/desktop/app/onboarding/page.tsx b/apps/desktop/app/onboarding/page.tsx
index 52476453..a7782a88 100644
--- a/apps/desktop/app/onboarding/page.tsx
+++ b/apps/desktop/app/onboarding/page.tsx
@@ -24,6 +24,7 @@ import {
updateDesktopOnboardingStatus,
} from "@/lib/onboarding"
import {
+ chooseSmfsMountPath,
getDefaultSmfsContainerTag,
getSmfsState,
mountSmfs,
@@ -340,6 +341,9 @@ function FilesystemStep({
}) {
const [tag, setTag] = useState("sm_fs_desktop")
const [status, setStatus] = useState(null)
+ const [selectedMountPath, setSelectedMountPath] = useState(
+ null,
+ )
const [loading, setLoading] = useState(true)
const [busy, setBusy] = useState(false)
const [error, setError] = useState(null)
@@ -353,7 +357,16 @@ function FilesystemStep({
getSmfsState(),
])
setTag(defaultTag)
- setStatus(statuses[0] ?? null)
+ const nextStatus = statuses[0] ?? null
+ setStatus(nextStatus)
+ if (
+ nextStatus?.mountPath &&
+ (nextStatus.mountPathConfigured ||
+ nextStatus.state === "mounted" ||
+ nextStatus.state === "external")
+ ) {
+ setSelectedMountPath(nextStatus.mountPath)
+ }
} catch (err) {
setError(formatUnknownError(err, "Could not load filesystem status"))
} finally {
@@ -369,7 +382,12 @@ function FilesystemStep({
setError(null)
setBusy(true)
try {
- setStatus(await mountSmfs(tag))
+ if (!selectedMountPath) {
+ throw new Error("Choose a folder before mounting SMFS")
+ }
+ const nextStatus = await mountSmfs(tag, selectedMountPath)
+ setStatus(nextStatus)
+ setSelectedMountPath(nextStatus.mountPath)
} catch (err) {
setError(formatUnknownError(err, "Could not mount memory folder"))
} finally {
@@ -377,7 +395,25 @@ function FilesystemStep({
}
}
+ async function chooseFolder() {
+ setError(null)
+ setBusy(true)
+ try {
+ const path = await chooseSmfsMountPath()
+ if (path) {
+ setSelectedMountPath(path)
+ }
+ } catch (err) {
+ setError(formatUnknownError(err, "Could not choose mount folder"))
+ } finally {
+ setBusy(false)
+ }
+ }
+
const mounted = status?.state === "mounted" || status?.state === "external"
+ const mountPath =
+ selectedMountPath ?? (status?.mountPathConfigured ? status.mountPath : null)
+ const canMount = Boolean(mountPath) && !loading && !busy
return (
@@ -410,8 +446,11 @@ function FilesystemStep({
-
- {status?.tag ?? tag}
+
+ {mountPath ? compactPath(mountPath) : "No folder selected"}
{error ? {error}
: null}
@@ -438,16 +477,25 @@ function FilesystemStep({
Mount folder
- Create the local memory folder for this Mac
+ Choose or create the local folder SMFS should mount into
+