Thinking UI

Chat HistoryPRO

A sidebar of past conversations grouped by recency, with a gliding active highlight, inline rename and delete.

Code

1 file · 376 lines of TypeScriptPRO

Chat History is part of Pro

Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.

Motion notes

  • The active highlight is a single shared element that glides between rows on the layout spring, so switching chats feels like moving through one list, not repainting it.
  • New chats slide down into the top of the list out of a soft blur while the rows below make room. Deleted rows collapse their own height, so nothing below jumps.
  • Rows only clip while they open or close. Once settled, the highlight and the menu are never cut off. A renamed title swaps in with the shared vertical blur.
  • The "…" button appears on hover or keyboard focus and opens a small menu with arrow-key navigation. With reduced motion, rows fade instead of collapsing and the highlight jumps.

Usage

Example
<ChatHistory
    chats={chats}
    activeId={chatId}
    onSelect={openChat}
    onNewChat={startChat}
    onRename={(id, title) => renameChat(id, title)}
    onDelete={(id) => setChats((c) => c.filter((x) => x.id !== id))}
  />

Props

PropTypeDefaultDescription
chatsChatHistoryItem[]—{ id, title, updatedAt: Date | number | string }. Sorted newest first and grouped into Today, Yesterday, Previous 7 days and Older.
activeIdstring—The open conversation. Gets aria-current="page".
onSelect(id: string) => void—Called when a row is clicked.
onNewChat() => void—Shows a New chat button above the list.
onRename(id: string, title: string) => void—Enables inline rename. Called with the trimmed title when it changed.
onDelete(id: string) => void—Enables delete. Remove the chat from chats to collapse its row.
nowDate | number—Reference time for grouping. Pass it for deterministic SSR. Defaults to mount time.
menuIdstring | null—Controlled open menu. null closes it.
onMenuIdChange(id: string | null) => void—Called when a menu opens or closes.
renamingIdstring | null—Controlled row in rename mode. null ends renaming.
onRenamingIdChange(id: string | null) => void—Called when renaming starts or ends.
classNamestring—Classes for the nav.