Skip to content

Commit 8d1ecd1

Browse files
avinashmadhwani02Harness
authored andcommitted
feat: Added replace in loadThreads (#10828)
* 4b3ccc format * 44c72e feat: Added replace in loadThreads
1 parent ca9859e commit 8d1ecd1

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/ai-chat-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@harnessio/ai-chat-core",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"scripts": {

packages/ai-chat-core/src/runtime/ThreadListRuntime/ThreadListRuntime.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ export class ThreadListRuntime extends BaseSubscribable {
215215
this._searchQuery = options.query
216216
}
217217

218+
if (options?.replace) {
219+
const threadsToDelete = Array.from(this._threads.keys()).filter(id => id !== this._mainThreadId)
220+
for (const threadId of threadsToDelete) {
221+
this._threads.delete(threadId)
222+
this._threadItems.delete(threadId)
223+
this._threadStates.delete(threadId)
224+
}
225+
}
226+
218227
this._isLoading = true
219228
this.notifySubscribers()
220229

packages/ai-chat-core/src/types/adapters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface ThreadListLoadOptions {
6363
query?: string
6464
offset?: number
6565
limit?: number
66+
replace?: boolean // If true, clears existing threads before loading
6667
// Allow custom pagination params for flexibility
6768
[key: string]: any
6869
}

0 commit comments

Comments
 (0)