fix(desktop): restore T3 Connect sign-in (#4809)

Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-07-29 10:59:12 +02:00
1 parent 694f8d1c6e
commit 1b4830ff06
4 files changed
+40 -3

No files matched your search

@@ -0,0 +1,18 @@
import { describe, expect, it } from "vite-plus/test";
import { resolveClerkSignInProps } from "./authRedirect";
describe("resolveClerkSignInProps", () => {
it("returns to the current browser URL on the web", () => {
const href = "https://app.t3.codes/connect?state=state-1#details";
expect(resolveClerkSignInProps(href, false)).toEqual({ forceRedirectUrl: href });
});
it("omits the redirect override on packaged desktop", () => {
expect(resolveClerkSignInProps("t3code://app/#/settings/general", true)).toEqual({});
});
it("omits the redirect override on development desktop", () => {
expect(resolveClerkSignInProps("t3code-dev://app/#/settings/general", true)).toEqual({});
});
});
@@ -0,0 +1,12 @@
export interface ClerkSignInProps {
forceRedirectUrl?: string;
}
// Clerk's native-app allowlist only authorizes the bare renderer root
// (t3code://app/), which @clerk/electron's OAuth transport already supplies,
// so any page-derived redirect override gets the whole sign-in request
// rejected. On Electron, omit the override and let Clerk use its defaults.
export function resolveClerkSignInProps(href: string, isElectron: boolean): ClerkSignInProps {
if (isElectron) return {};
return { forceRedirectUrl: href };
}
@@ -1,9 +1,12 @@
import { useClerk } from "@clerk/react";
import { isElectron } from "../../env";
import { resolveClerkSignInProps } from "./authRedirect";
export function useT3ConnectAuthPrompt() {
const clerk = useClerk();
const openAuthPrompt = () => {
clerk.openSignIn({ forceRedirectUrl: window.location.href });
clerk.openSignIn(resolveClerkSignInProps(window.location.href, isElectron));
};
return { authPrompt: null, openAuthPrompt };
}
@@ -8,8 +8,10 @@ import {
readConnectCliCallbackResult,
rememberConnectCliAuthState,
} from "../../cloud/connectCliAuth";
import { isElectron } from "../../env";
import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
import { AuthSurfaceShell } from "../auth/AuthSurfaceShell";
import { resolveClerkSignInProps } from "../clerk/authRedirect";
import { Button } from "../ui/button";
function ConnectCliAuthMessage({
@@ -59,7 +61,7 @@ export function ConnectCliAuthorizeSurface() {
if (!isSignedIn) {
if (!signInOpened.current) {
signInOpened.current = true;
clerk.openSignIn({ forceRedirectUrl: window.location.href });
clerk.openSignIn(resolveClerkSignInProps(window.location.href, isElectron));
}
return;
}
@@ -95,7 +97,9 @@ export function ConnectCliAuthorizeSurface() {
<div className="mt-6">
<Button
type="button"
onClick={() => clerk.openSignIn({ forceRedirectUrl: window.location.href })}
onClick={() =>
clerk.openSignIn(resolveClerkSignInProps(window.location.href, isElectron))
}
>
Sign in
</Button>