@assistant-ui/react 0.11.41 → 0.11.43
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.
- package/dist/client/AssistantClient.d.ts.map +1 -1
- package/dist/client/AssistantClient.js.map +1 -1
- package/dist/client/ModelContext.d.ts +1 -1
- package/dist/client/ModelContext.d.ts.map +1 -1
- package/dist/client/ModelContext.js.map +1 -1
- package/dist/client/ModelContextClient.d.ts +1 -1
- package/dist/client/ThreadMessageClient.d.ts +1 -0
- package/dist/client/ThreadMessageClient.d.ts.map +1 -1
- package/dist/client/ThreadMessageClient.js +3 -1
- package/dist/client/ThreadMessageClient.js.map +1 -1
- package/dist/client/types/Message.d.ts +2 -0
- package/dist/client/types/Message.d.ts.map +1 -1
- package/dist/client/types/ModelContext.d.ts +1 -1
- package/dist/client/types/ModelContext.d.ts.map +1 -1
- package/dist/client/types/Tools.d.ts +1 -2
- package/dist/client/types/Tools.d.ts.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.d.ts +5 -1
- package/dist/context/providers/ThreadViewportProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.js +17 -6
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/context/react/AssistantApiContext.d.ts +1 -1
- package/dist/context/react/AssistantApiContext.d.ts.map +1 -1
- package/dist/context/react/AssistantApiContext.js +1 -2
- package/dist/context/react/AssistantApiContext.js.map +1 -1
- package/dist/context/stores/ThreadViewport.d.ts +33 -3
- package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
- package/dist/context/stores/ThreadViewport.js +67 -5
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/devtools/DevToolsHooks.d.ts +1 -1
- package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
- package/dist/devtools/DevToolsHooks.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +2 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts +3 -3
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.d.ts +1 -1
- package/dist/legacy-runtime/client/ThreadRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/runtime/MessageRuntime.d.ts +3 -0
- package/dist/legacy-runtime/runtime/MessageRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/MessageRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts +2 -0
- package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +1 -0
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.js +6 -3
- package/dist/legacy-runtime/runtime/ThreadRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +5 -5
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts +1 -0
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +1 -0
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts +1 -0
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.js +2 -1
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts +2 -2
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +31 -11
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/index.d.ts +1 -0
- package/dist/primitives/composer/index.d.ts.map +1 -1
- package/dist/primitives/composer/index.js +2 -0
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts +3 -0
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js +24 -2
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts +7 -2
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +7 -4
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +17 -3
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +19 -5
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts +31 -0
- package/dist/primitives/thread/ThreadViewportFooter.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadViewportFooter.js +27 -0
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -0
- package/dist/primitives/thread/ThreadViewportSlack.d.ts +20 -0
- package/dist/primitives/thread/ThreadViewportSlack.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadViewportSlack.js +77 -0
- package/dist/primitives/thread/ThreadViewportSlack.js.map +1 -0
- package/dist/primitives/thread/index.d.ts +3 -0
- package/dist/primitives/thread/index.d.ts.map +1 -1
- package/dist/primitives/thread/index.js +7 -1
- package/dist/primitives/thread/index.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts +6 -0
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +17 -8
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.d.ts +3 -1
- package/dist/utils/hooks/useOnScrollToBottom.d.ts.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.d.ts +11 -0
- package/dist/utils/hooks/useSizeHandle.d.ts.map +1 -0
- package/dist/utils/hooks/useSizeHandle.js +30 -0
- package/dist/utils/hooks/useSizeHandle.js.map +1 -0
- package/dist/utils/tap-store/derived-scopes.d.ts +2 -1
- package/dist/utils/tap-store/derived-scopes.d.ts.map +1 -1
- package/dist/utils/tap-store/derived-scopes.js.map +1 -1
- package/dist/utils/tap-store/store.d.ts +2 -1
- package/dist/utils/tap-store/store.d.ts.map +1 -1
- package/dist/utils/tap-store/store.js.map +1 -1
- package/package.json +3 -3
- package/src/client/AssistantClient.ts +1 -1
- package/src/client/ModelContext.ts +1 -1
- package/src/client/ThreadMessageClient.tsx +4 -1
- package/src/client/types/Message.ts +3 -0
- package/src/client/types/ModelContext.ts +1 -1
- package/src/client/types/Tools.ts +1 -2
- package/src/context/providers/ThreadViewportProvider.tsx +27 -5
- package/src/context/react/AssistantApiContext.tsx +2 -5
- package/src/context/stores/ThreadViewport.tsx +125 -7
- package/src/devtools/DevToolsHooks.ts +1 -1
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +6 -1
- package/src/legacy-runtime/client/ComposerRuntimeClient.ts +3 -3
- package/src/legacy-runtime/client/ThreadRuntimeClient.ts +2 -2
- package/src/legacy-runtime/runtime/MessageRuntime.ts +2 -0
- package/src/legacy-runtime/runtime/RuntimeBindings.ts +2 -0
- package/src/legacy-runtime/runtime/ThreadRuntime.ts +6 -3
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +5 -5
- package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx +1 -0
- package/src/legacy-runtime/runtime-cores/utils/MessageRepository.tsx +1 -0
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +35 -12
- package/src/primitives/composer/index.ts +1 -0
- package/src/primitives/message/MessageRoot.tsx +45 -2
- package/src/primitives/thread/ThreadScrollToBottom.tsx +12 -3
- package/src/primitives/thread/ThreadViewport.tsx +35 -9
- package/src/primitives/thread/ThreadViewportFooter.tsx +57 -0
- package/src/primitives/thread/ThreadViewportSlack.tsx +109 -0
- package/src/primitives/thread/index.ts +3 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.tsx +24 -12
- package/src/utils/hooks/useOnScrollToBottom.tsx +3 -1
- package/src/utils/hooks/useSizeHandle.ts +43 -0
- package/src/utils/tap-store/derived-scopes.ts +2 -1
- package/src/utils/tap-store/store.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,E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Ac,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;aACpD,SAAS,IAAI,IAAI;aACjB,0BAA0B,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAE5D,IAAW,QAAQ,6BAElB;IAED,IAAW,KAAK,gJAUf;IAED,SAAgB,QAAQ,mCAA8C;gBAEzC,gBAAgB,EAAE,oBAAoB;IAE5D,eAAe;IAItB,OAAO,CAAC,cAAc,CAAqD;IACpE,eAAe,CAAC,SAAS,EAAE,MAAM;IAGjC,SAAS,CAAC,SAAS,EAAE,MAAM;IAe3B,cAAc,CAAC,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"BaseThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,KAAK,kBAAkB,GAAG;IAC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AAE,MAAM,GAAG,MAAM,EAAE;IAIxC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK7C,SAAS,CAAC,kBAAkB;IAIrB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB;IAOrD,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAK5C,cAAc,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,qBAAqB;IAsBhE,OAAO,CAAC,aAAa,CAA0B;IACxC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAEhC,KAAK,CAAC,SAAS,EAAE,MAAM;IA8BvB,YAAY;IAMnB,SAAS,CAAC,iBAAiB;IAQpB,MAAM;IAIN,MAAM,CAAC,IAAI,EAAE,yBAAyB;IAOtC,KAAK,CAAC,eAAe,CAAC,EAAE,SAAS,iBAAiB,EAAE;IAI3D,OAAO,CAAC,iBAAiB,CAGrB;IAEG,WAAW,CAAC,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,IAAI;CAiBvE"}
|
|
@@ -58,6 +58,7 @@ export type ThreadRuntimeCore = Readonly<{
|
|
|
58
58
|
getMessageById: (messageId: string) => {
|
|
59
59
|
parentId: string | null;
|
|
60
60
|
message: ThreadMessage;
|
|
61
|
+
index: number;
|
|
61
62
|
} | undefined;
|
|
62
63
|
getBranches: (messageId: string) => readonly string[];
|
|
63
64
|
switchToBranch: (branchId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,SAAS,EA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AW,CAAC,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAC9E,0BAA0B,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAClD,CAAC,CAAC"}
|
|
@@ -11,6 +11,7 @@ export declare class RemoteThreadListHookInstanceManager extends BaseSubscribabl
|
|
|
11
11
|
getMessageById: (messageId: string) => {
|
|
12
12
|
parentId: string | null;
|
|
13
13
|
message: import("../../..").ThreadMessage;
|
|
14
|
+
index: number;
|
|
14
15
|
} | undefined;
|
|
15
16
|
getBranches: (messageId: string) => readonly string[];
|
|
16
17
|
switchToBranch: (branchId: string) => void;
|
|
@@ -46,6 +47,7 @@ export declare class RemoteThreadListHookInstanceManager extends BaseSubscribabl
|
|
|
46
47
|
getMessageById: (messageId: string) => {
|
|
47
48
|
parentId: string | null;
|
|
48
49
|
message: import("../../..").ThreadMessage;
|
|
50
|
+
index: number;
|
|
49
51
|
} | undefined;
|
|
50
52
|
getBranches: (messageId: string) => readonly string[];
|
|
51
53
|
switchToBranch: (branchId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,EAAE,EAKF,iBAAiB,EACjB,aAAa,EACd,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,oBAAoB,GAAG,MAAM,gBAAgB,CAAC;AAKnD,qBAAa,mCAAoC,SAAQ,gBAAgB;IACvE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,0BAA0B,CAAsB;gBAE5C,WAAW,EAAE,oBAAoB;IAKtC,kBAAkB,CAAC,QAAQ,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,EAAE,EAKF,iBAAiB,EACjB,aAAa,EACd,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,oBAAoB,GAAG,MAAM,gBAAgB,CAAC;AAKnD,qBAAa,mCAAoC,SAAQ,gBAAgB;IACvE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,0BAA0B,CAAsB;gBAE5C,WAAW,EAAE,oBAAoB;IAKtC,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBnC,oBAAoB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMrC,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAKlC,cAAc,CAAC,cAAc,EAAE,oBAAoB;IAO1D,OAAO,CAAC,0BAA0B,CAgDhC;IAEF,OAAO,CAAC,0BAA0B,CAc/B;IAEI,+BAA+B,EAAE,EAAE,CAAC;QACzC,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C,CAAC,CAUA;CACH"}
|
|
@@ -49,6 +49,7 @@ export declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscriba
|
|
|
49
49
|
getMessageById: (messageId: string) => {
|
|
50
50
|
parentId: string | null;
|
|
51
51
|
message: import("../../..").ThreadMessage;
|
|
52
|
+
index: number;
|
|
52
53
|
} | undefined;
|
|
53
54
|
getBranches: (messageId: string) => readonly string[];
|
|
54
55
|
switchToBranch: (branchId: string) => void;
|
|
@@ -84,6 +85,7 @@ export declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscriba
|
|
|
84
85
|
getMessageById: (messageId: string) => {
|
|
85
86
|
parentId: string | null;
|
|
86
87
|
message: import("../../..").ThreadMessage;
|
|
88
|
+
index: number;
|
|
87
89
|
} | undefined;
|
|
88
90
|
getBranches: (messageId: string) => readonly string[];
|
|
89
91
|
switchToBranch: (branchId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EACL,8BAA8B,EAC9B,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAA8B,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,KAAK,gBAAgB,GACjB;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAA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C,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9C,MAAM,CAAC,kBAAkB,EAAE,MAAM;IAkBjC,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9D,OAAO,CAAC,WAAW,CAA8B;IAE1C,0BAA0B,EAAE,EAAE,CA4BnC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRepository.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/utils/MessageRepository.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA0BtD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yDAAyD;IACzD,QAAQ,EAAE,KAAK,CAAC;QACd,OAAO,EAAE,aAAa,CAAC;QACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,CAAC,CAAC;CACJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB;IACpC;;;;;;OAMG;0BAES,SAAS,iBAAiB,EAAE,KACrC,yBAAyB;CAgB7B,CAAC;AA6CF;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,uDAAuD;IACvD,OAAO,CAAC,QAAQ,CAAwC;IACxD,+EAA+E;IAC/E,OAAO,CAAC,IAAI,CAAkC;IAC9C,sCAAsC;IACtC,OAAO,CAAC,IAAI,CAGV;IAEF;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAgEjB,+EAA+E;IAC/E,OAAO,CAAC,SAAS,CAMd;IAEH;;;OAGG;IACH,IAAI,MAAM,kBAET;IAED;;;;OAIG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM;IAuB3B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,aAAa;IAmClE;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"MessageRepository.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/utils/MessageRepository.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA0BtD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yDAAyD;IACzD,QAAQ,EAAE,KAAK,CAAC;QACd,OAAO,EAAE,aAAa,CAAC;QACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,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yB;CAQvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/utils/MessageRepository.tsx"],"sourcesContent":["import type { ThreadMessage } from \"../../../types\";\nimport { RunConfig } from \"../../../types/AssistantTypes\";\nimport { generateId, generateOptimisticId } from \"../../../utils/idUtils\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { getAutoStatus } from \"../external-store/auto-status\";\nimport { fromThreadMessageLike } from \"../external-store/ThreadMessageLike\";\n\n/**\n * Represents a parent node in the repository tree structure.\n */\ntype RepositoryParent = {\n /** IDs of child messages */\n children: string[];\n /** Reference to the next message in the active branch */\n next: RepositoryMessage | null;\n};\n\n/**\n * Represents a message node in the repository tree structure.\n */\ntype RepositoryMessage = RepositoryParent & {\n /** Reference to the parent message */\n prev: RepositoryMessage | null;\n /** The actual message data */\n current: ThreadMessage;\n /** The depth level in the tree (0 for root messages) */\n level: number;\n};\n\n/**\n * Represents a message item that can be exported from the repository.\n */\nexport type ExportedMessageRepositoryItem = {\n /** The message data */\n message: ThreadMessage;\n /** ID of the parent message, or null for root messages */\n parentId: string | null;\n /** The run configuration for the message */\n runConfig?: RunConfig;\n};\n\n/**\n * Represents the entire repository state for export/import.\n */\nexport type ExportedMessageRepository = {\n /** ID of the head message, or null/undefined if no head */\n headId?: string | null;\n /** Array of all messages with their parent references */\n messages: Array<{\n message: ThreadMessage;\n parentId: string | null;\n runConfig?: RunConfig;\n }>;\n};\n\n/**\n * Utility functions for working with exported message repositories.\n */\nexport const ExportedMessageRepository = {\n /**\n * Converts an array of messages to an ExportedMessageRepository format.\n * Creates parent-child relationships based on the order of messages in the array.\n *\n * @param messages - Array of message-like objects to convert\n * @returns ExportedMessageRepository with parent-child relationships established\n */\n fromArray: (\n messages: readonly ThreadMessageLike[],\n ): ExportedMessageRepository => {\n const conv = messages.map((m) =>\n fromThreadMessageLike(\n m,\n generateId(),\n getAutoStatus(false, false, false, false, undefined),\n ),\n );\n\n return {\n messages: conv.map((m, idx) => ({\n parentId: idx > 0 ? conv[idx - 1]!.id : null,\n message: m,\n })),\n };\n },\n};\n\n/**\n * Recursively finds the head (leaf) message in a branch.\n *\n * @param message - The starting message or parent node\n * @returns The leaf message of the branch, or null if not found\n */\nconst findHead = (\n message: RepositoryMessage | RepositoryParent,\n): RepositoryMessage | null => {\n if (message.next) return findHead(message.next);\n if (\"current\" in message) return message;\n return null;\n};\n\n/**\n * A utility class for caching computed values and invalidating the cache when needed.\n */\nclass CachedValue<T> {\n private _value: T | null = null;\n\n /**\n * @param func - The function that computes the cached value\n */\n constructor(private func: () => T) {}\n\n /**\n * Gets the cached value, computing it if necessary.\n */\n get value() {\n if (this._value === null) {\n this._value = this.func();\n }\n return this._value;\n }\n\n /**\n * Invalidates the cache, forcing recomputation on next access.\n */\n dirty() {\n this._value = null;\n }\n}\n\n/**\n * A repository that manages a tree of messages with branching capabilities.\n * Supports operations like adding, updating, and deleting messages, as well as\n * managing multiple conversation branches.\n */\nexport class MessageRepository {\n /** Map of message IDs to repository message objects */\n private messages = new Map<string, RepositoryMessage>();\n /** Reference to the current head (most recent) message in the active branch */\n private head: RepositoryMessage | null = null;\n /** Root node of the tree structure */\n private root: RepositoryParent = {\n children: [],\n next: null,\n };\n\n /**\n * Recursively updates the level of a message and all its descendants.\n *\n * @param message - The message to update\n * @param newLevel - The new level for the message\n */\n private updateLevels(message: RepositoryMessage, newLevel: number) {\n message.level = newLevel;\n for (const childId of message.children) {\n const childMessage = this.messages.get(childId);\n if (childMessage) {\n this.updateLevels(childMessage, newLevel + 1);\n }\n }\n }\n\n /**\n * Performs link/unlink operations between messages in the tree.\n *\n * @param newParent - The new parent message, or null\n * @param child - The child message to operate on\n * @param operation - The type of operation to perform:\n * - \"cut\": Remove the child from its current parent\n * - \"link\": Add the child to a new parent\n * - \"relink\": Both cut and link operations\n */\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n // remove from parentOrRoot.children\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n // update parentOrRoot.next\n if (parentOrRoot.next === child) {\n const fallbackId = parentOrRoot.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n parentOrRoot.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n // ensure the child is not part of parent tree\n for (\n let current: RepositoryMessage | null = newParent;\n current;\n current = current.prev\n ) {\n if (current.current.id === child.current.id) {\n throw new Error(\n \"MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.\",\n );\n }\n }\n\n // add to parentOrRoot.children\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n // update parentOrRoot.next\n if (findHead(child) === this.head || newParentOrRoot.next === null) {\n newParentOrRoot.next = child;\n }\n\n child.prev = newParent;\n\n // update levels when linking/relinking to a new parent\n const newLevel = newParent ? newParent.level + 1 : 0;\n this.updateLevels(child, newLevel);\n }\n }\n\n /** Cached array of messages in the current active branch, from root to head */\n private _messages = new CachedValue<readonly ThreadMessage[]>(() => {\n const messages = new Array<ThreadMessage>((this.head?.level ?? -1) + 1);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n });\n\n /**\n * Gets the ID of the current head message.\n * @returns The ID of the head message, or null if no messages exist\n */\n get headId() {\n return this.head?.current.id ?? null;\n }\n\n /**\n * Gets all messages in the current active branch, from root to head.\n * @param headId - Optional ID of the head message to get messages for. If not provided, uses the current head.\n * @returns Array of messages in the specified branch\n */\n getMessages(headId?: string) {\n if (headId === undefined || headId === this.head?.current.id) {\n return this._messages.value;\n }\n\n const headMessage = this.messages.get(headId);\n if (!headMessage) {\n throw new Error(\n \"MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n\n const messages = new Array<ThreadMessage>(headMessage.level + 1);\n for (\n let current: RepositoryMessage | null = headMessage;\n current;\n current = current.prev\n ) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n /**\n * Adds a new message or updates an existing one in the repository.\n * If the message ID already exists, the message is updated and potentially relinked to a new parent.\n * If the message is new, it's added as a child of the specified parent.\n *\n * @param parentId - ID of the parent message, or null for root messages\n * @param message - The message to add or update\n * @throws Error if the parent message is not found\n */\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n this._messages.dirty();\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n\n this._messages.dirty();\n }\n\n /**\n * Gets a message and its parent ID by message ID.\n *\n * @param messageId - ID of the message to retrieve\n * @returns Object containing the message and its parent ID\n * @throws Error if the message is not found\n */\n getMessage(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n return {\n parentId: message.prev?.current.id ?? null,\n message: message.current,\n };\n }\n\n /**\n * Adds an optimistic message to the repository.\n * An optimistic message is a temporary placeholder that will be replaced by a real message later.\n *\n * @param parentId - ID of the parent message, or null for root messages\n * @param message - The core message to convert to an optimistic message\n * @returns The generated optimistic ID\n */\n appendOptimisticMessage(parentId: string | null, message: ThreadMessageLike) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(\n parentId,\n fromThreadMessageLike(message, optimisticId, { type: \"running\" }),\n );\n\n return optimisticId;\n }\n\n /**\n * Deletes a message from the repository and relinks its children.\n *\n * @param messageId - ID of the message to delete\n * @param replacementId - Optional ID of the message to become the new parent of the children,\n * undefined means use the deleted message's parent,\n * null means use the root\n * @throws Error if the message or replacement is not found\n */\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = findHead(replacement ?? this.root);\n }\n\n this._messages.dirty();\n }\n\n /**\n * Gets all branch IDs (sibling messages) at the level of a specified message.\n *\n * @param messageId - ID of the message to find branches for\n * @returns Array of message IDs representing branches\n * @throws Error if the message is not found\n */\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n /**\n * Switches the active branch to the one containing the specified message.\n *\n * @param messageId - ID of the message in the branch to switch to\n * @throws Error if the branch is not found\n */\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const prevOrRoot = message.prev ?? this.root;\n prevOrRoot.next = message;\n\n this.head = findHead(message);\n\n this._messages.dirty();\n }\n\n /**\n * Resets the head to a specific message or null.\n *\n * @param messageId - ID of the message to set as head, or null to clear the head\n * @throws Error if the message is not found\n */\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.clear();\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.children.length > 0) {\n const deleteDescendants = (msg: RepositoryMessage) => {\n for (const childId of msg.children) {\n const childMessage = this.messages.get(childId);\n if (childMessage) {\n deleteDescendants(childMessage);\n this.messages.delete(childId);\n }\n }\n };\n deleteDescendants(message);\n\n message.children = [];\n message.next = null;\n }\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n\n this._messages.dirty();\n }\n\n /**\n * Clears all messages from the repository.\n */\n clear(): void {\n this.messages.clear();\n this.head = null;\n this.root = {\n children: [],\n next: null,\n };\n this._messages.dirty();\n }\n\n /**\n * Exports the repository state for persistence.\n *\n * @returns Exportable repository state\n */\n export(): ExportedMessageRepository {\n const exportItems: ExportedMessageRepository[\"messages\"] = [];\n\n // hint: we are relying on the insertion order of the messages\n // this is important for the import function to properly link the messages\n for (const [, message] of this.messages) {\n exportItems.push({\n message: message.current,\n parentId: message.prev?.current.id ?? null,\n });\n }\n\n return {\n headId: this.head?.current.id ?? null,\n messages: exportItems,\n };\n }\n\n /**\n * Imports repository state from an exported repository.\n *\n * @param repository - The exported repository state to import\n */\n import({ headId, messages }: ExportedMessageRepository) {\n for (const { message, parentId } of messages) {\n this.addOrUpdateMessage(parentId, message);\n }\n\n // switch to the saved head id if it is not the most recent message\n this.resetHead(headId ?? messages.at(-1)?.message.id ?? null);\n }\n}\n"],"mappings":";AAEA,SAAS,YAAY,4BAA4B;AAEjD,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAqD/B,IAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvC,WAAW,CACT,aAC8B;AAC9B,UAAM,OAAO,SAAS;AAAA,MAAI,CAAC,MACzB;AAAA,QACE;AAAA,QACA,WAAW;AAAA,QACX,cAAc,OAAO,OAAO,OAAO,OAAO,MAAS;AAAA,MACrD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,UAAU,KAAK,IAAI,CAAC,GAAG,SAAS;AAAA,QAC9B,UAAU,MAAM,IAAI,KAAK,MAAM,CAAC,EAAG,KAAK;AAAA,QACxC,SAAS;AAAA,MACX,EAAE;AAAA,IACJ;AAAA,EACF;AACF;AAQA,IAAM,WAAW,CACf,YAC6B;AAC7B,MAAI,QAAQ,KAAM,QAAO,SAAS,QAAQ,IAAI;AAC9C,MAAI,aAAa,QAAS,QAAO;AACjC,SAAO;AACT;AAKA,IAAM,cAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAMnB,YAAoB,MAAe;AAAf;AAAA,EAAgB;AAAA,EAL5B,SAAmB;AAAA;AAAA;AAAA;AAAA,EAU3B,IAAI,QAAQ;AACV,QAAI,KAAK,WAAW,MAAM;AACxB,WAAK,SAAS,KAAK,KAAK;AAAA,IAC1B;AACA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ;AACN,SAAK,SAAS;AAAA,EAChB;AACF;AAOO,IAAM,oBAAN,MAAwB;AAAA;AAAA,EAErB,WAAW,oBAAI,IAA+B;AAAA;AAAA,EAE9C,OAAiC;AAAA;AAAA,EAEjC,OAAyB;AAAA,IAC/B,UAAU,CAAC;AAAA,IACX,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAA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AC9B,iBAAK,SAAS,OAAO,OAAO;AAAA,UAC9B;AAAA,QACF;AAAA,MACF;AACA,wBAAkB,OAAO;AAEzB,cAAQ,WAAW,CAAC;AACpB,cAAQ,OAAO;AAAA,IACjB;AAEA,SAAK,OAAO;AACZ,aACM,UAAoC,SACxC,SACA,UAAU,QAAQ,MAClB;AACA,UAAI,QAAQ,MAAM;AAChB,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IACF;AAEA,SAAK,UAAU,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,QAAc;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,MACV,UAAU,CAAC;AAAA,MACX,MAAM;AAAA,IACR;AACA,SAAK,UAAU,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAoC;AAClC,UAAM,cAAqD,CAAC;AAI5D,eAAW,CAAC,EAAE,OAAO,KAAK,KAAK,UAAU;AACvC,kBAAY,KAAK;AAAA,QACf,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ,MAAM,QAAQ,MAAM;AAAA,MACxC,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,MACL,QAAQ,KAAK,MAAM,QAAQ,MAAM;AAAA,MACjC,UAAU;AAAA,IACZ;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,EAAE,QAAQ,SAAS,GAA8B;AACtD,eAAW,EAAE,SAAS,SAAS,KAAK,UAAU;AAC5C,WAAK,mBAAmB,UAAU,OAAO;AAAA,IAC3C;AAGA,SAAK,UAAU,UAAU,SAAS,GAAG,EAAE,GAAG,QAAQ,MAAM,IAAI;AAAA,EAC9D;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/utils/MessageRepository.tsx"],"sourcesContent":["import type { ThreadMessage } from \"../../../types\";\nimport { RunConfig } from \"../../../types/AssistantTypes\";\nimport { generateId, generateOptimisticId } from \"../../../utils/idUtils\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { getAutoStatus } from \"../external-store/auto-status\";\nimport { fromThreadMessageLike } from \"../external-store/ThreadMessageLike\";\n\n/**\n * Represents a parent node in the repository tree structure.\n */\ntype RepositoryParent = {\n /** IDs of child messages */\n children: string[];\n /** Reference to the next message in the active branch */\n next: RepositoryMessage | null;\n};\n\n/**\n * Represents a message node in the repository tree structure.\n */\ntype RepositoryMessage = RepositoryParent & {\n /** Reference to the parent message */\n prev: RepositoryMessage | null;\n /** The actual message data */\n current: ThreadMessage;\n /** The depth level in the tree (0 for root messages) */\n level: number;\n};\n\n/**\n * Represents a message item that can be exported from the repository.\n */\nexport type ExportedMessageRepositoryItem = {\n /** The message data */\n message: ThreadMessage;\n /** ID of the parent message, or null for root messages */\n parentId: string | null;\n /** The run configuration for the message */\n runConfig?: RunConfig;\n};\n\n/**\n * Represents the entire repository state for export/import.\n */\nexport type ExportedMessageRepository = {\n /** ID of the head message, or null/undefined if no head */\n headId?: string | null;\n /** Array of all messages with their parent references */\n messages: Array<{\n message: ThreadMessage;\n parentId: string | null;\n runConfig?: RunConfig;\n }>;\n};\n\n/**\n * Utility functions for working with exported message repositories.\n */\nexport const ExportedMessageRepository = {\n /**\n * Converts an array of messages to an ExportedMessageRepository format.\n * Creates parent-child relationships based on the order of messages in the array.\n *\n * @param messages - Array of message-like objects to convert\n * @returns ExportedMessageRepository with parent-child relationships established\n */\n fromArray: (\n messages: readonly ThreadMessageLike[],\n ): ExportedMessageRepository => {\n const conv = messages.map((m) =>\n fromThreadMessageLike(\n m,\n generateId(),\n getAutoStatus(false, false, false, false, undefined),\n ),\n );\n\n return {\n messages: conv.map((m, idx) => ({\n parentId: idx > 0 ? conv[idx - 1]!.id : null,\n message: m,\n })),\n };\n },\n};\n\n/**\n * Recursively finds the head (leaf) message in a branch.\n *\n * @param message - The starting message or parent node\n * @returns The leaf message of the branch, or null if not found\n */\nconst findHead = (\n message: RepositoryMessage | RepositoryParent,\n): RepositoryMessage | null => {\n if (message.next) return findHead(message.next);\n if (\"current\" in message) return message;\n return null;\n};\n\n/**\n * A utility class for caching computed values and invalidating the cache when needed.\n */\nclass CachedValue<T> {\n private _value: T | null = null;\n\n /**\n * @param func - The function that computes the cached value\n */\n constructor(private func: () => T) {}\n\n /**\n * Gets the cached value, computing it if necessary.\n */\n get value() {\n if (this._value === null) {\n this._value = this.func();\n }\n return this._value;\n }\n\n /**\n * Invalidates the cache, forcing recomputation on next access.\n */\n dirty() {\n this._value = null;\n }\n}\n\n/**\n * A repository that manages a tree of messages with branching capabilities.\n * Supports operations like adding, updating, and deleting messages, as well as\n * managing multiple conversation branches.\n */\nexport class MessageRepository {\n /** Map of message IDs to repository message objects */\n private messages = new Map<string, RepositoryMessage>();\n /** Reference to the current head (most recent) message in the active branch */\n private head: RepositoryMessage | null = null;\n /** Root node of the tree structure */\n private root: RepositoryParent = {\n children: [],\n next: null,\n };\n\n /**\n * Recursively updates the level of a message and all its descendants.\n *\n * @param message - The message to update\n * @param newLevel - The new level for the message\n */\n private updateLevels(message: RepositoryMessage, newLevel: number) {\n message.level = newLevel;\n for (const childId of message.children) {\n const childMessage = this.messages.get(childId);\n if (childMessage) {\n this.updateLevels(childMessage, newLevel + 1);\n }\n }\n }\n\n /**\n * Performs link/unlink operations between messages in the tree.\n *\n * @param newParent - The new parent message, or null\n * @param child - The child message to operate on\n * @param operation - The type of operation to perform:\n * - \"cut\": Remove the child from its current parent\n * - \"link\": Add the child to a new parent\n * - \"relink\": Both cut and link operations\n */\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n // remove from parentOrRoot.children\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n // update parentOrRoot.next\n if (parentOrRoot.next === child) {\n const fallbackId = parentOrRoot.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n parentOrRoot.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n // ensure the child is not part of parent tree\n for (\n let current: RepositoryMessage | null = newParent;\n current;\n current = current.prev\n ) {\n if (current.current.id === child.current.id) {\n throw new Error(\n \"MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.\",\n );\n }\n }\n\n // add to parentOrRoot.children\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n // update parentOrRoot.next\n if (findHead(child) === this.head || newParentOrRoot.next === null) {\n newParentOrRoot.next = child;\n }\n\n child.prev = newParent;\n\n // update levels when linking/relinking to a new parent\n const newLevel = newParent ? newParent.level + 1 : 0;\n this.updateLevels(child, newLevel);\n }\n }\n\n /** Cached array of messages in the current active branch, from root to head */\n private _messages = new CachedValue<readonly ThreadMessage[]>(() => {\n const messages = new Array<ThreadMessage>((this.head?.level ?? -1) + 1);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n });\n\n /**\n * Gets the ID of the current head message.\n * @returns The ID of the head message, or null if no messages exist\n */\n get headId() {\n return this.head?.current.id ?? null;\n }\n\n /**\n * Gets all messages in the current active branch, from root to head.\n * @param headId - Optional ID of the head message to get messages for. If not provided, uses the current head.\n * @returns Array of messages in the specified branch\n */\n getMessages(headId?: string) {\n if (headId === undefined || headId === this.head?.current.id) {\n return this._messages.value;\n }\n\n const headMessage = this.messages.get(headId);\n if (!headMessage) {\n throw new Error(\n \"MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n\n const messages = new Array<ThreadMessage>(headMessage.level + 1);\n for (\n let current: RepositoryMessage | null = headMessage;\n current;\n current = current.prev\n ) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n /**\n * Adds a new message or updates an existing one in the repository.\n * If the message ID already exists, the message is updated and potentially relinked to a new parent.\n * If the message is new, it's added as a child of the specified parent.\n *\n * @param parentId - ID of the parent message, or null for root messages\n * @param message - The message to add or update\n * @throws Error if the parent message is not found\n */\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n this._messages.dirty();\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n\n this._messages.dirty();\n }\n\n /**\n * Gets a message and its parent ID by message ID.\n *\n * @param messageId - ID of the message to retrieve\n * @returns Object containing the message and its parent ID\n * @throws Error if the message is not found\n */\n getMessage(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n return {\n parentId: message.prev?.current.id ?? null,\n message: message.current,\n index: message.level,\n };\n }\n\n /**\n * Adds an optimistic message to the repository.\n * An optimistic message is a temporary placeholder that will be replaced by a real message later.\n *\n * @param parentId - ID of the parent message, or null for root messages\n * @param message - The core message to convert to an optimistic message\n * @returns The generated optimistic ID\n */\n appendOptimisticMessage(parentId: string | null, message: ThreadMessageLike) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(\n parentId,\n fromThreadMessageLike(message, optimisticId, { type: \"running\" }),\n );\n\n return optimisticId;\n }\n\n /**\n * Deletes a message from the repository and relinks its children.\n *\n * @param messageId - ID of the message to delete\n * @param replacementId - Optional ID of the message to become the new parent of the children,\n * undefined means use the deleted message's parent,\n * null means use the root\n * @throws Error if the message or replacement is not found\n */\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = findHead(replacement ?? this.root);\n }\n\n this._messages.dirty();\n }\n\n /**\n * Gets all branch IDs (sibling messages) at the level of a specified message.\n *\n * @param messageId - ID of the message to find branches for\n * @returns Array of message IDs representing branches\n * @throws Error if the message is not found\n */\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n /**\n * Switches the active branch to the one containing the specified message.\n *\n * @param messageId - ID of the message in the branch to switch to\n * @throws Error if the branch is not found\n */\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const prevOrRoot = message.prev ?? this.root;\n prevOrRoot.next = message;\n\n this.head = findHead(message);\n\n this._messages.dirty();\n }\n\n /**\n * Resets the head to a specific message or null.\n *\n * @param messageId - ID of the message to set as head, or null to clear the head\n * @throws Error if the message is not found\n */\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.clear();\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.children.length > 0) {\n const deleteDescendants = (msg: RepositoryMessage) => {\n for (const childId of msg.children) {\n const childMessage = this.messages.get(childId);\n if (childMessage) {\n deleteDescendants(childMessage);\n this.messages.delete(childId);\n }\n }\n };\n deleteDescendants(message);\n\n message.children = [];\n message.next = null;\n }\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n\n this._messages.dirty();\n }\n\n /**\n * Clears all messages from the repository.\n */\n clear(): void {\n this.messages.clear();\n this.head = null;\n this.root = {\n children: [],\n next: null,\n };\n this._messages.dirty();\n }\n\n /**\n * Exports the repository state for persistence.\n *\n * @returns Exportable repository state\n */\n export(): ExportedMessageRepository {\n const exportItems: ExportedMessageRepository[\"messages\"] = [];\n\n // hint: we are relying on the insertion order of the messages\n // this is important for the import function to properly link the messages\n for (const [, message] of this.messages) {\n exportItems.push({\n message: message.current,\n parentId: message.prev?.current.id ?? null,\n });\n }\n\n return {\n headId: this.head?.current.id ?? null,\n messages: exportItems,\n };\n }\n\n /**\n * Imports repository state from an exported repository.\n *\n * @param repository - The exported repository state to import\n */\n import({ headId, messages }: ExportedMessageRepository) {\n for (const { message, parentId } of messages) {\n this.addOrUpdateMessage(parentId, message);\n }\n\n // switch to the saved head id if it is not the most recent message\n this.resetHead(headId ?? messages.at(-1)?.message.id ?? null);\n }\n}\n"],"mappings":";AAEA,SAAS,YAAY,4BAA4B;AAEjD,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAqD/B,I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IACjB;AAEA,SAAK,OAAO;AACZ,aACM,UAAoC,SACxC,SACA,UAAU,QAAQ,MAClB;AACA,UAAI,QAAQ,MAAM;AAChB,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IACF;AAEA,SAAK,UAAU,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,QAAc;AACZ,SAAK,SAAS,MAAM;AACpB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,MACV,UAAU,CAAC;AAAA,MACX,MAAM;AAAA,IACR;AACA,SAAK,UAAU,MAAM;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAoC;AAClC,UAAM,cAAqD,CAAC;AAI5D,eAAW,CAAC,EAAE,OAAO,KAAK,KAAK,UAAU;AACvC,kBAAY,KAAK;AAAA,QACf,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ,MAAM,QAAQ,MAAM;AAAA,MACxC,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,MACL,QAAQ,KAAK,MAAM,QAAQ,MAAM;AAAA,MACjC,UAAU;AAAA,IACZ;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,EAAE,QAAQ,SAAS,GAA8B;AACtD,eAAW,EAAE,SAAS,SAAS,KAAK,UAAU;AAC5C,WAAK,mBAAmB,UAAU,OAAO;AAAA,IAC3C;AAGA,SAAK,UAAU,UAAU,SAAS,GAAG,EAAE,GAAG,QAAQ,MAAM,IAAI;AAAA,EAC9D;AACF;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare namespace
|
|
2
|
+
export declare namespace ComposerPrimitiveAttachmentDropzone {
|
|
3
3
|
type Element = HTMLDivElement;
|
|
4
4
|
type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
asChild?: boolean | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const ComposerPrimitiveAttachmentDropzone: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
10
10
|
asChild?: boolean | undefined;
|
|
11
11
|
disabled?: boolean | undefined;
|
|
12
12
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerAttachmentDropzone.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAttachmentDropzone.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerAttachmentDropzone.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAttachmentDropzone.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,yBAAiB,mCAAmC,CAAC;IACnD,KAAY,OAAO,GAAG,cAAc,CAAC;IACrC,KAAY,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;QACzD,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAChC,CAAC;CACH;AAED,eAAO,MAAM,mCAAmC;cALlC,OAAO,GAAG,SAAS;eAClB,OAAO,GAAG,SAAS;wCA6EhC,CAAC"}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/primitives/composer/ComposerAttachmentDropzone.tsx
|
|
2
4
|
import { forwardRef, useCallback, useState } from "react";
|
|
3
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
6
|
import { useAssistantApi } from "../../context/index.js";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
var
|
|
8
|
+
var ComposerPrimitiveAttachmentDropzone = forwardRef(({ disabled, asChild = false, children, ...rest }, ref) => {
|
|
7
9
|
const [isDragging, setIsDragging] = useState(false);
|
|
8
10
|
const api = useAssistantApi();
|
|
9
|
-
const
|
|
11
|
+
const handleDragEnterCapture = useCallback(
|
|
10
12
|
(e) => {
|
|
11
13
|
if (disabled) return;
|
|
12
14
|
e.preventDefault();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
setIsDragging(true);
|
|
16
|
+
},
|
|
17
|
+
[disabled]
|
|
18
|
+
);
|
|
19
|
+
const handleDragOverCapture = useCallback(
|
|
20
|
+
(e) => {
|
|
21
|
+
if (disabled) return;
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
if (!isDragging) setIsDragging(true);
|
|
24
|
+
},
|
|
25
|
+
[disabled, isDragging]
|
|
26
|
+
);
|
|
27
|
+
const handleDragLeaveCapture = useCallback(
|
|
28
|
+
(e) => {
|
|
29
|
+
if (disabled) return;
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
const next = e.relatedTarget;
|
|
32
|
+
if (next && e.currentTarget.contains(next)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setIsDragging(false);
|
|
15
36
|
},
|
|
16
37
|
[disabled]
|
|
17
38
|
);
|
|
@@ -19,7 +40,6 @@ var ComposerAttachmentDropzone = forwardRef(({ disabled, asChild = false, childr
|
|
|
19
40
|
async (e) => {
|
|
20
41
|
if (disabled) return;
|
|
21
42
|
e.preventDefault();
|
|
22
|
-
e.stopPropagation();
|
|
23
43
|
setIsDragging(false);
|
|
24
44
|
for (const file of e.dataTransfer.files) {
|
|
25
45
|
try {
|
|
@@ -32,10 +52,10 @@ var ComposerAttachmentDropzone = forwardRef(({ disabled, asChild = false, childr
|
|
|
32
52
|
[disabled, api]
|
|
33
53
|
);
|
|
34
54
|
const dragProps = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
onDragEnterCapture: handleDragEnterCapture,
|
|
56
|
+
onDragOverCapture: handleDragOverCapture,
|
|
57
|
+
onDragLeaveCapture: handleDragLeaveCapture,
|
|
58
|
+
onDropCapture: handleDrop
|
|
39
59
|
};
|
|
40
60
|
const Comp = asChild ? Slot : "div";
|
|
41
61
|
return /* @__PURE__ */ jsx(
|
|
@@ -49,8 +69,8 @@ var ComposerAttachmentDropzone = forwardRef(({ disabled, asChild = false, childr
|
|
|
49
69
|
}
|
|
50
70
|
);
|
|
51
71
|
});
|
|
52
|
-
|
|
72
|
+
ComposerPrimitiveAttachmentDropzone.displayName = "ComposerPrimitive.AttachmentDropzone";
|
|
53
73
|
export {
|
|
54
|
-
|
|
74
|
+
ComposerPrimitiveAttachmentDropzone
|
|
55
75
|
};
|
|
56
76
|
//# sourceMappingURL=ComposerAttachmentDropzone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/composer/ComposerAttachmentDropzone.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/composer/ComposerAttachmentDropzone.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useState } from \"react\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport React from \"react\";\nimport { useAssistantApi } from \"../../context\";\n\nexport namespace ComposerPrimitiveAttachmentDropzone {\n export type Element = HTMLDivElement;\n export type Props = React.HTMLAttributes<HTMLDivElement> & {\n asChild?: boolean | undefined;\n disabled?: boolean | undefined;\n };\n}\n\nexport const ComposerPrimitiveAttachmentDropzone = forwardRef<\n HTMLDivElement,\n ComposerPrimitiveAttachmentDropzone.Props\n>(({ disabled, asChild = false, children, ...rest }, ref) => {\n const [isDragging, setIsDragging] = useState(false);\n const api = useAssistantApi();\n\n const handleDragEnterCapture = useCallback(\n (e: React.DragEvent) => {\n if (disabled) return;\n e.preventDefault();\n setIsDragging(true);\n },\n [disabled],\n );\n\n const handleDragOverCapture = useCallback(\n (e: React.DragEvent) => {\n if (disabled) return;\n e.preventDefault();\n if (!isDragging) setIsDragging(true);\n },\n [disabled, isDragging],\n );\n\n const handleDragLeaveCapture = useCallback(\n (e: React.DragEvent) => {\n if (disabled) return;\n e.preventDefault();\n const next = e.relatedTarget as Node | null;\n if (next && e.currentTarget.contains(next)) {\n return;\n }\n setIsDragging(false);\n },\n [disabled],\n );\n\n const handleDrop = useCallback(\n async (e: React.DragEvent) => {\n if (disabled) return;\n e.preventDefault();\n setIsDragging(false);\n for (const file of e.dataTransfer.files) {\n try {\n await api.composer().addAttachment(file);\n } catch (error) {\n console.error(\"Failed to add attachment:\", error);\n }\n }\n },\n [disabled, api],\n );\n\n const dragProps = {\n onDragEnterCapture: handleDragEnterCapture,\n onDragOverCapture: handleDragOverCapture,\n onDragLeaveCapture: handleDragLeaveCapture,\n onDropCapture: handleDrop,\n };\n\n const Comp = asChild ? Slot : \"div\";\n\n return (\n <Comp\n {...(isDragging ? { \"data-dragging\": \"true\" } : null)}\n ref={ref}\n {...dragProps}\n {...rest}\n >\n {children}\n </Comp>\n );\n});\n\nComposerPrimitiveAttachmentDropzone.displayName =\n \"ComposerPrimitive.AttachmentDropzone\";\n"],"mappings":";;;AAEA,SAAS,YAAY,aAAa,gBAAgB;AAElD,SAAS,YAAY;AAErB,SAAS,uBAAuB;AA0E5B;AAhEG,IAAM,sCAAsC,WAGjD,CAAC,EAAE,UAAU,UAAU,OAAO,UAAU,GAAG,KAAK,GAAG,QAAQ;AAC3D,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,MAAM,gBAAgB;AAE5B,QAAM,yBAAyB;AAAA,IAC7B,CAAC,MAAuB;AACtB,UAAI,SAAU;AACd,QAAE,eAAe;AACjB,oBAAc,IAAI;AAAA,IACpB;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,wBAAwB;AAAA,IAC5B,CAAC,MAAuB;AACtB,UAAI,SAAU;AACd,QAAE,eAAe;AACjB,UAAI,CAAC,WAAY,eAAc,IAAI;AAAA,IACrC;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,yBAAyB;AAAA,IAC7B,CAAC,MAAuB;AACtB,UAAI,SAAU;AACd,QAAE,eAAe;AACjB,YAAM,OAAO,EAAE;AACf,UAAI,QAAQ,EAAE,cAAc,SAAS,IAAI,GAAG;AAC1C;AAAA,MACF;AACA,oBAAc,KAAK;AAAA,IACrB;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,aAAa;AAAA,IACjB,OAAO,MAAuB;AAC5B,UAAI,SAAU;AACd,QAAE,eAAe;AACjB,oBAAc,KAAK;AACnB,iBAAW,QAAQ,EAAE,aAAa,OAAO;AACvC,YAAI;AACF,gBAAM,IAAI,SAAS,EAAE,cAAc,IAAI;AAAA,QACzC,SAAS,OAAO;AACd,kBAAQ,MAAM,6BAA6B,KAAK;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,UAAU,GAAG;AAAA,EAChB;AAEA,QAAM,YAAY;AAAA,IAChB,oBAAoB;AAAA,IACpB,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,eAAe;AAAA,EACjB;AAEA,QAAM,OAAO,UAAU,OAAO;AAE9B,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAI,aAAa,EAAE,iBAAiB,OAAO,IAAI;AAAA,MAChD;AAAA,MACC,GAAG;AAAA,MACH,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ,CAAC;AAED,oCAAoC,cAClC;","names":[]}
|
|
@@ -5,5 +5,6 @@ export { ComposerPrimitiveCancel as Cancel } from "./ComposerCancel";
|
|
|
5
5
|
export { ComposerPrimitiveAddAttachment as AddAttachment } from "./ComposerAddAttachment";
|
|
6
6
|
export { ComposerPrimitiveAttachments as Attachments } from "./ComposerAttachments";
|
|
7
7
|
export { ComposerPrimitiveAttachmentByIndex as AttachmentByIndex } from "./ComposerAttachments";
|
|
8
|
+
export { ComposerPrimitiveAttachmentDropzone as AttachmentDropzone } from "./ComposerAttachmentDropzone";
|
|
8
9
|
export { ComposerPrimitiveIf as If } from "./ComposerIf";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,qBAAqB,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,8BAA8B,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,4BAA4B,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,kCAAkC,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,mBAAmB,IAAI,EAAE,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,qBAAqB,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,8BAA8B,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,4BAA4B,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,kCAAkC,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,mCAAmC,IAAI,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,EAAE,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -6,10 +6,12 @@ import { ComposerPrimitiveCancel } from "./ComposerCancel.js";
|
|
|
6
6
|
import { ComposerPrimitiveAddAttachment } from "./ComposerAddAttachment.js";
|
|
7
7
|
import { ComposerPrimitiveAttachments } from "./ComposerAttachments.js";
|
|
8
8
|
import { ComposerPrimitiveAttachmentByIndex } from "./ComposerAttachments.js";
|
|
9
|
+
import { ComposerPrimitiveAttachmentDropzone } from "./ComposerAttachmentDropzone.js";
|
|
9
10
|
import { ComposerPrimitiveIf } from "./ComposerIf.js";
|
|
10
11
|
export {
|
|
11
12
|
ComposerPrimitiveAddAttachment as AddAttachment,
|
|
12
13
|
ComposerPrimitiveAttachmentByIndex as AttachmentByIndex,
|
|
14
|
+
ComposerPrimitiveAttachmentDropzone as AttachmentDropzone,
|
|
13
15
|
ComposerPrimitiveAttachments as Attachments,
|
|
14
16
|
ComposerPrimitiveCancel as Cancel,
|
|
15
17
|
ComposerPrimitiveIf as If,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/composer/index.ts"],"sourcesContent":["export { ComposerPrimitiveRoot as Root } from \"./ComposerRoot\";\nexport { ComposerPrimitiveInput as Input } from \"./ComposerInput\";\nexport { ComposerPrimitiveSend as Send } from \"./ComposerSend\";\nexport { ComposerPrimitiveCancel as Cancel } from \"./ComposerCancel\";\nexport { ComposerPrimitiveAddAttachment as AddAttachment } from \"./ComposerAddAttachment\";\nexport { ComposerPrimitiveAttachments as Attachments } from \"./ComposerAttachments\";\nexport { ComposerPrimitiveAttachmentByIndex as AttachmentByIndex } from \"./ComposerAttachments\";\nexport { ComposerPrimitiveIf as If } from \"./ComposerIf\";\n"],"mappings":";AAAA,SAAkC,6BAAY;AAC9C,SAAmC,8BAAa;AAChD,SAAkC,6BAAY;AAC9C,SAAoC,+BAAc;AAClD,SAA2C,sCAAqB;AAChE,SAAyC,oCAAmB;AAC5D,SAA+C,0CAAyB;AACxE,SAAgC,2BAAU;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/composer/index.ts"],"sourcesContent":["export { ComposerPrimitiveRoot as Root } from \"./ComposerRoot\";\nexport { ComposerPrimitiveInput as Input } from \"./ComposerInput\";\nexport { ComposerPrimitiveSend as Send } from \"./ComposerSend\";\nexport { ComposerPrimitiveCancel as Cancel } from \"./ComposerCancel\";\nexport { ComposerPrimitiveAddAttachment as AddAttachment } from \"./ComposerAddAttachment\";\nexport { ComposerPrimitiveAttachments as Attachments } from \"./ComposerAttachments\";\nexport { ComposerPrimitiveAttachmentByIndex as AttachmentByIndex } from \"./ComposerAttachments\";\nexport { ComposerPrimitiveAttachmentDropzone as AttachmentDropzone } from \"./ComposerAttachmentDropzone\";\nexport { ComposerPrimitiveIf as If } from \"./ComposerIf\";\n"],"mappings":";AAAA,SAAkC,6BAAY;AAC9C,SAAmC,8BAAa;AAChD,SAAkC,6BAAY;AAC9C,SAAoC,+BAAc;AAClD,SAA2C,sCAAqB;AAChE,SAAyC,oCAAmB;AAC5D,SAA+C,0CAAyB;AACxE,SAAgD,2CAA0B;AAC1E,SAAgC,2BAAU;","names":[]}
|
|
@@ -15,6 +15,9 @@ export declare namespace MessagePrimitiveRoot {
|
|
|
15
15
|
* hover state management for the message. It automatically tracks when the user
|
|
16
16
|
* is hovering over the message, which can be used by child components like action bars.
|
|
17
17
|
*
|
|
18
|
+
* When `turnAnchor="top"` is set on the viewport, this component
|
|
19
|
+
* registers itself as the scroll anchor if it's the last user message.
|
|
20
|
+
*
|
|
18
21
|
* @example
|
|
19
22
|
* ```tsx
|
|
20
23
|
* <MessagePrimitive.Root>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,KAAK,YAAY,EAEjB,wBAAwB,EAEzB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,KAAK,YAAY,EAEjB,wBAAwB,EAEzB,MAAM,OAAO,CAAC;AAkEf,yBAAiB,oBAAoB,CAAC;IACpC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD;;;OAGG;IACH,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;CACpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB;;0DAiB/B,CAAC"}
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from "react";
|
|
9
9
|
import { useAssistantApi, useAssistantState } from "../../context/index.js";
|
|
10
10
|
import { useManagedRef } from "../../utils/hooks/useManagedRef.js";
|
|
11
|
+
import { useSizeHandle } from "../../utils/hooks/useSizeHandle.js";
|
|
11
12
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
13
|
+
import { useThreadViewport } from "../../context/react/ThreadViewportContext.js";
|
|
14
|
+
import { ThreadPrimitiveViewportSlack } from "../thread/ThreadViewportSlack.js";
|
|
12
15
|
import { jsx } from "react/jsx-runtime";
|
|
13
16
|
var useIsHoveringRef = () => {
|
|
14
17
|
const api = useAssistantApi();
|
|
@@ -34,10 +37,29 @@ var useIsHoveringRef = () => {
|
|
|
34
37
|
);
|
|
35
38
|
return useManagedRef(callbackRef);
|
|
36
39
|
};
|
|
40
|
+
var useMessageViewportRef = () => {
|
|
41
|
+
const turnAnchor = useThreadViewport((s) => s.turnAnchor);
|
|
42
|
+
const registerUserHeight = useThreadViewport(
|
|
43
|
+
(s) => s.registerUserMessageHeight
|
|
44
|
+
);
|
|
45
|
+
const shouldRegisterAsInset = useAssistantState(
|
|
46
|
+
({ thread, message }) => turnAnchor === "top" && message.role === "user" && message.index === thread.messages.length - 2 && thread.messages.at(-1)?.role === "assistant"
|
|
47
|
+
);
|
|
48
|
+
const getHeight = useCallback((el) => el.offsetHeight, []);
|
|
49
|
+
return useSizeHandle(
|
|
50
|
+
shouldRegisterAsInset ? registerUserHeight : null,
|
|
51
|
+
getHeight
|
|
52
|
+
);
|
|
53
|
+
};
|
|
37
54
|
var MessagePrimitiveRoot = forwardRef((props, forwardRef2) => {
|
|
38
55
|
const isHoveringRef = useIsHoveringRef();
|
|
39
|
-
const
|
|
40
|
-
|
|
56
|
+
const anchorUserMessageRef = useMessageViewportRef();
|
|
57
|
+
const ref = useComposedRefs(
|
|
58
|
+
forwardRef2,
|
|
59
|
+
isHoveringRef,
|
|
60
|
+
anchorUserMessageRef
|
|
61
|
+
);
|
|
62
|
+
return /* @__PURE__ */ jsx(ThreadPrimitiveViewportSlack, { children: /* @__PURE__ */ jsx(Primitive.div, { ...props, ref }) });
|
|
41
63
|
});
|
|
42
64
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
|
43
65
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n ComponentPropsWithoutRef,\n useCallback,\n} from \"react\";\nimport { useAssistantApi, useAssistantState } from \"../../context\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\n\nconst useIsHoveringRef = () => {\n const api = useAssistantApi();\n const message = useAssistantState(() => api.message());\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) message.setIsHovering(true);\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n /**\n * Props for the MessagePrimitive.Root component.\n * Accepts all standard div element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardRef) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardRef
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n ComponentPropsWithoutRef,\n useCallback,\n} from \"react\";\nimport { useAssistantApi, useAssistantState } from \"../../context\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useThreadViewport } from \"../../context/react/ThreadViewportContext\";\nimport { ThreadPrimitiveViewportSlack } from \"../thread/ThreadViewportSlack\";\n\nconst useIsHoveringRef = () => {\n const api = useAssistantApi();\n const message = useAssistantState(() => api.message());\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) message.setIsHovering(true);\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\n/**\n * Hook that registers the anchor user message as a content inset.\n * Only registers if: user message, at index messages.length-2, and last message is assistant.\n */\nconst useMessageViewportRef = () => {\n const turnAnchor = useThreadViewport((s) => s.turnAnchor);\n const registerUserHeight = useThreadViewport(\n (s) => s.registerUserMessageHeight,\n );\n\n // inset rules:\n // - the previous user message before the last assistant message registers its full height\n const shouldRegisterAsInset = useAssistantState(\n ({ thread, message }) =>\n turnAnchor === \"top\" &&\n message.role === \"user\" &&\n message.index === thread.messages.length - 2 &&\n thread.messages.at(-1)?.role === \"assistant\",\n );\n\n const getHeight = useCallback((el: HTMLElement) => el.offsetHeight, []);\n\n return useSizeHandle(\n shouldRegisterAsInset ? registerUserHeight : null,\n getHeight,\n );\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n /**\n * Props for the MessagePrimitive.Root component.\n * Accepts all standard div element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * When `turnAnchor=\"top\"` is set on the viewport, this component\n * registers itself as the scroll anchor if it's the last user message.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardRef) => {\n const isHoveringRef = useIsHoveringRef();\n const anchorUserMessageRef = useMessageViewportRef();\n const ref = useComposedRefs<HTMLDivElement>(\n forwardRef,\n isHoveringRef,\n anchorUserMessageRef,\n );\n\n return (\n <ThreadPrimitiveViewportSlack>\n <Primitive.div {...props} ref={ref} />\n </ThreadPrimitiveViewportSlack>\n );\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,oCAAoC;AAwGvC;AAtGN,IAAM,mBAAmB,MAAM;AAC7B,QAAM,MAAM,gBAAgB;AAC5B,QAAM,UAAU,kBAAkB,MAAM,IAAI,QAAQ,CAAC;AAErD,QAAM,cAAc;AAAA,IAClB,CAAC,OAAoB;AACnB,YAAM,mBAAmB,MAAM;AAC7B,gBAAQ,cAAc,IAAI;AAAA,MAC5B;AACA,YAAM,mBAAmB,MAAM;AAC7B,gBAAQ,cAAc,KAAK;AAAA,MAC7B;AAEA,SAAG,iBAAiB,cAAc,gBAAgB;AAClD,SAAG,iBAAiB,cAAc,gBAAgB;AAElD,UAAI,GAAG,QAAQ,QAAQ,EAAG,SAAQ,cAAc,IAAI;AAEpD,aAAO,MAAM;AACX,WAAG,oBAAoB,cAAc,gBAAgB;AACrD,WAAG,oBAAoB,cAAc,gBAAgB;AACrD,gBAAQ,cAAc,KAAK;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,cAAc,WAAW;AAClC;AAMA,IAAM,wBAAwB,MAAM;AAClC,QAAM,aAAa,kBAAkB,CAAC,MAAM,EAAE,UAAU;AACxD,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,EAAE;AAAA,EACX;AAIA,QAAM,wBAAwB;AAAA,IAC5B,CAAC,EAAE,QAAQ,QAAQ,MACjB,eAAe,SACf,QAAQ,SAAS,UACjB,QAAQ,UAAU,OAAO,SAAS,SAAS,KAC3C,OAAO,SAAS,GAAG,EAAE,GAAG,SAAS;AAAA,EACrC;AAEA,QAAM,YAAY,YAAY,CAAC,OAAoB,GAAG,cAAc,CAAC,CAAC;AAEtE,SAAO;AAAA,IACL,wBAAwB,qBAAqB;AAAA,IAC7C;AAAA,EACF;AACF;AAgCO,IAAM,uBAAuB,WAGlC,CAAC,OAAOA,gBAAe;AACvB,QAAM,gBAAgB,iBAAiB;AACvC,QAAM,uBAAuB,sBAAsB;AACnD,QAAM,MAAM;AAAA,IACVA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SACE,oBAAC,gCACC,8BAAC,UAAU,KAAV,EAAe,GAAG,OAAO,KAAU,GACtC;AAEJ,CAAC;AAED,qBAAqB,cAAc;","names":["forwardRef"]}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { ActionButtonElement, ActionButtonProps } from "../../utils/createActionButton";
|
|
2
|
-
declare
|
|
2
|
+
export declare namespace useThreadScrollToBottom {
|
|
3
|
+
type Options = {
|
|
4
|
+
behavior?: ScrollBehavior | undefined;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
declare const useThreadScrollToBottom: ({ behavior, }?: useThreadScrollToBottom.Options) => (() => void) | null;
|
|
3
8
|
export declare namespace ThreadPrimitiveScrollToBottom {
|
|
4
9
|
type Element = ActionButtonElement;
|
|
5
10
|
type Props = ActionButtonProps<typeof useThreadScrollToBottom>;
|
|
6
11
|
}
|
|
7
12
|
export declare const ThreadPrimitiveScrollToBottom: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
13
|
asChild?: boolean;
|
|
9
|
-
}, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
14
|
+
}, "ref"> & useThreadScrollToBottom.Options & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
15
|
export {};
|
|
11
16
|
//# sourceMappingURL=ThreadScrollToBottom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadScrollToBottom.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAOxC,QAAA,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ThreadScrollToBottom.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAOxC,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,OAAO,GAAG;QACpB,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;KACvC,CAAC;CACH;AAED,QAAA,MAAM,uBAAuB,GAAI,gBAE9B,uBAAuB,CAAC,OAAY,wBAWtC,CAAC;AAEF,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,uBAAuB,CAAC,CAAC;CACvE;AAED,eAAO,MAAM,6BAA6B;;+FAIzC,CAAC"}
|
|
@@ -9,18 +9,21 @@ import {
|
|
|
9
9
|
useThreadViewport,
|
|
10
10
|
useThreadViewportStore
|
|
11
11
|
} from "../../context/react/ThreadViewportContext.js";
|
|
12
|
-
var useThreadScrollToBottom = (
|
|
12
|
+
var useThreadScrollToBottom = ({
|
|
13
|
+
behavior
|
|
14
|
+
} = {}) => {
|
|
13
15
|
const isAtBottom = useThreadViewport((s) => s.isAtBottom);
|
|
14
16
|
const threadViewportStore = useThreadViewportStore();
|
|
15
17
|
const handleScrollToBottom = useCallback(() => {
|
|
16
|
-
threadViewportStore.getState().scrollToBottom();
|
|
17
|
-
}, [threadViewportStore]);
|
|
18
|
+
threadViewportStore.getState().scrollToBottom({ behavior });
|
|
19
|
+
}, [threadViewportStore, behavior]);
|
|
18
20
|
if (isAtBottom) return null;
|
|
19
21
|
return handleScrollToBottom;
|
|
20
22
|
};
|
|
21
23
|
var ThreadPrimitiveScrollToBottom = createActionButton(
|
|
22
24
|
"ThreadPrimitive.ScrollToBottom",
|
|
23
|
-
useThreadScrollToBottom
|
|
25
|
+
useThreadScrollToBottom,
|
|
26
|
+
["behavior"]
|
|
24
27
|
);
|
|
25
28
|
export {
|
|
26
29
|
ThreadPrimitiveScrollToBottom
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nconst useThreadScrollToBottom = () => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom();\n }, [threadViewportStore]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;
|
|
1
|
+
{"version":3,"sources":["../../../src/primitives/thread/ThreadScrollToBottom.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAQP,IAAM,0BAA0B,CAAC;AAAA,EAC/B;AACF,IAAqC,CAAC,MAAM;AAC1C,QAAM,aAAa,kBAAkB,CAAC,MAAM,EAAE,UAAU;AAExD,QAAM,sBAAsB,uBAAuB;AAEnD,QAAM,uBAAuB,YAAY,MAAM;AAC7C,wBAAoB,SAAS,EAAE,eAAe,EAAE,SAAS,CAAC;AAAA,EAC5D,GAAG,CAAC,qBAAqB,QAAQ,CAAC;AAElC,MAAI,WAAY,QAAO;AACvB,SAAO;AACT;AAOO,IAAM,gCAAgC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,CAAC,UAAU;AACb;","names":[]}
|
|
@@ -6,9 +6,16 @@ export declare namespace ThreadPrimitiveViewport {
|
|
|
6
6
|
/**
|
|
7
7
|
* Whether to automatically scroll to the bottom when new messages are added.
|
|
8
8
|
* When enabled, the viewport will automatically scroll to show the latest content.
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* Default false if `turnAnchor` is "top", otherwise defaults to true.
|
|
10
11
|
*/
|
|
11
12
|
autoScroll?: boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Controls scroll anchoring behavior for new messages.
|
|
15
|
+
* - "bottom" (default): Messages anchor at the bottom, classic chat behavior.
|
|
16
|
+
* - "top": New user messages anchor at the top of the viewport for a focused reading experience.
|
|
17
|
+
*/
|
|
18
|
+
turnAnchor?: "top" | "bottom" | undefined;
|
|
12
19
|
};
|
|
13
20
|
}
|
|
14
21
|
/**
|
|
@@ -20,7 +27,7 @@ export declare namespace ThreadPrimitiveViewport {
|
|
|
20
27
|
*
|
|
21
28
|
* @example
|
|
22
29
|
* ```tsx
|
|
23
|
-
* <ThreadPrimitive.Viewport
|
|
30
|
+
* <ThreadPrimitive.Viewport turnAnchor="top">
|
|
24
31
|
* <ThreadPrimitive.Messages components={{ Message: MyMessage }} />
|
|
25
32
|
* </ThreadPrimitive.Viewport>
|
|
26
33
|
* ```
|
|
@@ -31,8 +38,15 @@ export declare const ThreadPrimitiveViewport: import("react").ForwardRefExoticCo
|
|
|
31
38
|
/**
|
|
32
39
|
* Whether to automatically scroll to the bottom when new messages are added.
|
|
33
40
|
* When enabled, the viewport will automatically scroll to show the latest content.
|
|
34
|
-
*
|
|
41
|
+
*
|
|
42
|
+
* Default false if `turnAnchor` is "top", otherwise defaults to true.
|
|
35
43
|
*/
|
|
36
44
|
autoScroll?: boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Controls scroll anchoring behavior for new messages.
|
|
47
|
+
* - "bottom" (default): Messages anchor at the bottom, classic chat behavior.
|
|
48
|
+
* - "top": New user messages anchor at the top of the viewport for a focused reading experience.
|
|
49
|
+
*/
|
|
50
|
+
turnAnchor?: "top" | "bottom" | undefined;
|
|
37
51
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
52
|
//# sourceMappingURL=ThreadViewport.d.ts.map
|