@assistant-ui/react 0.5.84 → 0.5.85

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -4652,7 +4652,14 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
4652
4652
  var LocalThreadManagerRuntimeCore = class {
4653
4653
  constructor(_threadFactory) {
4654
4654
  this._threadFactory = _threadFactory;
4655
- this._mainThread = this._threadFactory(generateId(), { messages: [] });
4655
+ const threadId = generateId();
4656
+ this._threadData.set(threadId, {
4657
+ data: { messages: [] },
4658
+ metadata: { threadId },
4659
+ isArchived: false
4660
+ });
4661
+ this._threads = [{ threadId }];
4662
+ this._mainThread = this._threadFactory(threadId, { messages: [] });
4656
4663
  }
4657
4664
  _threadData = /* @__PURE__ */ new Map();
4658
4665
  _threads = [];
@@ -4675,17 +4682,21 @@ var LocalThreadManagerRuntimeCore = class {
4675
4682
  this._performThreadSwitch(thread);
4676
4683
  }
4677
4684
  switchToNewThread() {
4678
- if (!this._mainThread) return;
4679
- const thread = this._threadFactory(generateId(), { messages: [] });
4685
+ const threadId = generateId();
4686
+ this._threadData.set(threadId, {
4687
+ data: { messages: [] },
4688
+ metadata: { threadId },
4689
+ isArchived: false
4690
+ });
4691
+ this._threads = [{ threadId }];
4692
+ const thread = this._threadFactory(threadId, { messages: [] });
4680
4693
  this._performThreadSwitch(thread);
4681
4694
  }
4682
4695
  _performThreadSwitch(newThreadCore) {
4683
- if (this._mainThread) {
4684
- const data = this._threadData.get(this._mainThread.threadId);
4685
- if (!data) throw new Error("Thread not found");
4686
- const exprt = this._mainThread.export();
4687
- data.data = exprt;
4688
- }
4696
+ const data = this._threadData.get(this._mainThread.threadId);
4697
+ if (!data) throw new Error("Thread not found");
4698
+ const exprt = this._mainThread.export();
4699
+ data.data = exprt;
4689
4700
  this._mainThread._notifyEventSubscribers("switched-away");
4690
4701
  this._mainThread = newThreadCore;
4691
4702
  newThreadCore._notifyEventSubscribers("switched-to");