From abb1f60b71ec1418dd064ec19a430cdc42f30200 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Wed, 27 May 2026 13:54:13 -0500 Subject: [PATCH] fix: show electron change server header for localserver --- scripts/patch-better-sqlite3.cjs | 15 +- scripts/patch-nan.cjs | 17 +- src/ui/auth/Auth.tsx | 820 ++++++++++++++++--------------- 3 files changed, 447 insertions(+), 405 deletions(-) diff --git a/scripts/patch-better-sqlite3.cjs b/scripts/patch-better-sqlite3.cjs index 91e270df..b6ac303a 100644 --- a/scripts/patch-better-sqlite3.cjs +++ b/scripts/patch-better-sqlite3.cjs @@ -1,7 +1,12 @@ const fs = require("node:fs"); const path = require("node:path"); -const betterSqlite3Dir = path.join(__dirname, "..", "node_modules", "better-sqlite3"); +const betterSqlite3Dir = path.join( + __dirname, + "..", + "node_modules", + "better-sqlite3", +); const macrosPath = path.join(betterSqlite3Dir, "src", "util", "macros.cpp"); const helpersPath = path.join(betterSqlite3Dir, "src", "util", "helpers.cpp"); const entryPath = path.join(betterSqlite3Dir, "src", "better_sqlite3.cpp"); @@ -91,7 +96,11 @@ const entryPatched = patchFile(entryPath, [ ]); if (macrosPatched || helpersPatched || entryPatched) { - console.log("[patch-better-sqlite3] Applied compatibility patches for newer Electron/V8"); + console.log( + "[patch-better-sqlite3] Applied compatibility patches for newer Electron/V8", + ); } else { - console.log("[patch-better-sqlite3] Already patched or target code not found"); + console.log( + "[patch-better-sqlite3] Already patched or target code not found", + ); } diff --git a/scripts/patch-nan.cjs b/scripts/patch-nan.cjs index 4a69da18..5fec17f9 100644 --- a/scripts/patch-nan.cjs +++ b/scripts/patch-nan.cjs @@ -45,7 +45,12 @@ const nanHeaderPatched = patchFile(path.join(nanDir, "nan.h"), [ // cpu-features binding.cc includes before , so the nan.h patch // above is too late. Patch binding.cc directly to inject the compat define first. -const cpuFeaturesDir = path.join(__dirname, "..", "node_modules", "cpu-features"); +const cpuFeaturesDir = path.join( + __dirname, + "..", + "node_modules", + "cpu-features", +); const bindingPath = path.join(cpuFeaturesDir, "src", "binding.cc"); const bindingPatched = patchFile(bindingPath, [ { @@ -70,11 +75,11 @@ if (fs.existsSync(implPath)) { if (!src.includes(TAG)) { src = src.replace( /v8::External::New\(v8::Isolate::GetCurrent\(\),\s*value\)/g, - `v8::External::New(v8::Isolate::GetCurrent(), value, ${TAG})` + `v8::External::New(v8::Isolate::GetCurrent(), value, ${TAG})`, ); src = src.replace( /v8::External::New\(isolate,\s*reinterpret_cast\(callback\)\)/g, - `v8::External::New(isolate, reinterpret_cast(callback), ${TAG})` + `v8::External::New(isolate, reinterpret_cast(callback), ${TAG})`, ); } @@ -97,7 +102,7 @@ if (fs.existsSync(callbacksPath)) { // Pattern: .As()->Value()) — always followed by )) src = src.replace( /\.As\(\)->Value\(\)\)/g, - `.As()->Value(${TAG}))` + `.As()->Value(${TAG}))`, ); } @@ -108,7 +113,9 @@ if (fs.existsSync(callbacksPath)) { } if (nanHeaderPatched || bindingPatched || implPatched || callbacksPatched) { - console.log("[patch-nan] Applied compatibility patches for Electron 42 / V8 13+"); + console.log( + "[patch-nan] Applied compatibility patches for Electron 42 / V8 13+", + ); } else { console.log("[patch-nan] Already patched or target code not found"); } diff --git a/src/ui/auth/Auth.tsx b/src/ui/auth/Auth.tsx index 33153c25..ab6e8d5f 100644 --- a/src/ui/auth/Auth.tsx +++ b/src/ui/auth/Auth.tsx @@ -758,7 +758,7 @@ export function Auth({ onLogin }: AuthProps) { ); - if (currentServerUrl && !webviewAuthSuccess) + if (!webviewAuthSuccess && showServerConfig === false && currentServerUrl) return (
@@ -858,453 +858,479 @@ export function Auth({ onLogin }: AuthProps) { ]; return ( -
- {/* Left decorative panel */} -
-
-
- - TERMIX - -
- - {t("auth.tagline")} +
+ {isElectron() && !isInElectronWebView() && showServerConfig === false && ( +
+ + + {t("serverConfig.localServer")} +
+
+ )} +
+ {/* Left decorative panel */} +
+
+
+ + TERMIX + +
+ + {t("auth.tagline")} + +
-
- {/* Right panel */} -
-
- {/* TOTP view */} - {view === "totp" && ( -
-
-

{t("auth.twoFactorAuth")}

-

- {t("auth.enterCode")} -

-
-
- - - setTotpCode(e.target.value.replace(/\D/g, "")) - } - disabled={loading} - className="text-center text-2xl tracking-widest font-mono" - autoComplete="one-time-code" - /> - - - -
-
- )} - - {/* Reset password view */} - {view === "reset" && ( -
- -
-

- {t("auth.forgotPassword")} -

-

- {t("auth.resetCodeDesc")} -

-
-
- {(["email", "code", "newpass"] as ResetStep[]).map( - (step, i) => { - const stepIdx = ["email", "code", "newpass"].indexOf( - resetStep, - ); - const done = i < stepIdx; - const active = i === stepIdx; - return ( -
-
- {done ? : i + 1} -
- {i < 2 && ( -
- )} -
- ); - }, - )} -
- {resetStep === "email" && ( -
- + {/* Right panel */} +
+
+ {/* TOTP view */} + {view === "totp" && ( +
+
+

+ {t("auth.twoFactorAuth")} +

+

+ {t("auth.enterCode")} +

+
+ + setUsername(e.target.value)} - placeholder="your_username" - disabled={loading} - /> - - - - )} - {resetStep === "code" && ( -
- - - setResetCode(e.target.value.replace(/\D/g, "")) - } + ref={totpInputRef} + id="totp-code" + type="text" placeholder="000000" maxLength={6} - className="text-center font-mono text-lg tracking-widest" + value={totpCode} + onChange={(e) => + setTotpCode(e.target.value.replace(/\D/g, "")) + } disabled={loading} + className="text-center text-2xl tracking-widest font-mono" + autoComplete="one-time-code" />
- )} - {resetStep === "newpass" && ( -
+ )} + + {/* Reset password view */} + {view === "reset" && ( +
+ +
+

+ {t("auth.forgotPassword")} +

+

+ {t("auth.resetCodeDesc")} +

+
+
+ {(["email", "code", "newpass"] as ResetStep[]).map( + (step, i) => { + const stepIdx = ["email", "code", "newpass"].indexOf( + resetStep, + ); + const done = i < stepIdx; + const active = i === stepIdx; + return ( +
+
+ {done ? : i + 1} +
+ {i < 2 && ( +
+ )} +
+ ); + }, + )} +
+ {resetStep === "email" && ( + + + setUsername(e.target.value)} + placeholder="your_username" + disabled={loading} + /> + + + + )} + {resetStep === "code" && ( +
- + + setResetCode(e.target.value.replace(/\D/g, "")) + } + placeholder="000000" + maxLength={6} + className="text-center font-mono text-lg tracking-widest" + disabled={loading} + /> + + + + + )} + {resetStep === "newpass" && ( +
- {loading - ? t("common.loading") - : t("auth.resetPasswordButton")} - -
- )} -
- )} - - {/* Login / Register / External */} - {(view === "login" || view === "register" || view === "external") && ( -
-
- {TAB_ITEMS.filter((item) => item.show).map((item) => ( - - ))} + + + + + + + + + )}
+ )} -
-

- {view === "login" - ? t("auth.loginTitle") - : view === "register" - ? t("auth.registerTitle") - : t("auth.loginWithExternal")} -

-

- {view === "login" - ? t("auth.loginSubtitle", "") - : view === "register" - ? t("auth.registerSubtitle", "") - : t("auth.loginWithExternalDesc")} -

-
+ {/* Login / Register / External */} + {(view === "login" || + view === "register" || + view === "external") && ( +
+
+ {TAB_ITEMS.filter((item) => item.show).map((item) => ( + + ))} +
- {view === "external" && ( -
- {isElectron() ? ( -

- {t("auth.externalNotSupportedInElectron")} -

- ) : ( - <> +
+

+ {view === "login" + ? t("auth.loginTitle") + : view === "register" + ? t("auth.registerTitle") + : t("auth.loginWithExternal")} +

+

+ {view === "login" + ? t("auth.loginSubtitle", "") + : view === "register" + ? t("auth.registerSubtitle", "") + : t("auth.loginWithExternalDesc")} +

+
+ + {view === "external" && ( +
+ {isElectron() ? ( +

+ {t("auth.externalNotSupportedInElectron")} +

+ ) : ( + <> +
+ setRememberMe(v === true)} + /> + +
+ + + )} +
+ )} + + {view === "login" && ( +
+ +
+ + setUsername(e.target.value)} + placeholder="username" + className="pl-8" + disabled={loading} + autoFocus + /> +
+
+ + + +
setRememberMe(v === true)} + disabled={loading} />
- - - )} -
- )} - - {view === "login" && ( - - -
- - setUsername(e.target.value)} - placeholder="username" - className="pl-8" - disabled={loading} - autoFocus - /> + {passwordResetAllowed && ( + + )}
-
- - - -
-
- setRememberMe(v === true)} + > + {loading ? ( + t("common.loading") + ) : ( + + + {t("common.login")} + + )} + + + )} + + {view === "register" && ( +
+ +
+ + setUsername(e.target.value)} + placeholder="choose_a_username" + className="pl-8" + disabled={loading} + autoFocus + /> +
+
+ + - -
- {passwordResetAllowed && ( + + + + + + + )} + + +

+ {view === "login" && registrationAllowed ? ( + <> + {t("auth.noAccount", "Don't have an account?")}{" "} - )} -

- - - )} - - {view === "register" && ( -
- -
- - setUsername(e.target.value)} - placeholder="choose_a_username" - className="pl-8" - disabled={loading} - autoFocus - /> -
-
- - - - + + ) : null} +

+
+ + {t("common.language")} + + handleLanguageChange(e.target.value)} - className="px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring" - > - {LANGUAGES.map((lang) => ( - - ))} - + {LANGUAGES.map((lang) => ( + + ))} + +
-
- )} + )} +