Skip to content
563 linesCodeBlameRaw
1import { useEffect, useMemo, useRef, useState } from "react";
2import {
3 isRouteErrorResponse,
4 Link,
5 Links,
6 Meta,
7 Outlet,
8 Scripts,
9 ScrollRestoration,
10 type ShouldRevalidateFunctionArgs,
11 useLocation,
12 useMatches,
13 useRouteError,
14 useRouteLoaderData,
15} from "react-router";
16
17import { type User, awaitsConfirmation, hasAccessIn, sharedWorkspaces } from "@g1t/contracts";
18
19import type { Route } from "./+types/root";
20import appCss from "./app.css?url";
21import displayFont from "@g1t/theme/fonts/bricolage-grotesque-latin.woff2?url";
22import sansFont from "@g1t/theme/fonts/hanken-grotesk-latin.woff2?url";
23import { ButtonLink } from "./components/ui";
24import { Card } from "./components/ui/card";
25import { AppShell, Progress, type ShellData, useLeaving } from "./components/shell";
26import { SiteFooter } from "./components/footer";
27import { PublicHeader } from "./components/public-header";
28import { SpikeBanner } from "./components/spike-banner";
29import { PolicyNotice } from "./components/policy-notice";
30import { identify } from "./lib/analytics.client";
31import { visitorAsksFirst } from "./lib/analytics-consent";
32import { AnalyticsConsent } from "./components/analytics-consent";
33import { readCookie } from "./lib/mission";
34import { WORKSPACE_COOKIE, workspaceFor } from "./lib/workspace-choice";
35import { PageMain } from "./components/landmark";
36import { NotFound } from "./components/not-found";
37import { frameOf } from "./lib/chrome";
38import { DOCK_COOKIE, SIDEBAR_COOKIE, pinsToShow, sidebarClosed } from "./lib/apps";
39import { savedPins } from "./lib/dock.server";
40import { StandaloneFrame } from "./components/standalone";
41import { billing, chat, identity, inbox, projects, workspaceAgents } from "./lib/services.server";
42import { teamsByAgent } from "./lib/people";
43import { unreadTotals } from "./lib/chat";
44import { countsFor, readableRepos } from "./lib/access.server";
45import { shortCache } from "./lib/cache.server";
46import { getViewer, viewerMiddleware } from "./lib/session.server";
47import { shortcutOf, workspaceProjects } from "./lib/workspace-projects.server";
48import { registrationMode } from "./lib/registration.server";
49import { addresses } from "./lib/addresses.server";
50import { RELOADED_KEY, RELOAD_GIVE_UP_MS, clientNavigated, reloadFixes, reloadedBefore } from "./lib/stale-build";
51import { useNonce } from "./lib/nonce";
52import { isNeedsSignIn } from "./lib/website-token";
53import { offerTicket, setLiveViaToken } from "./lib/live-socket";
54import { socketTicketFor } from "./lib/socket-ticket.server";
55import { LiveNotifications } from "./components/notifications/live-notifications";
56import { THEME_COLOR, THEME_COOKIE, readTheme, themeAttribute, useThemeChoice } from "./lib/theme";
57
58
59export const links: Route.LinksFunction = () => [
60 { rel: "icon", href: "/favicon.ico", sizes: "32x32" },
61 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
62 { rel: "icon", type: "image/png", sizes: "192x192", href: "/icon-192.png" },
63 { rel: "icon", type: "image/png", sizes: "512x512", href: "/icon-512.png" },
64 // Home screens and password managers look for a square, opaque 180px tile;
65 // the "-precomposed" name is served too, for the ones that ask for it.
66 { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
67 // Installable: name, icons and colours for "Add to Home Screen" (public/site.webmanifest;
68 // manifest.webmanifest is the same file, kept for installs that already point at it).
69 { rel: "manifest", href: "/site.webmanifest" },
70 // The text and headline faces are wanted on every page, so they start
71 // loading with the stylesheet; mono waits until something uses it.
72 { rel: "preload", href: sansFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
73 { rel: "preload", href: displayFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
74];
75
76export const middleware: Route.MiddlewareFunction[] = [viewerMiddleware];
77
78export async function loader({ context, params, request }: Route.LoaderArgs) {
79 const user = getViewer(context);
80 const cookies = request.headers.get("cookie");
81 const chosen = readCookie(cookies, WORKSPACE_COOKIE);
82 const dock = readCookie(cookies, DOCK_COOKIE);
83 // Whether sign-up takes an invite: the sign-up page says so, and
84 // Settings → Invites offers invites to g1t only then. Cached per isolate.
85 const [shell, mode, sounds] = await Promise.all([
86 // An account still confirming its address sees only the pages that
87 // allows (lib/confirm-gate.ts), in the visitor's frame.
88 user && !awaitsConfirmation(user)
89 ? shellFor(user, params, chosen, context).catch((error: unknown) => {
90 // A sidebar that could not be read is no reason to lose the page,
91 // or to draw it as if they were signed out.
92 console.error("root: the sidebar could not be read", error);
93 return bareShell(user, params, chosen);
94 })
95 : visitorShell(params, context),
96 registrationMode(),
97 // Their chat sounds, with the page, so the first live event already
98 // respects them (lib/sounds.ts); the defaults when identity is slow.
99 user && !awaitsConfirmation(user) ? identity.soundSettings(user).catch(() => null) : Promise.resolve(null),
100 ]);
101 // The apps this person pinned to their rail here: as their account keeps
102 // them (read with the rest of the shell), else as this device's cookie
103 // remembers them (lib/apps.ts).
104 if (shell.workspace) shell.pins = pinsToShow(shell.pins, dock, shell.workspace.slug);
105 // Where this g1t lives, for clone lines, agent setup and link previews.
106 return {
107 user,
108 shell,
109 // For a page opened with an access token: the feed socket's ticket,
110 // minted here so the feed opens without asking for one (lib/live-socket.ts).
111 liveTicket: user?.token?.website ? await socketTicketFor(context, request, "/-/live") : null,
112 // Whether they folded the sidebar away, so the page is drawn that way from the start.
113 sidebarClosed: sidebarClosed(readCookie(cookies, SIDEBAR_COOKIE)),
114 // Their Appearance, so the page is drawn in it from the first byte (lib/theme.ts).
115 theme: readTheme(readCookie(cookies, THEME_COOKIE)),
116 // What they hear when chat moves (components/notifications/sounds.tsx).
117 sounds,
118 inviteOnly: mode !== "open",
119 addresses: addresses(),
120 // Visitors from where the law asks first are asked before analytics runs.
121 analyticsConsent: visitorAsksFirst(request),
122 };
123}
124
125/**
126 * The sidebar for someone not signed in: nothing of their own, only the
127 * open counts of the project being looked at. One call, and only in a
128 * project; it answers the same for a private project as a missing one.
129 */
130async function visitorShell(params: { owner?: string; repo?: string }, context: Route.LoaderArgs["context"]): Promise<ShellData> {
131 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
132 const counts = path ? await countsFor(context, params) : null;
133 return {
134 workspace: null,
135 repos: [],
136 repo: path && counts?.ok ? { ...path, member: false, issues: counts.value.issues, pulls: counts.value.pulls } : null,
137 limit: null,
138 monthUsageMicros: null,
139 };
140}
141
142/** The sidebar from what the session already says, with no service asked. */
143function bareShell(user: User, params: { owner?: string; repo?: string }, chosen: string | null): ShellData {
144 return {
145 workspace: workspaceFor(user.workspaces ?? [], chosen, params),
146 repos: [],
147 repo: null,
148 limit: null,
149 monthUsageMicros: null,
150 };
151}
152
153/**
154 * The sidebar only changes with the workspace or repository being looked
155 * at, or after something was submitted: not on every page within them.
156 */
157export function shouldRevalidate({
158 currentParams,
159 nextParams,
160 formMethod,
161 defaultShouldRevalidate,
162}: ShouldRevalidateFunctionArgs) {
163 if (formMethod && formMethod !== "GET") return defaultShouldRevalidate;
164 return currentParams.owner !== nextParams.owner || currentParams.repo !== nextParams.repo;
165}
166
167/**
168 * The sidebar: the workspace whose pages or project these are when it is
169 * one of yours, else the one you chose (lib/workspace-choice.ts); its
170 * projects; and the repository being looked at.
171 */
172async function shellFor(
173 user: User,
174 params: { owner?: string; repo?: string },
175 chosen: string | null,
176 context: Route.LoaderArgs["context"],
177): Promise<ShellData> {
178 const memberships = user.workspaces ?? [];
179 const workspace = workspaceFor(memberships, chosen, params);
180 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
181 const now = new Date();
182 const monthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
183 // What the sidebar shows of the workspace changes rarely: kept for a few
184 // seconds per person and workspace, except just after they changed
185 // something (lib/cache.server.ts).
186 const kept = <T,>(what: string, load: () => Promise<T>) =>
187 workspace ? shortCache(`shell:${what}:${user.id}:${workspace.slug}`, SHELL_TTL_MS, load) : Promise.resolve(null);
188 const [listed, counts, status, usage, limit, entitlements, shared, unread, shortcuts, chatUnread, teamAgents, dockPins] = await Promise.all([
189 // Every project, for the palette and the count; the sidebar lists only
190 // the person's pinned and recent ones (lib/pins.ts).
191 workspace ? workspaceProjects(workspace.slug, user) : Promise.resolve(null),
192 path ? countsFor(context, params) : Promise.resolve(null),
193 // Whether billing is on, without reading the account: that asks the
194 // card processor about the workspace's cards, too slow for every page.
195 kept("status", () => billing.status()).catch(() => null),
196 kept(`usage:${monthStart}`, () => billing.usage(workspace!.slug, user, monthStart)).catch(() => null),
197 kept("limit", () => billing.limit(workspace!.slug, user)).catch(() => null),
198 kept("entitlements", () => billing.entitlements(workspace!.slug)).catch(() => null),
199 sharedRepos(user),
200 // The bell's count: one query, never kept, so marking an item shows at once.
201 inbox.counts(user.username).catch(() => null),
202 // Never kept: opening a project moves it up Recent.
203 workspace ? projects.shortcuts(workspace.slug, user).catch(() => null) : Promise.resolve(null),
204 // The rail's Chat badge: never kept, and never waited on for long.
205 workspace ? chatUnreadFor(workspace.slug, user) : Promise.resolve(null),
206 // Home's Recent and the Agents sidebar, on every page: never waited on for long.
207 workspace ? agentsFor(workspace.slug, user) : Promise.resolve(null),
208 // The rail's pins, kept with the account so every device shows the same
209 // rail; never kept here, so a pin shows the moment it is made. Null
210 // falls back to the cookie (lib/dock.server.ts).
211 workspace ? savedPins(user, workspace.slug) : Promise.resolve(null),
212 ]);
213 return {
214 workspace,
215 // Projects are what the sidebar lists: what the workspace builds and runs.
216 repos: listed?.ok ? listed.value.map(shortcutOf) : [],
217 pinned: (shortcuts?.pinned ?? []).map(shortcutOf),
218 recent: (shortcuts?.recent ?? []).map(shortcutOf),
219 repo:
220 path && counts?.ok
221 ? {
222 ...path,
223 // Until the repository's own page says what their role is.
224 member: hasAccessIn(user, path.namespace),
225 issues: counts.value.issues,
226 pulls: counts.value.pulls,
227 }
228 : null,
229 // Where the workspace stands against its usage limit, once billing is on.
230 limit:
231 status?.enabled && limit?.ok
232 ? {
233 exposureMicros: limit.value.exposureMicros,
234 ceilingMicros: limit.value.ceilingMicros,
235 state: limit.value.state,
236 comped: limit.value.trust === "internal",
237 }
238 : null,
239 free: Boolean(status?.free),
240 // A spend spike or a hold pauses new compute: the shell says so on every page.
241 compute:
242 workspace && entitlements && (entitlements.paused || entitlements.spike?.status === "open")
243 ? { paused: entitlements.paused, spike: entitlements.spike ?? null, owner: workspace.role === "owner" }
244 : null,
245 shared,
246 inbox: unread,
247 chat: chatUnread,
248 agents: teamAgents,
249 pins: dockPins ?? undefined,
250 // While g1t is free every charge is zero, so usage is shown at cost.
251 // Usage at price, the one figure every page shows.
252 monthUsageMicros: usage?.ok ? (usage.value.free ? usage.value.usedMicros : (usage.value.priceMicros ?? usage.value.spentMicros)) : null,
253 };
254}
255
256/** Starred and recent conversations Home's sidebar lists. */
257const SHELL_CONVERSATIONS = 8;
258
259/**
260 * What is unread in chat, for the rail, and the starred and latest
261 * conversations, for Home's sidebar; null when chat is slow to answer or
262 * does not.
263 */
264async function chatUnreadFor(slug: string, user: User): Promise<ShellData["chat"]> {
265 const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), CHAT_BADGE_WAIT_MS));
266 const read = chat
267 .sidebar(slug, user)
268 .then((result) => {
269 if (!result.ok) return null;
270 const entries = result.value.entries;
271 const latest = [...entries].sort((a, b) => (b.channel.last_message_at ?? "").localeCompare(a.channel.last_message_at ?? ""));
272 return {
273 ...unreadTotals(entries),
274 starred: entries.filter((e) => e.starred).slice(0, SHELL_CONVERSATIONS),
275 recent: latest.slice(0, SHELL_CONVERSATIONS),
276 };
277 })
278 .catch(() => null);
279 return Promise.race([read, timeout]);
280}
281
282/** The workspace's agents, as the shell lists them; null when the agents service is slow or down. */
283async function agentsFor(slug: string, user: User): Promise<ShellData["agents"]> {
284 const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), CHAT_BADGE_WAIT_MS));
285 // The workspace's agents and the person's own personal ones, for "Yours",
286 // with the teams each is on, for the Agents sidebar's groups.
287 const read = Promise.all([workspaceAgents.list(slug, user, { personal: "mine" }), identity.teamAgentIndex(slug).catch(() => null)])
288 .then(([result, index]) => {
289 if (!result.ok) return null;
290 const teams = index ? teamsByAgent(index) : null;
291 return result.value
292 .filter((agent) => !agent.archived_at)
293 .map((agent) => ({
294 id: agent.id,
295 handle: agent.handle,
296 display_name: agent.display_name,
297 avatar: agent.avatar,
298 avatar_seed: agent.avatar_seed,
299 role: agent.role,
300 title: agent.title,
301 status: agent.status,
302 builtin: agent.builtin === true,
303 scope: agent.scope,
304 ...(teams ? { teams: teams[agent.id] ?? [] } : {}),
305 }));
306 })
307 .catch(() => null);
308 return Promise.race([read, timeout]);
309}
310
311/** The longest the rail's Chat badge holds up a page. */
312const CHAT_BADGE_WAIT_MS = 300;
313
314/**
315 * How long the sidebar's workspace answers are kept: as long as someone's
316 * own changes read fresh anyway (lib/perf.ts `PRIMARY_WINDOW_SECONDS`).
317 */
318const SHELL_TTL_MS = 30_000;
319
320/** Most repositories listed under Shared with you. */
321const MAX_SHARED = 20;
322
323/**
324 * Repositories shared with the user in workspaces they do not belong to,
325 * by their grants: only those, never the workspace's other repositories.
326 */
327async function sharedRepos(user: User): Promise<ShellData["shared"]> {
328 const outside = new Set(sharedWorkspaces(user));
329 if (outside.size === 0) return [];
330 const ids = (user.grants ?? []).filter((grant) => outside.has(grant.workspace)).map((grant) => grant.repo_id).slice(0, MAX_SHARED);
331 const found = await readableRepos(ids, user);
332 return found
333 .map((repo) => ({ namespace: repo.namespace, name: repo.name, isPrivate: repo.isPrivate }))
334 .sort((a, b) => `${a.namespace}/${a.name}`.localeCompare(`${b.namespace}/${b.name}`));
335}
336
337/**
338 * The root's data as the browser last had it. When a navigation fails in a
339 * way that takes the root's data with it, the error is still drawn in the
340 * person's own frame, signed in, not the visitor's. Never kept on the
341 * server, where one module serves everyone.
342 */
343let lastRoot: Awaited<ReturnType<typeof loader>> | undefined;
344
345export function Layout({ children }: { children: React.ReactNode }) {
346 const nonce = useNonce();
347 // Undefined when the root loader itself failed.
348 const loaded = useRouteLoaderData<typeof loader>("root");
349 const inBrowser = typeof document !== "undefined";
350 if (loaded && inBrowser) lastRoot = loaded;
351 const root = loaded ?? (inBrowser ? lastRoot : undefined);
352 const user = root?.user;
353 // A page opened with an access token signs its live sockets in with tickets (lib/live-socket.ts).
354 if (inBrowser) {
355 setLiveViaToken(Boolean(user?.token?.website));
356 offerTicket("/-/live", root?.liveTicket);
357 }
358 const { pathname, search } = useLocation();
359 // Drawn around the error page too: a 404 keeps the sidebar out of a
360 // project or workspace the viewer cannot see.
361 const error = useRouteError();
362 const missing = isRouteErrorResponse(error) && error.status === 404;
363 // The billing page shows the full banner itself.
364 const paused = root?.shell?.compute && root.shell.workspace && !pathname.endsWith("/-/billing") && (
365 <SpikeBanner
366 compact
367 slug={root.shell.workspace.slug}
368 entitlements={{ paused: root.shell.compute.paused, spike: root.shell.compute.spike }}
369 owner={root.shell.compute.owner}
370 />
371 );
372 // On the few pages an account still confirming its address can open
373 // besides /confirm-email (policies, support, signing in): the way back.
374 const verify = user && awaitsConfirmation(user) && pathname !== "/confirm-email" && (
375 <p
376 role="status"
377 className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-b border-warn/30 bg-warn/10 px-4 py-2 text-sm"
378 >
379 <span>Confirm your email address to start using g1t.</span>
380 <Link to="/confirm-email" className="font-medium underline underline-offset-4">
381 Enter your code
382 </Link>
383 </p>
384 );
385 // A workspace that requires two-factor authentication of someone who
386 // has not turned it on: they keep their place, and cannot use it yet.
387 const held = user?.held && user.held.length > 0 && pathname !== "/settings/two-factor" && <PolicyNotice held={user.held} />;
388 const leaving = useLeaving();
389 // Auto, Light or Dark: as the cookie said when the page was drawn, or as just switched.
390 const theme = useThemeChoice(root?.theme);
391 // Which frame the page is drawn in (lib/chrome.ts): on its own, the app's, or the public one.
392 const frame = frameOf(pathname, {
393 signedIn: user != null && !awaitsConfirmation(user),
394 workspace: (user?.workspaces ?? []).length > 0,
395 });
396 const banner =
397 paused || verify || held ? (
398 <>
399 {paused}
400 {verify}
401 {held}
402 </>
403 ) : null;
404 return (
405 <html lang="en" data-theme={themeAttribute(theme)}>
406 <head>
407 <meta charSet="utf-8" />
408 <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
409 {/* The browser bar matches the page: one colour for a chosen theme, the system's for Auto. */}
410 {theme === "auto" ? (
411 <>
412 <meta name="theme-color" media="(prefers-color-scheme: light)" content={THEME_COLOR.light} />
413 <meta name="theme-color" media="(prefers-color-scheme: dark)" content={THEME_COLOR.dark} />
414 </>
415 ) : (
416 <meta name="theme-color" content={THEME_COLOR[theme]} />
417 )}
418 <meta name="mobile-web-app-capable" content="yes" />
419 <meta name="apple-mobile-web-app-capable" content="yes" />
420 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
421 {/* The stylesheet before everything React Router preloads, so a slow
422 connection paints sooner. */}
423 <link rel="stylesheet" href={appCss} precedence="default" />
424 {root?.analyticsConsent && <meta name="g1t-analytics" content="consent" />}
425 <Meta />
426 <Links nonce={nonce} />
427 </head>
428 <body className="flex min-h-screen flex-col" data-frame={frame === "app" && user && root?.shell ? "app" : frame}>
429 {/* The first stop for the keyboard: past the menus, to the page. */}
430 <a
431 href="#content"
432 className="sr-only rounded-md bg-fg px-3 py-2 text-sm font-medium text-bg focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[70]"
433 >
434 Skip to content
435 </a>
436 {frame === "standalone" ? (
437 <StandaloneFrame>{children}</StandaloneFrame>
438 ) : frame === "app" && user && root?.shell ? (
439 <AppShell user={user} shell={root.shell} missing={missing} banner={banner} sidebarClosed={root.sidebarClosed}>
440 {children}
441 </AppShell>
442 ) : (
443 <>
444 <Progress />
445 <PublicHeader user={user} />
446 {banner}
447 <div id="content" tabIndex={-1} {...leaving} className={`grow outline-none ${leaving.className}`}>
448 {children}
449 </div>
450 <SiteFooter user={user} />
451 </>
452 )}
453 {/* Live notifications for the signed-in: the feed socket, toasts, the tab's count (components/notifications). */}
454 {user && !awaitsConfirmation(user) && (
455 <LiveNotifications
456 workspace={root?.shell?.workspace?.slug ?? null}
457 inbox={root?.shell?.inbox?.unread ?? null}
458 sounds={root?.sounds ?? null}
459 me={{ id: user.id, username: user.username }}
460 />
461 )}
462 <AnalyticsConsent />
463 <ScrollRestoration nonce={nonce} />
464 <Scripts nonce={nonce} />
465 </body>
466 </html>
467 );
468}
469
470export default function App() {
471 const userId = useRouteLoaderData<typeof loader>("root")?.user?.id ?? null;
472 // Tell analytics who is signed in, once per change; signing out forgets them.
473 const lastUserId = useRef<string | null>(null);
474 useEffect(() => {
475 identify(userId, lastUserId.current);
476 lastUserId.current = userId;
477 }, [userId]);
478 return <Outlet />;
479}
480
481export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
482 const location = useLocation();
483 const matches = useMatches();
484 const href = location.pathname + location.search + location.hash;
485 // A tab left open across a deploy: load the address again as a whole
486 // page, once, rather than show an error the reload fixes. A document load
487 // never reloads, so the server and the hydrating client render the same.
488 const reloadable = reloadFixes({
489 error,
490 status: isRouteErrorResponse(error) ? error.status : undefined,
491 clientNavigation: clientNavigated(location.key),
492 caughtByCatchAll: matches.at(-1)?.id === "routes/not-found",
493 });
494 // Already loaded again once, or the reload never started: show the page.
495 const tried = useMemo(() => reloadable && reloadedBefore(href), [reloadable, href]);
496 const [gaveUp, setGaveUp] = useState<string | null>(null);
497 const reload = reloadable && !tried && gaveUp !== href;
498 useEffect(() => {
499 if (!reload) return;
500 try {
501 sessionStorage.setItem(RELOADED_KEY, href);
502 } catch {
503 // No session storage: reload anyway; a document load never asks again.
504 }
505 window.location.assign(href);
506 const timer = window.setTimeout(() => setGaveUp(href), RELOAD_GIVE_UP_MS);
507 return () => window.clearTimeout(timer);
508 }, [reload, href]);
509 if (reload) {
510 return (
511 <PageMain className="mx-auto max-w-xl px-4 py-32 text-center text-sm text-muted" aria-busy="true">
512 <title>Loading · g1t</title>
513 Loading the latest version of g1t…
514 </PageMain>
515 );
516 }
517
518 let title = "Something went wrong";
519 let details = "An unexpected error occurred. Try again in a moment.";
520 let stack: string | undefined;
521
522 if (isRouteErrorResponse(error)) {
523 // The same page for something private and something missing.
524 if (error.status === 404) {
525 return (
526 <>
527 <title>Not found · g1t</title>
528 <NotFound data={error.data} />
529 </>
530 );
531 }
532 if (typeof error.data === "string" && error.data) {
533 details = error.data;
534 }
535 // A token asked for what needs a real sign-in (lib/website-token.ts).
536 if (isNeedsSignIn(error.data)) {
537 title = "This needs you to sign in";
538 details = error.data.message;
539 }
540 } else if (import.meta.env.DEV && error instanceof Error) {
541 details = error.message;
542 stack = error.stack;
543 }
544
545 return (
546 <PageMain className="mx-auto max-w-xl px-4 py-32 text-center">
547 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
548 <p className="mt-3 text-muted">{details}</p>
549 <div className="mt-8">
550 <ButtonLink to="/" variant="outline">
551 Back to home
552 </ButtonLink>
553 </div>
554 {stack && (
555 <Card asChild tone="plain" radius="lg" className="mt-8 overflow-x-auto p-4 text-left text-xs">
556 <pre>
557 <code>{stack}</code>
558 </pre>
559 </Card>
560 )}
561 </PageMain>
562 );
563}