Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(web): guide signup and improve reconnect recovery (#559)

Gustavo Ye851b9d23e6ba
diff --git a/scripts/ci/e2e-shards.mjs b/scripts/ci/e2e-shards.mjs
index 6e83800fd..c652678f6 100644
--- a/scripts/ci/e2e-shards.mjs
+++ b/scripts/ci/e2e-shards.mjs
@@ -32,7 +32,8 @@ export const SPEC_SECONDS = {
"22-committed-message-delivery.spec.ts": 85,
"23-message-selection-context-menu.spec.ts": 10,
"24-composer-overflow.spec.ts": 35,
- "25-composer-accessory-rail-occupancy.spec.ts": 60,
+ "25-community-ws-reconnect-overlay.spec.ts": 60,
+ "25-composer-accessory-rail-occupancy.spec.ts": 95,
"26-mobile-forum-post-actions.spec.ts": 45,
"27-canonical-forum-post-delete.spec.ts": 30,
"28-community-delete-media-cleanup.spec.ts": 45,
@@ -40,6 +41,7 @@ export const SPEC_SECONDS = {
"29-multi-device-read-state.spec.ts": 45,
"30-bot-profile-audit-preview.spec.ts": 35,
"31-mention-candidate-pagination.spec.ts": 10,
+ "31-machine-guide-motion.spec.ts": 10,
"32-mobile-ws-foreground-validation.spec.ts": 80,
"33-picker-async-layout.spec.ts": 57,
"34-inbox-read-race.spec.ts": 42,
diff --git a/scripts/ci/e2e-shards.test.ts b/scripts/ci/e2e-shards.test.ts
index 2fa90c278..e17eaaac0 100644
--- a/scripts/ci/e2e-shards.test.ts
+++ b/scripts/ci/e2e-shards.test.ts
@@ -70,7 +70,7 @@ describe("planE2eShards", () => {
expect(first).toHaveLength(E2E_SHARD_COUNT)
expect([...assigned].sort()).toEqual(specs)
expect(new Set(assigned).size).toBe(specs.length)
- expect(totals.sort((left, right) => left - right)).toEqual([256, 256, 257, 259, 259])
+ expect(totals.sort((left, right) => left - right)).toEqual([276, 277, 278, 280, 281])
expect(Math.max(...totals) / Math.min(...totals)).toBeLessThanOrEqual(1.15)
})
diff --git a/src/web/src/app/c/community-shell.tsx b/src/web/src/app/c/community-shell.tsx
index 6413cf4d7..3be0668bd 100644
--- a/src/web/src/app/c/community-shell.tsx
+++ b/src/web/src/app/c/community-shell.tsx
@@ -13,6 +13,7 @@ import { useCommunityWs } from "@/hooks/community/use-community-ws"
import { useCommunityWsStore } from "@/stores/community/ws"
import { PerfTraceBootstrap } from "@/components/perf/perf-trace-bootstrap"
import { CommunityOnboardingGuide } from "@/components/community/onboarding/community-onboarding-guide"
+import { CommunityWsReconnectBoundary } from "@/components/community/shell/community-ws-reconnect-overlay"
/**
* Client wrapper that provides the QueryClient, CurrentUser, and the
@@ -88,8 +89,10 @@ function CommunityBootstrap({ children }: { children: ReactNode }) {
return (
<>
<PerfTraceBootstrap />
- <CommunityOnboardingGuide />
- {children}
+ <CommunityWsReconnectBoundary>
+ <CommunityOnboardingGuide />
+ {children}
+ </CommunityWsReconnectBoundary>
</>
)
}
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index 1ce99ec4c..a4910a1a0 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -83,6 +83,60 @@
display: none;
}
+.community-ws-connecting-loader {
+ display: grid;
+ width: 100px;
+ aspect-ratio: 1;
+ box-sizing: border-box;
+ padding: 10px;
+ background: var(--background);
+ filter: blur(5px) contrast(10);
+ mix-blend-mode: darken;
+}
+
+.dark .community-ws-connecting-loader {
+ mix-blend-mode: lighten;
+}
+
+.community-ws-connecting-loader::before,
+.community-ws-connecting-loader::after {
+ grid-area: 1 / 1;
+ background:
+ linear-gradient(var(--primary) 0 0) left,
+ linear-gradient(var(--primary) 0 0) right;
+ background-size: 20px 40px;
+ background-origin: content-box;
+ background-repeat: no-repeat;
+ content: "";
+}
+
+.community-ws-connecting-loader::after {
+ width: 20px;
+ height: 20px;
+ margin: auto 0;
+ border-radius: 50%;
+ background: var(--primary);
+ animation: community-ws-connecting 1s infinite;
+}
+
+body.driver-active .community-ws-reconnect-overlay,
+body.driver-active .community-ws-reconnect-overlay * {
+ pointer-events: auto;
+}
+
+@keyframes community-ws-connecting {
+ 90%,
+ 100% {
+ transform: translateX(300%);
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .community-ws-connecting-loader::after {
+ animation: none;
+ }
+}
+
.community-guide-me {
position: relative;
display: inline-flex;
@@ -97,6 +151,25 @@
animation: community-guide-me-orbit 4.8s linear infinite;
}
+.community-guide-me-orbit-holder {
+ position: absolute;
+ inset: 0;
+ pointer-events: none;
+}
+
+.community-guide-me-orbit-holder.is-intro {
+ opacity: 0;
+}
+
+.community-guide-me-orbit-holder.is-intro.is-ready {
+ animation: community-first-signup-orbit-handoff 4s linear forwards;
+}
+
+.community-guide-me-orbit-holder.is-intro .community-guide-me-orbit,
+.community-guide-me-orbit-holder.is-intro .community-guide-me-avatar {
+ animation-play-state: paused;
+}
+
.community-guide-me-avatar {
position: absolute;
top: -3px;
@@ -123,6 +196,186 @@
}
}
+.community-first-signup-guide {
+ --guide-end-scale: 0.1875;
+ --guide-clearance-scale: 0.3076923077;
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 40;
+ display: inline-flex;
+ width: 128px;
+ height: 128px;
+ opacity: 0;
+ pointer-events: none;
+ offset-anchor: top left;
+ offset-distance: 0%;
+ offset-rotate: 0deg;
+ will-change: offset-distance, opacity, translate;
+}
+
+.community-first-signup-guide.is-ready {
+ animation: community-first-signup-guide-travel 4s linear both;
+}
+
+.community-first-signup-guide-scale {
+ display: inline-flex;
+ width: 100%;
+ height: 100%;
+ transform-origin: top left;
+ will-change: transform;
+}
+
+.community-first-signup-guide-art {
+ display: inline-flex;
+ width: 100%;
+ height: 100%;
+ transform-origin: 50% 100%;
+ will-change: transform;
+}
+
+.community-first-signup-guide .alook-avatar-eyes {
+ transform-box: fill-box;
+ transform-origin: center;
+ will-change: transform;
+}
+
+.community-first-signup-guide.is-ready .community-first-signup-guide-art {
+ animation: community-first-signup-guide-body 4s linear both;
+}
+
+.community-first-signup-guide.is-ready .community-first-signup-guide-scale {
+ animation: community-first-signup-guide-scale 4s linear both;
+}
+
+.community-first-signup-guide.is-ready .alook-avatar-eyes {
+ animation: community-first-signup-guide-eyes 4s linear both;
+}
+
+@keyframes community-first-signup-guide-travel {
+ 0% {
+ opacity: 0;
+ offset-distance: 0%;
+ translate: 0 18px;
+ animation-timing-function: var(--ease-out);
+ }
+
+ 7.5%, 62.5% {
+ opacity: 1;
+ offset-distance: 0%;
+ translate: 0 0;
+ }
+
+ 67.5% {
+ opacity: 1;
+ offset-distance: 0%;
+ translate: 0 0;
+ animation-timing-function: var(--guide-flight-ease);
+ }
+
+ 97.5% {
+ opacity: 1;
+ offset-distance: 100%;
+ translate: 0 0;
+ }
+
+ 100% {
+ opacity: 0;
+ offset-distance: 100%;
+ translate: 0 0;
+ }
+}
+
+@keyframes community-first-signup-guide-eyes {
+ 0% { transform: translateX(0); }
+ 11% {
+ transform: translateX(0);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 19% {
+ transform: translateX(-3px);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 30% { transform: translateX(0); }
+ 36% {
+ transform: translateX(0);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 44% {
+ transform: translateX(3px);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 55%, 100% { transform: translateX(0); }
+}
+
+@keyframes community-first-signup-guide-body {
+ 0%, 32%, 94%, 100% {
+ transform: none;
+ }
+
+ 13%, 38% {
+ transform: none;
+ animation-timing-function: var(--ease-out);
+ }
+
+ 17%, 28% {
+ transform: rotate(-5deg) scaleX(0.94) scaleY(1.04);
+ }
+
+ 42%, 55% {
+ transform: rotate(5deg) scaleX(0.94) scaleY(1.04);
+ }
+
+ 62.5% {
+ transform: none;
+ animation-timing-function: var(--ease-in);
+ }
+
+ 67.5% {
+ transform: translateY(5px) scaleX(1.04) scaleY(0.92);
+ animation-timing-function: var(--guide-flight-ease);
+ }
+
+ 74%, 88% {
+ transform: scaleX(0.96) scaleY(1.06);
+ }
+}
+
+@keyframes community-first-signup-guide-scale {
+ 0%, 67.5% {
+ transform: scale(1);
+ animation-timing-function: var(--guide-flight-ease);
+ }
+
+ 97.5%, 100% {
+ transform: scale(var(--guide-end-scale));
+ }
+}
+
+@keyframes community-first-signup-guide-scale-mobile {
+ 0%, 67.5% {
+ transform: scale(1);
+ animation-timing-function: var(--guide-flight-ease);
+ }
+
+ 82% {
+ transform: scale(var(--guide-clearance-scale));
+ animation-timing-function: var(--guide-flight-ease);
+ }
+
+ 97.5%, 100% {
+ transform: scale(var(--guide-end-scale));
+ }
+}
+
+@keyframes community-first-signup-orbit-handoff {
+ 0% { opacity: 0; }
+ 97.4% {
+ opacity: 0;
+ }
+ 97.5%, 100% { opacity: 1; }
+}
+
.driver-popover.community-onboarding-popover .driver-popover-arrow-side-left {
border-left-color: var(--card);
}
@@ -287,11 +540,46 @@ body.community-onboarding-active.driver-active :is(
}
@media (max-width: 639px) {
+ .community-first-signup-guide {
+ width: 104px;
+ height: 104px;
+ }
+
+ .community-first-signup-guide .alook-avatar-eyes {
+ animation-name: community-first-signup-guide-eyes-mobile;
+ }
+
+ .community-first-signup-guide.is-ready .community-first-signup-guide-scale {
+ animation-name: community-first-signup-guide-scale-mobile;
+ }
+
.community-onboarding-card {
padding: 11px 12px;
}
}
+@keyframes community-first-signup-guide-eyes-mobile {
+ 0% { transform: translateX(0); }
+ 11% {
+ transform: translateX(0);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 19% {
+ transform: translateX(-2px);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 30% { transform: translateX(0); }
+ 36% {
+ transform: translateX(0);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 44% {
+ transform: translateX(2px);
+ animation-timing-function: var(--ease-in-out);
+ }
+ 55%, 100% { transform: translateX(0); }
+}
+
@media (max-height: 520px) {
.community-onboarding-card {
padding: 8px 10px;
@@ -299,6 +587,14 @@ body.community-onboarding-active.driver-active :is(
}
@media (prefers-reduced-motion: reduce) {
+ .community-first-signup-guide {
+ display: none;
+ }
+
+ .community-guide-me-orbit-holder.is-intro.is-ready {
+ animation: community-first-signup-orbit-reduced 120ms var(--ease-out) forwards;
+ }
+
.community-guide-me-orbit,
.community-guide-me-avatar {
animation: none;
@@ -329,7 +625,16 @@ body.community-onboarding-active.driver-active :is(
}
}
+@keyframes community-first-signup-orbit-reduced {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+
:root {
+ --guide-flight-ease: cubic-bezier(0.45, 0, 0.2, 1);
+ --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
+ --ease-in: cubic-bezier(0.8, 0, 0.8, 0.2);
+ --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
--community-onboarding-overlay: oklch(0.18 0.03 230);
--background: oklch(1 0 0);
--app-bg: var(--background);
diff --git a/src/web/src/components/avatar/generated-avatar.tsx b/src/web/src/components/avatar/generated-avatar.tsx
index 2534520b2..b72cf062d 100644
--- a/src/web/src/components/avatar/generated-avatar.tsx
+++ b/src/web/src/components/avatar/generated-avatar.tsx
@@ -5,16 +5,18 @@ export function GeneratedAvatar({
seed,
size = 40,
className,
+ motionParts = false,
}: {
seed: string
size?: number | string
className?: string
+ motionParts?: boolean
}) {
return (
<span className={cn("inline-flex overflow-hidden align-middle", className)} style={{ width: size, height: size }}>
<span
className="size-full [&>svg]:block [&>svg]:size-full"
- dangerouslySetInnerHTML={{ __html: renderFaceSvg(seed) }}
+ dangerouslySetInnerHTML={{ __html: renderFaceSvg(seed, { motionParts }) }}
/>
</span>
)
diff --git a/src/web/src/components/community/machines/guide-me-avatar-motion.test.ts b/src/web/src/components/community/machines/guide-me-avatar-motion.test.ts
new file mode 100644
index 000000000..f0fba5a0b
--- /dev/null
+++ b/src/web/src/components/community/machines/guide-me-avatar-motion.test.ts
@@ -0,0 +1,123 @@
+import { readFileSync } from "node:fs"
+import React from "react"
+import TestRenderer, { act } from "react-test-renderer"
+import { describe, expect, it, vi } from "vitest"
+import { tid } from "@/lib/community/testids"
+import {
+ GuideMeAvatarMotion,
+ guideMotionGeometry,
+ guideMotionPath,
+ scheduleAfterStablePaint,
+} from "./guide-me-avatar-motion"
+
+describe("first-signup guide avatar motion", () => {
+ it("lands a large avatar exactly on the existing orbit avatar", () => {
+ const geometry = guideMotionGeometry(
+ { left: 100, top: 80, right: 900, bottom: 680, width: 800, height: 600 },
+ { left: 610, top: 300, right: 634, bottom: 324, width: 24, height: 24 },
+ 128,
+ )
+
+ expect(geometry).toMatchObject({
+ startX: 164,
+ startY: 492,
+ controlX: 395.92,
+ endX: 610,
+ endY: 300,
+ endScale: 0.1875,
+ })
+ expect(geometry.controlY).toBeCloseTo(175.12)
+ expect(guideMotionPath(geometry)).toBe(
+ 'path("M 164 492 Q 395.92 175.12, 610 300")',
+ )
+ })
+
+ it("uses the rendered mobile avatar size when calculating the handoff scale", () => {
+ const geometry = guideMotionGeometry(
+ { left: 0, top: 0, right: 390, bottom: 700, width: 390, height: 700 },
+ { left: 280, top: 410, right: 304, bottom: 434, width: 24, height: 24 },
+ 104,
+ )
+
+ expect(geometry.startX).toBe(31.2)
+ expect(geometry.startY).toBe(532)
+ expect(geometry.controlX).toBeCloseTo(205.36)
+ expect(geometry.controlY).toBeCloseTo(500.28)
+ expect(geometry.control2X).toBeCloseTo(250.144)
+ expect(geometry.control2Y).toBeCloseTo(480.76)
+ expect(geometry.endScale).toBeCloseTo(24 / 104)
+ expect(geometry.clearanceScale).toBeCloseTo(32 / 104)
+ expect(guideMotionPath(geometry)).toBe(
+ 'path("M 31.2 532 C 205.35999999999999 500.28, 250.144 480.76, 280 410")',
+ )
+ })
+
+ it("waits for two animation frames so the empty state paints before motion starts", () => {
+ const frames = new Map<number, FrameRequestCallback>()
+ let nextFrame = 0
+ const scheduler = {
+ requestAnimationFrame: vi.fn((callback: FrameRequestCallback) => {
+ nextFrame += 1
+ frames.set(nextFrame, callback)
+ return nextFrame
+ }),
+ cancelAnimationFrame: vi.fn((frame: number) => {
+ frames.delete(frame)
+ }),
+ }
+ const start = vi.fn()
+
+ const cancel = scheduleAfterStablePaint(start, scheduler)
+
+ expect(start).not.toHaveBeenCalled()
+ const firstFrame = frames.get(1)!
+ frames.delete(1)
+ firstFrame(16)
+ expect(start).not.toHaveBeenCalled()
+
+ const secondFrame = frames.get(2)!
+ frames.delete(2)
+ secondFrame(32)
+ expect(start).toHaveBeenCalledOnce()
+
+ cancel()
+ expect(scheduler.cancelAnimationFrame).toHaveBeenCalledWith(1)
+ expect(scheduler.cancelAnimationFrame).toHaveBeenCalledWith(2)
+ })
+
+ it("uses phase easings for the one-shot NPC motion while leaving orbit linear", () => {
+ const styles = readFileSync(new URL("../../../app/globals.css", import.meta.url), "utf8")
+
+ expect(styles).toContain(
+ "animation: community-guide-me-orbit 4.8s linear infinite;",
+ )
+ expect(styles).toContain(
+ "animation: community-first-signup-guide-travel 4s linear both;",
+ )
+ expect(styles).toContain("offset-distance: 100%;")
+ expect(styles).toContain("animation-timing-function: var(--ease-out);")
+ expect(styles).toContain("animation-timing-function: var(--ease-in);")
+ expect(styles).toContain("transform: translateX(-3px);")
+ expect(styles).toContain("transform: translateX(2px);")
+ expect(styles).toContain("animation-timing-function: var(--guide-flight-ease);")
+ expect(styles).toContain("animation-name: community-first-signup-guide-scale-mobile;")
+ expect(styles).toContain("transform: scale(var(--guide-clearance-scale));")
+ })
+
+ it("exposes stable QA targets for the travelling avatar and exact orbit landing point", async () => {
+ let renderer!: TestRenderer.ReactTestRenderer
+ await act(async () => {
+ renderer = TestRenderer.create(
+ React.createElement(GuideMeAvatarMotion, {
+ seed: "same-guide-face",
+ intro: true,
+ stageRef: { current: null },
+ onIntroComplete: vi.fn(),
+ }),
+ )
+ })
+
+ expect(renderer.root.findByProps({ "data-testid": tid.machineFirstSignupGuide })).toBeTruthy()
+ expect(renderer.root.findByProps({ "data-testid": tid.machineGuideAvatarTarget })).toBeTruthy()
+ })
+})
diff --git a/src/web/src/components/community/machines/guide-me-avatar-motion.tsx b/src/web/src/components/community/machines/guide-me-avatar-motion.tsx
new file mode 100644
index 000000000..362932c71
--- /dev/null
+++ b/src/web/src/components/community/machines/guide-me-avatar-motion.tsx
@@ -0,0 +1,180 @@
+"use client"
+
+import { useEffect, useRef, useState, type AnimationEvent, type RefObject } from "react"
+import { GeneratedAvatar } from "@/components/avatar"
+import { tid } from "@/lib/community/testids"
+
+const REDUCED_MOTION_MS = 140
+
+type AnimationFrameScheduler = Pick<Window, "requestAnimationFrame" | "cancelAnimationFrame">
+
+export function scheduleAfterStablePaint(
+ callback: () => void,
+ scheduler: AnimationFrameScheduler = window,
+) {
+ let secondFrame: number | null = null
+ const firstFrame = scheduler.requestAnimationFrame(() => {
+ secondFrame = scheduler.requestAnimationFrame(callback)
+ })
+
+ return () => {
+ scheduler.cancelAnimationFrame(firstFrame)
+ if (secondFrame !== null) scheduler.cancelAnimationFrame(secondFrame)
+ }
+}
+
+type Rect = Pick<DOMRect, "left" | "top" | "right" | "bottom" | "width" | "height">
+
+export type GuideMotionGeometry = {
+ startX: number
+ startY: number
+ controlX: number
+ controlY: number
+ control2X?: number
+ control2Y?: number
+ endX: number
+ endY: number
+ endScale: number
+ clearanceScale: number
+}
+
+export function guideMotionGeometry(
+ stage: Rect,
+ landing: Rect,
+ avatarSize: number,
+): GuideMotionGeometry {
+ const sideInset = Math.min(96, Math.max(24, stage.width * 0.08))
+ const bottomInset = Math.min(64, Math.max(24, stage.height * 0.1))
+ const startX = stage.left + sideInset
+ const startY = stage.bottom - avatarSize - bottomInset
+ const endX = landing.left
+ const endY = landing.top
+ const distanceX = endX - startX
+ const distanceY = startY - endY
+ const arcLift = Math.min(180, Math.max(72, Math.abs(distanceX) * 0.28))
+ const mobile = avatarSize < 128
+
+ return {
+ startX,
+ startY,
+ controlX: mobile ? startX + distanceX * 0.7 : startX + distanceX * 0.52,
+ controlY: mobile
+ ? startY - distanceY * 0.26
+ : Math.min(startY, endY) - arcLift,
+ control2X: mobile ? startX + distanceX * 0.88 : undefined,
+ control2Y: mobile ? startY - distanceY * 0.42 : undefined,
+ endX,
+ endY,
+ endScale: landing.width / avatarSize,
+ clearanceScale: Math.min(1, 32 / avatarSize),
+ }
+}
+
+export function guideMotionPath(geometry: GuideMotionGeometry): string {
+ if (geometry.control2X !== undefined && geometry.control2Y !== undefined) {
+ return `path("M ${geometry.startX} ${geometry.startY} C ${geometry.controlX} ${geometry.controlY}, ${geometry.control2X} ${geometry.control2Y}, ${geometry.endX} ${geometry.endY}")`
+ }
+ return `path("M ${geometry.startX} ${geometry.startY} Q ${geometry.controlX} ${geometry.controlY}, ${geometry.endX} ${geometry.endY}")`
+}
+
+export function GuideMeAvatarMotion({
+ seed,
+ intro,
+ stageRef,
+ onIntroComplete,
+}: {
+ seed: string
+ intro: boolean
+ stageRef: RefObject<HTMLElement | null>
+ onIntroComplete: () => void
+}) {
+ const introRef = useRef<HTMLSpanElement>(null)
+ const landingRef = useRef<HTMLSpanElement>(null)
+ const [ready, setReady] = useState(false)
+
+ useEffect(() => {
+ if (!intro) {
+ setReady(false)
+ return
+ }
+ const stage = stageRef.current
+ const avatar = introRef.current
+ const landing = landingRef.current
+ if (!stage || !avatar || !landing) return
+
+ let reducedTimer: number | undefined
+ const cancelStablePaint = scheduleAfterStablePaint(() => {
+ const avatarSize = avatar.getBoundingClientRect().width
+ const geometry = guideMotionGeometry(
+ stage.getBoundingClientRect(),
+ landing.getBoundingClientRect(),
+ avatarSize,
+ )
+ avatar.style.offsetPath = guideMotionPath(geometry)
+ avatar.style.setProperty("--guide-end-scale", String(geometry.endScale))
+ avatar.style.setProperty("--guide-clearance-scale", String(geometry.clearanceScale))
+
+ setReady(true)
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
+ reducedTimer = window.setTimeout(onIntroComplete, REDUCED_MOTION_MS)
+ }
+ })
+
+ return () => {
+ cancelStablePaint()
+ if (reducedTimer !== undefined) window.clearTimeout(reducedTimer)
+ }
+ }, [intro, onIntroComplete, stageRef])
+
+ const handleAnimationEnd = (event: AnimationEvent<HTMLSpanElement>) => {
+ if (
+ event.target === event.currentTarget &&
+ event.animationName === "community-first-signup-guide-travel"
+ ) {
+ onIntroComplete()
+ }
+ }
+
+ return (
+ <>
+ <span
+ className={`community-guide-me-orbit-holder${intro ? " is-intro" : ""}${ready ? " is-ready" : ""}`}
+ aria-hidden="true"
+ >
+ <span className="community-guide-me-orbit">
+ <span
+ ref={landingRef}
+ className="community-guide-me-avatar"
+ data-testid={tid.machineGuideAvatarTarget}
+ >
+ <GeneratedAvatar
+ seed={seed}
+ size={24}
+ className="rounded-full ring-2 ring-background shadow-sm"
+ />
+ </span>
+ </span>
+ </span>
+ {intro ? (
+ <span
+ ref={introRef}
+ className={`community-first-signup-guide${ready ? " is-ready" : ""}`}
+ data-testid={tid.machineFirstSignupGuide}
+ aria-hidden="true"
+ onAnimationEnd={handleAnimationEnd}
+ >
+ <span className="community-first-signup-guide-scale">
+ <span className="community-first-signup-guide-art">
+ <GeneratedAvatar
+ seed={seed}
+ size="100%"
+ motionParts
+ className="rounded-full ring-2 ring-background shadow-lg"
+ />
+ </span>
+ </span>
+ </span>
+ ) : null}
+ </>
+ )
+}
diff --git a/src/web/src/components/community/machines/machine-list.test.ts b/src/web/src/components/community/machines/machine-list.test.ts
index 5573ffe5b..ed14103c4 100644
--- a/src/web/src/components/community/machines/machine-list.test.ts
+++ b/src/web/src/components/community/machines/machine-list.test.ts
@@ -8,6 +8,7 @@ const mocks = vi.hoisted(() => ({
toastError: vi.fn(),
fetchLatestDaemonVersion: vi.fn(),
machinesLoading: { current: false },
+ onboardingState: { current: "done" as unknown },
}))
vi.mock("sonner", () => ({
@@ -57,6 +58,10 @@ vi.mock("@/components/ui/skeleton", () => ({
Skeleton: (props: Record<string, unknown>) => React.createElement("skeleton-row", props),
}))
vi.mock("@/components/avatar", () => ({ GeneratedAvatar: () => null }))
+vi.mock("./guide-me-avatar-motion", () => ({
+ GuideMeAvatarMotion: (props: Record<string, unknown>) =>
+ React.createElement("guide-avatar-motion", props),
+}))
vi.mock("./machine-card", () => ({ MachineCard: () => null }))
vi.mock("./pair-machine-sheet", () => ({ PairMachineSheet: () => null }))
vi.mock("@/components/community/onboarding-tiles/connect-tile", () => ({ ConnectTile: () => null }))
@@ -73,7 +78,7 @@ vi.mock("@/lib/community-onboarding", () => ({
readCommunityOnboardingState: vi.fn(() => null),
startCommunityOnboarding: vi.fn(),
updateCommunityOnboardingResources: vi.fn(),
- useCommunityOnboarding: () => "done",
+ useCommunityOnboarding: () => mocks.onboardingState.current,
}))
vi.mock("@/lib/api/config", () => ({
fetchLatestDaemonVersion: mocks.fetchLatestDaemonVersion,
@@ -111,6 +116,29 @@ describe("machine daemon update UI", () => {
package: "@alook/daemon",
})
mocks.machinesLoading.current = false
+ mocks.onboardingState.current = "done"
+ })
+
+ it("plays the guide once per empty-page mount and replays after remount", async () => {
+ mocks.onboardingState.current = null
+
+ let renderer!: TestRenderer.ReactTestRenderer
+ await act(async () => {
+ renderer = TestRenderer.create(React.createElement(MachineList))
+ })
+
+ const firstVisit = renderer.root.findByType("guide-avatar-motion")
+ expect(firstVisit.props.intro).toBe(true)
+ expect(firstVisit.props.seed).toMatch(/^alook-guide-/)
+
+ act(() => firstVisit.props.onIntroComplete())
+ expect(renderer.root.findByType("guide-avatar-motion").props.intro).toBe(false)
+
+ act(() => renderer.unmount())
+ await act(async () => {
+ renderer = TestRenderer.create(React.createElement(MachineList))
+ })
+ expect(renderer.root.findByType("guide-avatar-motion").props.intro).toBe(true)
})
it("loads Community update eligibility from the daemon package endpoint", async () => {
diff --git a/src/web/src/components/community/machines/machine-list.tsx b/src/web/src/components/community/machines/machine-list.tsx
index 7966cef46..00470f2e7 100644
--- a/src/web/src/components/community/machines/machine-list.tsx
+++ b/src/web/src/components/community/machines/machine-list.tsx
@@ -14,7 +14,6 @@ import {
import { Button } from "@/components/ui/button"
import { Card } from "@/components/ui/card"
import { Skeleton } from "@/components/ui/skeleton"
-import { GeneratedAvatar } from "@/components/avatar"
import {
AlertDialog,
AlertDialogContent,
@@ -45,6 +44,7 @@ import {
useCommunityOnboarding,
} from "@/lib/community-onboarding"
import { removeCommunityParam } from "@/lib/community/community-route"
+import { GuideMeAvatarMotion } from "./guide-me-avatar-motion"
// Loading placeholder shaped like a real MachineCard (size-10 rounded-xl icon +
// name row + meta lines + trailing kebab slot) so the list doesn't reflow when
@@ -189,6 +189,8 @@ export function MachineList({ onBack }: { onBack?: () => void } = {}) {
const [confirmUpdate, setConfirmUpdate] = useState<CommunityMachineSummary | null>(null)
const [latestVersion, setLatestVersion] = useState<string | null>(null)
const [guideAvatarSeed, setGuideAvatarSeed] = useState("alook-guide")
+ const [guideIntroActive, setGuideIntroActive] = useState(true)
+ const emptyStageRef = useRef<HTMLDivElement>(null)
const onboardingState = useCommunityOnboarding()
const controllerMode = getAppMode()
@@ -329,6 +331,10 @@ export function MachineList({ onBack }: { onBack?: () => void } = {}) {
void requestMachineUpdate(machine.id)
}, [])
+ const finishGuideIntro = useCallback(() => {
+ setGuideIntroActive(false)
+ }, [])
+
const botsToDelete = confirmDelete
? bots.filter((b) => b.machineId === confirmDelete.id)
: []
@@ -343,7 +349,7 @@ export function MachineList({ onBack }: { onBack?: () => void } = {}) {
return (
<div className="flex min-h-0 flex-1 flex-col">
{backBar}
- <div className="flex flex-1 flex-col items-center justify-center gap-4 p-12 text-center">
+ <div ref={emptyStageRef} className="flex flex-1 flex-col items-center justify-center gap-4 p-12 text-center">
<div className="w-full max-w-70 overflow-hidden rounded-xl">
<div className="aspect-200/130 w-full">
<ConnectTile />
@@ -366,15 +372,12 @@ export function MachineList({ onBack }: { onBack?: () => void } = {}) {
</Button>
<span className="community-guide-me">
{onboardingState === null ? (
- <span className="community-guide-me-orbit" aria-hidden="true">
- <span className="community-guide-me-avatar">
- <GeneratedAvatar
- seed={guideAvatarSeed}
- size={24}
- className="rounded-full ring-2 ring-background shadow-sm"
- />
- </span>
- </span>
+ <GuideMeAvatarMotion
+ seed={guideAvatarSeed}
+ intro={guideIntroActive}
+ stageRef={emptyStageRef}
+ onIntroComplete={finishGuideIntro}
+ />
) : null}
<Button
variant="ghost"
diff --git a/src/web/src/components/community/messages/composer-accessory-rail-layout.test.ts b/src/web/src/components/community/messages/composer-accessory-rail-layout.test.ts
index a2c83f1d2..f9cb3fd67 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail-layout.test.ts
+++ b/src/web/src/components/community/messages/composer-accessory-rail-layout.test.ts
@@ -6,29 +6,18 @@ import {
describe("allocateComposerAccessoryRail", () => {
it.each([
- [false, false, false, "empty"],
- [true, false, false, "left-only"],
- [false, true, false, "centered"],
- [false, false, true, "right-only"],
- [true, true, false, "centered"],
- [true, false, true, "left-right"],
- [false, true, true, "centered"],
- [true, true, true, "centered"],
- ] satisfies Array<[boolean, boolean, boolean, ComposerAccessoryRailLayout]>) (
- "maps normal left=%s center=%s right=%s to %s",
- (left, center, right, expected) => {
- expect(allocateComposerAccessoryRail({ mode: "normal", left, center, right }))
- .toBe(expected)
+ [false, false, "empty"],
+ [true, false, "left-only"],
+ [false, true, "centered"],
+ [true, true, "centered"],
+ ] satisfies Array<[boolean, boolean, ComposerAccessoryRailLayout]>) (
+ "maps normal left=%s center=%s to %s",
+ (left, center, expected) => {
+ expect(allocateComposerAccessoryRail({ mode: "normal", left, center })).toBe(expected)
},
)
- it.each([
- [false, false],
- [true, false],
- [false, true],
- [true, true],
- ])("keeps selection centered for left=%s right=%s", (left, right) => {
- expect(allocateComposerAccessoryRail({ mode: "selection", left, right }))
- .toBe("centered")
+ it("keeps selection centered independently of side occupancy", () => {
+ expect(allocateComposerAccessoryRail({ mode: "selection" })).toBe("centered")
})
})
diff --git a/src/web/src/components/community/messages/composer-accessory-rail-layout.ts b/src/web/src/components/community/messages/composer-accessory-rail-layout.ts
index 41089f569..ab1fc9151 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail-layout.ts
+++ b/src/web/src/components/community/messages/composer-accessory-rail-layout.ts
@@ -3,27 +3,21 @@ export type ComposerAccessoryRailOccupancy =
mode: "normal"
left: boolean
center: boolean
- right: boolean
}
| {
mode: "selection"
- left: boolean
- right: boolean
}
export type ComposerAccessoryRailLayout =
| "empty"
| "centered"
- | "left-right"
| "left-only"
- | "right-only"
export function allocateComposerAccessoryRail(
occupancy: ComposerAccessoryRailOccupancy,
): ComposerAccessoryRailLayout {
- if (occupancy.mode === "selection" || occupancy.center) return "centered"
- if (occupancy.left && occupancy.right) return "left-right"
+ if (occupancy.mode === "selection") return "centered"
+ if (occupancy.center) return "centered"
if (occupancy.left) return "left-only"
- if (occupancy.right) return "right-only"
return "empty"
}
diff --git a/src/web/src/components/community/messages/composer-accessory-rail.test.ts b/src/web/src/components/community/messages/composer-accessory-rail.test.ts
index 1f76e382b..5a3aa71f5 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail.test.ts
+++ b/src/web/src/components/community/messages/composer-accessory-rail.test.ts
@@ -44,14 +44,14 @@ describe("ComposerAccessoryRail", () => {
})
function render(overrides: Partial<typeof baseProps> = {}) {
- let renderer: TestRenderer.ReactTestRenderer
+ let renderer!: TestRenderer.ReactTestRenderer
act(() => {
renderer = TestRenderer.create(React.createElement(ComposerAccessoryRail, {
...baseProps,
...overrides,
}))
})
- return renderer!
+ return renderer
}
function slotClassName(renderer: TestRenderer.ReactTestRenderer, testId: string): string {
@@ -66,18 +66,13 @@ describe("ComposerAccessoryRail", () => {
}
it.each([
- [false, false, false, "empty", null, null, null],
- [true, false, false, "left-only", "col-start-1", null, null],
- [false, true, false, "centered", null, "col-start-2", null],
- [false, false, true, "right-only", null, null, "col-start-1"],
- [true, true, false, "centered", "col-start-1", "col-start-2", null],
- [true, false, true, "left-right", "col-start-1", null, "col-start-2"],
- [false, true, true, "centered", null, "col-start-2", "col-start-3"],
- [true, true, true, "centered", "col-start-1", "col-start-2", "col-start-3"],
+ [false, false, "empty"],
+ [true, false, "left-only"],
+ [false, true, "centered"],
+ [true, true, "centered"],
] as const)(
- "renders normal DOM matrix left=%s center=%s right=%s as %s",
- (left, center, right, layout, leftColumn, centerColumn, rightColumn) => {
- if (right) useCommunityWsStore.getState().setConnectionStatus("reconnecting")
+ "renders normal DOM matrix left=%s center=%s as %s",
+ (left, center, layout) => {
const renderer = render({
typingNames: left ? ["Alice"] : [],
scrollCount: center ? 2 : 0,
@@ -88,82 +83,50 @@ describe("ComposerAccessoryRail", () => {
.toHaveLength(left ? 1 : 0)
expect(renderer.root.findAllByProps({ "data-testid": tid.scrollToPresent }))
.toHaveLength(center ? 1 : 0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsStatus }))
- .toHaveLength(right ? 1 : 0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
if (layout === "empty") return
expect(rails[0].props["data-layout"]).toBe(layout)
- if (leftColumn) {
- expect(slotClassName(renderer, tid.typingIndicator)).toContain(leftColumn)
- }
- if (centerColumn) {
- expect(slotClassName(renderer, tid.scrollToPresent)).toContain(centerColumn)
- }
- if (rightColumn) {
- const rightSlot = slotClassName(renderer, tid.wsStatus)
- expect(rightSlot).toContain(rightColumn)
- expect(rightSlot).toContain("justify-self-end")
- }
+ if (left) expect(slotClassName(renderer, tid.typingIndicator)).toContain("col-start-1")
+ if (center) expect(slotClassName(renderer, tid.scrollToPresent)).toContain("col-start-2")
},
)
- it.each([
- [false, false],
- [true, false],
- [false, true],
- [true, true],
- ])("renders selection DOM matrix left=%s right=%s", (left, right) => {
- if (right) useCommunityWsStore.getState().setConnectionStatus("reconnecting")
- const renderer = render({
- selectMode: true,
- selectedCount: 2,
- typingNames: left ? ["Alice"] : [],
- scrollCount: 0,
- })
+ it("keeps selection centered, hides typing on mobile, and wires its actions", () => {
+ const renderer = render({ selectMode: true, selectedCount: 12 })
const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
- expect(rail.props["data-layout"]).toBe("centered")
- expect(renderer.root.findAllByProps({ "data-testid": tid.messageSelectionToolbar }))
- .toHaveLength(1)
- expect(slotClassName(renderer, tid.messageSelectionToolbar)).toContain("col-start-2")
- expect(renderer.root.findAllByProps({ "data-testid": tid.typingIndicator }))
- .toHaveLength(left ? 1 : 0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsStatus }))
- .toHaveLength(right ? 1 : 0)
+ expect(rail.props).toMatchObject({
+ "data-layout": "centered",
+ "data-selection": "active",
+ })
expect(renderer.root.findAllByProps({ "data-testid": tid.scrollToPresent })).toHaveLength(0)
- if (left) {
- const leftSlot = slotClassName(renderer, tid.typingIndicator)
- expect(leftSlot).toContain("hidden")
- expect(leftSlot).toContain("sm:col-start-1")
- expect(leftSlot).toContain("sm:block")
- }
- if (right) {
- const rightSlot = slotClassName(renderer, tid.wsStatus)
- expect(rightSlot).toContain("col-start-3")
- expect(rightSlot).toContain("justify-self-end")
- }
+ expect(slotClassName(renderer, tid.messageSelectionToolbar)).toContain("col-start-2")
+
+ const typingSlotClassName = slotClassName(renderer, tid.typingIndicator)
+ expect(typingSlotClassName).toContain("hidden")
+ expect(typingSlotClassName).toContain("sm:block")
+
+ const toolbar = renderer.root.findByProps({ "data-testid": tid.messageSelectionToolbar })
+ expect(toolbar.props.className).toContain("h-10")
+ expect(toolbar.props.className).toContain("max-w-full")
+ const cancel = renderer.root.findByProps({ "aria-label": "Cancel message selection" })
+ const share = renderer.root.findByProps({
+ "aria-label": "Share 12 selected messages as image",
+ })
+ expect(cancel.props.className).toContain("w-11")
+ expect(share.props.className).toContain("after:-inset-y-1.5")
+ act(() => cancel.props.onClick())
+ act(() => share.props.onClick())
+ expect(baseProps.onCancelSelection).toHaveBeenCalledOnce()
+ expect(baseProps.onShareSelection).toHaveBeenCalledOnce()
})
- it("owns the only floating position and lays out normal typing, scroll, and no healthy WS node", () => {
+ it("centers the scroll control, preserves the floating boundary, and wires scroll", () => {
const renderer = render()
const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
expect(rail.props.className).toContain("absolute")
expect(rail.props["data-layout"]).toBe("centered")
- expect(rail.props.className).toContain("px-2")
- expect(rail.props.className).toContain("sm:px-4")
- expect(renderer.root.findByProps({ "data-testid": tid.typingIndicator }).props.className)
- .toContain("min-w-0")
- expect(renderer.root.findByProps({ "data-testid": tid.typingIndicator }).props.className)
- .toContain("max-w-full")
expect(renderer.root.findByProps({ "data-testid": tid.scrollToPresent }).props["aria-label"])
.toBe("Jump to present, 4 unread below")
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsStatus })).toHaveLength(0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
-
- const positioned = renderer.root.findAll((node) =>
- typeof node.props.className === "string" && node.props.className.includes("absolute"))
- expect(positioned).toEqual([rail])
-
const grid = rail.findAllByType("div").find((node) => node.props.className?.includes("grid w-full"))!
expect(grid.props.className)
.toContain("grid-cols-[minmax(0,1fr)_minmax(0,max-content)_minmax(0,1fr)]")
@@ -171,164 +134,22 @@ describe("ComposerAccessoryRail", () => {
expect(baseProps.onScroll).toHaveBeenCalledOnce()
})
- it("does not render the normal rail when all three occupancies are empty", () => {
- const renderer = render({ scrollCount: 0, typingNames: [] })
- expect(renderer.root.findAllByProps({ "data-testid": tid.composerAccessoryRail })).toHaveLength(0)
- })
-
- it("reclaims the center track for typing before a right-aligned WS status", () => {
+ it("never reserves composer space for WebSocket state", () => {
useCommunityWsStore.getState().setConnectionStatus("reconnecting")
- const renderer = render({ scrollCount: 0 })
- const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
- expect(rail.props["data-layout"]).toBe("left-right")
- const grid = rail.findAllByType("div").find((node) => node.props.className?.includes("grid w-full"))!
- expect(grid.props.className).toContain("grid-cols-[minmax(0,1fr)_auto]")
- expect(grid.children).toHaveLength(2)
- expect(grid.children[0].props.className).toContain("col-start-1")
- expect(grid.children[0].props.className).toContain("min-w-0")
- expect(grid.children[1].props.className).toContain("col-start-2")
- expect(grid.children[1].props.className).toContain("justify-self-end")
- })
-
- it("shows an accessible muted warning reconnecting control without a spinner", () => {
- useCommunityWsStore.getState().setConnectionStatus("reconnecting")
- const renderer = render({ scrollCount: 0, typingNames: [] })
- const status = renderer.root.findByProps({ "data-testid": tid.wsStatus })
- expect(status.props).toMatchObject({
- "data-ws-status": "reconnecting",
- "aria-label": "WebSocket reconnecting",
- "aria-live": "polite",
- role: "status",
- tabIndex: 0,
- })
- expect(status.type).toBe("span")
- expect(status.props.className).toContain("text-warning")
- expect(status.props.className).toContain("focus-visible:ring-3")
- const statusVisuals = status.findAllByType("span")
- .filter((node) => node.props.className?.includes("size-8"))
- expect(statusVisuals).toHaveLength(2)
- expect(statusVisuals.every((node) => node.props.className.includes("self-end"))).toBe(true)
- expect(renderer.root.findByType("tooltip-content").children).toContain("Reconnecting…")
- expect(renderer.root.findAll((node) => node.props.className?.includes("animate-spin"))).toHaveLength(0)
- const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
- expect(rail.props["data-layout"]).toBe("right-only")
- const grid = rail.findAllByType("div").find((node) => node.props.className?.includes("grid w-full"))!
- expect(grid.props.className).toContain("grid-cols-[minmax(0,1fr)]")
- expect(grid.children).toHaveLength(1)
- expect(grid.children[0].props.className).toContain("col-start-1")
- expect(grid.children[0].props.className).toContain("justify-self-end")
- })
-
- it("shows a destructive failed retry button with a 40px desktop hit target", () => {
- const reconnectNow = vi.fn()
- useCommunityWsStore.getState().bindReconnectNow(reconnectNow)
- useCommunityWsStore.getState().setConnectionStatus("failed")
- const renderer = render({ scrollCount: 0, typingNames: [] })
- const retry = renderer.root.findByProps({ "data-testid": tid.wsRetry })
- expect(retry.type).toBe("button")
- expect(retry.props["aria-label"]).toBe("WebSocket connection failed. Retry now")
- expect(retry.props.className).toContain("text-destructive")
- expect(retry.props.className).toContain("sm:size-10")
- const retryVisual = retry.findAllByType("span")
- .find((node) => node.props.className?.includes("size-8"))!
- expect(retryVisual.props.className).toContain("self-end")
- act(() => retry.props.onClick())
- expect(reconnectNow).toHaveBeenCalledOnce()
- })
-
- it("stays absent during validation, then replaces outage controls and removes them on recovery", () => {
- const renderer = render({ scrollCount: 0, typingNames: [] })
- expect(renderer.root.findAllByProps({ "data-testid": tid.composerAccessoryRail })).toHaveLength(0)
-
- act(() => useCommunityWsStore.getState().setConnectionStatus("reconnecting"))
- const status = renderer.root.findByProps({ "data-testid": tid.wsStatus })
- expect(status.props).toMatchObject({
- "data-ws-status": "reconnecting",
- "aria-label": "WebSocket reconnecting",
- })
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
-
- act(() => useCommunityWsStore.getState().setConnectionStatus("failed"))
- const retry = renderer.root.findByProps({ "data-testid": tid.wsRetry })
- expect(retry.props).toMatchObject({
- "data-ws-status": "failed",
- "aria-label": "WebSocket connection failed. Retry now",
- })
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsStatus })).toHaveLength(0)
-
- act(() => useCommunityWsStore.getState().setConnectionStatus("connected"))
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsStatus })).toHaveLength(0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
- expect(renderer.root.findAllByProps({ "data-testid": tid.composerAccessoryRail })).toHaveLength(0)
- })
-
- it("replaces scroll with selection controls and preserves desktop typing", () => {
- const renderer = render({ selectMode: true, selectedCount: 3 })
- const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
- expect(rail.props["data-selection"]).toBe("active")
- expect(renderer.root.findAllByProps({ "data-testid": tid.scrollToPresent })).toHaveLength(0)
- expect(renderer.root.findByProps({ "data-testid": tid.messageSelectionToolbar })).toBeTruthy()
- expect(renderer.root.findByProps({ "data-testid": tid.typingIndicator })).toBeTruthy()
+ const empty = render({ typingNames: [], scrollCount: 0 })
+ expect(empty.root.findAllByProps({ "data-testid": tid.composerAccessoryRail })).toHaveLength(0)
- const grid = rail.findAllByType("div").find((node) => node.props.className?.includes("grid w-full"))!
- expect(grid.props.className)
- .toContain("grid-cols-[minmax(0,1fr)_minmax(0,max-content)_minmax(0,1fr)]")
- })
-
- it("uses a symmetric mobile selection grid with a compact capped toolbar and hides typing below sm", () => {
useCommunityWsStore.getState().setConnectionStatus("failed")
- const renderer = render({ selectMode: true, selectedCount: 12 })
- const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
- const grid = rail.findAllByType("div").find((node) => node.props.className?.includes("grid w-full"))!
- expect(grid.props.className)
- .toContain("grid-cols-[minmax(0,1fr)_minmax(0,max-content)_minmax(0,1fr)]")
- expect(grid.props.className).toContain("gap-1")
- expect(grid.props.className).toContain("sm:gap-2")
-
- const typingParent = renderer.root.findAllByType("div")
- .find((node) => node.props.className?.includes("hidden min-w-0 max-w-full"))!
- expect(typingParent.props.className).toContain("hidden")
- expect(typingParent.props.className).toContain("max-w-full")
- expect(typingParent.props.className).toContain("sm:block")
- const toolbar = renderer.root.findByProps({ "data-testid": tid.messageSelectionToolbar })
- expect(toolbar.props.className).toContain("h-10")
- expect(toolbar.props.className).toContain("w-fit")
- expect(toolbar.props.className).toContain("max-w-full")
- expect(toolbar.props.className).not.toContain("max-w-[calc(100vw-7rem)]")
- expect(toolbar.props.className).toContain("sm:h-auto")
- const toolbarSlot = rail.findAllByType("div")
- .find((node) => node.props.className?.includes("col-start-2"))!
- expect(toolbarSlot.props.className).toContain("justify-self-center")
-
- const count = toolbar.findAllByType("span")
- .find((node) => node.props.className?.includes("flex-1"))!
- expect(count.children.join("")).toBe("12 selected")
- expect(count.props.className).toContain("flex-1")
- expect(count.props.className).toContain("truncate")
-
- const cancel = renderer.root.findByProps({ "aria-label": "Cancel message selection" })
- expect(cancel.props.className).toContain("h-8")
- expect(cancel.props.className).toContain("w-11")
- expect(cancel.props.className).toContain("after:-inset-y-1.5")
-
- const share = renderer.root.findByProps({
- "aria-label": "Share 12 selected messages as image",
- })
- expect(share.props.className).toContain("h-8")
- expect(share.props.className).toContain("px-2")
- expect(share.props.className).toContain("after:-inset-y-1.5")
-
- const wsRetry = renderer.root.findByProps({ "data-testid": tid.wsRetry })
- expect(wsRetry.props.className).toContain("size-11")
- const wsSlot = rail.findAllByType("div")
- .find((node) => node.props.className?.includes("col-start-3"))!
- expect(wsSlot.props.className).toContain("min-w-0")
- expect(wsSlot.props.className).toContain("max-w-full")
- expect(wsSlot.props.className).toContain("justify-self-end")
+ const typing = render({ scrollCount: 0 })
+ expect(typing.root.findByProps({ "data-testid": tid.composerAccessoryRail }).props["data-layout"])
+ .toBe("left-only")
+ expect(typing.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
})
- it("does not reintroduce a viewport-derived rail or toolbar width cap", () => {
+ it("does not reintroduce WS ownership or a viewport-derived width cap", () => {
const source = readFileSync(new URL("./composer-accessory-rail.tsx", import.meta.url), "utf8")
+ expect(source).not.toContain("@/stores/community/ws")
+ expect(source).not.toContain("WsStatusControl")
expect(source).not.toMatch(/max-w-\[calc\([^\]]*vw/)
})
})
diff --git a/src/web/src/components/community/messages/composer-accessory-rail.tsx b/src/web/src/components/community/messages/composer-accessory-rail.tsx
index eacbda727..8811d3d5b 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail.tsx
+++ b/src/web/src/components/community/messages/composer-accessory-rail.tsx
@@ -1,16 +1,12 @@
"use client"
-import { ArrowDown, ImageIcon, Radio, WifiOff, X } from "lucide-react"
+import { ArrowDown, ImageIcon, X } from "lucide-react"
import { Button } from "@/components/ui/button"
import { NumberTicker } from "@/components/ui/number-ticker"
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
import { tid } from "@/lib/community/testids"
import { cn } from "@/lib/utils"
-import { useCommunityWsStore } from "@/stores/community/ws"
-import {
- allocateComposerAccessoryRail,
- type ComposerAccessoryRailLayout,
-} from "./composer-accessory-rail-layout"
+import { allocateComposerAccessoryRail } from "./composer-accessory-rail-layout"
import { TypingIndicator } from "./typing-indicator"
export function ComposerAccessoryRail({
@@ -32,14 +28,11 @@ export function ComposerAccessoryRail({
onCancelSelection: () => void
onShareSelection: () => void
}) {
- const connectionStatus = useCommunityWsStore((state) => state.connectionStatus)
- const reconnectNow = useCommunityWsStore((state) => state.reconnectNow)
const hasTyping = typingNames.length > 0
const hasScroll = scrollCount > 0
- const hasWsStatus = connectionStatus !== "connected"
const layout = allocateComposerAccessoryRail(selectMode
- ? { mode: "selection", left: hasTyping, right: hasWsStatus }
- : { mode: "normal", left: hasTyping, center: hasScroll, right: hasWsStatus })
+ ? { mode: "selection" }
+ : { mode: "normal", left: hasTyping, center: hasScroll })
if (layout === "empty") return null
@@ -54,8 +47,7 @@ export function ComposerAccessoryRail({
className={cn(
"grid w-full items-end gap-1 sm:gap-2",
layout === "centered" && "grid-cols-[minmax(0,1fr)_minmax(0,max-content)_minmax(0,1fr)]",
- layout === "left-right" && "grid-cols-[minmax(0,1fr)_auto]",
- (layout === "left-only" || layout === "right-only") && "grid-cols-[minmax(0,1fr)]",
+ layout === "left-only" && "grid-cols-[minmax(0,1fr)]",
)}
>
{selectMode ? (
@@ -72,16 +64,11 @@ export function ComposerAccessoryRail({
onShare={onShareSelection}
/>
</div>
- {hasWsStatus && (
- <div key="right" className="col-start-3 min-w-0 max-w-full justify-self-end">
- <WsStatusControl status={connectionStatus} onRetry={reconnectNow} />
- </div>
- )}
</>
) : (
<>
{hasTyping && (
- <div key="left" className={normalSlotClassName(layout, "left")}>
+ <div key="left" className="col-start-1 min-w-0 max-w-full">
<TypingIndicator names={typingNames} className="w-fit max-w-full" />
</div>
)}
@@ -90,11 +77,6 @@ export function ComposerAccessoryRail({
<ScrollControl count={scrollCount} mode={scrollMode} onClick={onScroll} />
</div>
)}
- {hasWsStatus && (
- <div key="right" className={normalSlotClassName(layout, "right")}>
- <WsStatusControl status={connectionStatus} onRetry={reconnectNow} />
- </div>
- )}
</>
)}
</div>
@@ -102,22 +84,6 @@ export function ComposerAccessoryRail({
)
}
-function normalSlotClassName(
- layout: ComposerAccessoryRailLayout,
- side: "left" | "right",
-): string {
- const column = layout === "centered"
- ? side === "left" ? "col-start-1" : "col-start-3"
- : layout === "left-right"
- ? side === "left" ? "col-start-1" : "col-start-2"
- : "col-start-1"
- return cn(
- column,
- "min-w-0 max-w-full",
- side === "right" && "justify-self-end",
- )
-}
-
function SelectionToolbar({
selectedCount,
onCancel,
@@ -192,62 +158,3 @@ function ScrollControl({
</button>
)
}
-
-function WsStatusControl({
- status,
- onRetry,
-}: {
- status: "connected" | "reconnecting" | "failed"
- onRetry: () => void
-}) {
- if (status === "connected") return null
- const failed = status === "failed"
- const label = failed
- ? "WebSocket connection failed. Retry now"
- : "WebSocket reconnecting"
- const triggerClassName = cn(
- "pointer-events-auto relative grid size-11 place-items-center rounded-full outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50 sm:size-10",
- failed
- ? "text-destructive hover:bg-destructive/10"
- : "cursor-default text-warning",
- )
- return (
- <Tooltip>
- <TooltipTrigger
- render={failed ? (
- <button
- type="button"
- data-testid={tid.wsRetry}
- data-ws-status={status}
- aria-label={label}
- onClick={onRetry}
- className={triggerClassName}
- />
- ) : (
- <span
- role="status"
- aria-live="polite"
- tabIndex={0}
- data-testid={tid.wsStatus}
- data-ws-status={status}
- aria-label={label}
- className={triggerClassName}
- />
- )}
- >
- {!failed && (
- <span className="absolute size-8 self-end rounded-full bg-warning/10 motion-safe:animate-pulse" />
- )}
- <span
- className={cn(
- "relative grid size-8 self-end place-items-center rounded-full border bg-background/90 shadow-(--e1) backdrop-blur-sm",
- failed ? "border-destructive/30" : "border-warning/30",
- )}
- >
- {failed ? <WifiOff className="size-4" /> : <Radio className="size-4" />}
- </span>
- </TooltipTrigger>
- <TooltipContent>{failed ? "Connection failed · Retry" : "Reconnecting…"}</TooltipContent>
- </Tooltip>
- )
-}
diff --git a/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts b/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts
new file mode 100644
index 000000000..a81c11995
--- /dev/null
+++ b/src/web/src/components/community/shell/community-ws-reconnect-overlay.test.ts
@@ -0,0 +1,92 @@
+import React from "react"
+import TestRenderer, { act } from "react-test-renderer"
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
+import { tid } from "@/lib/community/testids"
+import { useCommunityWsStore } from "@/stores/community/ws"
+import { CommunityWsReconnectBoundary } from "./community-ws-reconnect-overlay"
+
+describe("CommunityWsReconnectBoundary", () => {
+ beforeEach(() => {
+ useCommunityWsStore.getState().reset()
+ })
+
+ afterEach(() => {
+ useCommunityWsStore.getState().reset()
+ })
+
+ function render() {
+ const focus = vi.fn()
+ let renderer!: TestRenderer.ReactTestRenderer
+ act(() => {
+ renderer = TestRenderer.create(
+ React.createElement(
+ CommunityWsReconnectBoundary,
+ null,
+ React.createElement("button", { type: "button" }, "Underlying action"),
+ ),
+ { createNodeMock: () => ({ focus }) },
+ )
+ })
+ return { renderer, focus }
+ }
+
+ it("leaves connected content interactive without rendering an overlay", () => {
+ const { renderer } = render()
+ const content = renderer.root.findByProps({ className: "contents" })
+ expect(content.props.inert).toBeUndefined()
+ expect(content.props["aria-hidden"]).toBeUndefined()
+ expect(renderer.root.findAllByProps({ "data-testid": tid.wsReconnectOverlay }))
+ .toHaveLength(0)
+ })
+
+ it("blocks the content and announces a reconnecting state", () => {
+ const { renderer, focus } = render()
+ act(() => useCommunityWsStore.getState().setConnectionStatus("reconnecting"))
+
+ const content = renderer.root.findByProps({ className: "contents" })
+ expect(content.props).toMatchObject({ inert: true, "aria-hidden": true })
+ const overlay = renderer.root.findByProps({ "data-testid": tid.wsReconnectOverlay })
+ expect(overlay.props).toMatchObject({
+ "data-ws-status": "reconnecting",
+ "aria-modal": "true",
+ role: "dialog",
+ tabIndex: -1,
+ })
+ expect(overlay.props.className).toContain("fixed inset-0")
+ expect(overlay.props.className).toContain("community-ws-reconnect-overlay")
+ expect(overlay.props.className).toContain("z-2147483647")
+ expect(overlay.props.className).toContain("backdrop-blur-sm")
+ expect(renderer.root.findByProps({ role: "status" }).props).toMatchObject({
+ "aria-atomic": "true",
+ "aria-live": "polite",
+ })
+ expect(renderer.root.findByType("h2").children).toEqual(["Connecting…"])
+ const motion = renderer.root.findByProps({ "data-connecting-motion": "" })
+ expect(motion.props.className).toContain("community-ws-connecting-loader")
+ expect(renderer.root.findAllByProps({ "data-testid": tid.wsRetry })).toHaveLength(0)
+ expect(focus).toHaveBeenCalledOnce()
+ })
+
+ it("shows an accessible mobile-sized Retry action and restores immediately", () => {
+ const reconnectNow = vi.fn()
+ useCommunityWsStore.getState().bindReconnectNow(reconnectNow)
+ const { renderer } = render()
+ act(() => useCommunityWsStore.getState().setConnectionStatus("failed"))
+
+ expect(renderer.root.findByProps({ role: "alert" }).props).toMatchObject({
+ "aria-atomic": "true",
+ "aria-live": "assertive",
+ })
+ expect(renderer.root.findByType("h2").children).toEqual(["Connection lost"])
+ const retry = renderer.root.findByProps({ "data-testid": tid.wsRetry })
+ expect(retry.props.className).toContain("h-11")
+ expect(retry.props.className).toContain("sm:h-10")
+ act(() => retry.props.onClick())
+ expect(reconnectNow).toHaveBeenCalledOnce()
+
+ act(() => useCommunityWsStore.getState().setConnectionStatus("connected"))
+ expect(renderer.root.findAllByProps({ "data-testid": tid.wsReconnectOverlay }))
+ .toHaveLength(0)
+ expect(renderer.root.findByProps({ className: "contents" }).props.inert).toBeUndefined()
+ })
+})
diff --git a/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx b/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx
new file mode 100644
index 000000000..70cdd6ce5
--- /dev/null
+++ b/src/web/src/components/community/shell/community-ws-reconnect-overlay.tsx
@@ -0,0 +1,92 @@
+"use client"
+
+import { useEffect, useRef, type ReactNode } from "react"
+import { WifiOff } from "lucide-react"
+import { Button } from "@/components/ui/button"
+import { tid } from "@/lib/community/testids"
+import { useCommunityWsStore } from "@/stores/community/ws"
+
+export function CommunityWsReconnectBoundary({ children }: { children: ReactNode }) {
+ const connectionStatus = useCommunityWsStore((state) => state.connectionStatus)
+ const reconnectNow = useCommunityWsStore((state) => state.reconnectNow)
+ const blocked = connectionStatus !== "connected"
+ const dialogRef = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ if (!blocked) return
+ const dialog = dialogRef.current
+ dialog?.focus()
+ if (typeof document === "undefined") return
+ const keepFocusInDialog = (event: FocusEvent) => {
+ if (!dialog || dialog.contains(event.target as Node)) return
+ dialog.focus()
+ }
+ document.addEventListener("focusin", keepFocusInDialog)
+ return () => document.removeEventListener("focusin", keepFocusInDialog)
+ }, [blocked, connectionStatus])
+
+ return (
+ <>
+ <div
+ className="contents"
+ inert={blocked ? true : undefined}
+ aria-hidden={blocked ? true : undefined}
+ >
+ {children}
+ </div>
+ {blocked && (
+ <div
+ ref={dialogRef}
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="community-ws-reconnect-title"
+ tabIndex={-1}
+ data-testid={tid.wsReconnectOverlay}
+ data-ws-status={connectionStatus}
+ className="community-ws-reconnect-overlay fixed inset-0 z-2147483647 grid place-items-center bg-background/60 px-4 outline-none backdrop-blur-sm supports-backdrop-filter:bg-background/45 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-150"
+ >
+ <div className="flex w-full max-w-xs flex-col items-center text-center text-foreground">
+ {connectionStatus === "failed" ? (
+ <>
+ <div
+ role="alert"
+ aria-live="assertive"
+ aria-atomic="true"
+ >
+ <div
+ aria-hidden="true"
+ className="mx-auto mb-4 grid size-10 place-items-center rounded-md bg-destructive/10 text-destructive"
+ >
+ <WifiOff className="size-5" />
+ </div>
+ <h2 id="community-ws-reconnect-title" className="font-heading text-base font-medium">
+ Connection lost
+ </h2>
+ </div>
+ <Button
+ type="button"
+ data-testid={tid.wsRetry}
+ onClick={reconnectNow}
+ className="mt-4 h-11 w-full sm:h-10 sm:w-auto sm:min-w-24"
+ >
+ Retry
+ </Button>
+ </>
+ ) : (
+ <div role="status" aria-live="polite" aria-atomic="true" className="flex flex-col items-center">
+ <div
+ aria-hidden="true"
+ data-connecting-motion=""
+ className="community-ws-connecting-loader mb-4"
+ />
+ <h2 id="community-ws-reconnect-title" className="font-heading text-base font-medium">
+ Connecting…
+ </h2>
+ </div>
+ )}
+ </div>
+ </div>
+ )}
+ </>
+ )
+}
diff --git a/src/web/src/lib/avatar/face.test.ts b/src/web/src/lib/avatar/face.test.ts
index 5b199269e..7c8640d72 100644
--- a/src/web/src/lib/avatar/face.test.ts
+++ b/src/web/src/lib/avatar/face.test.ts
@@ -39,6 +39,16 @@ describe("renderFaceSvg", () => {
expect(svg.trim().endsWith("</svg>")).toBe(true)
})
+ it("can expose stable face-part hooks without changing the default SVG", () => {
+ const defaultSvg = renderFaceSvg("guide-face")
+ const motionSvg = renderFaceSvg("guide-face", { motionParts: true })
+
+ expect(defaultSvg).not.toContain("alook-avatar-eyes")
+ expect(motionSvg).toContain('class="alook-avatar-shell"')
+ expect(motionSvg).toContain('class="alook-avatar-eyes"')
+ expect(motionSvg).toContain('class="alook-avatar-mouth"')
+ })
+
it("uses no <mask> id (would collide across many faces on one page)", () => {
const svg = renderFaceSvg("Alice")
expect(svg).not.toContain("<mask")
diff --git a/src/web/src/lib/avatar/face.ts b/src/web/src/lib/avatar/face.ts
index 06d27fb75..64818c502 100644
--- a/src/web/src/lib/avatar/face.ts
+++ b/src/web/src/lib/avatar/face.ts
@@ -124,7 +124,10 @@ export const FACE_VOCABULARY = {
// Render a generated beam face to an SVG string for the given seed + palette.
// Feature choice is deterministic on the seed hash; the head is placed in the
// lower band so the top ~20% stays clear for a hat.
-export function renderFaceSvg(seed: string): string {
+export function renderFaceSvg(
+ seed: string,
+ { motionParts = false }: { motionParts?: boolean } = {},
+): string {
const i = avatarHash(seed)
const theme = avatarThemeFromSeed(seed)
const wrapper = theme.face
@@ -157,9 +160,13 @@ export function renderFaceSvg(seed: string): string {
const eyeSpread = i % 2
const mouthSpread = i % 2
- const wrapperEl = `<path d="${shapePath}" fill="${wrapper}"/>`
- const eyes = eyeFn(eyeSpread, c)
- const mouth = mouthFn(mouthSpread, c)
+ const wrapperEl = `<path${motionParts ? ' class="alook-avatar-shell"' : ""} d="${shapePath}" fill="${wrapper}"/>`
+ const eyes = motionParts
+ ? `<g class="alook-avatar-eyes">${eyeFn(eyeSpread, c)}</g>`
+ : eyeFn(eyeSpread, c)
+ const mouth = motionParts
+ ? `<g class="alook-avatar-mouth">${mouthFn(mouthSpread, c)}</g>`
+ : mouthFn(mouthSpread, c)
// The face is nested inside the head's transform group and shares its EXACT
// transform, so features always sit on the wrapper fill, centered on it. Both
diff --git a/src/web/src/lib/community/testids.test.ts b/src/web/src/lib/community/testids.test.ts
index aeb5c9511..de1731ef1 100644
--- a/src/web/src/lib/community/testids.test.ts
+++ b/src/web/src/lib/community/testids.test.ts
@@ -2,6 +2,11 @@ import { describe, expect, it } from "vitest"
import { tid } from "./testids"
describe("community QA selectors", () => {
+ it("exposes the global reconnect overlay independently from its Retry action", () => {
+ expect(tid.wsReconnectOverlay).toBe("community-ws-reconnect-overlay")
+ expect(tid.wsRetry).toBe("community-ws-retry")
+ })
+
it("keys forum-title read models by their stable child identity", () => {
expect(tid.inboxUnreadChild("post_1")).toBe("community-inbox-unread-child-post_1")
expect(tid.inboxUnreadChannel("channel_1")).toBe("community-inbox-unread-channel-channel_1")
diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.ts
index bb31d74a4..10fc1101c 100644
--- a/src/web/src/lib/community/testids.ts
+++ b/src/web/src/lib/community/testids.ts
@@ -11,7 +11,7 @@ export const tid = {
scrollToPresent: "community-scroll-to-present",
messageSelectionToolbar: "community-message-selection-toolbar",
messageScroller: "community-message-scroller",
- wsStatus: "community-ws-status",
+ wsReconnectOverlay: "community-ws-reconnect-overlay",
wsRetry: "community-ws-retry",
serverAdd: "community-server-add",
serverRailScroll: "community-server-rail-scroll",
@@ -46,6 +46,8 @@ export const tid = {
inviteCard: (token: string) => `community-invite-card-${token}`,
inviteCardAction: (token: string) => `community-invite-card-action-${token}`,
machinePairOpen: "community-machine-pair-open",
+ machineFirstSignupGuide: "machine-first-signup-guide",
+ machineGuideAvatarTarget: "machine-guide-avatar-target",
machinePairCommand: "community-machine-pair-command",
machinePairCopy: "community-machine-pair-copy",
machinePairDesktopConnect: "community-machine-pair-desktop-connect",
diff --git a/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts b/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts
new file mode 100644
index 000000000..9299c5390
--- /dev/null
+++ b/src/web/src/test/e2e-ui/25-community-ws-reconnect-overlay.spec.ts
@@ -0,0 +1,184 @@
+import type { WebSocketRoute } from "@playwright/test"
+import { test, expect } from "./_fixtures/community-fixture"
+import { composerEditable, gotoAfterUserWsAuth } from "./_fixtures/actions"
+import { seedChannel, seedServer } from "./_fixtures/seed"
+import { tid } from "./_fixtures/testids"
+
+test("real WebSocket outage blocks the whole community surface and Retry restores it", async ({ asUser }, testInfo) => {
+ test.setTimeout(120_000)
+ const serverId = await seedServer("alice", `Reconnect overlay ${Date.now()}`)
+ const channelId = await seedChannel("alice", serverId, "reconnect-overlay")
+ const alice = await asUser("alice")
+ let aliceWs: WebSocketRoute | null = null
+ await alice.page.routeWebSocket((url) => url.pathname.endsWith("/user"), (ws) => {
+ aliceWs = ws
+ ws.connectToServer()
+ })
+ await alice.page.emulateMedia({ reducedMotion: "reduce" })
+ await alice.page.setViewportSize({ width: 390, height: 844 })
+ await gotoAfterUserWsAuth(alice.page, `/c/channels/${serverId}/${channelId}`)
+ const composer = composerEditable(alice.page)
+ await expect(composer).toBeVisible()
+ await expect(alice.page.getByTestId(tid.wsReconnectOverlay)).toHaveCount(0)
+
+ try {
+ await alice.context.setOffline(true)
+ expect(aliceWs).not.toBeNull()
+ await aliceWs!.close({ code: 1012, reason: "reconnect overlay e2e outage" })
+
+ const overlay = alice.page.getByTestId(tid.wsReconnectOverlay)
+ await expect(overlay).toBeVisible({ timeout: 10_000 })
+ await expect(overlay).toHaveAttribute("data-ws-status", "reconnecting")
+ await expect(overlay).toBeFocused()
+ await expect(overlay.getByRole("status")).toContainText("Connecting…")
+ const reconnectingEvidence = await overlay.evaluate((element) => {
+ const rect = element.getBoundingClientRect()
+ const content = element.previousElementSibling as HTMLElement | null
+ const connectingMotion = element.querySelector<HTMLElement>("[data-connecting-motion]")
+ return {
+ ariaHidden: content?.getAttribute("aria-hidden"),
+ inert: content?.hasAttribute("inert"),
+ animationName: connectingMotion
+ ? getComputedStyle(connectingMotion, "::after").animationName
+ : null,
+ rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
+ viewport: { width: innerWidth, height: innerHeight },
+ }
+ })
+ expect(reconnectingEvidence).toMatchObject({
+ ariaHidden: "true",
+ inert: true,
+ animationName: "none",
+ rect: { x: 0, y: 0, width: 390, height: 844 },
+ viewport: { width: 390, height: 844 },
+ })
+ await alice.page.keyboard.press("Tab")
+ expect(await alice.page.evaluate(() => {
+ const inertRoot = document.querySelector("[inert]")
+ return inertRoot?.contains(document.activeElement) ?? false
+ })).toBe(false)
+ const mobileReconnectPath = testInfo.outputPath("390-reconnecting-reduced-motion.png")
+ await alice.page.screenshot({ path: mobileReconnectPath })
+ await testInfo.attach("390-reconnecting-reduced-motion.png", {
+ path: mobileReconnectPath,
+ contentType: "image/png",
+ })
+
+ await alice.page.setViewportSize({ width: 1280, height: 900 })
+ expect(await overlay.boundingBox()).toMatchObject({ x: 0, y: 0, width: 1280, height: 900 })
+ const desktopReconnectPath = testInfo.outputPath("1280-reconnecting-reduced-motion.png")
+ await alice.page.screenshot({ path: desktopReconnectPath })
+ await testInfo.attach("1280-reconnecting-reduced-motion.png", {
+ path: desktopReconnectPath,
+ contentType: "image/png",
+ })
+ await alice.page.setViewportSize({ width: 390, height: 844 })
+
+ const retry = alice.page.getByTestId(tid.wsRetry)
+ await expect(retry).toBeVisible({ timeout: 40_000 })
+ await expect(overlay).toHaveAttribute("data-ws-status", "failed")
+ await expect(overlay.getByRole("alert")).toContainText("Connection lost")
+ expect((await retry.boundingBox())!.height).toBeGreaterThanOrEqual(44)
+
+ await alice.page.setViewportSize({ width: 1280, height: 900 })
+ const desktopRect = await overlay.boundingBox()
+ expect(desktopRect).toMatchObject({ x: 0, y: 0, width: 1280, height: 900 })
+ expect((await retry.boundingBox())!.height).toBeGreaterThanOrEqual(40)
+ await testInfo.attach("1280-failed-retry.png", {
+ body: await alice.page.screenshot(),
+ contentType: "image/png",
+ })
+
+ await alice.context.setOffline(false)
+ await retry.click()
+ await expect(overlay).toHaveCount(0, { timeout: 20_000 })
+ await expect(composer).toBeVisible()
+ expect(await alice.page.locator("[inert]").count()).toBe(0)
+ } finally {
+ await alice.context.setOffline(false)
+ }
+})
+
+test("an active onboarding guide yields visual and focus priority during outage, then resumes", async ({ browser }, testInfo) => {
+ test.setTimeout(90_000)
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 } })
+ const page = await context.newPage()
+ let userWs: WebSocketRoute | null = null
+ await page.routeWebSocket((url) => url.pathname.endsWith("/user"), (ws) => {
+ userWs = ws
+ ws.connectToServer()
+ })
+
+ try {
+ await page.goto("/sign-in")
+ await page.getByRole("textbox", { name: "Email" }).fill(
+ `guide-reconnect-${process.pid}-${Date.now()}@example.com`,
+ )
+ await page.getByRole("button", { name: "Sign in", exact: true }).click()
+ await page.waitForURL("**/c/me/machines", { waitUntil: "commit" })
+ await expect(page.getByRole("heading", { name: "No machines yet" })).toBeVisible()
+ await page.getByRole("button", { name: "Guide me" }).click()
+
+ const guide = page.locator(".driver-popover.community-onboarding-popover")
+ await expect(guide).toBeVisible()
+ await expect(guide.getByRole("heading", { name: "Give your bot a place to run" })).toBeVisible()
+ await expect(page.locator("body")).toHaveClass(/community-onboarding-active/)
+
+ await context.setOffline(true)
+ expect(userWs).not.toBeNull()
+ await userWs!.close({ code: 1012, reason: "active onboarding reconnect e2e outage" })
+
+ const overlay = page.getByTestId(tid.wsReconnectOverlay)
+ await expect(overlay).toBeVisible({ timeout: 10_000 })
+ await expect(overlay).toBeFocused()
+ const stacking = await page.evaluate((overlayId) => {
+ const reconnect = document.querySelector<HTMLElement>(`[data-testid='${overlayId}']`)
+ const popover = document.querySelector<HTMLElement>(".driver-popover")
+ const activeTarget = document.querySelector<HTMLElement>(".driver-active-element")
+ if (!reconnect || !popover || !activeTarget) throw new Error("stacking targets are missing")
+ const reconnectRect = reconnect.getBoundingClientRect()
+ const topAtCenter = document.elementFromPoint(
+ reconnectRect.left + reconnectRect.width / 2,
+ reconnectRect.top + reconnectRect.height / 2,
+ )
+ return {
+ reconnect: Number.parseInt(getComputedStyle(reconnect).zIndex, 10),
+ popover: Number.parseInt(getComputedStyle(popover).zIndex, 10),
+ activeTarget: Number.parseInt(getComputedStyle(activeTarget).zIndex, 10),
+ topBelongsToReconnect: reconnect.contains(topAtCenter),
+ }
+ }, tid.wsReconnectOverlay)
+ expect(stacking.reconnect).toBeGreaterThan(stacking.popover)
+ expect(stacking.reconnect).toBeGreaterThan(stacking.activeTarget)
+ expect(stacking.topBelongsToReconnect).toBe(true)
+
+ await guide.getByRole("button", { name: "Skip guide" }).evaluate((element) => {
+ (element as HTMLElement).focus()
+ })
+ await expect(overlay).toBeFocused()
+ await page.keyboard.press("Tab")
+ expect(await page.evaluate((overlayId) => {
+ const reconnect = document.querySelector(`[data-testid='${overlayId}']`)
+ return reconnect?.contains(document.activeElement) ?? false
+ }, tid.wsReconnectOverlay)).toBe(true)
+ await testInfo.attach("390-active-onboarding-reconnecting.png", {
+ body: await page.screenshot(),
+ contentType: "image/png",
+ })
+
+ await context.setOffline(false)
+ await expect(overlay).toHaveCount(0, { timeout: 20_000 })
+ await expect(guide).toBeVisible()
+ await expect(page.locator("body")).toHaveClass(/community-onboarding-active/)
+ await guide.getByRole("button", { name: "Skip guide" }).evaluate((element) => {
+ (element as HTMLElement).click()
+ })
+ await expect(guide).toHaveCount(0)
+ await expect(page.locator("body")).not.toHaveClass(/community-onboarding-active/)
+ } finally {
+ if (!page.isClosed()) {
+ await context.setOffline(false)
+ await context.close()
+ }
+ }
+})
diff --git a/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts b/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
index 113918974..c5f545164 100644
--- a/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
+++ b/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
@@ -1,4 +1,4 @@
-import type { Page, TestInfo, WebSocketRoute } from "@playwright/test"
+import type { Page, TestInfo } from "@playwright/test"
import { test, expect } from "./_fixtures/community-fixture"
import { composerEditable, gotoAfterUserWsAuth, sendMessage } from "./_fixtures/actions"
import { renameUser, seedChannel, seedJoinServer, seedMessage, seedServer } from "./_fixtures/seed"
@@ -21,8 +21,6 @@ type RailMetrics = {
composer: Rect
typing: Rect | null
center: Rect | null
- right: Rect | null
- rightVisual: Rect | null
documentClientWidth: number
documentScrollWidth: number
typingText: {
@@ -42,8 +40,6 @@ async function railMetrics(page: Page): Promise<RailMetrics> {
const find = (id: string) => target.querySelector<HTMLElement>(`[data-testid='${id}']`)
const typing = find(ids.typing)
const center = find(ids.scroll) ?? find(ids.selection)
- const right = find(ids.wsStatus) ?? find(ids.wsRetry)
- const rightVisual = right?.querySelector<HTMLElement>(":scope > span.relative") ?? null
const typingText = typing?.querySelector<HTMLElement>("span.min-w-0.truncate") ?? null
const style = typingText ? getComputedStyle(typingText) : null
const toRect = (value: DOMRect) => ({
@@ -59,8 +55,6 @@ async function railMetrics(page: Page): Promise<RailMetrics> {
composer: toRect(document.querySelector<HTMLElement>(`[data-testid='${ids.composer}']`)!.getBoundingClientRect()),
typing: typing ? toRect(typing.getBoundingClientRect()) : null,
center: center ? toRect(center.getBoundingClientRect()) : null,
- right: right ? toRect(right.getBoundingClientRect()) : null,
- rightVisual: rightVisual ? toRect(rightVisual.getBoundingClientRect()) : null,
documentClientWidth: document.documentElement.clientWidth,
documentScrollWidth: document.documentElement.scrollWidth,
typingText: typingText && style
@@ -77,8 +71,6 @@ async function railMetrics(page: Page): Promise<RailMetrics> {
typing: tid.typingIndicator,
scroll: tid.scrollToPresent,
selection: tid.messageSelectionToolbar,
- wsStatus: tid.wsStatus,
- wsRetry: tid.wsRetry,
composer: tid.channelComposerShell,
}).then(async (metrics) => {
await expect(composer).toBeVisible()
@@ -89,7 +81,7 @@ async function railMetrics(page: Page): Promise<RailMetrics> {
function expectContained(metrics: RailMetrics, state: string, width: number): void {
const evidence = `${state}@${width}: ${JSON.stringify(metrics)}`
expect(metrics.documentScrollWidth, evidence).toBe(metrics.documentClientWidth)
- for (const control of [metrics.typing, metrics.center, metrics.right]) {
+ for (const control of [metrics.typing, metrics.center]) {
if (!control || control.width === 0) continue
expect(control.left, evidence).toBeGreaterThanOrEqual(metrics.rail.left - 0.5)
expect(control.right, evidence).toBeLessThanOrEqual(metrics.rail.right + 0.5)
@@ -103,7 +95,6 @@ async function captureState(args: {
layout: RailMetrics["layout"]
center: boolean
typing: boolean
- right: boolean
selection?: boolean
widths?: readonly number[]
}): Promise<Record<number, RailMetrics>> {
@@ -114,7 +105,6 @@ async function captureState(args: {
layout,
center,
typing,
- right,
selection = false,
widths = MOBILE_WIDTHS,
} = args
@@ -138,10 +128,6 @@ async function captureState(args: {
await expect(rail).toHaveAttribute("data-layout", layout!)
await expect(page.getByTestId(tid.typingIndicator)).toHaveCount(typing ? 1 : 0)
await expect(page.getByTestId(tid.messageSelectionToolbar)).toHaveCount(selection ? 1 : 0)
- const rightControl = page.locator(
- `[data-testid='${tid.wsStatus}'], [data-testid='${tid.wsRetry}']`,
- )
- await expect(rightControl).toHaveCount(right ? 1 : 0)
const metrics = await railMetrics(page)
expectContained(metrics, state, width)
if (center) {
@@ -149,17 +135,6 @@ async function captureState(args: {
expect(Math.abs(metrics.center!.center - metrics.composer.center), `${state}@${width}`)
.toBeLessThanOrEqual(1)
}
- if (typing && right) {
- expect(metrics.typing!.right, `${state}@${width}`).toBeLessThan(metrics.right!.left)
- }
- if (right) {
- expect(metrics.rightVisual, `${state}@${width}`).not.toBeNull()
- const visibleBaseline = metrics.center?.bottom ?? metrics.typing?.bottom ?? metrics.rail.bottom
- expect(
- Math.abs(metrics.rightVisual!.bottom - visibleBaseline),
- `${state}@${width}: visible WS bottom must align with its rail peers`,
- ).toBeLessThanOrEqual(1)
- }
evidence[width] = metrics
await testInfo.attach(`${width}-${state}.png`, {
body: await page.screenshot(),
@@ -208,11 +183,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
const alice = await asUser("alice")
const bob = await asUser("bob")
- let aliceWs: WebSocketRoute | null = null
- await alice.page.routeWebSocket((url) => url.pathname.endsWith("/user"), (ws) => {
- aliceWs = ws
- ws.connectToServer()
- })
await alice.page.setViewportSize({ width: 390, height: 844 })
await bob.page.setViewportSize({ width: 390, height: 844 })
const route = `/c/channels/${serverId}/${channelId}`
@@ -246,7 +216,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
layout: "centered",
center: true,
typing: false,
- right: false,
selection: true,
})
await alice.page.getByRole("button", { name: "Cancel message selection" }).click()
@@ -264,7 +233,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
layout: "centered",
center: true,
typing: false,
- right: false,
})
const bobEditor = composerEditable(bob.page)
@@ -283,7 +251,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
layout: "centered",
center: true,
typing: true,
- right: false,
})
await alice.page.getByTestId(tid.typingIndicator).evaluate((element) => {
@@ -302,7 +269,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
layout: "left-only",
center: false,
typing: true,
- right: false,
})
expect(leftOnly[320].typingText?.overflowX).toBe("hidden")
expect(leftOnly[320].typingText?.textOverflow).toBe("ellipsis")
@@ -320,7 +286,6 @@ test("composer accessory rail reallocates every occupied slot without overflow",
layout: "centered",
center: true,
typing: true,
- right: false,
selection: true,
widths: [390, 1280],
})
@@ -330,157 +295,32 @@ test("composer accessory rail reallocates every occupied slot without overflow",
await bobEditor.click()
await bob.page.keyboard.press("ControlOrMeta+A")
await bob.page.keyboard.press("Backspace")
- await bob.page.keyboard.type("typing occupancy outage")
+ await bob.page.keyboard.type("typing occupancy settle")
await expect(alice.page.getByTestId(tid.typingIndicator)).toBeVisible({ timeout: 4_000 })
}).toPass({ timeout: 20_000 })
- try {
- await alice.context.setOffline(true)
- expect(aliceWs).not.toBeNull()
- await aliceWs!.close({ code: 1012, reason: "occupancy e2e outage" })
- const unhealthyWs = alice.page.locator(
- `[data-testid='${tid.wsStatus}'], [data-testid='${tid.wsRetry}']`,
- )
- await expect(unhealthyWs).toBeVisible({ timeout: 10_000 })
- await expect(alice.page.locator("[data-e2e-node-identity='typing-survived']")).toHaveCount(1)
- await expect(alice.page.locator("[data-e2e-dot-identity='dot-survived']")).toHaveCount(1)
-
- await scrollRoot.evaluate((element) => {
- element.scrollTop = 0
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toBeVisible()
- await captureState({
- page: alice.page,
- testInfo,
- state: "l-c-r",
- layout: "centered",
- center: true,
- typing: true,
- right: true,
- widths: [390, 320, 1280],
- })
-
- await scrollRoot.evaluate((element) => {
- element.scrollTop = element.scrollHeight
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toHaveCount(0)
- row = alice.page.getByTestId(tid.message(selectableMessageId))
- await row.hover()
- await alice.page.getByTestId(tid.messageShare(selectableMessageId)).click()
- await expect(alice.page.getByTestId(tid.messageSelectionToolbar)).toBeVisible()
- await captureState({
- page: alice.page,
- testInfo,
- state: "selection-l-r",
- layout: "centered",
- center: true,
- typing: true,
- right: true,
- selection: true,
- widths: [390, 320, 1280],
- })
- await alice.page.getByRole("button", { name: "Cancel message selection" }).click()
- await scrollRoot.evaluate((element) => {
- element.scrollTop = element.scrollHeight
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toHaveCount(0)
-
- const leftRight = await captureState({
- page: alice.page,
- testInfo,
- state: "l-r",
- layout: "left-right",
- center: false,
- typing: true,
- right: true,
- widths: [390, 320, 1280],
- })
- expect(leftRight[320].typingText!.scrollWidth).toBeGreaterThan(leftRight[320].typingText!.clientWidth)
-
- await expect(alice.page.getByTestId(tid.typingIndicator)).toHaveCount(0, { timeout: 15_000 })
- await scrollRoot.evaluate((element) => {
- element.scrollTop = 0
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toBeVisible()
- await captureState({
- page: alice.page,
- testInfo,
- state: "c-r",
- layout: "centered",
- center: true,
- typing: false,
- right: true,
- widths: [390, 320, 1280],
- })
-
- await scrollRoot.evaluate((element) => {
- element.scrollTop = element.scrollHeight
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toHaveCount(0)
- await captureState({
- page: alice.page,
- testInfo,
- state: "r-only",
- layout: "right-only",
- center: false,
- typing: false,
- right: true,
- widths: [390, 320, 1280],
- })
-
- const retry = alice.page.getByTestId(tid.wsRetry)
- await expect(retry).toBeVisible({ timeout: 40_000 })
- await retry.focus()
- await retry.evaluate((element) => {
- element.setAttribute("data-e2e-node-identity", "retry-survived")
- })
- await expect(retry).toBeFocused()
- await scrollRoot.evaluate((element) => {
- element.scrollTop = 0
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toBeVisible()
- await expect(alice.page.locator("[data-e2e-node-identity='retry-survived']")).toBeFocused()
- await scrollRoot.evaluate((element) => {
- element.scrollTop = element.scrollHeight
- element.dispatchEvent(new Event("scroll"))
- })
- await expect(alice.page.getByTestId(tid.scrollToPresent)).toHaveCount(0)
- await expect(alice.page.locator("[data-e2e-node-identity='retry-survived']")).toBeFocused()
-
- await alice.page.setViewportSize({ width: 390, height: 844 })
- row = alice.page.getByTestId(tid.message(selectableMessageId))
- await row.hover()
- await alice.page.getByTestId(tid.messageShare(selectableMessageId)).click()
- await expect(alice.page.getByTestId(tid.messageSelectionToolbar)).toBeVisible()
- await captureState({
- page: alice.page,
- testInfo,
- state: "selection-r",
- layout: "centered",
- center: true,
- typing: false,
- right: true,
- selection: true,
- widths: [390, 320, 1280],
- })
- await alice.page.getByRole("button", { name: "Cancel message selection" }).click()
- } finally {
- await alice.context.setOffline(false)
- }
+ await expect(alice.page.getByTestId(tid.typingIndicator)).toHaveCount(0, { timeout: 15_000 })
+ await scrollRoot.evaluate((element) => {
+ element.scrollTop = 0
+ element.dispatchEvent(new Event("scroll"))
+ })
+ await expect(alice.page.getByTestId(tid.scrollToPresent)).toBeVisible()
+ await captureState({
+ page: alice.page,
+ testInfo,
+ state: "settled-center",
+ layout: "centered",
+ center: true,
+ typing: false,
+ widths: [390, 320, 1280],
+ })
- await alice.page.evaluate((retryTestId) => {
- document.querySelector<HTMLElement>(`[data-testid='${retryTestId}']`)?.click()
- }, tid.wsRetry)
- await expect(alice.page.locator(
- `[data-testid='${tid.wsStatus}'], [data-testid='${tid.wsRetry}']`,
- )).toHaveCount(0, { timeout: 20_000 })
- await expect(alice.page.getByTestId(tid.composerAccessoryRail)).toHaveCount(0)
+ await scrollRoot.evaluate((element) => {
+ element.scrollTop = element.scrollHeight
+ element.dispatchEvent(new Event("scroll"))
+ })
+ await expect(alice.page.getByTestId(tid.scrollToPresent)).toHaveCount(0)
+ await captureEmptyState(alice.page, testInfo)
await scrollRoot.evaluate((element) => {
element.scrollTop = 0
diff --git a/src/web/src/test/e2e-ui/31-machine-guide-motion.spec.ts b/src/web/src/test/e2e-ui/31-machine-guide-motion.spec.ts
new file mode 100644
index 000000000..a361c6423
--- /dev/null
+++ b/src/web/src/test/e2e-ui/31-machine-guide-motion.spec.ts
@@ -0,0 +1,172 @@
+import { test, expect } from "./_fixtures/community-fixture"
+import { tid } from "./_fixtures/testids"
+
+test("first-signup mobile guide clears the empty-state actions across the full flight", async ({ browser }) => {
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 } })
+ const page = await context.newPage()
+
+ try {
+ await page.goto("/sign-in")
+ await page.getByRole("textbox", { name: "Email" }).fill(
+ `guide-motion-${process.pid}-${Date.now()}@example.com`,
+ )
+ await page.getByRole("button", { name: "Sign in", exact: true }).click()
+ await page.waitForURL("**/c/me/machines", { waitUntil: "commit" })
+ await expect(page.getByRole("heading", { name: "No machines yet" })).toBeVisible()
+
+ await page.waitForFunction(
+ ({ travellerId, scaleAnimationName }) => {
+ const traveller = document.querySelector(`[data-testid="${travellerId}"]`)
+ const scale = traveller?.querySelector(".community-first-signup-guide-scale")
+ return Boolean(
+ traveller?.getAnimations().some(
+ (animation) => animation instanceof CSSAnimation &&
+ animation.animationName === "community-first-signup-guide-travel",
+ ) && scale?.getAnimations().some(
+ (animation) => animation instanceof CSSAnimation &&
+ animation.animationName === scaleAnimationName,
+ ),
+ )
+ },
+ {
+ travellerId: tid.machineFirstSignupGuide,
+ scaleAnimationName: "community-first-signup-guide-scale-mobile",
+ },
+ )
+
+ const report = await page.evaluate(({ travellerId, targetId }) => {
+ const traveller = document.querySelector(`[data-testid="${travellerId}"]`)
+ const scale = traveller?.querySelector(".community-first-signup-guide-scale")
+ const target = document.querySelector(`[data-testid="${targetId}"]`)
+ const connect = [...document.querySelectorAll("button")].find(
+ (button) => button.textContent?.trim() === "Connect a machine",
+ )
+ const guide = [...document.querySelectorAll("button")].find(
+ (button) => button.textContent?.trim() === "Guide me",
+ )
+ const copy = [...document.querySelectorAll("p")].find((element) =>
+ element.textContent?.includes("your bots run on it always-on"),
+ )
+ if (
+ !(traveller instanceof HTMLElement) ||
+ !(scale instanceof HTMLElement) ||
+ !(target instanceof HTMLElement) ||
+ !(connect instanceof HTMLElement) ||
+ !(guide instanceof HTMLElement) ||
+ !(copy instanceof HTMLElement)
+ ) {
+ throw new Error("mobile guide geometry targets are missing")
+ }
+
+ const travelAnimation = traveller.getAnimations().find(
+ (animation) => animation instanceof CSSAnimation &&
+ animation.animationName === "community-first-signup-guide-travel",
+ )
+ const scaleAnimation = scale.getAnimations().find(
+ (animation) => animation instanceof CSSAnimation &&
+ animation.animationName === "community-first-signup-guide-scale-mobile",
+ )
+ if (!travelAnimation || !scaleAnimation) {
+ throw new Error("mobile guide animations are missing")
+ }
+ travelAnimation.pause()
+ scaleAnimation.pause()
+
+ const rect = (element: Element) => {
+ const value = element.getBoundingClientRect()
+ return {
+ left: value.left,
+ top: value.top,
+ right: value.right,
+ bottom: value.bottom,
+ width: value.width,
+ height: value.height,
+ }
+ }
+ const overlapArea = (
+ a: ReturnType<typeof rect>,
+ b: ReturnType<typeof rect>,
+ ) => Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) *
+ Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top))
+
+ const connectRect = rect(connect)
+ const guideRect = rect(guide)
+ const copyRect = rect(copy)
+ const targetRect = rect(target)
+ const violations = {
+ connect: [] as number[],
+ largeClearance: [] as number[],
+ viewport: [] as number[],
+ scaleIncrease: [] as number[],
+ }
+ let previousSize = Number.POSITIVE_INFINITY
+ let minLargeClearance = Number.POSITIVE_INFINITY
+ let maxBottom = Number.NEGATIVE_INFINITY
+ let finalRect = rect(scale)
+
+ // The flight occupies 67.5%–97.5% of the 4s animation. Sampling 401
+ // points covers both endpoints and every 0.25% increment of the flight.
+ for (let index = 0; index <= 400; index += 1) {
+ const progress = index / 400
+ const currentTime = 2700 + progress * 1200
+ travelAnimation.currentTime = currentTime
+ scaleAnimation.currentTime = currentTime
+
+ const avatarRect = rect(scale)
+ const connectOverlap = overlapArea(avatarRect, connectRect)
+ const guideOverlap = overlapArea(avatarRect, guideRect)
+ const clearance = avatarRect.top - Math.max(connectRect.bottom, guideRect.bottom, copyRect.bottom)
+
+ if (connectOverlap > 0.01) violations.connect.push(index)
+ if (avatarRect.width > 32) {
+ minLargeClearance = Math.min(minLargeClearance, clearance)
+ if (clearance < 8 || guideOverlap > 0.01) {
+ violations.largeClearance.push(index)
+ }
+ }
+ if (
+ avatarRect.left < -0.01 ||
+ avatarRect.top < -0.01 ||
+ avatarRect.right > innerWidth + 0.01 ||
+ avatarRect.bottom > innerHeight + 0.01
+ ) {
+ violations.viewport.push(index)
+ }
+ if (avatarRect.width > previousSize + 0.01) {
+ violations.scaleIncrease.push(index)
+ }
+
+ previousSize = avatarRect.width
+ maxBottom = Math.max(maxBottom, avatarRect.bottom)
+ finalRect = avatarRect
+ }
+
+ return {
+ sampleCount: 401,
+ violations,
+ minLargeClearance,
+ maxBottom,
+ finalRect,
+ targetRect,
+ }
+ }, {
+ travellerId: tid.machineFirstSignupGuide,
+ targetId: tid.machineGuideAvatarTarget,
+ })
+
+ expect(report.sampleCount).toBe(401)
+ expect(report.violations).toEqual({
+ connect: [],
+ largeClearance: [],
+ viewport: [],
+ scaleIncrease: [],
+ })
+ expect(report.minLargeClearance).toBeGreaterThanOrEqual(8)
+ expect(report.maxBottom).toBeLessThanOrEqual(844)
+ for (const key of ["left", "top", "right", "bottom", "width", "height"] as const) {
+ expect(report.finalRect[key]).toBeCloseTo(report.targetRect[key], 4)
+ }
+ } finally {
+ await context.close()
+ }
+})
diff --git a/src/web/src/test/e2e-ui/32-mobile-ws-foreground-validation.spec.ts b/src/web/src/test/e2e-ui/32-mobile-ws-foreground-validation.spec.ts
index cc3893fef..af6178504 100644
--- a/src/web/src/test/e2e-ui/32-mobile-ws-foreground-validation.spec.ts
+++ b/src/web/src/test/e2e-ui/32-mobile-ws-foreground-validation.spec.ts
@@ -74,9 +74,7 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
window.dispatchEvent(new Event("online"))
})
}
- const wsControls = alice.page.locator(
- `[data-testid='${tid.wsStatus}'], [data-testid='${tid.wsRetry}']`,
- )
+ const wsOverlay = alice.page.getByTestId(tid.wsReconnectOverlay)
const initialConnectionCount = proxy.connectionCount()
const initialTokenRequests = tokenRequests
@@ -89,7 +87,7 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
frame.direction === "client-to-server"
&& (frame.type === "raw.ping" || frame.type === "connection.ping"),
)).toEqual([])
- await expect(wsControls).toHaveCount(0)
+ await expect(wsOverlay).toHaveCount(0)
const healthyStart = proxy.connectionFrames.length
await setVisibility("visible")
@@ -108,7 +106,7 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
).length).toBe(1)
expect(proxy.connectionCount()).toBe(initialConnectionCount)
expect(tokenRequests).toBe(initialTokenRequests)
- await expect(wsControls).toHaveCount(0)
+ await expect(wsOverlay).toHaveCount(0)
await expect(composerEditable(alice.page)).toBeVisible()
await setVisibility("hidden")
@@ -124,9 +122,9 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
).length).toBe(1)
proxy.sendConnectionFrame({ type: "connection.pong", nonce: "queued_stale_nonce" })
await alice.page.waitForTimeout(WS_CONNECTION_VALIDATION_TIMEOUT_MS - 1_000)
- await expect(wsControls).toHaveCount(0)
+ await expect(wsOverlay).toHaveCount(0)
- await expect(alice.page.getByTestId(tid.wsStatus)).toHaveAttribute(
+ await expect(wsOverlay).toHaveAttribute(
"data-ws-status",
"reconnecting",
{ timeout: 5_000 },
@@ -145,18 +143,18 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
expect(proxy.releaseHeldConnections((frame) =>
frame.type === "auth.ok" && frame.connectionId === failedConnectionBaseline + 1,
)).toBe(1)
- await expect(wsControls).toHaveCount(0, { timeout: 10_000 })
+ await expect(wsOverlay).toHaveCount(0, { timeout: 10_000 })
await expect(composerEditable(alice.page)).toBeVisible()
try {
await alice.context.setOffline(true)
await proxy.disconnect()
- await expect(alice.page.getByTestId(tid.wsStatus)).toHaveAttribute(
+ await expect(wsOverlay).toHaveAttribute(
"data-ws-status",
"reconnecting",
{ timeout: 10_000 },
)
- await expect(alice.page.getByTestId(tid.wsRetry)).toHaveAttribute(
+ await expect(wsOverlay).toHaveAttribute(
"data-ws-status",
"failed",
{ timeout: 40_000 },
@@ -166,7 +164,7 @@ test("mobile foreground proof is exact, bounded, and recovers through one curren
}
await alice.page.getByTestId(tid.wsRetry).click()
- await expect(wsControls).toHaveCount(0, { timeout: 20_000 })
+ await expect(wsOverlay).toHaveCount(0, { timeout: 20_000 })
const body = `foreground recovery ${stamp}`
await sendMessage(bob.page, body)
await expect(alice.page.getByText(body, { exact: true })).toBeVisible({ timeout: 20_000 })