The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Accounts: fixes from the review, in the browser
Adarsh44d09c2c2a32
diff --git a/src/app/providers.tsx b/src/app/providers.tsxindex 2cc768d1..2a964351 100644--- a/src/app/providers.tsx+++ b/src/app/providers.tsx@@ -6,7 +6,8 @@ import { useEffect, useState } from "react";import dynamic from "next/dynamic";import { GuestPrompt } from "@/components/guest-prompt";import { AddKeyPrompt } from "@/components/keys/your-keys";-import { AUTH_CHANNEL } from "@/lib/api";+import { toast } from "sonner";+import { AUTH_CHANNEL, takeNotice, type ViewerInfo } from "@/lib/api";/** The GPU pre-flight's guided fix: loaded after the page, listening for "fuobe:gpu-setup". */const GuidedFixHost = dynamic(() => import("@/components/gpu/guided-fix").then((m) => m.GuidedFixHost), { ssr: false });@@ -30,12 +31,22 @@ export function Providers({ children }: { children: React.ReactNode }) {useEffect(() => {if (typeof BroadcastChannel === "undefined") return;const c = new BroadcastChannel(AUTH_CHANNEL);- c.onmessage = () => {- void client.invalidateQueries({ queryKey: ["viewer"] });+ c.onmessage = async () => {void client.invalidateQueries({ queryKey: ["status"] });+ await client.invalidateQueries({ queryKey: ["viewer"] });+ // A studio without public sign-up has nothing for someone signed out but its sign-in page: loading again takes+ // this tab there, rather than showing a guest's pages that offer an account it can't make.+ const v = client.getQueryData<ViewerInfo>(["viewer"]);+ if (v && !v.signedIn && !v.publicSignup && window.location.pathname !== "/login") window.location.reload();};return () => c.close();}, [client]);+ // What the last page left to say (Delete account lands here as a guest, which looks the same as signing out). The+ // Toaster below is listening by now: a child's effects run before this one.+ useEffect(() => {+ if (takeNotice() === "account-deleted")+ toast.success("Your account was deleted", { description: "Its uploads, runs, GPU connection and saved keys are gone. You're signed out." });+ }, []);return (<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange><QueryClientProvider client={client}>diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsxindex 4ad6bd75..9595054a 100644--- a/src/components/app-sidebar.tsx+++ b/src/components/app-sidebar.tsx@@ -40,7 +40,7 @@ import { IntentLink } from "@/components/intent-link";import { JobNotifications } from "@/components/job-notifications";import { NAV, type NavGroupDef } from "@/components/nav-items";import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";-import { CONNECT_GPU_EVENT, signInHref, signOut, useEngineMode, useHydrated, useStatus, useViewer, type StatusInfo } from "@/lib/api";+import { CONNECT_GPU_EVENT, signInHref, signOut, useEngineMode, useHydrated, useStatus, useViewer, VIEWER_KEY, type StatusInfo } from "@/lib/api";import { deviceLabel } from "@/lib/gpu/readiness";import { useModKey } from "@/lib/keys";import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, NEW_CREATION_HREF, parseClosed, scrollFades, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";@@ -373,8 +373,6 @@ function SearchRow() {);}-const VIEWER_KEY = "fuobe:viewer";-/*** Runs while the HTML is parsed: `<html data-viewer="owner">` in a browser where the owner was signed in last time, so* the row kept for "Sign up / Log in" (or an account's menu) isn't drawn and then taken away on every page load.@@ -494,10 +492,17 @@ function AccountRow() {<ChevronsUpDown className="text-muted-foreground" /></SidebarMenuButton></DropdownMenuTrigger>- <DropdownMenuContent side={isMobile ? "top" : "right"} align="end" className="min-w-56">+ {/* As wide as the email (on one line, up to 22rem), never narrower than the row: an address breaks only when it must,+ and the menu keeps clear of the screen's edges. */}+ <DropdownMenuContent+ side={isMobile ? "top" : "right"}+ align="end"+ collisionPadding={8}+ className="w-max max-w-[min(22rem,var(--radix-dropdown-menu-content-available-width))] min-w-[max(14rem,var(--radix-dropdown-menu-trigger-width))]"+ ><DropdownMenuLabel className="font-normal"><span className="block text-[11px]">Signed in as</span>- <span className="block text-[13px] break-all text-foreground">{account.email}</span>+ <span className="block text-[13px] [overflow-wrap:anywhere] text-foreground">{account.email}</span></DropdownMenuLabel><DropdownMenuSeparator /><DropdownMenuItem asChild>diff --git a/src/components/gpu/connect-choice.tsx b/src/components/gpu/connect-choice.tsxindex 20c64363..a9ec7c68 100644--- a/src/components/gpu/connect-choice.tsx+++ b/src/components/gpu/connect-choice.tsx@@ -206,7 +206,7 @@ export interface ConnectChoiceProps {reason?: FindReason;onStart?: () => void;onNotNow?: () => void;- /** The two options' box: 36rem at most from sm up, unless a wider page lifts that (sm:max-w-none). */+ /** The two options' box (and the link's form): 36rem at most from sm up, unless a wider page lifts that (sm:max-w-none). */className?: string;}@@ -230,7 +230,7 @@ export function ConnectChoice({ fromRun, kind, reason, onStart, onNotNow, classNreturn (<div className="space-y-4"><p className="rounded-xl bg-muted px-3 py-2.5 text-[13px] text-muted-foreground">{unsupportedWords(support)}</p>- <YourGpu />+ <YourGpu className={className} /></div>);}@@ -274,7 +274,7 @@ export function ConnectChoice({ fromRun, kind, reason, onStart, onNotNow, classN</button>{(link || linked) && (<div className="mt-3">- <YourGpu />+ <YourGpu className={className} /></div>)}</div>diff --git a/src/components/gpu/connect-gpu.tsx b/src/components/gpu/connect-gpu.tsxindex 4432ccab..221f0f93 100644--- a/src/components/gpu/connect-gpu.tsx+++ b/src/components/gpu/connect-gpu.tsx@@ -12,7 +12,7 @@ import { KeyInstead } from "@/components/keys/your-keys";import { Button } from "@/components/ui/button";import { Skeleton } from "@/components/ui/skeleton";import { useGpuCheck, useGpuReadiness } from "@/hooks/use-gpu";-import { signInHref, useViewer } from "@/lib/api";+import { signInHref, useStatus, useViewer } from "@/lib/api";import { safeNext } from "@/lib/safe-redirect";/**@@ -66,13 +66,13 @@ export function ConnectGpu() {const title = welcome ? "Welcome! Connect your GPU" : "Connect your GPU";const lead = "Make things on your own graphics card with ComfyUI. It's free, private and has no run limit. Fuobe checks what your ComfyUI has, and shows what each studio still needs.";- const done = (- <div className="flex flex-wrap items-center justify-end gap-2">- <Button asChild variant="ghost" className="h-11 sm:h-9">- <Link href={next}>Not now</Link>- </Button>- <Button asChild className="h-11 sm:h-9">- <Link href={next}>Start creating</Link>+ // One way on, to where the person was going: "Not now" while nothing runs their work, "Start creating" once a GPU is+ // connected or a fal.ai or Replicate key is saved.+ const hasKey = !!useStatus().data?.viewer?.keys?.length;+ const done = (connected: boolean) => (+ <div className="flex justify-end">+ <Button asChild variant={connected ? "default" : "outline"} className="h-11 sm:h-9">+ <Link href={next}>{connected ? "Start creating" : "Not now"}</Link></Button></div>);@@ -151,7 +151,7 @@ export function ConnectGpu() {{reason === "refused" && <p className="mb-3 text-[13px] text-destructive">Fuobe can't use this address. Connect your own ComfyUI.</p>}<ConnectChoice className="sm:max-w-none" /></Card>- {done}+ {done(hasKey)}</div>);@@ -208,7 +208,7 @@ export function ConnectGpu() {</div></Card>{report && <ReadinessBoard view={view!} owner={!isAccount} onCheck={() => void check.start()} checking={check.running} />}- {done}+ {done(true)}</div>);}diff --git a/src/components/gpu/your-gpu.tsx b/src/components/gpu/your-gpu.tsxindex 21982192..5b050ee2 100644--- a/src/components/gpu/your-gpu.tsx+++ b/src/components/gpu/your-gpu.tsx@@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { responseError, toastError } from "@/lib/refusals";+import { cn } from "@/lib/utils";interface GpuState {/** A link, or the ComfyUI on this computer (connect-choice.tsx shows that one). */@@ -34,9 +35,10 @@ async function call<T>(method: string, body?: unknown, test = false): Promise<T>/*** "Your GPU" (public sign-up): an account's own ComfyUI, where its runs go (never this studio's keys* or GPU). The server calls it, so it needs a public address: a Cloudflare Tunnel or ngrok in front- * of a local ComfyUI. Nothing here looks for a ComfyUI on this device: it shows the tunnel command.+ * of a local ComfyUI. Nothing here looks for a ComfyUI on this device: it shows the tunnel command. 36rem wide at most+ * from sm up, unless a wider page lifts that (className, as ConnectChoice's).*/-export function YourGpu() {+export function YourGpu({ className }: { className?: string } = {}) {const qc = useQueryClient();const id = useId();const q = useQuery({ queryKey: ["account-gpu"], queryFn: () => call<GpuState>("GET") });@@ -85,7 +87,7 @@ export function YourGpu() {const gpu = q.data.gpu?.mode === "computer" ? null : q.data.gpu;return (- <div className="w-full min-w-0 space-y-4 sm:max-w-[36rem]">+ <div className={cn("w-full min-w-0 space-y-4 sm:max-w-[36rem]", className)}><p className="text-[13px] text-muted-foreground">Free accounts run on their own ComfyUI, never on this studio's own keys or GPU. Runs from the Image, Video and Audio studios on open-source models go to it. It must bereachable from the internet, for example through a Cloudflare Tunnel or ngrok in front of your ComfyUI.@@ -119,9 +121,12 @@ export function YourGpu() {</div><div className="space-y-1.5"><Label htmlFor={`${id}-token`} className="text-[13px]">- Token <span className="text-muted-foreground">(optional, sent as Authorization: Bearer)</span>+ Access token <span className="text-muted-foreground">(optional)</span></Label>- <Input id={`${id}-token`} type="password" autoComplete="off" value={token} onChange={(e) => setToken(e.target.value)} />+ <Input id={`${id}-token`} type="password" autoComplete="off" value={token} onChange={(e) => setToken(e.target.value)} aria-describedby={`${id}-token-hint`} />+ <p id={`${id}-token-hint`} className="text-[12px] text-muted-foreground">+ Only if your tunnel or ComfyUI asks for a password or token.+ </p></div>{error && <p className="text-[12px] text-destructive">{error}</p>}{info && (diff --git a/src/components/guest-prompt.tsx b/src/components/guest-prompt.tsxindex b28b33dd..b2b54d23 100644--- a/src/components/guest-prompt.tsx+++ b/src/components/guest-prompt.tsx@@ -1,16 +1,17 @@"use client";-import { Cpu, Sparkles } from "lucide-react";+import { useQueryClient } from "@tanstack/react-query";+import { Cpu, LogIn, Sparkles } from "lucide-react";import Link from "next/link";import { usePathname } from "next/navigation";-import { Suspense, useCallback, useEffect, useState } from "react";+import { Suspense, useCallback, useEffect, useRef, useState } from "react";import { ConnectChoice } from "@/components/gpu/connect-choice";import type { FindReason } from "@/components/gpu/computer-runner";import { takeGpuRetry } from "@/hooks/use-gpu";import { KeyInstead } from "@/components/keys/your-keys";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";-import { CONNECT_GPU_EVENT, GUEST_PROMPT_EVENT, refusalCard, signInHref, useStatus, watchGuestRefusals, type RefusalCard } from "@/lib/api";+import { CONNECT_GPU_EVENT, GUEST_PROMPT_EVENT, refusalCard, signInHref, useStatus, useViewer, watchGuestRefusals, type RefusalCard } from "@/lib/api";import { CLOUD_KEY } from "@/lib/your-keys";/**@@ -21,7 +22,8 @@ import { CLOUD_KEY } from "@/lib/your-keys";* a key" when it has no key yet. Mounted once, in the app's providers, so it outlives the page: a* card closes when the page changes (its own Sign up or Log in, Back), and never opens on the* sign-in page (refusalCard). Opened by a run that was refused, "Connect your GPU" keeps that run- * and starts it by itself once the GPU is connected.+ * and starts it by itself once the GPU is connected. Refused as a guest while this page still had+ * someone signed in (the password changed in another browser), it says "You were signed out" instead.*/export function GuestPrompt() {// The last card stays while the dialog animates out.@@ -35,6 +37,14 @@ export function GuestPrompt() {setRetry(null);}, []);const viewer = useStatus().data?.viewer;+ const qc = useQueryClient();+ // Who this page was for, for the refusal that comes when that sign-in ended elsewhere: "owner", "account", or null.+ const who = useViewer().data;+ const was = useRef<"owner" | "account" | null>(null);+ useEffect(() => {+ was.current = who?.signedIn ? (who.owner ? "owner" : "account") : null;+ }, [who]);+ const [signedOut, setSignedOut] = useState<"owner" | "account" | null>(null);useEffect(() => {watchGuestRefusals();const show = (kind: RefusalCard["kind"]) => {@@ -44,7 +54,16 @@ export function GuestPrompt() {setOpen(true);return true;};- const guest = () => show("guest");+ const guest = () => {+ // Signed in a moment ago: not an offer to sign up, but to log in again; and the page asks who is looking.+ const out = was.current;+ if (show("guest")) setSignedOut(out);+ if (out) {+ was.current = null;+ void qc.invalidateQueries({ queryKey: ["viewer"] });+ void qc.invalidateQueries({ queryKey: ["status"] });+ }+ };const gpu = (e: Event) => {// The run that was refused (the composer leaves its retry as it sends): kept until the GPU is connected.const r = takeGpuRetry();@@ -58,7 +77,7 @@ export function GuestPrompt() {window.removeEventListener(GUEST_PROMPT_EVENT, guest);window.removeEventListener(CONNECT_GPU_EVENT, gpu);};- }, []);+ }, [qc]);return (<><Suspense fallback={null}>@@ -93,6 +112,23 @@ export function GuestPrompt() {onNotNow={() => setRetry(null)}/></>+ ) : signedOut ? (+ <>+ <DialogHeader>+ <div className="mb-1 grid size-10 place-items-center rounded-xl bg-primary text-primary-foreground">+ <LogIn className="size-5" />+ </div>+ <DialogTitle>You were signed out</DialogTitle>+ <DialogDescription>This browser isn't signed in any more, for example because the password was changed in another browser. Log in again to go on.</DialogDescription>+ </DialogHeader>+ <DialogFooter className="gap-2 sm:justify-start">+ <Button asChild>+ <Link href={logInAgain(signedOut, card?.here)} onClick={close}>+ Log in+ </Link>+ </Button>+ </DialogFooter>+ </>) : (<><DialogHeader>@@ -122,6 +158,13 @@ export function GuestPrompt() {);}+/** Log in again, coming back here: the owner to the studio's own sign-in. */+function logInAgain(who: "owner" | "account", here?: string): string {+ const href = signInHref("login", here);+ if (who !== "owner") return href;+ return `${href}${href.includes("?") ? "&" : "?"}owner=1`;+}+const TITLES: Record<FindReason | "run", string> = {run: "Connect your GPU to run this",setting: "Your ComfyUI needs Fuobe's setting again",diff --git a/src/components/login-form.tsx b/src/components/login-form.tsxindex e993b9a3..377ae812 100644--- a/src/components/login-form.tsx+++ b/src/components/login-form.tsx@@ -6,7 +6,7 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";import { useEffect, useState } from "react";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";-import { announceAuthChange, signOut, useViewer } from "@/lib/api";+import { announceAuthChange, rememberViewer, signOut, useViewer } from "@/lib/api";import { safeNext } from "@/lib/safe-redirect";import { cn } from "@/lib/utils";@@ -67,10 +67,12 @@ export function LoginForm() {if (res.ok) {// Only a page on this site: never bounce to another origin after signing in.const after = safeNext(params.get("next"), window.location.origin);- // A new account connects its GPU first (the pre-flight board), then goes on to where it was headed.+ // A new account connects its GPU first (the pre-flight board), then goes on to where it was headed. Not back to+ // Settings' Your GPU (its Sign up free): the welcome page is that same choice.const q = new URLSearchParams({ welcome: "1" });- if (after !== "/" && !after.startsWith("/connect")) q.set("next", after);+ if (after !== "/" && !after.startsWith("/connect") && !after.startsWith("/settings#your-gpu")) q.set("next", after);const dest = mode === "signup" ? new URL(`/connect?${q}`, window.location.origin).toString() : after;+ rememberViewer(mode === "owner" ? "owner" : "account");announceAuthChange();window.location.assign(dest);return;diff --git a/src/components/owner-settings.tsx b/src/components/owner-settings.tsxindex 95c309e7..fe3752ff 100644--- a/src/components/owner-settings.tsx+++ b/src/components/owner-settings.tsx@@ -1,5 +1,6 @@"use client";+import { useQueryClient } from "@tanstack/react-query";import { Eye, EyeOff, Info, KeyRound, Loader2, LogOut, Scale, Trash2 } from "lucide-react";import Link from "next/link";import { useId, useState } from "react";@@ -8,7 +9,7 @@ import { Button } from "@/components/ui/button";import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";-import { announceAuthChange, signInHref, signOut, useHydrated, useViewer } from "@/lib/api";+import { announceAuthChange, leaveNotice, rememberViewer, signInHref, signOut, useHydrated, useViewer } from "@/lib/api";import { cn } from "@/lib/utils";/** Settings' line under its title: what this viewer finds on the page. Nothing until the viewer is known (as below). */@@ -18,7 +19,7 @@ export function SettingsIntro() {if (!hydrated || !v) return null;if (v.owner)return "Choose open source, paid APIs or both, connect providers, point Fuobe at your ComfyUI server, and choose how prompts get enhanced. Keys stay on this server.";- return v.account ? "Your account, your GPU and your own keys. The studio's own settings are its owner's." : "Create a free account and connect your own GPU.";+ return v.account ? "Your account, your GPU and your own keys. The studio's own settings are its owner's." : "How a free account runs Fuobe, and every model's licence.";}/**@@ -89,25 +90,44 @@ function Licences() {*/function AccountSection({ email }: { email: string }) {const id = useId();+ const qc = useQueryClient();const [open, setOpen] = useState(false);const [changing, setChanging] = useState(false);const [password, setPassword] = useState("");const [busy, setBusy] = useState(false);const [error, setError] = useState("");+ // The password was wrong (403): only then is its field marked, not for "too many tries" or no answer.+ const [wrong, setWrong] = useState(false);const remove = async (e: React.FormEvent) => {e.preventDefault();setBusy(true);setError("");+ setWrong(false);try {const res = await fetch("/api/auth/me", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ password }) });if (res.status === 204) {- // This browser's other tabs hear it, then a full load: the page and every cached answer were the account's.+ // This browser's other tabs hear it, then a full load (as a guest's): the page and every cached answer were the+ // account's. The home page says it was deleted, which a sign-out alone would look the same as.+ rememberViewer("guest");+ leaveNotice("account-deleted");announceAuthChange();window.location.replace(window.location.origin);return;}+ if (res.status === 401) {+ // This browser was signed out (the password was changed in another one): the page shows Log in instead.+ setBusy(false);+ setOpen(false);+ setPassword("");+ toast("You were signed out", { description: "This browser isn't signed in any more. Log in again to delete your account." });+ void qc.invalidateQueries({ queryKey: ["viewer"] });+ void qc.invalidateQueries({ queryKey: ["status"] });+ announceAuthChange();+ return;+ }const body = (await res.json().catch(() => ({}))) as { error?: string };setError(body.error ?? `The account wasn't deleted (${res.status})`);+ setWrong(res.status === 403);} catch {setError("The account wasn't deleted: the studio didn't answer. Try again.");}@@ -140,7 +160,7 @@ function AccountSection({ email }: { email: string }) {</Button></div></div>- <ChangePassword open={changing} onOpenChange={setChanging} />+ <ChangePassword email={email} open={changing} onOpenChange={setChanging} /><Dialogopen={open}onOpenChange={(o) => {@@ -148,6 +168,7 @@ function AccountSection({ email }: { email: string }) {setOpen(o);setPassword("");setError("");+ setWrong(false);}}><DialogContent className="sm:max-w-md">@@ -168,7 +189,7 @@ function AccountSection({ email }: { email: string }) {autoComplete="current-password"value={password}onChange={(e) => setPassword(e.target.value)}- aria-invalid={!!error}+ aria-invalid={wrong}aria-describedby={error ? `${id}-error` : undefined}autoFocus/>@@ -219,33 +240,49 @@ function PasswordInput({ id, shown, onShow, ...props }: React.ComponentProps<typ* Settings → Account → Change password (PATCH /api/auth/me): the current password, then the new one. Every other* browser signed in to the account is signed out; this one stays signed in.*/-function ChangePassword({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {+function ChangePassword({ email, open, onOpenChange }: { email: string; open: boolean; onOpenChange: (open: boolean) => void }) {const id = useId();+ const qc = useQueryClient();const [current, setCurrent] = useState("");const [next, setNext] = useState("");const [shown, setShown] = useState(false);const [busy, setBusy] = useState(false);const [error, setError] = useState("");+ // The current password was wrong (403): only then is its field marked, not for "too many tries" or no answer.+ const [wrong, setWrong] = useState(false);const short = next.length > 0 && next.length < 8;const reset = () => {setCurrent("");setNext("");setShown(false);setError("");+ setWrong(false);};const save = async (e: React.FormEvent) => {e.preventDefault();setBusy(true);setError("");+ setWrong(false);try {const res = await fetch("/api/auth/me", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ current, next }) });if (res.ok) {toast.success("Password changed", { description: "You're still signed in here. Any other browser signed in to your account is signed out." });reset();onOpenChange(false);+ } else if (res.status === 401) {+ // This browser was signed out (the password was changed in another one): the page shows Log in instead.+ setBusy(false);+ reset();+ onOpenChange(false);+ toast("You were signed out", { description: "This browser isn't signed in any more. Log in again to change your password." });+ void qc.invalidateQueries({ queryKey: ["viewer"] });+ void qc.invalidateQueries({ queryKey: ["status"] });+ announceAuthChange();+ return;} else {const body = (await res.json().catch(() => ({}))) as { error?: string };setError(body.error ?? `The password wasn't changed (${res.status})`);+ setWrong(res.status === 403);}} catch {setError("The password wasn't changed: the studio didn't answer. Try again.");@@ -265,8 +302,10 @@ function ChangePassword({ open, onOpenChange }: { open: boolean; onOpenChange: (<form onSubmit={save} className="space-y-4"><DialogHeader><DialogTitle>Change your password</DialogTitle>- <DialogDescription>Any other browser signed in to your account is signed out. You stay signed in here.</DialogDescription>+ <DialogDescription>Changing your password signs out every other browser where you're signed in. You stay signed in here.</DialogDescription></DialogHeader>+ {/* The account's email, for password managers: they update its saved login rather than save a new one. */}+ <input type="email" name="username" autoComplete="username" value={email} readOnly hidden /><div className="space-y-1.5"><Label htmlFor={`${id}-current`} className="text-[13px]">Current password@@ -278,7 +317,7 @@ function ChangePassword({ open, onOpenChange }: { open: boolean; onOpenChange: (autoComplete="current-password"value={current}onChange={(e) => setCurrent(e.target.value)}- aria-invalid={!!error}+ aria-invalid={wrong}aria-describedby={error ? `${id}-error` : undefined}autoFocus/>diff --git a/src/components/security-settings.tsx b/src/components/security-settings.tsxindex 0d8153bf..079d185b 100644--- a/src/components/security-settings.tsx+++ b/src/components/security-settings.tsx@@ -20,7 +20,7 @@ import { Checkbox } from "@/components/ui/checkbox";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { Switch } from "@/components/ui/switch";-import { announceAuthChange } from "@/lib/api";+import { announceAuthChange, rememberViewer } from "@/lib/api";import { copyWithToast } from "@/lib/clipboard";import { timeAgo } from "@/lib/format";import { responseError, toastError } from "@/lib/refusals";@@ -224,7 +224,9 @@ function SignOutEveryone({ tokens }: { tokens: number }) {setBusy(true);try {await call("/api/auth/sessions", "POST", { tokens: revoke });- // This browser is signed out too.+ // This browser is signed out too: its other tabs hear of it, and the next page starts as a guest's.+ rememberViewer("guest");+ announceAuthChange();router.replace("/login?owner=1");} catch (e) {toastError(e);@@ -333,7 +335,8 @@ export function SecuritySettings() {className="-my-1 h-7"onClick={async () => {await fetch("/api/auth/logout", { method: "POST" });- // This browser's other tabs stop going on as the owner.+ // This browser's other tabs stop going on as the owner, and the next page starts as a guest's.+ rememberViewer("guest");announceAuthChange();router.replace("/login");}}diff --git a/src/lib/api.ts b/src/lib/api.tsindex fad00cd7..34fe78a5 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -1124,9 +1124,45 @@ export function announceAuthChange(): void {} catch {}}+/** Who used this browser last ("owner", "account" or "guest"): the sidebar's first-paint script reads it (app-sidebar.tsx). */+export const VIEWER_KEY = "fuobe:viewer";++/**+ * Who the next page is for, said before it loads (signing in or out): the sidebar keeps the right row from its first+ * frame, so its menu doesn't move when the viewer is known.+ */+export function rememberViewer(kind: "owner" | "account" | "guest"): void {+ try {+ localStorage.setItem(VIEWER_KEY, kind);+ } catch {}+}++/** A word for the next page this tab loads (sessionStorage), when the change itself leaves nothing to see on it. */+const NOTICE_KEY = "fuobe:notice";+export type Notice = "account-deleted";++/** Leaves a notice for the next page, which shows it once (src/app/providers.tsx). */+export function leaveNotice(notice: Notice): void {+ try {+ sessionStorage.setItem(NOTICE_KEY, notice);+ } catch {}+}++/** The notice the last page left, once: reading it removes it. */+export function takeNotice(): Notice | null {+ try {+ const n = sessionStorage.getItem(NOTICE_KEY);+ sessionStorage.removeItem(NOTICE_KEY);+ return n === "account-deleted" ? n : null;+ } catch {+ return null;+ }+}+/** Signing out: the server forgets the session, the other tabs hear of it, and the page starts again signed out. */export async function signOut(): Promise<void> {await fetch("/api/auth/logout", { method: "POST" });+ rememberViewer("guest");announceAuthChange();window.location.reload();}