Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

570 B
Raw Blame
import { useLayoutEffect, useRef, type UIEvent } from 'react'
import { scrolledToEnd } from './trace-turns'

/** A scroll box that opens at the end and follows new content there until the reader scrolls up. */
export function useFollowEnd() {
  const ref = useRef<HTMLDivElement>(null)
  const atEnd = useRef(true)
  useLayoutEffect(() => {
    const el = ref.current
    if (el && atEnd.current) el.scrollTop = el.scrollHeight
  })
  const onScroll = (e: UIEvent<HTMLDivElement>) => {
    atEnd.current = scrolledToEnd(e.currentTarget)
  }
  return { ref, onScroll }
}