66 ɵselectThreadsIsLoading ,
77 ɵselectHasNextPage ,
88 ɵselectIsFetchingNextPage ,
9- type ɵThread as CoreThread ,
109 type ɵThreadRuntimeContext ,
1110 type ɵThreadStore ,
1211} from "@copilotkit/core" ;
@@ -24,7 +23,14 @@ import {
2423 * Each thread has a unique `id`, an optional human-readable `name`, and
2524 * timestamp fields tracking creation and update times.
2625 */
27- export interface Thread extends CoreThread { }
26+ export interface Thread {
27+ id : string ;
28+ agentId : string ;
29+ name : string | null ;
30+ archived : boolean ;
31+ createdAt : string ;
32+ updatedAt : string ;
33+ }
2834
2935/**
3036 * Configuration for the {@link useThreads} hook.
@@ -68,18 +74,18 @@ export interface UseThreadsResult {
6874 error : Error | null ;
6975 /**
7076 * `true` when there are more threads available to fetch via
71- * {@link fetchNextPage }. Only meaningful when `limit` is set.
77+ * {@link fetchMoreThreads }. Only meaningful when `limit` is set.
7278 */
73- hasNextPage : boolean ;
79+ hasMoreThreads : boolean ;
7480 /**
7581 * `true` while a subsequent page of threads is being fetched.
7682 */
77- isFetchingNextPage : boolean ;
83+ isFetchingMoreThreads : boolean ;
7884 /**
79- * Fetch the next page of threads. No-op when {@link hasNextPage } is
80- * `false` or a page fetch is already in progress.
85+ * Fetch the next page of threads. No-op when {@link hasMoreThreads } is
86+ * `false` or a fetch is already in progress.
8187 */
82- fetchNextPage : ( ) => void ;
88+ fetchMoreThreads : ( ) => void ;
8389 /**
8490 * Rename a thread on the platform.
8591 * Resolves when the server confirms the update; rejects on failure.
@@ -169,11 +175,25 @@ export function useThreads({
169175 } ) ,
170176 ) ;
171177
172- const threads = useThreadStoreSelector ( store , ɵselectThreads ) ;
178+ const coreThreads = useThreadStoreSelector ( store , ɵselectThreads ) ;
179+ const threads : Thread [ ] = useMemo (
180+ ( ) =>
181+ coreThreads . map (
182+ ( { id, agentId, name, archived, createdAt, updatedAt } ) => ( {
183+ id,
184+ agentId,
185+ name,
186+ archived,
187+ createdAt,
188+ updatedAt,
189+ } ) ,
190+ ) ,
191+ [ coreThreads ] ,
192+ ) ;
173193 const storeIsLoading = useThreadStoreSelector ( store , ɵselectThreadsIsLoading ) ;
174194 const storeError = useThreadStoreSelector ( store , ɵselectThreadsError ) ;
175- const hasNextPage = useThreadStoreSelector ( store , ɵselectHasNextPage ) ;
176- const isFetchingNextPage = useThreadStoreSelector (
195+ const hasMoreThreads = useThreadStoreSelector ( store , ɵselectHasNextPage ) ;
196+ const isFetchingMoreThreads = useThreadStoreSelector (
177197 store ,
178198 ɵselectIsFetchingNextPage ,
179199 ) ;
@@ -240,15 +260,15 @@ export function useThreads({
240260 [ store ] ,
241261 ) ;
242262
243- const fetchNextPage = useCallback ( ( ) => store . fetchNextPage ( ) , [ store ] ) ;
263+ const fetchMoreThreads = useCallback ( ( ) => store . fetchNextPage ( ) , [ store ] ) ;
244264
245265 return {
246266 threads,
247267 isLoading,
248268 error,
249- hasNextPage ,
250- isFetchingNextPage ,
251- fetchNextPage ,
269+ hasMoreThreads ,
270+ isFetchingMoreThreads ,
271+ fetchMoreThreads ,
252272 renameThread,
253273 archiveThread,
254274 deleteThread,
0 commit comments