ChatView (chat-view.tsx)

orin · ui, chat-ui, streaming, llm-chat, ai, realtime

Renders chat UI using AI SDK's useChat hook; manages messages, input state, and streaming responses.

"use client";

import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport, type UIMessage } from "ai";
import {
  useCallback,
  useEffect,
  useEffectEvent,
  useLayoutEffect,
  useMemo,
  useRef,
  useState,
  type CSSProperties,
} from "react";
import { useRouter } from "next/navigation";
import { motion, useReducedMotion } from "motion/react";
import { useStickToBottomContext } from "use-stick-to-bottom";
import { useShallow } from "zustand/react/shallow";

import {
  ChatMessageList,
  PENDING_ASSISTANT_ID,
} from "@/components/chat/message-list";
import {
  getComposerInput,
  useComposerStore,
} from "@/lib/stores/composer-store";
import { invalidateConversations, removeConversationOptimistic } from "@/lib/stores/conversations-store";
import {
  fetchConversationData,
  

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key