Thread List
ProA searchable conversation history grouped by recency — pinned, today, yesterday, the last seven days, older — with rename, pin and delete per row.
import { SvThreadListComponent } from '@styloviz-pro/ai-chat';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
With row actions
Server search
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 noid, so selection survives a reorder.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| threads | readonly SvThread[] | [] | The conversations. |
| activeId | string | null (two-way) | null | Id of the open conversation. Two-way: picking a row writes it. |
| query | string (two-way) | '' | The search term. Two-way, so it can be restored. |
| debounceMs | number | 300 | Delay before `searched` fires, in milliseconds. `0` emits immediately. |
| filterLocally | boolean | true | Filter `threads` by title and preview here. Turn off when the server searches. |
| searchable | boolean | true | Show the search box. |
| groupBy | SvThreadGroupBy | 'recency' | Group by recency, or one flat list. |
| actions | readonly SvThreadAction[] | [] | Row actions to offer, in this order. Empty shows none. |
| now | Date | null | null | "Now" for grouping and time labels; `null` uses the clock. |
| loading | boolean | false | True while the host is fetching the list. |
| error | SvDataError | string | null | null | The last failure fetching the list, or null. |
| itemKey | SvItemKey<SvThread> | 'id' | Stable identity for each thread. |
| labels | Partial<SvAiChatProLabels> | {} | Per-instance text, merged over the registry's `aiChatPro` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| searched | string | The debounced search term — fetch matching threads when searching on the server. |
| threadRename | SvThreadRename | The user renamed a thread. Persist it and bind the new list back. |
| threadPin | SvThreadPin | The user pinned or unpinned a thread. |
| threadDelete | string | The user confirmed deleting a thread. The payload is its id. |
| retry | void | The host should re-run the failed fetch. |
| activeIdChange | string | null | Emits the new `activeId` whenever it changes — the output half of `[(activeId)]`. |
| queryChange | string | Emits 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
Bound to the names this component actually exposes.
Host class
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.