Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

perf(web): defer landing demos and show hero immediately

Gus3e495be5b5d6
diff --git a/src/web/public/landing/people/alex.webp b/src/web/public/landing/people/alex.webp
index 41c6f9f0a..d2a7c58e2 100644
Binary files a/src/web/public/landing/people/alex.webp and b/src/web/public/landing/people/alex.webp differ
diff --git a/src/web/public/landing/people/lin.webp b/src/web/public/landing/people/lin.webp
index 406300a43..7fd9d7091 100644
Binary files a/src/web/public/landing/people/lin.webp and b/src/web/public/landing/people/lin.webp differ
diff --git a/src/web/public/landing/people/nina.webp b/src/web/public/landing/people/nina.webp
index aee62d7b2..0f9c38969 100644
Binary files a/src/web/public/landing/people/nina.webp and b/src/web/public/landing/people/nina.webp differ
diff --git a/src/web/public/landing/people/priya.webp b/src/web/public/landing/people/priya.webp
index 95275686a..4e084df5c 100644
Binary files a/src/web/public/landing/people/priya.webp and b/src/web/public/landing/people/priya.webp differ
diff --git a/src/web/public/landing/posters/continuity.webp b/src/web/public/landing/posters/continuity.webp
new file mode 100644
index 000000000..c2a899f7e
Binary files /dev/null and b/src/web/public/landing/posters/continuity.webp differ
diff --git a/src/web/public/landing/posters/identity.webp b/src/web/public/landing/posters/identity.webp
new file mode 100644
index 000000000..11ec246db
Binary files /dev/null and b/src/web/public/landing/posters/identity.webp differ
diff --git a/src/web/public/landing/posters/machine.webp b/src/web/public/landing/posters/machine.webp
new file mode 100644
index 000000000..140dd28e7
Binary files /dev/null and b/src/web/public/landing/posters/machine.webp differ
diff --git a/src/web/public/landing/posters/mobile.webp b/src/web/public/landing/posters/mobile.webp
new file mode 100644
index 000000000..550c5c640
Binary files /dev/null and b/src/web/public/landing/posters/mobile.webp differ
diff --git a/src/web/public/landing/posters/profile.webp b/src/web/public/landing/posters/profile.webp
new file mode 100644
index 000000000..84a350585
Binary files /dev/null and b/src/web/public/landing/posters/profile.webp differ
diff --git a/src/web/public/landing/posters/server.webp b/src/web/public/landing/posters/server.webp
new file mode 100644
index 000000000..7e778bce6
Binary files /dev/null and b/src/web/public/landing/posters/server.webp differ
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index e9140cef1..2696e4b2e 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -966,6 +966,14 @@ body.driver-active .community-ws-reconnect-overlay * {
overflow: visible;
}
+.hero-artwork[data-static-paper] .tw-body-front {
+ transform-style: preserve-3d;
+}
+
+.hero-artwork[data-static-paper] .tw-paper-track {
+ transform: translateX(-50%) translateZ(-1px);
+}
+
/* Back face */
.tw-body-back {
position: absolute;
diff --git a/src/web/src/components/home/deferred-landing-media.dom.test.tsx b/src/web/src/components/home/deferred-landing-media.dom.test.tsx
new file mode 100644
index 000000000..299dbb59a
--- /dev/null
+++ b/src/web/src/components/home/deferred-landing-media.dom.test.tsx
@@ -0,0 +1,68 @@
+import React, { lazy } from "react"
+import { renderToString } from "react-dom/server"
+import { act, fireEvent, render, screen } from "@/test/react-dom-harness"
+import { afterEach, describe, expect, it, vi } from "vitest"
+import { DeferredLandingMedia } from "./deferred-landing-media"
+
+const props = { poster: "/landing/posters/server.webp", width: 1120, height: 660 }
+afterEach(() => vi.unstubAllGlobals())
+
+describe("deferred landing media", () => {
+ it("keeps a dimensioned static image in server HTML without invoking the chunk", () => {
+ const load = vi.fn()
+ const Demo = lazy(load)
+ const html = renderToString(<DeferredLandingMedia {...props}><Demo /></DeferredLandingMedia>)
+ expect(load).not.toHaveBeenCalled()
+ expect(html).toContain('width="1120"')
+ expect(html).toContain('height="660"')
+ expect(html).toContain('loading="lazy"')
+ })
+
+ it("loads only on intersection and preserves the poster while the chunk is pending", async () => {
+ let observeCallback: IntersectionObserverCallback = () => undefined
+ const disconnect = vi.fn()
+ vi.stubGlobal("IntersectionObserver", class {
+ constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit) {
+ observeCallback = callback
+ expect(options.rootMargin).toBe("100px")
+ }
+ observe = vi.fn()
+ disconnect = disconnect
+ })
+ let resolve!: (value: { default: () => React.ReactNode }) => void
+ const load = vi.fn(() => new Promise<{ default: () => React.ReactNode }>((done) => { resolve = done }))
+ const Demo = lazy(load)
+ const { container, unmount } = render(<DeferredLandingMedia {...props}><Demo /></DeferredLandingMedia>)
+ expect(load).not.toHaveBeenCalled()
+ await act(async () => observeCallback([{ isIntersecting: false }] as IntersectionObserverEntry[], {} as IntersectionObserver))
+ expect(load).not.toHaveBeenCalled()
+ await act(async () => observeCallback([{ isIntersecting: true }] as IntersectionObserverEntry[], {} as IntersectionObserver))
+ expect(load).not.toHaveBeenCalled()
+ let finishDecode!: () => void
+ const image = container.querySelector("img")!
+ Object.defineProperty(image, "decode", { value: () => new Promise<void>((done) => { finishDecode = done }) })
+ await act(async () => fireEvent.load(image))
+ expect(load).not.toHaveBeenCalled()
+ await act(async () => finishDecode())
+ expect(load).toHaveBeenCalledTimes(1)
+ expect(container.querySelector("img")?.getAttribute("src")).toBe(props.poster)
+ expect(disconnect).toHaveBeenCalled()
+ await act(async () => resolve({ default: () => <span>Live demo</span> }))
+ expect(screen.getByText("Live demo")).toBeTruthy()
+ expect(container.querySelector("img")).toBeNull()
+ expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe("1120 / 660")
+ unmount()
+ expect(disconnect.mock.calls.length).toBeGreaterThan(1)
+ })
+
+ it("activates without IntersectionObserver and keeps a poster on chunk failure", async () => {
+ vi.stubGlobal("IntersectionObserver", undefined)
+ const error = vi.spyOn(console, "error").mockImplementation(() => undefined)
+ const Demo = lazy(() => Promise.reject(new Error("offline")))
+ const { container } = render(<DeferredLandingMedia {...props}><Demo /></DeferredLandingMedia>)
+ fireEvent.error(container.querySelector("img")!)
+ await act(async () => { await Promise.resolve() })
+ expect(container.querySelector("img")?.getAttribute("src")).toBe(props.poster)
+ error.mockRestore()
+ })
+})
diff --git a/src/web/src/components/home/deferred-landing-media.tsx b/src/web/src/components/home/deferred-landing-media.tsx
new file mode 100644
index 000000000..f511b679a
--- /dev/null
+++ b/src/web/src/components/home/deferred-landing-media.tsx
@@ -0,0 +1,78 @@
+"use client"
+
+import { useAtom, useCreateAtom } from "@tanstack/react-store"
+import { Component, lazy, Suspense, useCallback, useEffect, useRef, type ReactNode } from "react"
+import type { LandingShellMotion } from "./landing-shell-motion"
+import type { ComponentProps } from "react"
+
+const Shell = lazy(() => import("./landing-shell-motion").then((module) => ({ default: module.LandingShellMotion })))
+const Mobile = lazy(() => import("./landing-shell-motion").then((module) => ({ default: module.LandingMobileChatMotion })))
+const Profile = lazy(() => import("./landing-profile-content"))
+
+class MediaFallback extends Component<{ children: ReactNode; fallback: ReactNode }, { failed: boolean }> {
+ state = { failed: false }
+ static getDerivedStateFromError() { return { failed: true } }
+ render() { return this.state.failed ? this.props.fallback : this.props.children }
+}
+
+export function DeferredLandingMedia({ poster, width, height, children, priority = false, alt = "" }: {
+ poster: string
+ priority?: boolean
+ alt?: string
+ width: number
+ height: number
+ children: ReactNode
+}) {
+ const ref = useRef<HTMLDivElement>(null)
+ const [near, setNear] = useAtom(useCreateAtom(false))
+ const [posterReady, setPosterReady] = useAtom(useCreateAtom(false))
+ const imageRef = useRef<HTMLImageElement>(null)
+ const active = near && posterReady
+ const finishPoster = useCallback(async (image: HTMLImageElement) => {
+ try { await image.decode() } catch {}
+ setPosterReady(true)
+ }, [setPosterReady])
+ useEffect(() => {
+ const image = imageRef.current
+ if (image?.complete) void finishPoster(image)
+ }, [finishPoster])
+ useEffect(() => {
+ const element = ref.current
+ if (!element) return
+ if (typeof IntersectionObserver === "undefined") {
+ setNear(true)
+ return
+ }
+ const observer = new IntersectionObserver((entries) => {
+ if (entries.some((entry) => entry.isIntersecting)) {
+ setNear(true)
+ observer.disconnect()
+ }
+ }, { rootMargin: "100px" })
+ observer.observe(element)
+ return () => observer.disconnect()
+ }, [setNear])
+ const fallback = (
+ <img ref={imageRef} src={poster} width={width} height={height} alt={alt}
+ loading={priority ? "eager" : "lazy"} fetchPriority={priority ? "high" : "auto"} decoding="async"
+ onLoad={(event) => { void finishPoster(event.currentTarget) }} onError={() => setPosterReady(true)}
+ style={{ display: "block", width: "100%", height: "auto" }} />
+ )
+ return (
+ <div ref={ref} data-landing-deferred={poster} style={{ width: "100%", aspectRatio: `${width} / ${height}` }}>
+ {active ? <MediaFallback fallback={fallback}><Suspense fallback={fallback}>{children}</Suspense></MediaFallback> : fallback}
+ </div>
+ )
+}
+
+export function DeferredShellMotion(props: ComponentProps<typeof LandingShellMotion>) {
+ return <DeferredLandingMedia poster={`/landing/posters/${props.scene}.webp`} width={1120} height={660} priority={props.scene === "server"}><Shell {...props} /></DeferredLandingMedia>
+}
+
+export function DeferredMobileChatMotion(props: { beat: number }) {
+ return <DeferredLandingMedia poster="/landing/posters/mobile.webp" width={390} height={788}><Mobile {...props} /></DeferredLandingMedia>
+}
+
+export function DeferredProfileCard() {
+ return <DeferredLandingMedia poster="/landing/posters/profile.webp" width={300} height={308} alt="Maya — Free for dinner. I keep the same account, identity, and relationships across every room."><Profile /></DeferredLandingMedia>
+}
diff --git a/src/web/src/components/home/hero-avatar-swarm.module.css b/src/web/src/components/home/hero-avatar-swarm.module.css
index 0ce384ac7..099489524 100644
--- a/src/web/src/components/home/hero-avatar-swarm.module.css
+++ b/src/web/src/components/home/hero-avatar-swarm.module.css
@@ -19,6 +19,15 @@
animation: avatar-travel var(--avatar-duration) var(--avatar-delay) linear forwards;
}
+.runner:has(img[data-remote-image-state]:not([data-remote-image-state="ready"])) {
+ visibility: hidden;
+ animation-play-state: paused;
+}
+
+.runner:has(img[data-remote-image-state]:not([data-remote-image-state="ready"])) :is(.face, .shadow) {
+ animation-play-state: paused;
+}
+
.face,
.shadow {
position: absolute;
diff --git a/src/web/src/components/home/hero-section.tsx b/src/web/src/components/home/hero-section.tsx
index 9c175082a..a333e724f 100644
--- a/src/web/src/components/home/hero-section.tsx
+++ b/src/web/src/components/home/hero-section.tsx
@@ -27,6 +27,7 @@ export function HeroSection({
headlineClassName,
headlineStyle,
typewriterClassName,
+ staticPaper = false,
largeCtas = false,
highlightPrimaryCta = false,
showMobileDesktopHint = true,
@@ -46,6 +47,7 @@ export function HeroSection({
headlineClassName?: string;
headlineStyle?: CSSProperties;
typewriterClassName?: string;
+ staticPaper?: boolean;
largeCtas?: boolean;
highlightPrimaryCta?: boolean;
showMobileDesktopHint?: boolean;
@@ -141,8 +143,9 @@ export function HeroSection({
</div>
{/* Full Typewriter */}
- <div className={`hero-artwork absolute inset-0 ${typewriterClassName ?? ""}`}>
+ <div data-static-paper={staticPaper || undefined} className={`hero-artwork absolute inset-0 ${typewriterClassName ?? ""}`}>
<TypewriterVisual
+ animateEntrance={!staticPaper}
entranceDelay={1.2}
className="absolute! inset-0"
/>
diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.ts
index 73f3c26f4..9396ac280 100644
--- a/src/web/src/components/home/landing-content.test.ts
+++ b/src/web/src/components/home/landing-content.test.ts
@@ -81,7 +81,9 @@ describe("landing content contract", () => {
expect(heroSource).not.toMatch(/className="hero-(?:brand|clipboard|providers|ctas)[^\n]*style=\{\{ opacity: 0 \}\}/)
expect(heroSource).not.toMatch(/opacity:\s*0/)
expect(heroSource).toContain("<TypewriterVisual")
- expect(heroSource).toContain("entranceDelay={1.2}")
+ expect(heroSource).toContain("staticPaper = false")
+ expect(heroSource).toContain("animateEntrance={!staticPaper}")
+ expect(readFileSync(path.join(root, "src/components/home/landing-page.tsx"), "utf8")).toContain(" staticPaper")
})
it("frames continuity as one agent remembering and acting across rooms", () => {
@@ -406,14 +408,14 @@ describe("landing content contract", () => {
expect(landingPageSource).toContain("A familiar face")
expect(landingPageSource).toContain("Bring a familiar agent along.")
expect(landingPageSource).not.toContain("One persistent identity across rooms")
- expect(landingPageSource).toContain("I keep the same account, identity, and relationships across every room.")
+ expect(readFileSync(path.join(root, "src/components/home/landing-profile-content.tsx"), "utf8")).toContain("I keep the same account, identity, and relationships across every room.")
expect(landingPageSource).toContain("styles.sectionLead")
expect(landingPageSource).toContain('<p className={styles.sectionMuted}>{LANDING_CONTINUITY.kicker}</p>')
expect(landingPageSource).toContain("InteractiveIdentityProfileCard")
- expect(landingPageSource).toContain('name: "Maya"')
- expect(landingPageSource).toContain('userId: "maya"')
+ expect(readFileSync(path.join(root, "src/components/home/landing-profile-content.tsx"), "utf8")).toContain('name: "Maya"')
+ expect(readFileSync(path.join(root, "src/components/home/landing-profile-content.tsx"), "utf8")).toContain('userId: "maya"')
expect(landingPageSource).not.toContain('"landing-maya"')
- expect(landingPageSource).toContain('initialStatusText="Free for dinner"')
+ expect(readFileSync(path.join(root, "src/components/home/landing-profile-content.tsx"), "utf8")).toContain('initialStatusText="Free for dinner"')
expect(landingPageSource).toContain("IdentityProof")
expect(landingPageSource).toContain('data-testid="landing-identity-proof"')
expect(landingPageSource).toContain('data-testid="landing-identity-motion"')
diff --git a/src/web/src/components/home/landing-page.render.test.ts b/src/web/src/components/home/landing-page.render.test.ts
index 1473991c5..81ab9136f 100644
--- a/src/web/src/components/home/landing-page.render.test.ts
+++ b/src/web/src/components/home/landing-page.render.test.ts
@@ -2,6 +2,7 @@ import { createElement } from "react"
import { renderToStaticMarkup } from "react-dom/server"
import { describe, expect, it, vi } from "vitest"
import { LandingPage } from "./landing-page"
+import LandingProfileContent from "./landing-profile-content"
vi.mock("./landing-page.module.css", () => ({
default: new Proxy({}, { get: (_target, key) => String(key) }),
@@ -26,10 +27,12 @@ describe("landing identity profile preview", () => {
)?.[0]
expect(identityCard).toBeDefined()
- expect(identityCard).toContain("Maya")
- expect(identityCard).toContain("Free for dinner")
- expect(identityCard).toContain(LANDING_PROFILE_ABOUT)
- expect(identityCard).not.toContain("Unknown")
+ expect(identityCard).toContain("/landing/posters/profile.webp")
+ const profile = renderToStaticMarkup(createElement(LandingProfileContent))
+ expect(profile).toContain("Maya")
+ expect(profile).toContain("Free for dinner")
+ expect(profile).toContain(LANDING_PROFILE_ABOUT)
+ expect(profile).not.toContain("Unknown")
})
it("renders logo, slogan, and social links before second-row navigation", () => {
diff --git a/src/web/src/components/home/landing-page.tsx b/src/web/src/components/home/landing-page.tsx
index 7e0fe872c..ad693d6c1 100644
--- a/src/web/src/components/home/landing-page.tsx
+++ b/src/web/src/components/home/landing-page.tsx
@@ -4,15 +4,12 @@ import Image from "next/image"
import { useEffect, useRef, type PointerEvent as ReactPointerEvent } from "react"
import { LANDING_HUMAN_AVATARS } from "./landing-human-avatars"
import { GeneratedAvatar } from "@/components/avatar"
-import { ProfileCard } from "@/components/community/social/profile-card"
import { ProviderLogo } from "@/components/provider-logo"
-import type { CommunityProfile } from "@/lib/community/models/people"
-import { CommunityPreviewProfileOwner } from "@/stores/community/profile-preview"
import { HeroSection } from "./hero-section"
import { HeroAvatarSwarm } from "./hero-avatar-swarm"
import { HomepageFaq } from "./homepage-faq"
import { LandingReachMotion } from "./landing-reach-motion"
-import { LandingShellMotion } from "./landing-shell-motion"
+import { DeferredShellMotion as LandingShellMotion, DeferredProfileCard } from "./deferred-landing-media"
import { MarketingNav } from "./marketing-nav"
import { LandingFooter } from "./landing-footer"
import {
@@ -87,30 +84,6 @@ function RuntimeBadges() {
)
}
-const LANDING_PROFILE = {
- name: "Maya",
- userId: "maya",
- avatar: "Maya",
- contextLabel: "Agent",
- about: "I keep the same account, identity, and relationships across every room.",
- mutual: 0,
- presence: "online" as const,
-}
-
-const LANDING_IDENTITY_PREVIEW_PROFILES = new Map<string, CommunityProfile>([
- [
- "maya",
- {
- id: "maya",
- name: LANDING_PROFILE.name,
- avatar: LANDING_PROFILE.avatar,
- aboutMe: LANDING_PROFILE.about,
- presence: LANDING_PROFILE.presence,
- statusText: "Free for dinner",
- },
- ],
-])
-
const CLOSING_COMPANIONS = [
{ seed: "Maya", className: styles.closingCompanionLeft },
{ seed: "Alli", className: styles.closingCompanionTop },
@@ -163,17 +136,7 @@ function InteractiveIdentityProfileCard() {
>
<span className={styles.identityProfileCardSensor} aria-hidden="true" />
<div className={styles.identityProfileCardSurface}>
- <CommunityPreviewProfileOwner profiles={LANDING_IDENTITY_PREVIEW_PROFILES}>
- <ProfileCard
- embedded
- data={LANDING_PROFILE}
- x={0}
- y={0}
- bp="desktop"
- onClose={() => undefined}
- initialStatusText="Free for dinner"
- />
- </CommunityPreviewProfileOwner>
+ <DeferredProfileCard />
</div>
</div>
)
@@ -256,6 +219,7 @@ export function LandingPage({ isLoggedIn }: { isLoggedIn: boolean }) {
containerTestId={tid.landingHeaderContainer}
/>
<HeroSection
+ staticPaper
desktopSplit
nextSectionId="product"
isLoggedIn={isLoggedIn}
diff --git a/src/web/src/components/home/landing-profile-content.tsx b/src/web/src/components/home/landing-profile-content.tsx
new file mode 100644
index 000000000..a30024473
--- /dev/null
+++ b/src/web/src/components/home/landing-profile-content.tsx
@@ -0,0 +1,45 @@
+"use client"
+
+import { ProfileCard } from "@/components/community/social/profile-card"
+import type { CommunityProfile } from "@/lib/community/models/people"
+import { CommunityPreviewProfileOwner } from "@/stores/community/profile-preview"
+
+const LANDING_PROFILE = {
+ name: "Maya",
+ userId: "maya",
+ avatar: "Maya",
+ contextLabel: "Agent",
+ about: "I keep the same account, identity, and relationships across every room.",
+ mutual: 0,
+ presence: "online" as const,
+}
+
+const LANDING_IDENTITY_PREVIEW_PROFILES = new Map<string, CommunityProfile>([
+ [
+ "maya",
+ {
+ id: "maya",
+ name: LANDING_PROFILE.name,
+ avatar: LANDING_PROFILE.avatar,
+ aboutMe: LANDING_PROFILE.about,
+ presence: LANDING_PROFILE.presence,
+ statusText: "Free for dinner",
+ },
+ ],
+])
+
+export default function LandingProfileContent() {
+ return (
+ <CommunityPreviewProfileOwner profiles={LANDING_IDENTITY_PREVIEW_PROFILES}>
+ <ProfileCard
+ embedded
+ data={LANDING_PROFILE}
+ x={0}
+ y={0}
+ bp="desktop"
+ onClose={() => undefined}
+ initialStatusText="Free for dinner"
+ />
+ </CommunityPreviewProfileOwner>
+ )
+}
diff --git a/src/web/src/components/home/landing-reach-motion.tsx b/src/web/src/components/home/landing-reach-motion.tsx
index 86e5675ed..be09f2303 100644
--- a/src/web/src/components/home/landing-reach-motion.tsx
+++ b/src/web/src/components/home/landing-reach-motion.tsx
@@ -3,9 +3,9 @@
import { useAtom, useCreateAtom } from "@tanstack/react-store";
import { useEffect } from "react"
import {
- LandingMobileChatMotion,
- LandingShellMotion,
-} from "./landing-shell-motion"
+ DeferredMobileChatMotion as LandingMobileChatMotion,
+ DeferredShellMotion as LandingShellMotion,
+} from "./deferred-landing-media"
import {
SCENE_BEAT_DURATION_MS,
SCENE_FINAL_HOLD_MS,
diff --git a/src/web/src/components/typewriter-city-art.tsx b/src/web/src/components/typewriter-city-art.tsx
index 5aca0395c..762bab541 100644
--- a/src/web/src/components/typewriter-city-art.tsx
+++ b/src/web/src/components/typewriter-city-art.tsx
@@ -71,6 +71,7 @@ export function TypewriterCityArt() {
return (
<div ref={frameRef} className={styles.frame} role="img" aria-label="A giant Alook sculpture in an ASCII city, surrounded by buildings, a park, and streets.">
+ <link rel="preload" href="/fonts/jgs5/jgs5.ttf" as="font" type="font/ttf" crossOrigin="anonymous" />
<canvas ref={canvasRef} className={styles.canvas} aria-hidden="true" />
<pre className={`${styles.art}${ready ? ` ${styles.rendered}` : ""}`} aria-hidden="true">{TYPEWRITER_CITY_ART}</pre>
</div>
diff --git a/src/web/src/components/typewriter-visual.dom.test.tsx b/src/web/src/components/typewriter-visual.dom.test.tsx
index aba5d7a14..3d540c0ba 100644
--- a/src/web/src/components/typewriter-visual.dom.test.tsx
+++ b/src/web/src/components/typewriter-visual.dom.test.tsx
@@ -1,4 +1,5 @@
import React from "react";
+import { renderToString } from "react-dom/server";
import { render, screen } from "@/test/react-dom-harness";
import { describe, expect, it, vi } from "vitest";
@@ -8,6 +9,20 @@ import { TypewriterVisual } from "./typewriter-visual";
import { TYPEWRITER_CITY_ART } from "./typewriter-city-art-data";
describe("typewriter paper", () => {
+ it("announces the paper font in server HTML before hydration", () => {
+ const html = renderToString(<TypewriterVisual animateEntrance={false} />);
+ expect(html).toContain('rel="preload"');
+ expect(html).toContain('href="/fonts/jgs5/jgs5.ttf"');
+ expect(html).toContain('as="font"');
+ expect(html).toContain('crossorigin="anonymous"');
+ });
+
+ it("renders static hero paper visible before effects", () => {
+ const { container } = render(<TypewriterVisual animateEntrance={false} />);
+ expect((container.querySelector(".tw-paper") as HTMLElement).style.opacity).toBe("1");
+ expect(container.querySelector("pre")?.textContent).toBe(TYPEWRITER_CITY_ART);
+ });
+
it("shows the city without a switch control or consuming Enter", () => {
const { container } = render(<TypewriterVisual />);
expect(screen.getByRole("img", { name: /Alook sculpture/ })).toBeTruthy();
diff --git a/src/web/src/components/typewriter-visual.tsx b/src/web/src/components/typewriter-visual.tsx
index 7363d3ff3..e514154f2 100644
--- a/src/web/src/components/typewriter-visual.tsx
+++ b/src/web/src/components/typewriter-visual.tsx
@@ -22,6 +22,7 @@ const TW_VARS: React.CSSProperties = {
interface TypewriterVisualProps {
className?: string;
entranceDelay?: number;
+ animateEntrance?: boolean;
paper?: React.ReactNode;
blobScale?: number;
blobBottom?: string;
@@ -30,6 +31,7 @@ interface TypewriterVisualProps {
export function TypewriterVisual({
className,
entranceDelay = 0.3,
+ animateEntrance = true,
paper,
blobScale = 1,
blobBottom,
@@ -60,6 +62,7 @@ export function TypewriterVisual({
}, []);
useGSAP(() => {
+ if (!animateEntrance) return;
const paperEl = containerRef.current?.querySelector<HTMLElement>(".tw-paper");
if (!paperEl) return;
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
@@ -93,7 +96,7 @@ export function TypewriterVisual({
<div className="tw-body-front">
<div className="tw-paper-track">
- <div className={`tw-paper${paper == null ? " tw-paper-city" : ""}`}>
+ <div className={`tw-paper${paper == null ? " tw-paper-city" : ""}`} style={animateEntrance ? undefined : { opacity: 1 }}>
{paper ?? <TypewriterCityArt />}
</div>
</div>