fix(studio): show working reset-password command on Windows login error

The backend's "incorrect password" error already returns the correct,
PATH-based command ("unsloth studio reset-password"), which the installer puts
on PATH on every platform. The auth form rewrote it on Windows into a relative
path:

    .\unsloth_studio\Scripts\unsloth.exe studio reset-password

That only resolves when the terminal happens to be inside the Studio home dir
(~\.unsloth\studio). From any normal working directory (e.g. C:\Users\<you>) it
fails with CommandNotFoundException, so users could not follow the hint to
recover a forgotten password.

Remove the Windows-only rewrite (and its now-unused usePlatformStore import) and
display the backend's command as-is. Frontend typecheck passes (the one
remaining tsc error, @tauri-apps/plugin-window-state in provider.tsx, is a
pre-existing desktop-only module-resolution issue unrelated to this change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Han 2026-06-03 05:21:30 -07:00
commit c8be6f6af7

View file

@ -10,7 +10,6 @@ import { Eye, EyeOff } from "lucide-react";
import { useEffect, useState } from "react";
import type { ReactElement } from "react";
import type { SyntheticEvent } from "react";
import { usePlatformStore } from "@/config/env";
import { refreshSession } from "../api";
// Bootstrap credentials injected into index.html by the backend
@ -294,13 +293,13 @@ export function AuthForm({ mode }: AuthFormProps): ReactElement | null {
storeAuthTokens(token.access_token, token.refresh_token);
navigate({ to: getPostAuthRoute() });
} catch (err: unknown) {
let msg = err instanceof Error ? err.message : "Auth failed.";
if (msg.includes("unsloth studio reset-password") && usePlatformStore.getState().deviceType === "windows") {
msg = msg.replace(
"unsloth studio reset-password",
".\\unsloth_studio\\Scripts\\unsloth.exe studio reset-password",
);
}
// The backend already returns the correct, PATH-based command
// ("unsloth studio reset-password"), which the installer puts on PATH on
// every platform. Do NOT rewrite it to a relative Windows path like
// ".\unsloth_studio\Scripts\unsloth.exe ..." -- that only resolves when the
// terminal happens to be inside the Studio home dir, so it fails with
// CommandNotFoundException everywhere else. Show the backend message as-is.
const msg = err instanceof Error ? err.message : "Auth failed.";
setError(msg);
} finally {
setLoading(false);