Thread List

Pro

A searchable conversation history grouped by recency — pinned, today, yesterday, the last seven days, older — with rename, pin and delete per row.

</>sv-thread-list aichathistoryconversationssidebar
import { SvThreadListComponent } from '@styloviz-pro/ai-chat';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

With row actions

Pro

Server search

Pro

When to use

  • The history rail of a chat app — `sv-ai-chat`’s full-page layout uses it.
  • Any list of past sessions a user returns to by title and date.

Async states

  • loading
  • error
  • retry

Item identity & owned state

Item key
itemKey — set this when your rows have no id, so selection survives a reorder.

Inputs

NameTypeDefaultDescription
threadsreadonly SvThread[][]The conversations.
activeIdstring | null (two-way)nullId of the open conversation. Two-way: picking a row writes it.
querystring (two-way)''The search term. Two-way, so it can be restored.
debounceMsnumber300Delay before `searched` fires, in milliseconds. `0` emits immediately.
filterLocallybooleantrueFilter `threads` by title and preview here. Turn off when the server searches.
searchablebooleantrueShow the search box.
groupBySvThreadGroupBy'recency'Group by recency, or one flat list.
actionsreadonly SvThreadAction[][]Row actions to offer, in this order. Empty shows none.
nowDate | nullnull"Now" for grouping and time labels; `null` uses the clock.
loadingbooleanfalseTrue while the host is fetching the list.
errorSvDataError | string | nullnullThe last failure fetching the list, or null.
itemKeySvItemKey<SvThread>'id'Stable identity for each thread.
labelsPartial<SvAiChatProLabels>{}Per-instance text, merged over the registry's `aiChatPro` labels.

Outputs

EventPayload typeDescription
searchedstringThe debounced search term — fetch matching threads when searching on the server.
threadRenameSvThreadRenameThe user renamed a thread. Persist it and bind the new list back.
threadPinSvThreadPinThe user pinned or unpinned a thread.
threadDeletestringThe user confirmed deleting a thread. The payload is its id.
retryvoidThe host should re-run the failed fetch.
activeIdChangestring | nullEmits the new `activeId` whenever it changes — the output half of `[(activeId)]`.
queryChangestringEmits the new `query` whenever it changes — the output half of `[(query)]`.

Wire it to your API

This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.

Template

Pro

Bound to the names this component actually exposes.

Host class

Pro

Drive the three async inputs from your own fetch.

  • `queryChange` carries `string`, not an `SvDataQuery`, so `@styloviz/data`'s controller cannot take it as it is. The handler above keeps the latest one and fetches with it — map it to whatever your endpoint expects.
  • `debounceMs` (default 300) collapses a burst of typing into one request. Set it to 0 only when the query is driven by clicks.
  • Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.

Full walkthrough: Connecting to a backend.

Customization & theming

  • `groupBy`: `recency` or `none` (one flat list).
  • `[actions]` turns on row actions; delete takes two presses, the second confirming.
  • The async contract: `loading`, `error`, `retry`, `itemKey`, and two empties — no conversations at all, and none matching the search.
  • `[now]` fixes the clock for grouping and time labels (tests, screenshots).
  • Text comes from the `aiChatPro` labels, or per instance through `[labels]`.

Best practices

  • Do: Persist rename, pin and delete, then bind the new list back. The component never edits `threads`, so it cannot disagree with your server when a write fails.
  • Do: Pass `updatedAt` when you have it — a conversation continued today belongs under Today, not under the day it started.
  • Don't: Do not filter twice. With server search, set `[filterLocally]="false"` and fetch on `searched`, which is debounced.
  • Tip: `ChatSession` from `sv-ai-chat` already has the `SvThread` shape.

Accessibility

  • A `nav` landmark with one list per group, each labelled by its heading; the open thread carries `aria-current`.
  • Row actions appear on hover and are always reachable by keyboard and touch; each names the conversation it acts on.
  • The rename box takes focus, commits on Enter and cancels on Escape.

Feedback on Thread List

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.