Hooks

useDocyrusAgentThreads

Lists, renames, deletes and loads the messages of Docyrus AI assistant chat threads.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-agent-threads
Required Packages(2 packages)
pnpm add @tanstack/react-query ai

A verbatim port of the web hook. It manages the thread records (thread_type: 'assistant') of an agent and turns stored messages into AI SDK UIMessage[], ready for useChat().setMessages. useDocyrusAgentChat already embeds it.

Endpoints: GET /v1/apps/base/data-sources/thread/items (list), PATCH …/thread/items/{id} (rename), DELETE …/thread/items/{id} (delete), GET /v1/apps/base/data-sources/message/items (messages, max 200).

Usage

import { DocyrusAgentThreadsSidebar } from '@/components/docyrus-native/docyrus-agent';
import { useDocyrusAgentThreads } from '@/hooks/docyrus-native/use-docyrus-agent-threads';

const threads = useDocyrusAgentThreads({ client, agentId: AGENT_ID, userId: user?.id });

<DocyrusAgentThreadsSidebar
  agent={agent}
  threads={threads.threads}
  isLoading={threads.isLoading}
  onSelectThread={async thread => setMessages(await threads.loadMessages(thread.id))}
  onRenameThread={(thread, subject) => threads.renameThread(thread.id, subject)}
  onDeleteThread={thread => threads.deleteThread(thread.id)} />

API Reference

UseDocyrusAgentThreadsArgs

OptionTypeDefaultDescription
clientDocyrusAgentThreadsClient | null | undefined-Client with get / post / patch / delete
agentIdstring-Tenant AI agent ID (required)
userIdstring | nullnullOnly threads owned by / shared with this user
projectIdstring | nullnullOnly threads of this project
deploymentIdstring | nullnullFilter by deployment instead of agent
enabledboolean!!clientToggle the list query

UseDocyrusAgentThreadsResult

FieldTypeDescription
threadsDocyrusAgentThread[]{ id, title, createdAt, updatedAt, bodyText?, createdBy?, createdByName?, projectId? }, newest first
isLoading / errorboolean / Error | nullList query state
refresh() => Promise<void>Invalidate the list
loadMessages(threadId) => Promise<UIMessage[]>Messages as UIMessage[] (from body_json.parts, else body_text)
isLoadingMessagesbooleanloadMessages pending
renameThread(threadId, subject) => Promise<boolean>Rename
isRenamingbooleanRename pending
deleteThread(threadId) => Promise<boolean>Delete
isDeletingbooleanDelete pending

On this page