Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): isolate landing preview profiles (#710)
Gener455165870429
diff --git a/src/web/src/components/community/channels/channel-header.tsx b/src/web/src/components/community/channels/channel-header.tsxindex f8a675a3b..7c1a331ec 100644--- a/src/web/src/components/community/channels/channel-header.tsx+++ b/src/web/src/components/community/channels/channel-header.tsx@@ -73,7 +73,7 @@ export type ChannelNotifLevel = typeof USE_SERVER_DEFAULT | NotifLevelexport function ChannelHeader({channel, rightPanel, onToggle, notifLevel, onSetNotifLevel,- kind = "text", server, mobileBack, onBack, tools,+ kind = "text", server, mobileBack, mobileBackDisplay = "viewport", onBack, tools,onRename, titleRename, endActions, compactActions,}: {channel: string@@ -86,6 +86,7 @@ export function ChannelHeader({titleRename?: booleanserver?: { id: string; name: string; icon: string | null }mobileBack?: () => void+ mobileBackDisplay?: "viewport" | "always"onBack?: () => voidtools?: { threads?: boolean; pinned?: boolean; members?: boolean }endActions?: ReactNode@@ -108,13 +109,13 @@ export function ChannelHeader({{onBack && (<Button variant="ghost" size="icon-sm" onClick={onBack} className="text-muted-foreground hover:text-foreground" aria-label="Back"><ChevronLeft className="size-5" /></Button>)}- {mobileBack && <MessageHeaderMobileBack onNavigate={mobileBack} />}+ {mobileBack && <MessageHeaderMobileBack onNavigate={mobileBack} display={mobileBackDisplay} />}</>)const identity = (<>{server && <ServerCrumb id={server.id} name={server.name} icon={server.icon} size={6} className="ml-1" />}- <div className={`grid size-6 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground ${mobileBack ? "sm:ml-1" : server ? "" : "ml-1"}`}>+ <div className={`grid size-6 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground ${mobileBack ? (mobileBackDisplay === "viewport" ? "sm:ml-1" : "") : server ? "" : "ml-1"}`}><EntityIcon kind={kind} className="size-4" /></div><span className="min-w-0 truncate text-base font-semibold" title={channel}>{channel}</span>diff --git a/src/web/src/components/community/channels/message-header.test.ts b/src/web/src/components/community/channels/message-header.test.tsindex a41b55c2c..f64e943b4 100644--- a/src/web/src/components/community/channels/message-header.test.ts+++ b/src/web/src/components/community/channels/message-header.test.ts@@ -31,4 +31,16 @@ describe("MessageHeader", () => {act(() => back.props.onClick())expect(onNavigate).toHaveBeenCalledOnce()})++ it("can keep the same 44px control visible inside an embedded mobile preview", () => {+ const html = renderToStaticMarkup(createElement(MessageHeaderMobileBack, {+ onNavigate: () => undefined,+ display: "always",+ }))++ const button = html.match(/<button[^>]*aria-label="Back"[^>]*>/)?.[0]+ expect(button).toBeDefined()+ expect(button).toContain("size-11")+ expect(button).not.toContain("sm:hidden")+ })})diff --git a/src/web/src/components/community/channels/message-header.tsx b/src/web/src/components/community/channels/message-header.tsxindex 81c3cfda8..df7190016 100644--- a/src/web/src/components/community/channels/message-header.tsx+++ b/src/web/src/components/community/channels/message-header.tsx@@ -39,16 +39,24 @@ export function MessageHeader({)}-export function MessageHeaderMobileBack({ onNavigate, label = "Back" }: {+export function MessageHeaderMobileBack({+ onNavigate,+ label = "Back",+ display = "viewport",+}: {onNavigate: () => voidlabel?: string+ display?: "viewport" | "always"}) {return (<Buttonvariant="ghost"size="icon"onClick={onNavigate}- className="size-11 shrink-0 text-muted-foreground hover:text-foreground sm:hidden"+ className={cn(+ "size-11 shrink-0 text-muted-foreground hover:text-foreground",+ display === "viewport" && "sm:hidden",+ )}aria-label={label}><ChevronLeft className="size-5" />diff --git a/src/web/src/components/community/messages/message.render.test.ts b/src/web/src/components/community/messages/message.render.test.tsindex 1c6b89325..2f84166f6 100644--- a/src/web/src/components/community/messages/message.render.test.ts+++ b/src/web/src/components/community/messages/message.render.test.ts@@ -245,6 +245,22 @@ afterEach(() => {})describe("Message memo comparator", () => {+ it("keeps the strict Unknown fallback for unresolved live authors", () => {+ let renderer: TestRenderer.ReactTestRenderer+ act(() => {+ renderer = TestRenderer.create(makeTree({+ m: baseMsg({+ authorId: "unresolved",+ authorName: "Static fixture name",+ }),+ onOpenThread: vi.fn(),+ }), { createNodeMock: () => genericMock })+ })++ expect(textContent(renderer!.root)).toContain("Unknown")+ expect(textContent(renderer!.root)).not.toContain("Static fixture name")+ })+it("bails out when compared fields are unchanged despite a fresh `m` clone", () => {const onOpenThread = vi.fn()const stableProps = { onOpenThread }diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.tsindex 3bd103562..ad2ac2b96 100644--- a/src/web/src/components/home/landing-content.test.ts+++ b/src/web/src/components/home/landing-content.test.ts@@ -447,8 +447,9 @@ describe("landing content contract", () => {expect(`${reachSource} ${shellSource}`).not.toContain("Alook Web")expect(reachSource).toContain('<LandingShellMotion scene="server" beat={beat} />')expect(reachSource).toContain("<LandingMobileChatMotion beat={beat} />")- expect(shellSource).toContain('data-testid="landing-mobile-motion-stage"')- expect(shellSource).toContain("onBack={() => {}}")+ expect(shellSource).toContain("data-testid={tid.landingMobileMotionStage}")+ expect(shellSource).toContain("mobileBack={() => {}}")+ expect(shellSource).toContain('mobileBackDisplay="always"')expect(shellSource).toContain("stage.getBoundingClientRect().width / 390")expect(motionStyles).toContain("transform: scale(var(--mobile-stage-scale))")expect(motionStyles).toMatch(/\.mobileMessages\s*\{[\s\S]*?justify-content: flex-start;/)diff --git a/src/web/src/components/home/landing-page.render.test.ts b/src/web/src/components/home/landing-page.render.test.tsnew file mode 100644index 000000000..00304b7ee--- /dev/null+++ b/src/web/src/components/home/landing-page.render.test.ts@@ -0,0 +1,37 @@+import { createElement } from "react"+import { renderToStaticMarkup } from "react-dom/server"+import { describe, expect, it, vi } from "vitest"+import { LandingPage } from "./landing-page"++vi.mock("./landing-page.module.css", () => ({+ default: new Proxy({}, { get: (_target, key) => String(key) }),+}))+vi.mock("./hero-section", () => ({ HeroSection: () => null }))+vi.mock("./hero-avatar-swarm", () => ({ HeroAvatarSwarm: () => null }))+vi.mock("./homepage-faq", () => ({ HomepageFaq: () => null }))+vi.mock("./landing-reach-motion", () => ({ LandingReachMotion: () => null }))+vi.mock("./marketing-nav", () => ({ MarketingNav: () => null }))+vi.mock("./landing-shell-motion", async () => {+ const { createElement } = await import("react")+ return {+ LandingShellMotion: () => createElement("div", { "data-testid": "landing-identity-motion" }),+ }+})++describe("landing identity profile preview", () => {+ it("renders the static Maya profile without consulting live profile state", () => {+ const markup = renderToStaticMarkup(createElement(LandingPage, { isLoggedIn: false }))+ const identityCard = markup.match(+ /data-testid="landing-identity-card-tilt"[\s\S]*?data-testid="landing-identity-motion"/,+ )?.[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")+ })+})++const LANDING_PROFILE_ABOUT =+ "I keep the same account, identity, and relationships across every room."diff --git a/src/web/src/components/home/landing-page.tsx b/src/web/src/components/home/landing-page.tsxindex 70ac5b27d..685c2858a 100644--- a/src/web/src/components/home/landing-page.tsx+++ b/src/web/src/components/home/landing-page.tsx@@ -6,6 +6,8 @@ import { useEffect, useRef, type PointerEvent as ReactPointerEvent } from "reactimport { 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"@@ -115,6 +117,20 @@ const LANDING_PROFILE = {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 },@@ -167,15 +183,17 @@ function InteractiveIdentityProfileCard() {><span className={styles.identityProfileCardSensor} aria-hidden="true" /><div className={styles.identityProfileCardSurface}>- <ProfileCard- embedded- data={LANDING_PROFILE}- x={0}- y={0}- bp="desktop"- onClose={() => undefined}- initialStatusText="Free for dinner"- />+ <CommunityPreviewProfileOwner profiles={LANDING_IDENTITY_PREVIEW_PROFILES}>+ <ProfileCard+ embedded+ data={LANDING_PROFILE}+ x={0}+ y={0}+ bp="desktop"+ onClose={() => undefined}+ initialStatusText="Free for dinner"+ />+ </CommunityPreviewProfileOwner></div></div>)diff --git a/src/web/src/components/home/landing-shell-motion.render.test.ts b/src/web/src/components/home/landing-shell-motion.render.test.tsnew file mode 100644index 000000000..bf4988cda--- /dev/null+++ b/src/web/src/components/home/landing-shell-motion.render.test.ts@@ -0,0 +1,73 @@+import { createElement } from "react"+import { renderToStaticMarkup } from "react-dom/server"+import { describe, expect, it, vi } from "vitest"+import { LandingMobileChatMotion, LandingShellMotion } from "./landing-shell-motion"+import { SCENE_MAX_BEAT, type LandingScene } from "./landing-shell-motion-timeline"++vi.mock("./landing-shell-motion.module.css", () => ({+ default: new Proxy({}, { get: (_target, key) => String(key) }),+}))++const ALL_SCENES: LandingScene[] = [+ "server",+ "machine",+ "provider",+ "spaces",+ "identity",+ "continuity",+]++const CHANNEL_SCENES: LandingScene[] = ["server", "spaces", "identity", "continuity"]++function channelHeader(markup: string) {+ const headers = markup.match(/<header role="banner"[\s\S]*?<\/header>/g) ?? []+ return headers.find((header) => header.includes('viewBox="7 0 14 24"'))+}++describe("landing community preview rendering", () => {+ it.each(ALL_SCENES)("renders the final %s scene without unresolved fixture identities", (scene) => {+ const markup = renderToStaticMarkup(createElement(LandingShellMotion, {+ scene,+ beat: SCENE_MAX_BEAT[scene],+ }))++ expect(markup).not.toContain("Unknown")+ })++ it.each(CHANNEL_SCENES)("matches the real Text header in the %s scene", (scene) => {+ const markup = renderToStaticMarkup(createElement(LandingShellMotion, {+ scene,+ beat: SCENE_MAX_BEAT[scene],+ }))+ const header = channelHeader(markup)++ expect(header).toBeDefined()+ expect(header).not.toMatch(/aria-label="(?:Gus|Studio|Home|Game Night)"/)+ })++ it("uses the shared mobile Back control and isolated fixture identities", () => {+ const markup = renderToStaticMarkup(createElement(LandingMobileChatMotion, {+ beat: SCENE_MAX_BEAT.server,+ }))+ const header = channelHeader(markup)++ expect(markup).not.toContain("Unknown")+ expect(header).toBeDefined()+ expect(header).toContain('aria-label="Back"')+ expect(header).toMatch(/class="[^"]*size-11[^"]*"/)+ expect(header).not.toContain('aria-label="Gus"')+ })++ it("keeps true mobile header geometry when embedded in a desktop preview", () => {+ const markup = renderToStaticMarkup(createElement(LandingMobileChatMotion, {+ beat: SCENE_MAX_BEAT.server,+ }))+ const header = channelHeader(markup)+ const back = header?.match(/<button[^>]*aria-label="Back"[^>]*>/)?.[0]++ expect(back).toBeDefined()+ expect(back).toContain("size-11")+ expect(back).not.toContain("sm:hidden")+ expect(header).not.toContain("sm:ml-1")+ })+})diff --git a/src/web/src/components/home/landing-shell-motion.tsx b/src/web/src/components/home/landing-shell-motion.tsxindex 7d592e750..1c29d16e0 100644--- a/src/web/src/components/home/landing-shell-motion.tsx+++ b/src/web/src/components/home/landing-shell-motion.tsx@@ -47,11 +47,12 @@ import { BotRuntimeFields } from "@/components/community/bots/bot-runtime-fieldsimport { UserBar } from "@/components/community/shell/user-bar"import { useChannelTree } from "@/components/community/channels/use-channel-tree"import type { Category, Server } from "@/lib/community/models/navigation"-import type { DM } from "@/lib/community/models/people"+import type { CommunityProfile, DM } from "@/lib/community/models/people"import type { RenderMsg } from "@/lib/community/models/message"import type { UnreadServer } from "@/lib/community/models/inbox"import { serializeBeamSeed } from "@/lib/avatar/seed-url"import { tid } from "@/lib/community/testids"+import { CommunityPreviewProfileOwner } from "@/stores/community/profile-preview"import {LANDING_MACHINE_RUNTIMES,LANDING_IDENTITY_MAYA,@@ -447,6 +448,25 @@ const CONTINUITY_LIFE_MESSAGES: RenderMsg[] = [},]+const LANDING_PREVIEW_PROFILES = new Map<string, CommunityProfile>(+ [+ ...MESSAGES,+ ...Object.values(SPACE_MESSAGES).flat(),+ ...Object.values(IDENTITY_MESSAGES).flat(),+ ...DM_MESSAGES,+ ...CONTINUITY_DM_MESSAGES,+ ...CONTINUITY_WORK_MESSAGES,+ ...CONTINUITY_LIFE_MESSAGES,+ ].flatMap((message): [string, CommunityProfile][] => {+ if (!message.authorId || !message.authorName) return []+ return [[message.authorId, {+ id: message.authorId,+ name: message.authorName,+ avatar: message.authorAvatar,+ }]]+ }),+)+const CONTINUITY_WORK_UNREAD: UnreadServer[] = [{serverId: "work",@@ -707,14 +727,16 @@ export function LandingShellMotion({} as CSSProperties}>- <QueryClientProvider client={queryClient}>- <PrototypeShell- scene={scene}- snapshot={visualSnapshot}- machineIntroDescription={machineIntroDescription}- overviewDetails={overviewDetails}- />- </QueryClientProvider>+ <CommunityPreviewProfileOwner profiles={LANDING_PREVIEW_PROFILES}>+ <QueryClientProvider client={queryClient}>+ <PrototypeShell+ scene={scene}+ snapshot={visualSnapshot}+ machineIntroDescription={machineIntroDescription}+ overviewDetails={overviewDetails}+ />+ </QueryClientProvider>+ </CommunityPreviewProfileOwner><MousePointer2aria-hiddendata-testid="landing-motion-cursor"@@ -753,7 +775,7 @@ export function LandingMobileChatMotion({ beat }: { beat: number }) {<divref={stageRef}className={styles.mobileStage}- data-testid="landing-mobile-motion-stage"+ data-testid={tid.landingMobileMotionStage}data-beat={snapshot.beat}aria-hidden>@@ -765,40 +787,43 @@ export function LandingMobileChatMotion({ beat }: { beat: number }) {<span>9:41</span><span>Phone</span></div>- <QueryClientProvider client={queryClient}>- <div className={styles.mobileSurface}>- <ChannelHeader- channel="general"- rightPanel={null}- onToggle={() => {}}- onBack={() => {}}- server={{ id: "gus", name: "Gus", icon: null }}- tools={{ threads: false, pinned: false, members: false }}- />- <div className="flex min-h-0 flex-1 flex-col overflow-hidden">- <div className={`${styles.mobileMessages} flex-1 overflow-hidden px-2 py-2`}>- {MESSAGES.map((message, index) => (- <div- key={message.id}- data-visible={index < snapshot.visibleMessages}- className={styles.messageSlot}- >+ <CommunityPreviewProfileOwner profiles={LANDING_PREVIEW_PROFILES}>+ <QueryClientProvider client={queryClient}>+ <div className={styles.mobileSurface}>+ <ChannelHeader+ channel="general"+ kind="text"+ rightPanel={null}+ onToggle={() => {}}+ mobileBack={() => {}}+ mobileBackDisplay="always"+ tools={{ threads: false, pinned: false, members: false }}+ />+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">+ <div className={`${styles.mobileMessages} flex-1 overflow-hidden px-2 py-2`}>+ {MESSAGES.map((message, index) => (<div- className={targetClass(snapshot, `message-${message.authorId}`)}+ key={message.id}+ data-visible={index < snapshot.visibleMessages}+ className={styles.messageSlot}>- <Message m={message} onOpenThread={() => {}} />+ <div+ className={targetClass(snapshot, `message-${message.authorId}`)}+ >+ <Message m={message} onOpenThread={() => {}} />+ </div></div>- </div>- ))}+ ))}+ </div>+ <PrototypeComposer+ snapshot={snapshot}+ target="composer"+ placeholder="Message /general"+ /></div>- <PrototypeComposer- snapshot={snapshot}- target="composer"- placeholder="Message /general"- /></div>- </div>- </QueryClientProvider>+ </QueryClientProvider>+ </CommunityPreviewProfileOwner></div></div>)@@ -1130,9 +1155,9 @@ function ServerScene({<><ChannelHeaderchannel="general"+ kind="text"rightPanel={null}onToggle={() => {}}- server={{ id: "gus", name: "Gus", icon: null }}/><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><div className="relative flex-1 overflow-hidden px-4 py-3">@@ -1164,7 +1189,6 @@ function ServerScene({function SpacesScene({ snapshot }: { snapshot: SceneSnapshot }) {const room = snapshot.room- const server = SPACE_SERVERS.find((item) => item.id === room) ?? SPACE_SERVERS[0]const channel = SPACE_CHANNELS[room][0]?.channels[0]const messages = SPACE_MESSAGES[room]@@ -1172,9 +1196,9 @@ function SpacesScene({ snapshot }: { snapshot: SceneSnapshot }) {<><ChannelHeaderchannel={channel?.name ?? "general"}+ kind={channel?.type ?? "text"}rightPanel={null}onToggle={() => {}}- server={{ id: server.id, name: server.name, icon: server.icon ?? null }}/><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><div className="flex-1 overflow-hidden px-4 py-3">@@ -1209,16 +1233,15 @@ function SpacesScene({ snapshot }: { snapshot: SceneSnapshot }) {function IdentityScene({ snapshot }: { snapshot: SceneSnapshot }) {const room = snapshot.room- const server = SPACE_SERVERS.find((item) => item.id === room) ?? SPACE_SERVERS[0]const channel = SPACE_CHANNELS[room][0]?.channels[0]return (<><ChannelHeaderchannel={channel?.name ?? "general"}+ kind={channel?.type ?? "text"}rightPanel={null}onToggle={() => {}}- server={{ id: server.id, name: server.name, icon: server.icon ?? null }}/><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><div className="flex-1 overflow-hidden px-4 py-3">@@ -1280,7 +1303,6 @@ function ContinuityScene({ snapshot }: { snapshot: SceneSnapshot }) {}const room = snapshot.room- const server = SPACE_SERVERS.find((item) => item.id === room) ?? SPACE_SERVERS[0]const channel = CONTINUITY_CHANNELS[room][0]?.channels[0]const messages = room === "life"? CONTINUITY_LIFE_MESSAGES@@ -1290,9 +1312,9 @@ function ContinuityScene({ snapshot }: { snapshot: SceneSnapshot }) {<><ChannelHeaderchannel={channel?.name ?? "general"}+ kind={channel?.type ?? "text"}rightPanel={null}onToggle={() => {}}- server={{ id: server.id, name: server.name, icon: server.icon ?? null }}/><div className="flex min-h-0 flex-1 flex-col overflow-hidden"><div className="flex-1 overflow-hidden px-4 py-3">diff --git a/src/web/src/lib/community/testids.test.ts b/src/web/src/lib/community/testids.test.tsindex 388d3d5c5..2e73bcd47 100644--- a/src/web/src/lib/community/testids.test.ts+++ b/src/web/src/lib/community/testids.test.ts@@ -16,6 +16,10 @@ describe("community QA selectors", () => {expect(tid.onboardingIdentityOption("founder")).toBe("community-onboarding-identity-founder")})+ it("exposes the landing mobile motion stage from the canonical registry", () => {+ expect(tid.landingMobileMotionStage).toBe("landing-mobile-motion-stage")+ })+it("exposes the adaptive Inbox surface from the canonical registry", () => {expect(tid.userBar).toBe("community-user-bar")expect(tid.inboxTrigger).toBe("community-inbox-trigger")diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.tsindex 767bea769..0561b6097 100644--- a/src/web/src/lib/community/testids.ts+++ b/src/web/src/lib/community/testids.ts@@ -90,6 +90,7 @@ export const tid = {machineUpdateConfirm: "machine-update-confirm",daemonUpdateNotice: "daemon-update-notice",daemonUpdateAction: "daemon-update-action",+ landingMobileMotionStage: "landing-mobile-motion-stage",homeButton: "community-home-button",alookLogo: "community-alook-logo",botReportProblemItem: "bot-report-problem-item",diff --git a/src/web/src/stores/community/profile-preview.test.ts b/src/web/src/stores/community/profile-preview.test.tsnew file mode 100644index 000000000..9177168ff--- /dev/null+++ b/src/web/src/stores/community/profile-preview.test.ts@@ -0,0 +1,77 @@+import { createElement } from "react"+import TestRenderer, { act } from "react-test-renderer"+import { afterEach, describe, expect, it } from "vitest"+import type { CommunityProfile } from "@/lib/community/models/people"+import { CommunityPreviewProfileOwner } from "./profile-preview"+import {+ useCommunityProfile,+ useCommunityWsStore,+ useProfilesByUserId,+} from "./ws"++const activeRenderers: TestRenderer.ReactTestRenderer[] = []++function ProfileProbe({ userId }: { userId: string }) {+ const profile = useCommunityProfile(userId)+ const profiles = useProfilesByUserId()+ return createElement("output", {+ "data-profile-name": profile?.name,+ "data-map-name": profiles.get(userId)?.name,+ })+}++function renderProbe(userId: string, previewProfiles?: ReadonlyMap<string, CommunityProfile>) {+ const probe = createElement(ProfileProbe, { userId })+ let renderer!: TestRenderer.ReactTestRenderer+ act(() => {+ renderer = TestRenderer.create(+ previewProfiles+ ? createElement(CommunityPreviewProfileOwner, { profiles: previewProfiles }, probe)+ : probe,+ )+ })+ activeRenderers.push(renderer)+ return renderer.root.findByType("output")+}++afterEach(() => {+ act(() => {+ for (const renderer of activeRenderers) renderer.unmount()+ })+ activeRenderers.length = 0+ useCommunityWsStore.getState().reset()+})++describe("CommunityPreviewProfileOwner", () => {+ it("owns profile reads inside its subtree without mutating the live store", () => {+ const liveProfile = { id: "shared", name: "Live name" }+ const liveProfiles = new Map([[liveProfile.id, liveProfile]])+ useCommunityWsStore.setState({ profilesByUserId: liveProfiles })+ const previewProfiles = new Map([["shared", { id: "shared", name: "Preview name" }]])++ const owned = renderProbe("shared", previewProfiles)++ expect(owned.props).toMatchObject({+ "data-profile-name": "Preview name",+ "data-map-name": "Preview name",+ })+ expect(useCommunityWsStore.getState().profilesByUserId).toBe(liveProfiles)+ expect(useCommunityWsStore.getState().profilesByUserId.get("shared")?.name).toBe("Live name")+ })++ it("does not leak live identities into an incomplete preview owner", () => {+ useCommunityWsStore.setState({+ profilesByUserId: new Map([["live-only", { id: "live-only", name: "Live only" }]]),+ })++ const owned = renderProbe("live-only", new Map())+ const live = renderProbe("live-only")++ expect(owned.props["data-profile-name"]).toBeUndefined()+ expect(owned.props["data-map-name"]).toBeUndefined()+ expect(live.props).toMatchObject({+ "data-profile-name": "Live only",+ "data-map-name": "Live only",+ })+ })+})diff --git a/src/web/src/stores/community/profile-preview.tsx b/src/web/src/stores/community/profile-preview.tsxnew file mode 100644index 000000000..ceb66e38e--- /dev/null+++ b/src/web/src/stores/community/profile-preview.tsx@@ -0,0 +1,32 @@+"use client"++import { createContext, useContext, type Context, type ReactNode } from "react"+import type { CommunityProfile } from "@/lib/community/models/people"++type PreviewProfiles = ReadonlyMap<string, CommunityProfile>++let communityPreviewProfilesContext: Context<PreviewProfiles | null> | undefined++function getCommunityPreviewProfilesContext() {+ communityPreviewProfilesContext ??= createContext<PreviewProfiles | null>(null)+ return communityPreviewProfilesContext+}++export function CommunityPreviewProfileOwner({+ profiles,+ children,+}: {+ profiles: PreviewProfiles+ children: ReactNode+}) {+ const CommunityPreviewProfilesContext = getCommunityPreviewProfilesContext()+ return (+ <CommunityPreviewProfilesContext.Provider value={profiles}>+ {children}+ </CommunityPreviewProfilesContext.Provider>+ )+}++export function useCommunityPreviewProfiles() {+ return useContext(getCommunityPreviewProfilesContext())+}diff --git a/src/web/src/stores/community/ws.ts b/src/web/src/stores/community/ws.tsindex d9e5305ba..0832010c6 100644--- a/src/web/src/stores/community/ws.ts+++ b/src/web/src/stores/community/ws.ts@@ -7,6 +7,7 @@ import type {CommunityProfilePatch,CommunityProfileSnapshot,} from "@/lib/community/models/people"+import { useCommunityPreviewProfiles } from "@/stores/community/profile-preview"/*** Zustand store for community WS-live-patched state.@@ -338,13 +339,23 @@ export const useCommunityWsStore = create<CommunityWsStoreState>((set, get) => {// ── Selectors ────────────────────────────────────────────────────────────────export function useCommunityProfile(userId: string | null | undefined) {- return useCommunityWsStore((state) =>- userId ? state.profilesByUserId.get(userId) : undefined,+ const previewProfiles = useCommunityPreviewProfiles()+ const liveProfile = useCommunityWsStore((state) =>+ previewProfiles || !userId+ ? undefined+ : state.profilesByUserId.get(userId),)+ return previewProfiles && userId+ ? previewProfiles.get(userId)+ : liveProfile}export function useProfilesByUserId(): ReadonlyMap<string, CommunityProfile> {- return useCommunityWsStore((state) => state.profilesByUserId)+ const previewProfiles = useCommunityPreviewProfiles()+ const liveProfiles = useCommunityWsStore((state) =>+ previewProfiles ? null : state.profilesByUserId,+ )+ return previewProfiles ?? liveProfiles!}const EMPTY_AUDIT_EVENTS: BotAuditEventEntry[] = []diff --git a/src/web/src/test/e2e-ui/19-marketing-seo.spec.ts b/src/web/src/test/e2e-ui/19-marketing-seo.spec.tsindex 62f0c4ac5..f4d3b0fce 100644--- a/src/web/src/test/e2e-ui/19-marketing-seo.spec.ts+++ b/src/web/src/test/e2e-ui/19-marketing-seo.spec.ts@@ -1,4 +1,5 @@import { expect, test } from "./_fixtures/community-fixture"+import { tid } from "./_fixtures/testids"test("homepage SSR keeps product demos out of the heading tree", async ({ page, request }) => {const response = await request.get("/")@@ -14,3 +15,42 @@ test("homepage SSR keeps product demos out of the heading tree", async ({ page,expect(counts).toEqual({ h1: 1, demoHeadings: 0 })})++test("desktop landing keeps the embedded phone Back control on true mobile geometry", async ({ page }) => {+ await page.setViewportSize({ width: 1280, height: 900 })+ await page.emulateMedia({ reducedMotion: "reduce" })+ await page.goto("/")++ const stage = page.getByTestId(tid.landingMobileMotionStage)+ await stage.scrollIntoViewIfNeeded()+ const back = stage.locator('button[aria-label="Back"]')+ await expect(back).toBeVisible()+ await expect.poll(() => stage.evaluate((stageElement) => {+ const canvas = stageElement.firstElementChild+ if (!(canvas instanceof HTMLElement)) return false+ return Math.abs(canvas.getBoundingClientRect().width - stageElement.getBoundingClientRect().width) < 0.5+ })).toBe(true)++ const metrics = await stage.evaluate((stageElement) => {+ const backElement = stageElement.querySelector<HTMLElement>('button[aria-label="Back"]')+ const identityElement = stageElement.querySelector<HTMLElement>('[data-slot="message-header-identity"]')+ const canvas = stageElement.firstElementChild as HTMLElement | null+ if (!backElement || !identityElement || !canvas) return null+ const backRect = backElement.getBoundingClientRect()+ const identityRect = identityElement.getBoundingClientRect()+ const scale = canvas.getBoundingClientRect().width / canvas.offsetWidth+ return {+ backDisplay: getComputedStyle(backElement).display,+ backOffset: [backElement.offsetWidth, backElement.offsetHeight],+ backRect: [backRect.width / scale, backRect.height / scale],+ identityGap: (identityRect.left - backRect.right) / scale,+ }+ })++ expect(metrics).not.toBeNull()+ expect(metrics?.backDisplay).not.toBe("none")+ expect(metrics?.backOffset).toEqual([44, 44])+ expect(metrics?.backRect[0]).toBeCloseTo(44, 1)+ expect(metrics?.backRect[1]).toBeCloseTo(44, 1)+ expect(metrics?.identityGap).toBeCloseTo(4, 1)+})