Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): refine landing motion and ref parsing

Gus6ddc7f9c34dc
diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.ts
index 4238dd655..cdeac53dd 100644
--- a/src/web/src/components/home/landing-content.test.ts
+++ b/src/web/src/components/home/landing-content.test.ts
@@ -124,6 +124,7 @@ describe("landing content contract", () => {
const reachSource = readFileSync(path.join(root, "src/components/home/landing-reach-motion.tsx"), "utf8")
const reachStyles = readFileSync(path.join(root, "src/components/home/landing-reach-motion.module.css"), "utf8")
const shellSource = readFileSync(path.join(root, "src/components/home/landing-shell-motion.tsx"), "utf8")
+ const playbackSource = readFileSync(path.join(root, "src/components/home/use-landing-motion-playback.ts"), "utf8")
const heroSource = readFileSync(path.join(root, "src/components/home/hero-section.tsx"), "utf8")
const typewriterSource = readFileSync(path.join(root, "src/components/typewriter-visual.tsx"), "utf8")
const swarmSource = readFileSync(path.join(root, "src/components/home/hero-avatar-swarm.tsx"), "utf8")
@@ -173,6 +174,14 @@ describe("landing content contract", () => {
expect(publicLayout).toContain("Rooms for people and agents.")
expect(publicLayout).not.toContain("Personal Company")
expect(landingPageSource).toContain("export function LandingPage")
+ expect(playbackSource).toContain("LANDING_MOTION_VISIBILITY_THRESHOLD = 0.3")
+ expect(playbackSource).toContain("IntersectionObserver")
+ expect(playbackSource).toContain('LandingMotionVisibility = "hidden" | "paused" | "playing"')
+ expect(playbackSource).toContain('shouldReset: visibility === "hidden"')
+ expect(shellSource).toContain("reducedMotion || !isPlaying")
+ expect(shellSource).toContain("!reducedMotion && shouldReset")
+ expect(reachSource).toContain("reducedMotion || !isPlaying")
+ expect(reachSource).toContain("!reducedMotion && shouldReset")
expect(landingPageSource).toContain("isLoggedIn={isLoggedIn}")
expect(landingPageSource).toContain('homeHref="/"')
expect(landingPageSource).toContain("highlightActions")
@@ -250,6 +259,9 @@ describe("landing content contract", () => {
expect(landingPageSource).toContain('initialStatusText="Free for dinner"')
expect(landingPageSource).toContain("IdentityProof")
expect(landingPageSource).toContain('data-testid="landing-identity-proof"')
+ expect(landingPageSource).toContain('data-testid="landing-identity-motion"')
+ expect(landingPageSource).toContain('<LandingShellMotion scene="identity" />')
+ expect(landingPageSource).not.toContain('<ProductScene scene="spaces" />')
expect(landingPageSource).toContain("ResizeObserver")
expect(landingPageSource).toContain("--identity-card-fit-scale")
expect(landingPageSource).toContain("styles.identityCardSlot")
@@ -283,7 +295,7 @@ describe("landing content contract", () => {
expect(landingStyles).toContain("--landing-section-bg")
expect(landingStyles.match(/--tw-blob-theme:/g)).toHaveLength(1)
expect(landingPageSource).toContain('<ProductScene scene="server" />')
- expect(landingPageSource).toContain('<ProductScene scene="spaces" />')
+ expect(landingPageSource).toContain('<LandingShellMotion scene="identity" />')
expect(landingPageSource).toContain('<ProductScene scene="machine" />')
expect(landingPageSource).toContain('<LandingShellMotion scene="continuity" />')
expect(landingPageSource.match(/className=\{styles\.productLayout\}/g)).toHaveLength(3)
diff --git a/src/web/src/components/home/landing-page.tsx b/src/web/src/components/home/landing-page.tsx
index 8af501d4d..fbe211290 100644
--- a/src/web/src/components/home/landing-page.tsx
+++ b/src/web/src/components/home/landing-page.tsx
@@ -228,7 +228,14 @@ function IdentityProof() {
<InteractiveIdentityProfileCard />
</div>
<div ref={sceneSlotRef} className={styles.identitySceneSlot}>
- <ProductScene scene="spaces" />
+ <div
+ className={styles.galleryFrame}
+ role="img"
+ aria-label="Maya keeps one identity across Studio, Home, and Game Night"
+ data-testid="landing-identity-motion"
+ >
+ <LandingShellMotion scene="identity" />
+ </div>
</div>
</div>
)
diff --git a/src/web/src/components/home/landing-reach-motion.tsx b/src/web/src/components/home/landing-reach-motion.tsx
index dafc94982..33fa1ec65 100644
--- a/src/web/src/components/home/landing-reach-motion.tsx
+++ b/src/web/src/components/home/landing-reach-motion.tsx
@@ -11,6 +11,7 @@ import {
SCENE_MAX_BEAT,
} from "./landing-shell-motion-timeline"
import styles from "./landing-reach-motion.module.css"
+import { useLandingMotionPlayback } from "./use-landing-motion-playback"
function useReducedMotion() {
const [reduced, setReduced] = useState(false)
@@ -30,22 +31,32 @@ export function LandingReachMotion() {
const maxBeat = SCENE_MAX_BEAT.server
const reducedMotion = useReducedMotion()
const [beat, setBeat] = useState(0)
+ const {
+ targetRef: playbackRef,
+ isPlaying,
+ shouldReset,
+ } = useLandingMotionPlayback<HTMLDivElement>()
useEffect(() => {
setBeat(reducedMotion ? maxBeat : 0)
}, [maxBeat, reducedMotion])
useEffect(() => {
- if (reducedMotion) return
+ if (!reducedMotion && shouldReset) setBeat(0)
+ }, [reducedMotion, shouldReset])
+
+ useEffect(() => {
+ if (reducedMotion || !isPlaying) return
const delay = beat >= maxBeat ? SCENE_FINAL_HOLD_MS : SCENE_BEAT_DURATION_MS
const timer = window.setTimeout(() => {
setBeat((current) => (current >= maxBeat ? 0 : current + 1))
}, delay)
return () => window.clearTimeout(timer)
- }, [beat, maxBeat, reducedMotion])
+ }, [beat, isPlaying, maxBeat, reducedMotion])
return (
<div
+ ref={playbackRef}
className={styles.stage}
data-testid="landing-reach-motion"
data-beat={beat}
diff --git a/src/web/src/components/home/landing-shell-motion-timeline.ts b/src/web/src/components/home/landing-shell-motion-timeline.ts
index 4cf78a185..82f95240c 100644
--- a/src/web/src/components/home/landing-shell-motion-timeline.ts
+++ b/src/web/src/components/home/landing-shell-motion-timeline.ts
@@ -1,4 +1,4 @@
-export type LandingScene = "server" | "machine" | "provider" | "spaces" | "continuity"
+export type LandingScene = "server" | "machine" | "provider" | "spaces" | "identity" | "continuity"
export type LandingRoom = "work" | "life" | "play"
@@ -10,11 +10,19 @@ export const LANDING_MACHINE_RUNTIMES = [
"pi",
] as const
+export const LANDING_IDENTITY_MAYA = {
+ authorId: "maya",
+ authorName: "Maya",
+ authorAvatar: "avatar:beam:maya",
+ content: "I’m here.",
+} as const
+
export const SCENE_MAX_BEAT: Record<LandingScene, number> = {
server: 6,
machine: 7,
provider: 9,
spaces: 12,
+ identity: 12,
continuity: 14,
}
@@ -108,6 +116,21 @@ const SPACES_CAMERAS = [
{ scale: 1.18, x: 650, y: 180 },
WIDE_CAMERA,
]
+const IDENTITY_CAMERAS = [
+ WIDE_CAMERA,
+ { scale: 1.18, x: 160, y: 28 },
+ { scale: 1.18, x: 200, y: 105 },
+ { scale: 1.18, x: 650, y: 180 },
+ { scale: 1.18, x: 84, y: 190 },
+ { scale: 1.18, x: 160, y: 28 },
+ { scale: 1.18, x: 200, y: 105 },
+ { scale: 1.18, x: 650, y: 180 },
+ { scale: 1.18, x: 84, y: 250 },
+ { scale: 1.18, x: 160, y: 28 },
+ { scale: 1.18, x: 200, y: 105 },
+ { scale: 1.18, x: 650, y: 180 },
+ WIDE_CAMERA,
+]
const CONTINUITY_CAMERAS = [
WIDE_CAMERA,
{ scale: 1.22, x: 680, y: 570 },
@@ -246,6 +269,37 @@ export function sceneSnapshot(scene: LandingScene, requestedBeat: number): Scene
camera: CONTINUITY_CAMERAS[beat] ?? WIDE_CAMERA,
}
}
+ if (scene === "identity") {
+ const room = beat >= 9 ? "play" : beat >= 5 ? "life" : "work"
+ return {
+ beat,
+ visibleMessages: [3, 4, 7, 8, 11, 12].includes(beat) ? 1 : 0,
+ composerText: "",
+ machineState: "online",
+ pairSheet: "closed",
+ runtime: "claude",
+ model: null,
+ room,
+ inviteOpen: false,
+ inviteSent: false,
+ focus: [
+ null,
+ "space-server-name-work",
+ "space-channel-work",
+ "identity-message-maya",
+ "server-life",
+ "space-server-name-life",
+ "space-channel-life",
+ "identity-message-maya",
+ "server-play",
+ "space-server-name-play",
+ "space-channel-play",
+ "identity-message-maya",
+ null,
+ ][beat] ?? null,
+ camera: IDENTITY_CAMERAS[beat] ?? WIDE_CAMERA,
+ }
+ }
return {
beat,
visibleMessages: beat >= 9 ? 3 : beat >= 7 ? 3 : 2,
diff --git a/src/web/src/components/home/landing-shell-motion.test.ts b/src/web/src/components/home/landing-shell-motion.test.ts
index 9e05b1cf6..ee6185be5 100644
--- a/src/web/src/components/home/landing-shell-motion.test.ts
+++ b/src/web/src/components/home/landing-shell-motion.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest"
import {
LANDING_MACHINE_RUNTIMES,
+ LANDING_IDENTITY_MAYA,
SCENE_BEAT_DURATION_MS,
SCENE_FINAL_HOLD_MS,
SCENE_MAX_BEAT,
@@ -9,6 +10,11 @@ import {
sceneDurationMs,
sceneSnapshot,
} from "./landing-shell-motion-timeline"
+import {
+ LANDING_MOTION_VISIBILITY_THRESHOLD,
+ landingMotionVisibility,
+ shouldPlayLandingMotion,
+} from "./use-landing-motion-playback"
describe("landing shell motion timeline", () => {
it("reveals the server conversation in causal order", () => {
@@ -82,6 +88,28 @@ describe("landing shell motion timeline", () => {
expect(sceneSnapshot("spaces", 12)).toMatchObject({ room: "play", focus: null, camera: { scale: 1 } })
})
+ it("shows the same Maya identity across Studio, Home, and Game Night", () => {
+ expect(LANDING_IDENTITY_MAYA).toEqual({
+ authorId: "maya",
+ authorName: "Maya",
+ authorAvatar: "avatar:beam:maya",
+ content: "I’m here.",
+ })
+ expect(sceneSnapshot("identity", 0)).toMatchObject({ room: "work", visibleMessages: 0, focus: null })
+ expect(sceneSnapshot("identity", 1)).toMatchObject({ room: "work", visibleMessages: 0, focus: "space-server-name-work" })
+ expect(sceneSnapshot("identity", 2)).toMatchObject({ room: "work", visibleMessages: 0, focus: "space-channel-work" })
+ expect(sceneSnapshot("identity", 3)).toMatchObject({ room: "work", visibleMessages: 1, focus: "identity-message-maya" })
+ expect(sceneSnapshot("identity", 4)).toMatchObject({ room: "work", visibleMessages: 1, focus: "server-life" })
+ expect(sceneSnapshot("identity", 5)).toMatchObject({ room: "life", visibleMessages: 0, focus: "space-server-name-life" })
+ expect(sceneSnapshot("identity", 6)).toMatchObject({ room: "life", visibleMessages: 0, focus: "space-channel-life" })
+ expect(sceneSnapshot("identity", 7)).toMatchObject({ room: "life", visibleMessages: 1, focus: "identity-message-maya" })
+ expect(sceneSnapshot("identity", 8)).toMatchObject({ room: "life", visibleMessages: 1, focus: "server-play" })
+ expect(sceneSnapshot("identity", 9)).toMatchObject({ room: "play", visibleMessages: 0, focus: "space-server-name-play" })
+ expect(sceneSnapshot("identity", 10)).toMatchObject({ room: "play", visibleMessages: 0, focus: "space-channel-play" })
+ expect(sceneSnapshot("identity", 11)).toMatchObject({ room: "play", visibleMessages: 1, focus: "identity-message-maya" })
+ expect(sceneSnapshot("identity", 12)).toMatchObject({ room: "play", visibleMessages: 1, focus: null, camera: { scale: 1 } })
+ })
+
it("turns one Gus request into two proactive exchanges discovered through unread inbox items", () => {
expect(sceneSnapshot("continuity", 0)).toMatchObject({ room: "work", visibleMessages: 0, focus: null })
expect(sceneSnapshot("continuity", 1)).toMatchObject({ composerText: "Alli, please move today’s priorities forward.", visibleMessages: 0, focus: "continuity-dm-composer" })
@@ -105,7 +133,7 @@ describe("landing shell motion timeline", () => {
).toEqual(Array.from({ length: 8 }, () => ""))
})
- it("zooms in around the cursor and returns wide in all five acts", () => {
+ it("zooms in around the cursor and returns wide in every shell act", () => {
expect(sceneSnapshot("server", 1).camera.scale).toBe(1.22)
expect(sceneSnapshot("server", 6).camera.scale).toBe(1)
expect(sceneSnapshot("machine", 2).camera.scale).toBe(1.22)
@@ -116,6 +144,8 @@ describe("landing shell motion timeline", () => {
expect(sceneSnapshot("provider", 9).camera.scale).toBe(1)
expect(sceneSnapshot("spaces", 5).camera.scale).toBe(1.2)
expect(sceneSnapshot("spaces", 12).camera.scale).toBe(1)
+ expect(sceneSnapshot("identity", 3).camera.scale).toBe(1.18)
+ expect(sceneSnapshot("identity", 12).camera.scale).toBe(1)
expect(sceneSnapshot("continuity", 6).camera.scale).toBe(1.2)
expect(sceneSnapshot("continuity", 14).camera.scale).toBe(1)
})
@@ -125,6 +155,7 @@ describe("landing shell motion timeline", () => {
expect(sceneSnapshot("server", 99).beat).toBe(SCENE_MAX_BEAT.server)
expect(sceneSnapshot("machine", 99).machineState).toBe("bot-born")
expect(sceneSnapshot("spaces", 99)).toMatchObject({ room: "play", inviteSent: true })
+ expect(sceneSnapshot("identity", 99)).toMatchObject({ room: "play", inviteOpen: false })
})
it("exposes each act's complete playback duration to gallery consumers", () => {
@@ -134,9 +165,34 @@ describe("landing shell motion timeline", () => {
expect(sceneDurationMs("machine")).toBe(12_900)
expect(sceneDurationMs("provider")).toBe(15_900)
expect(sceneDurationMs("spaces")).toBe(20_400)
+ expect(sceneDurationMs("identity")).toBe(20_400)
expect(sceneDurationMs("continuity")).toBe(23_400)
})
+ it("pauses below 30% visibility without marking the scene for reset", () => {
+ expect(LANDING_MOTION_VISIBILITY_THRESHOLD).toBe(0.3)
+ expect(landingMotionVisibility({ isIntersecting: true, intersectionRatio: 0.001 })).toBe("paused")
+ expect(landingMotionVisibility({ isIntersecting: true, intersectionRatio: 0.299 })).toBe("paused")
+ expect(shouldPlayLandingMotion({ isIntersecting: true, intersectionRatio: 0.299 })).toBe(false)
+ })
+
+ it("resets only once the frame has completely left the viewport", () => {
+ expect(landingMotionVisibility({ isIntersecting: false, intersectionRatio: 0 })).toBe("hidden")
+ expect(landingMotionVisibility({ isIntersecting: true, intersectionRatio: 0 })).toBe("hidden")
+ })
+
+ it("restarts from the reset beat after re-entering at 30% visibility", () => {
+ const visibilitySequence = [
+ landingMotionVisibility({ isIntersecting: false, intersectionRatio: 0 }),
+ landingMotionVisibility({ isIntersecting: true, intersectionRatio: 0.12 }),
+ landingMotionVisibility({ isIntersecting: true, intersectionRatio: 0.3 }),
+ ]
+
+ expect(visibilitySequence).toEqual(["hidden", "paused", "playing"])
+ expect(shouldPlayLandingMotion({ isIntersecting: true, intersectionRatio: 0.3 })).toBe(true)
+ expect(shouldPlayLandingMotion({ isIntersecting: false, intersectionRatio: 0.8 })).toBe(false)
+ })
+
it("boosts focused gallery beats while preserving wide beats", () => {
expect(galleryCameraScale(1)).toBe(1)
expect(galleryCameraScale(1.18)).toBe(1.6)
diff --git a/src/web/src/components/home/landing-shell-motion.tsx b/src/web/src/components/home/landing-shell-motion.tsx
index 3ef08d2e0..bc5b316bf 100644
--- a/src/web/src/components/home/landing-shell-motion.tsx
+++ b/src/web/src/components/home/landing-shell-motion.tsx
@@ -50,6 +50,7 @@ import { serializeBeamSeed } from "@/lib/avatar/seed-url"
import { tid } from "@/lib/community/testids"
import {
LANDING_MACHINE_RUNTIMES,
+ LANDING_IDENTITY_MAYA,
SCENE_BEAT_DURATION_MS,
SCENE_FINAL_HOLD_MS,
SCENE_MAX_BEAT,
@@ -60,6 +61,7 @@ import {
type SceneSnapshot,
} from "./landing-shell-motion-timeline"
import styles from "./landing-shell-motion.module.css"
+import { useLandingMotionPlayback } from "./use-landing-motion-playback"
const SERVERS: Server[] = [
{ id: "gus", name: "Gus", initial: "G", active: true, mentions: 0, isOwner: true, icon: null },
@@ -322,6 +324,20 @@ const SPACE_MESSAGES: Record<LandingRoom, RenderMsg[]> = {
],
}
+const IDENTITY_MESSAGES: Record<LandingRoom, RenderMsg[]> = Object.fromEntries(
+ (["work", "life", "play"] as const).map((room, index) => [
+ room,
+ [{
+ id: `identity-${room}-maya`,
+ type: "chat" as const,
+ ...LANDING_IDENTITY_MAYA,
+ createdAt: `2026-08-06T06:0${index}:08.000Z`,
+ seq: 520 + index,
+ grouped: false,
+ }],
+ ]),
+) as Record<LandingRoom, RenderMsg[]>
+
const DM_MESSAGES: RenderMsg[] = [
{
id: "dm-message-gus",
@@ -593,6 +609,11 @@ export function LandingShellMotion({
beat?: number
}) {
const [localBeat, setLocalBeat] = useState(0)
+ const {
+ targetRef: playbackRef,
+ isPlaying,
+ shouldReset,
+ } = useLandingMotionPlayback<HTMLDivElement>()
const stageRef = useRef<HTMLDivElement>(null)
const cameraRef = useRef<HTMLDivElement>(null)
const [stageScale, setStageScale] = useState(1)
@@ -610,13 +631,19 @@ export function LandingShellMotion({
}, [controlledBeat, scene, maxBeat, reducedMotion])
useEffect(() => {
- if (controlledBeat !== undefined || reducedMotion) return
+ if (controlledBeat === undefined && !reducedMotion && shouldReset) {
+ setLocalBeat(0)
+ }
+ }, [controlledBeat, reducedMotion, shouldReset])
+
+ useEffect(() => {
+ if (controlledBeat !== undefined || reducedMotion || !isPlaying) return
const delay = beat >= maxBeat ? SCENE_FINAL_HOLD_MS : SCENE_BEAT_DURATION_MS
const timer = window.setTimeout(() => {
setLocalBeat((current) => (current >= maxBeat ? 0 : current + 1))
}, delay)
return () => window.clearTimeout(timer)
- }, [beat, controlledBeat, maxBeat, reducedMotion])
+ }, [beat, controlledBeat, isPlaying, maxBeat, reducedMotion])
useEffect(() => {
const stage = stageRef.current
@@ -644,7 +671,7 @@ export function LandingShellMotion({
)
return (
- <div className={styles.root}>
+ <div ref={playbackRef} className={styles.root}>
<div
ref={stageRef}
className={styles.stage}
@@ -780,8 +807,9 @@ function PrototypeShell({
const serverView =
scene === "server" ||
scene === "spaces" ||
+ scene === "identity" ||
continuityRoom !== null
- const room = scene === "spaces" ? snapshot.room : continuityRoom
+ const room = scene === "spaces" || scene === "identity" ? snapshot.room : continuityRoom
const servers = room
? SPACE_SERVERS.map((server) => ({ ...server, active: server.id === room }))
: SERVERS
@@ -821,6 +849,7 @@ function PrototypeShell({
)}
{scene === "provider" && <ProviderScene snapshot={snapshot} />}
{scene === "spaces" && <SpacesScene snapshot={snapshot} />}
+ {scene === "identity" && <IdentityScene snapshot={snapshot} />}
{scene === "continuity" && <ContinuityScene snapshot={snapshot} />}
</div>
</div>
@@ -1145,6 +1174,46 @@ function SpacesScene({ snapshot }: { snapshot: SceneSnapshot }) {
)
}
+function IdentityScene({ snapshot }: { snapshot: SceneSnapshot }) {
+ const room = snapshot.room
+ const server = SPACE_SERVERS.find((item) => item.id === room) ?? SPACE_SERVERS[0]
+ const channel = SPACE_CHANNELS[room][0]?.channels[0]
+
+ return (
+ <>
+ <ChannelHeader
+ channel={channel?.name ?? "general"}
+ rightPanel={null}
+ onToggle={() => {}}
+ server={{ id: server.id, name: server.name, icon: server.icon ?? null }}
+ />
+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
+ <div className="flex-1 overflow-hidden px-4 py-3">
+ {IDENTITY_MESSAGES[room].map((message, index) => (
+ <div
+ key={message.id}
+ data-visible={index < snapshot.visibleMessages}
+ className={styles.messageSlot}
+ >
+ <div
+ data-motion-target="identity-message-maya"
+ className={targetClass(snapshot, "identity-message-maya")}
+ >
+ <Message m={message} onOpenThread={() => {}} />
+ </div>
+ </div>
+ ))}
+ </div>
+ <PrototypeComposer
+ snapshot={snapshot}
+ target="identity-composer"
+ placeholder={`Message /${channel?.name ?? "general"}`}
+ />
+ </div>
+ </>
+ )
+}
+
function ContinuityScene({ snapshot }: { snapshot: SceneSnapshot }) {
if (snapshot.beat < 7) {
return (
diff --git a/src/web/src/components/home/use-landing-motion-playback.ts b/src/web/src/components/home/use-landing-motion-playback.ts
new file mode 100644
index 000000000..e2bd2bd91
--- /dev/null
+++ b/src/web/src/components/home/use-landing-motion-playback.ts
@@ -0,0 +1,47 @@
+"use client"
+
+import { useEffect, useRef, useState } from "react"
+
+export const LANDING_MOTION_VISIBILITY_THRESHOLD = 0.3
+
+export type LandingMotionVisibility = "hidden" | "paused" | "playing"
+
+export function landingMotionVisibility(
+ entry: Pick<IntersectionObserverEntry, "isIntersecting" | "intersectionRatio">,
+): LandingMotionVisibility {
+ if (!entry.isIntersecting || entry.intersectionRatio <= 0) return "hidden"
+ if (entry.intersectionRatio < LANDING_MOTION_VISIBILITY_THRESHOLD) return "paused"
+ return "playing"
+}
+
+export function shouldPlayLandingMotion(entry: Pick<IntersectionObserverEntry, "isIntersecting" | "intersectionRatio">) {
+ return landingMotionVisibility(entry) === "playing"
+}
+
+export function useLandingMotionPlayback<T extends Element>() {
+ const targetRef = useRef<T>(null)
+ const [visibility, setVisibility] = useState<LandingMotionVisibility>("hidden")
+
+ useEffect(() => {
+ const target = targetRef.current
+ if (!target) return
+ if (!("IntersectionObserver" in window)) {
+ setVisibility("playing")
+ return
+ }
+
+ const observer = new IntersectionObserver(
+ ([entry]) => setVisibility(entry ? landingMotionVisibility(entry) : "hidden"),
+ { threshold: [0, LANDING_MOTION_VISIBILITY_THRESHOLD] },
+ )
+ observer.observe(target)
+ return () => observer.disconnect()
+ }, [])
+
+ return {
+ targetRef,
+ visibility,
+ isPlaying: visibility === "playing",
+ shouldReset: visibility === "hidden",
+ }
+}
diff --git a/src/web/src/lib/community/chat-syntax-plugin.test.ts b/src/web/src/lib/community/chat-syntax-plugin.test.ts
index 0ba2e5cdd..820fc44ca 100644
--- a/src/web/src/lib/community/chat-syntax-plugin.test.ts
+++ b/src/web/src/lib/community/chat-syntax-plugin.test.ts
@@ -219,6 +219,43 @@ describe("chatSyntaxPlugin — channelRef", () => {
expect(refs[1]).toMatchObject({ value: "/Gus#5994/架构/#722#17" })
})
+ it("keeps a full-width comma after a thread-message ref outside the pill", () => {
+ const children = paragraphChildren(parse("详情和 Cecilia 建议在 /Gus#5994/架构/#722#114,"))
+ expect(children.map((child) => child.type)).toEqual(["text", "channelRef", "text"])
+ expect(children[1]).toMatchObject({ value: "/Gus#5994/架构/#722#114" })
+ expect(children[2]).toMatchObject({ type: "text", value: "," })
+ })
+
+ it("terminates refs at common ASCII, smart, CJK, and full-width closing punctuation", () => {
+ const terminators = [
+ ".", ",", ";", ":", "!", "?", ")", "]", "}", '"', "'", "—", "’", "”", "…",
+ "、", "。", "〉", "》", "」", "』", "】", "〕", "〗", "〙", "〛",
+ "!", """, "'", ")", ",", ".", ":", ";", "?", "]", "}",
+ ]
+
+ for (const terminator of terminators) {
+ const children = paragraphChildren(parse(`/Gus#5994/架构/#722#114${terminator}`))
+ expect(children.map((child) => child.type), terminator).toEqual(["channelRef", "text"])
+ expect(children[0], terminator).toMatchObject({ value: "/Gus#5994/架构/#722#114" })
+ expect(children[1], terminator).toMatchObject({ type: "text", value: terminator })
+ }
+ })
+
+ it("keeps hyphens and underscores inside valid ref segments", () => {
+ const children = paragraphChildren(parse("see /Gus-Team#5994/front_end-v2 now"))
+ expect(children[1]).toMatchObject({
+ type: "channelRef",
+ value: "/Gus-Team#5994/front_end-v2",
+ })
+ })
+
+ it("recognizes both refs when common punctuation is their only separator", () => {
+ for (const separator of [",", ",", "。", ")", "”"]) {
+ const children = paragraphChildren(parse(`/studio#0042/general#42${separator}/Gus#5994/架构/#722#17`))
+ expect(children.filter((child) => child.type === "channelRef"), separator).toHaveLength(2)
+ }
+ })
+
it("leaves a channel-ref-shaped path inside inline code literal", () => {
const children = paragraphChildren(parse("`/studio#0042/general`"))
expect(children.map((c) => c.type)).toEqual(["inlineCode"])
diff --git a/src/web/src/lib/community/chat-syntax-plugin.ts b/src/web/src/lib/community/chat-syntax-plugin.ts
index c8bf38f76..b34aa0ad0 100644
--- a/src/web/src/lib/community/chat-syntax-plugin.ts
+++ b/src/web/src/lib/community/chat-syntax-plugin.ts
@@ -47,8 +47,9 @@ import type { SpoilerNode } from "./spoiler-syntax"
// `REF_TERM` is the single source of truth for the terminator set — used BOTH
// as the segment-class exclusion (`REF_SEG`) and the trailing lookahead, so
// the two can't drift out of the disjointness the boundary relies on. It
-// covers ASCII `.,;:!?)]` AND the common FULL-WIDTH CJK sentence punctuation
-// `。!?;:、)】`: a Chinese sentence ends in `。`, so `看 /Gus#0042/架构。` must
+// covers ASCII sentence/closing punctuation and the common Unicode variants
+// used by CJK prose and smart quotes. A Chinese sentence ends in `。`, so
+// `看 /Gus#0042/架构。` must
// yield pill `/Gus#0042/架构` + literal `。`, not swallow the period — full-width
// terminators matter MORE here since this fix targets CJK names (Blair's QA
// flag). Kept as a string spliced into `new RegExp(...)` so the shared set is
@@ -66,7 +67,7 @@ import type { SpoilerNode } from "./spoiler-syntax"
// matches. The trailing boundary
// remains load-bearing so the match still ends at the exact ref. `u` flag for
// correct astral/emoji handling.
-const REF_TERM = ".,;:!?)\\]\\u3002\\uFF01\\uFF1F\\uFF1B\\uFF1A\\u3001\\uFF09\\u3011"
+const REF_TERM = ".,;:!?)\\]}\"'\\u2014\\u2019\\u201D\\u2026\\u3001\\u3002\\u3009\\u300B\\u300D\\u300F\\u3011\\u3015\\u3017\\u3019\\u301B\\uFF01\\uFF02\\uFF07\\uFF09\\uFF0C\\uFF0E\\uFF1A\\uFF1B\\uFF1F\\uFF3D\\uFF5D"
const REF_SEG = `[^\\s/#${REF_TERM}]+`
const HANDLE_SEG = `${REF_SEG}#\\d{4,}`
// `/server#disc/channel` plus an optional message/thread suffix. The suffix has two