Files
hanzo.ai/app/forward/_forward.tsx
zeekay 6c65e3e941 @hanzo/app 0.2.0: the app SDK, renamed from @hanzo/rooms
Every import, the catalog pin and the docs name @hanzo/app and
github.com/hanzoai/app. lib/rooms.ts is lib/app.ts and
components/rooms.tsx is components/app.tsx.
2026-10-22 19:07:20 -07:00

56 lines
1.9 KiB
TypeScript

'use client'
/**
* The visit is counted where it arrived, then the reader goes to the chat.
*
* The tag manager (app/providers.tsx `startTags`) loads the tags the visitor's
* choice and region allow, from the site's tag set: hanzo.chat's own GA4 stream
* and the Meta Pixel, beside our stream's `$pageview`. The page leaves once they
* have taken the page view (`tagsReady`) or after LIMIT, whichever is first, so
* a blocked tag never holds a reader here. A tag the choice does not load is not
* waited for. `authorize` carries the visitor to hanzo.ai and sends our stream's
* queue before the page goes. The query and fragment ride along, so
* hanzo.chat/?q=… asks the chat.
*/
import { useEffect } from 'react'
import { Box } from '@hanzo/ui'
import { Line } from '@hanzo/ui/marketing'
import { authorize, tagsReady } from '@hanzo/app/lib/tags'
import { WEB } from '@hanzo/app/lib/host'
/** The longest a reader waits on the tags. */
const LIMIT = 3000
/** Time for the last hit a tag queued to leave before the page does. */
const BEAT = 250
export default function Forward() {
useEffect(() => {
let timer = 0
let gone = false
void tagsReady(LIMIT).then(() => {
if (gone) return
timer = window.setTimeout(() => {
const { search, hash } = window.location
window.location.replace(authorize(`${WEB}${search}${hash}`))
}, BEAT)
})
return () => {
gone = true
window.clearTimeout(timer)
}
}, [])
return (
<Box display="flex" flexDirection="column" minH="100vh" bg="$background" items="center" justify="center" gap="$3">
<Line render="h1" display="block" fontSize="$4" fontWeight="500" color="var(--foreground)">
Opening Hanzo Chat…
</Line>
<Line href={WEB} fontSize="$2" color="color-mix(in oklab, var(--pure-white) 50%, transparent)">
hanzo.ai/chat
</Line>
</Box>
)
}