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-threadsRequired Packages(2 packages)
pnpm add @tanstack/react-query aiA 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
| Option | Type | Default | Description |
|---|---|---|---|
client | DocyrusAgentThreadsClient | null | undefined | - | Client with get / post / patch / delete |
agentId | string | - | Tenant AI agent ID (required) |
userId | string | null | null | Only threads owned by / shared with this user |
projectId | string | null | null | Only threads of this project |
deploymentId | string | null | null | Filter by deployment instead of agent |
enabled | boolean | !!client | Toggle the list query |
UseDocyrusAgentThreadsResult
| Field | Type | Description |
|---|---|---|
threads | DocyrusAgentThread[] | { id, title, createdAt, updatedAt, bodyText?, createdBy?, createdByName?, projectId? }, newest first |
isLoading / error | boolean / Error | null | List query state |
refresh | () => Promise<void> | Invalidate the list |
loadMessages | (threadId) => Promise<UIMessage[]> | Messages as UIMessage[] (from body_json.parts, else body_text) |
isLoadingMessages | boolean | loadMessages pending |
renameThread | (threadId, subject) => Promise<boolean> | Rename |
isRenaming | boolean | Rename pending |
deleteThread | (threadId) => Promise<boolean> | Delete |
isDeleting | boolean | Delete pending |