Index of every page on this site: llms.txt
All skills
assistant-ui avatar

/thread-list

@b0609e6
by assistant-uiassistant-ui/skills29 stars
7
Run it yourself

Builds and customizes multiple conversation lists in assistant-ui with the runtime connected ThreadList and ThreadListSidebar elements, ThreadListPrimitive, ThreadListItemPrimitive, ThreadListItemMorePrimitive, useAui, useAuiState, and threads.selectionChanged. Use when adding a conversation sidebar, switching, archiving, renaming, deleting, searching, grouping, paginating, or persisting threads, or when thread state is stale after authentication. Covers AssistantCloud, RemoteThreadListRuntime, and ExternalStoreThreadListAdapter. Use runtime for the active conversation runtime, cloud for managed authentication and persistence, and elements for registry installation and styling.

Use this Skill: https://skilld.dev/gh/assistant-ui/skills/thread-list

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈175 tokens for metadata: the name and description. ≈2.4k when used: this file. ≈6.1k more on demand in 3 files.

Description uses 8.8% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈700 characters, or 8.8%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

assistant-ui Thread List

Always consult assistant-ui.com/llms.txt for the latest API.

A runtime starts with one in memory conversation. Add a thread list only when people need to create, select, and manage multiple conversations. Choose the managed cloud path, a backend adapter, or an external store before choosing the UI.

References

Quick Start

Install the runtime connected list with npx assistant-ui@latest add thread-list. It creates components/assistant-ui/elements/thread-list.aui.tsx. Pass an AssistantCloud instance to useChatRuntime for managed threads, then render the list and active thread beneath the provider.

"use client";

import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import { AssistantCloud } from "assistant-cloud";
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
import { ThreadList } from "@/components/assistant-ui/elements/thread-list.aui";

const cloud = new AssistantCloud({
  baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL,
  anonymous: true,
});

export function Chat() {
  const runtime = useChatRuntime({ cloud });

  return (
    <AssistantRuntimeProvider runtime={runtime}>
      <div className="flex h-dvh">
        <aside className="w-72 border-e p-2">
          <ThreadList />
        </aside>
        <main className="min-w-0 flex-1">
          <Thread />
        </main>
      </div>
    </AssistantRuntimeProvider>
  );
}

Use the full sidebar shell when the project already uses the shadcn sidebar primitives. ThreadListSidebar renders the runtime connected thread list itself, so do not also mount ThreadList inside it.

import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
import { ThreadListSidebar } from "@/components/assistant-ui/elements/threadlist-sidebar.aui";

export function ChatLayout() {
  return (
    <SidebarProvider>
      <ThreadListSidebar />
      <SidebarInset>
        <Thread />
      </SidebarInset>
    </SidebarProvider>
  );
}

ThreadListSidebar still needs the AssistantRuntimeProvider ancestor from the first example. Its SidebarProvider is separate layout context.

Thread Operations

Use useAui() for commands. Scope accessors are properties, so use aui.threads and aui.threadListItem, never aui.threads(). Read each state value independently with useAuiState. A selector may return one primitive value or a stable runtime reference, but never an object or array literal.

import { useAui, useAuiState } from "@assistant-ui/react";

export function ThreadControls({ threadId }: { threadId: string }) {
  const aui = useAui();
  const activeThreadId = useAuiState((s) => s.threads.mainThreadId);
  const threadIds = useAuiState((s) => s.threads.threadIds);
  const isLoading = useAuiState((s) => s.threads.isLoading);

  const item = aui.threads.item({ id: threadId });

  return (
    <div>
      <p>{threadIds.length} conversations</p>
      <p>{activeThreadId === threadId ? "Current" : "Available"}</p>
      <button disabled={isLoading} onClick={() => aui.threads.switchToNewThread()}>
        New conversation
      </button>
      <button onClick={() => item.switchTo()}>Open</button>
      <button onClick={() => item.rename("Project planning")}>Rename</button>
      <button onClick={() => item.archive()}>Archive</button>
      <button onClick={() => item.delete()}>Delete</button>
    </div>
  );
}

Inside a thread item primitive, s.threadListItem is the item in scope. Select fields individually, not the whole state object, when a row only needs one value.

import { useAuiState } from "@assistant-ui/react";

export function ThreadRunningBadge() {
  const isRunning = useAuiState((s) => s.threadListItem.isRunning);
  return isRunning ? <span>Working</span> : null;
}

Compose a Custom List

Start from the three primitive namespaces when the installed element's date grouping, search, or visual treatment does not match the product. Items supplies the current item scope and its children render function replaces the deprecated components prop.

import {
  ThreadListItemMorePrimitive,
  ThreadListItemPrimitive,
  ThreadListPrimitive,
} from "@assistant-ui/react";

export function CustomThreadList() {
  return (
    <ThreadListPrimitive.Root className="flex flex-col gap-1">
      <ThreadListPrimitive.New>New conversation</ThreadListPrimitive.New>
      <ThreadListPrimitive.Items>
        {({ threadListItem }) => (
          <ThreadListItemPrimitive.Root data-thread-id={threadListItem.id}>
            <ThreadListItemPrimitive.Trigger className="flex-1 text-left">
              <ThreadListItemPrimitive.Title fallback="New conversation" />
            </ThreadListItemPrimitive.Trigger>
            <ThreadListItemMorePrimitive.Root sharedFocusGroup>
              <ThreadListItemMorePrimitive.Trigger>
                More
              </ThreadListItemMorePrimitive.Trigger>
              <ThreadListItemMorePrimitive.Content>
                <ThreadListItemPrimitive.Archive asChild>
                  <ThreadListItemMorePrimitive.Item>
                    Archive
                  </ThreadListItemMorePrimitive.Item>
                </ThreadListItemPrimitive.Archive>
                <ThreadListItemMorePrimitive.Separator />
                <ThreadListItemPrimitive.Delete asChild>
                  <ThreadListItemMorePrimitive.Item>
                    Delete
                  </ThreadListItemMorePrimitive.Item>
                </ThreadListItemPrimitive.Delete>
              </ThreadListItemMorePrimitive.Content>
            </ThreadListItemMorePrimitive.Root>
          </ThreadListItemPrimitive.Root>
        )}
      </ThreadListPrimitive.Items>
    </ThreadListPrimitive.Root>
  );
}

See custom UI for archived rows, load more, custom search, grouping, keyboard behavior, and the complete part reference.

Choose a Multi Conversation Path

Path Use it when Thread metadata lives in
AssistantCloud You want managed authentication, persistence, synchronization, and titles assistant-cloud
useRemoteThreadListRuntime with RemoteThreadListAdapter A LocalRuntime based runtime uses the application's database Your backend
ExternalStoreThreadListAdapter An ExternalStoreRuntime already owns messages and selection Your state store

The cloud quick start above is the managed path. The remote and external store paths have different ownership and lifecycle requirements. Follow remote adapter instead of mixing their APIs.

Observe Selection

threads.selectionChanged replaces the old per item switch events. It runs for every selection change and supplies both IDs. It does not run for the initial selection on mount.

import { useAuiEvent } from "@assistant-ui/react";

export function SelectionTelemetry() {
  useAuiEvent(
    "threads.selectionChanged",
    ({ threadId, previousThreadId }) => {
      recordThreadSelection({ threadId, previousThreadId });
    },
  );
  return null;
}

When this listener is inside an item row, compare threadId to s.threadListItem.id if it should react only when that row becomes current.

Common Gotchas

The list renders but no conversations persist

  • A default runtime is one in memory thread. Pass cloud, use a RemoteThreadListAdapter, or provide an ExternalStoreThreadListAdapter.
  • A remote adapter manages metadata only. Add a history adapter or another message persistence layer for each conversation's messages.

A thread switch uses stale messages

  • On a RemoteThreadList store entry, wrap the thread factory in withKey(id, ...) so a history adapter mounts for the selected ID.
  • Use backgroundThreads only when runs should continue after selection changes and retaining visited threads in memory is acceptable.

The sidebar has no runtime

  • ThreadList and ThreadListSidebar need an AssistantRuntimeProvider ancestor.
  • ThreadListSidebar also needs the shadcn SidebarProvider because it is a sidebar shell, not a runtime provider.

Rows re render on every unrelated store change

  • Replace selectors that return object or array literals with separate useAuiState calls. Returning s.threads.threadIds directly is safe because it is a runtime supplied stable reference.

The switch handler stopped firing after an upgrade

  • Subscribe to threads.selectionChanged and use previousThreadId. The retired threadListItem.switchedTo and threadListItem.switchedAway events are not the current integration point.

Related Skills

  • runtime -- choose and configure the runtime that owns the active conversation
  • cloud -- configure AssistantCloud authentication, persistence, and managed threads
  • elements -- install, style, and customize the runtime connected registry components

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides a well-structured and safe framework for building conversation thread management interfaces. It correctly follows security best practices by using environment variables for configuration and leveraging official vendor packages. A minor risk is present regarding the processing of thread titles and metadata, which could serve as a surface for indirect prompt injection if an agent interprets them as instructions without validation.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/3 files flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at b0609e6. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 3 months ago
  • React
  • TypeScript
  • assistant-ui
  • thread-management
  • chat-ui
  • conversation-history
  • cloud-persistence
  • custom-components

README badge

README badge for assistant-ui/skills/thread-list

Implements multi-thread conversation management for assistant-ui apps using a prebuilt ThreadList component or custom primitives (ThreadListPrimitive, ThreadListItemPrimitive). Handles thread CRUD operations (create, switch, rename, archive, delete) via the useAui API, with optional cloud persistence through AssistantCloud or local in-memory storage.

Generated from the current SKILL.md.

Does this skill work without cloud persistence?
Yes. You can use `useRemoteThreadListRuntime` with `InMemoryThreadListAdapter` for local-only thread management, though threads will not persist across sessions.
Can I build a custom thread list UI?
Yes. Use `ThreadListPrimitive` and `ThreadListItemPrimitive` components to compose a custom sidebar with full control over layout, styling, and actions like archive, delete, and rename.
What thread operations are available?
You can switch threads, create new threads, rename, archive, unarchive, delete, generate titles, and read thread IDs and archived status via the `useAui()` and `useAuiState()` hooks.
Do I need AssistantCloud for thread persistence?
Yes. Cloud-backed persistence requires `AssistantCloud` configured with your auth token and base URL passed to `useChatRuntime`.

Generated from the current SKILL.md. These answers refresh after source changes.