@yourgpt/copilot-sdk 2.1.5-alpha.3 → 2.1.5-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{MessageTree-CoIt_4nB.d.cts → MessageTree-B0JGQOCi.d.cts} +1 -1
  2. package/dist/{MessageTree-CzaN9Eul.d.ts → MessageTree-CSIHErPK.d.ts} +1 -1
  3. package/dist/{ThreadManager-BEAECB7Y.d.ts → ThreadManager-D7KwT2FJ.d.ts} +3 -1
  4. package/dist/{ThreadManager-Cw5fwyCN.d.cts → ThreadManager-DK46fVl3.d.cts} +3 -1
  5. package/dist/{chunk-WIXFZUEZ.cjs → chunk-B4YDIMP3.cjs} +4 -3
  6. package/dist/chunk-B4YDIMP3.cjs.map +1 -0
  7. package/dist/{chunk-WZ2TOZ7M.js → chunk-EEH3L64W.js} +4 -3
  8. package/dist/chunk-EEH3L64W.js.map +1 -0
  9. package/dist/{chunk-PT2TOHG5.js → chunk-FLZO2FO3.js} +6 -4
  10. package/dist/chunk-FLZO2FO3.js.map +1 -0
  11. package/dist/{chunk-TCPAT3WG.cjs → chunk-XUR3IOPX.cjs} +34 -32
  12. package/dist/chunk-XUR3IOPX.cjs.map +1 -0
  13. package/dist/core/index.cjs +72 -72
  14. package/dist/core/index.d.cts +4 -4
  15. package/dist/core/index.d.ts +4 -4
  16. package/dist/core/index.js +1 -1
  17. package/dist/react/index.cjs +62 -62
  18. package/dist/react/index.d.cts +6 -6
  19. package/dist/react/index.d.ts +6 -6
  20. package/dist/react/index.js +2 -2
  21. package/dist/{types-BeFBBZ5i.d.cts → types-waEqyE4K.d.cts} +5 -0
  22. package/dist/{types-BeFBBZ5i.d.ts → types-waEqyE4K.d.ts} +5 -0
  23. package/dist/ui/index.cjs +17 -10
  24. package/dist/ui/index.cjs.map +1 -1
  25. package/dist/ui/index.d.cts +2 -2
  26. package/dist/ui/index.d.ts +2 -2
  27. package/dist/ui/index.js +14 -7
  28. package/dist/ui/index.js.map +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-PT2TOHG5.js.map +0 -1
  31. package/dist/chunk-TCPAT3WG.cjs.map +0 -1
  32. package/dist/chunk-WIXFZUEZ.cjs.map +0 -1
  33. package/dist/chunk-WZ2TOZ7M.js.map +0 -1
@@ -7,9 +7,9 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
7
7
  import { VariantProps } from 'class-variance-authority';
8
8
  import * as use_stick_to_bottom from 'use-stick-to-bottom';
9
9
  import { d as WebSearchResult, f as WebSearchResponse } from '../types-ZguuKEs_.cjs';
10
- import { a as Thread, c as ThreadStorageAdapter, A as AsyncThreadStorageAdapter } from '../types-BeFBBZ5i.cjs';
10
+ import { a as Thread, c as ThreadStorageAdapter, A as AsyncThreadStorageAdapter } from '../types-waEqyE4K.cjs';
11
11
  import { T as ToolDefinition } from '../tools-tmksfhUo.cjs';
12
- import { B as BranchInfo } from '../MessageTree-CoIt_4nB.cjs';
12
+ import { B as BranchInfo } from '../MessageTree-B0JGQOCi.cjs';
13
13
  import { d as MCPUIIntent, n as MCPUIFrameProps, M as MCPUIResource } from '../types-B20VCJXL.cjs';
14
14
  import { ClassValue } from 'clsx';
15
15
 
@@ -7,9 +7,9 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
7
7
  import { VariantProps } from 'class-variance-authority';
8
8
  import * as use_stick_to_bottom from 'use-stick-to-bottom';
9
9
  import { d as WebSearchResult, f as WebSearchResponse } from '../types-ZguuKEs_.js';
10
- import { a as Thread, c as ThreadStorageAdapter, A as AsyncThreadStorageAdapter } from '../types-BeFBBZ5i.js';
10
+ import { a as Thread, c as ThreadStorageAdapter, A as AsyncThreadStorageAdapter } from '../types-waEqyE4K.js';
11
11
  import { T as ToolDefinition } from '../tools-tmksfhUo.js';
12
- import { B as BranchInfo } from '../MessageTree-CzaN9Eul.js';
12
+ import { B as BranchInfo } from '../MessageTree-CSIHErPK.js';
13
13
  import { d as MCPUIIntent, n as MCPUIFrameProps, M as MCPUIResource } from '../types-B20VCJXL.js';
14
14
  import { ClassValue } from 'clsx';
15
15
 
package/dist/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useCopilot, useThreadManager } from '../chunk-PT2TOHG5.js';
2
- import { createServerAdapter } from '../chunk-WZ2TOZ7M.js';
1
+ import { useCopilot, useThreadManager } from '../chunk-FLZO2FO3.js';
2
+ import { createServerAdapter } from '../chunk-EEH3L64W.js';
3
3
  import { DEFAULT_MCP_UI_SANDBOX, parseMCPUIMessage } from '../chunk-G4SF2PNQ.js';
4
4
  import '../chunk-EWVQWTNV.js';
5
5
  import '../chunk-VNLLW3ZI.js';
@@ -6551,7 +6551,7 @@ function useInternalThreadManager(config = {}) {
6551
6551
  clearCurrentThread,
6552
6552
  refreshThreads
6553
6553
  } = threadManager;
6554
- const { messages, setMessages, status, isLoading, getAllMessages } = useCopilot();
6554
+ const { messages, setMessages, status, isLoading, getAllMessages, switchBranch } = useCopilot();
6555
6555
  const isLoadingMessagesRef = useRef(false);
6556
6556
  const savingToThreadRef = useRef(null);
6557
6557
  const lastSavedSnapshotRef = useRef("");
@@ -6599,6 +6599,9 @@ function useInternalThreadManager(config = {}) {
6599
6599
  lastSavedSnapshotRef.current = getMessageSnapshot(uiMessages);
6600
6600
  savingToThreadRef.current = threadId;
6601
6601
  setMessages(uiMessages);
6602
+ if (thread.activeLeafId) {
6603
+ switchBranch(thread.activeLeafId);
6604
+ }
6602
6605
  } else {
6603
6606
  lastSavedSnapshotRef.current = "";
6604
6607
  savingToThreadRef.current = threadId;
@@ -6609,7 +6612,7 @@ function useInternalThreadManager(config = {}) {
6609
6612
  isLoadingMessagesRef.current = false;
6610
6613
  });
6611
6614
  },
6612
- [switchThread, setMessages, getMessageSnapshot, onThreadChange]
6615
+ [switchThread, setMessages, switchBranch, getMessageSnapshot, onThreadChange]
6613
6616
  );
6614
6617
  const handleNewThread = useCallback(async () => {
6615
6618
  isLoadingMessagesRef.current = true;
@@ -6647,6 +6650,9 @@ function useInternalThreadManager(config = {}) {
6647
6650
  lastSavedSnapshotRef.current = getMessageSnapshot(uiMessages);
6648
6651
  savingToThreadRef.current = currentThread.id;
6649
6652
  setMessages(uiMessages);
6653
+ if (currentThread.activeLeafId) {
6654
+ switchBranch(currentThread.activeLeafId);
6655
+ }
6650
6656
  } else {
6651
6657
  lastSavedSnapshotRef.current = "";
6652
6658
  savingToThreadRef.current = currentThread.id;
@@ -6655,7 +6661,7 @@ function useInternalThreadManager(config = {}) {
6655
6661
  requestAnimationFrame(() => {
6656
6662
  isLoadingMessagesRef.current = false;
6657
6663
  });
6658
- }, [enabled, adapter, currentThread, setMessages, getMessageSnapshot, onThreadChange]);
6664
+ }, [enabled, adapter, currentThread, setMessages, switchBranch, getMessageSnapshot, onThreadChange]);
6659
6665
  useEffect(() => {
6660
6666
  if (!enabled) return;
6661
6667
  if (isLoadingMessagesRef.current) {
@@ -6675,9 +6681,10 @@ function useInternalThreadManager(config = {}) {
6675
6681
  const coreMessages = convertToCore(
6676
6682
  allUIMessages.length > 0 ? allUIMessages : messages
6677
6683
  );
6684
+ const activeLeafId = messages[messages.length - 1]?.id;
6678
6685
  if (!currentThreadId && !savingToThreadRef.current) {
6679
6686
  savingToThreadRef.current = "creating";
6680
- createThread({ messages: coreMessages }).then((thread) => {
6687
+ createThread({ messages: coreMessages, activeLeafId }).then((thread) => {
6681
6688
  lastSavedSnapshotRef.current = currentSnapshot;
6682
6689
  savingToThreadRef.current = thread.id;
6683
6690
  onThreadChange?.(thread.id);
@@ -6687,7 +6694,7 @@ function useInternalThreadManager(config = {}) {
6687
6694
  if (savingToThreadRef.current && savingToThreadRef.current !== currentThreadId) {
6688
6695
  return;
6689
6696
  }
6690
- updateCurrentThread({ messages: coreMessages });
6697
+ updateCurrentThread({ messages: coreMessages, activeLeafId });
6691
6698
  lastSavedSnapshotRef.current = currentSnapshot;
6692
6699
  }, [
6693
6700
  enabled,