@assistant-ui/react 0.14.5 → 0.14.6
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/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +8 -2
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/AssistantContext.js +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/AttachmentContext.js +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/ComposerContext.js +1 -1
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +3 -3
- package/dist/legacy-runtime/hooks/MessageContext.js +2 -2
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/MessagePartContext.js +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +4 -4
- package/dist/legacy-runtime/hooks/ThreadContext.js +2 -2
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +1 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts +8 -0
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +8 -0
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts +7 -0
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +7 -0
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/utils.d.ts +7 -0
- package/dist/mcp-apps/utils.d.ts.map +1 -1
- package/dist/mcp-apps/utils.js +7 -0
- package/dist/mcp-apps/utils.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +6 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts +1 -5
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +1 -7
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.d.ts +16 -0
- package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +16 -0
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +15 -0
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +15 -0
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +15 -0
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +15 -0
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +15 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +15 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.d.ts +15 -0
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +15 -0
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts +15 -0
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +15 -0
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +50 -27
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/package.json +14 -16
- package/src/index.ts +6 -0
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +8 -2
- package/src/legacy-runtime/hooks/AssistantContext.ts +2 -2
- package/src/legacy-runtime/hooks/AttachmentContext.ts +2 -2
- package/src/legacy-runtime/hooks/ComposerContext.ts +2 -2
- package/src/legacy-runtime/hooks/MessageContext.ts +3 -3
- package/src/legacy-runtime/hooks/MessagePartContext.ts +2 -2
- package/src/legacy-runtime/hooks/ThreadContext.ts +4 -4
- package/src/legacy-runtime/hooks/ThreadListItemContext.ts +2 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.test.ts +254 -0
- package/src/mcp-apps/McpAppRenderer.tsx +8 -0
- package/src/mcp-apps/McpAppsRemoteHost.ts +7 -0
- package/src/mcp-apps/utils.ts +7 -0
- package/src/primitives/actionBar/ActionBarCopy.tsx +6 -1
- package/src/primitives/messagePart/MessagePartInProgress.ts +1 -17
- package/src/primitives/messagePart/useMessagePartData.ts +16 -0
- package/src/primitives/messagePart/useMessagePartFile.ts +15 -0
- package/src/primitives/messagePart/useMessagePartImage.ts +15 -0
- package/src/primitives/messagePart/useMessagePartReasoning.ts +15 -0
- package/src/primitives/messagePart/useMessagePartSource.ts +15 -0
- package/src/primitives/messagePart/useMessagePartText.ts +15 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +320 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +59 -29
- package/src/tests/BaseComposerRuntimeCore.test.ts +1 -1
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
import type { DataMessagePart } from "@assistant-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
4
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
5
|
+
* preserve the old hook's strict behavior.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const part = useAuiState((s) =>
|
|
10
|
+
* s.part.type === "data" && (!name || s.part.name === name)
|
|
11
|
+
* ? s.part
|
|
12
|
+
* : null,
|
|
13
|
+
* );
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
2
18
|
export declare const useMessagePartData: <T = any>(name?: string) => DataMessagePart<T> | null;
|
|
3
19
|
//# sourceMappingURL=useMessagePartData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartData.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,kBAAkB,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,MAAM,8BAiBxD,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartData.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,MAAM,8BAiBxD,CAAC"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const part = useAuiState((s) =>
|
|
11
|
+
* s.part.type === "data" && (!name || s.part.name === name)
|
|
12
|
+
* ? s.part
|
|
13
|
+
* : null,
|
|
14
|
+
* );
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
18
|
+
*/
|
|
3
19
|
export const useMessagePartData = (name) => {
|
|
4
20
|
const part = useAuiState((s) => {
|
|
5
21
|
if (s.part.type !== "data") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartData.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartData.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAU,IAAa,EAAE,EAAE;IAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,IAA0B,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartData.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartData.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAU,IAAa,EAAE,EAAE;IAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,IAA0B,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { FileMessagePart } from "@assistant-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
4
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
5
|
+
* preserve the old hook's strict behavior.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const file = useAuiState((s) => {
|
|
10
|
+
* if (s.part.type !== "file") return null;
|
|
11
|
+
* return s.part;
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
16
|
+
*/
|
|
2
17
|
export declare const useMessagePartFile: () => FileMessagePart & {
|
|
3
18
|
readonly status: import("@assistant-ui/core").MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
4
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartFile.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAG5E,eAAO,MAAM,kBAAkB;;CAW9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartFile.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAG5E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;;CAW9B,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const file = useAuiState((s) => {
|
|
11
|
+
* if (s.part.type !== "file") return null;
|
|
12
|
+
* return s.part;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
3
18
|
export const useMessagePartFile = () => {
|
|
4
19
|
const file = useAuiState((s) => {
|
|
5
20
|
if (s.part.type !== "file")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartFile.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartFile.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;YACxB,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA0C,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartFile.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartFile.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;YACxB,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA0C,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { ImageMessagePart } from "@assistant-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
4
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
5
|
+
* preserve the old hook's strict behavior.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const image = useAuiState((s) => {
|
|
10
|
+
* if (s.part.type !== "image") return null;
|
|
11
|
+
* return s.part;
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
16
|
+
*/
|
|
2
17
|
export declare const useMessagePartImage: () => ImageMessagePart & {
|
|
3
18
|
readonly status: import("@assistant-ui/core").MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
4
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartImage.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,oBAAoB,CAAC;AAG7E,eAAO,MAAM,mBAAmB;;CAW/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartImage.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,oBAAoB,CAAC;AAG7E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB;;CAW/B,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const image = useAuiState((s) => {
|
|
11
|
+
* if (s.part.type !== "image") return null;
|
|
12
|
+
* return s.part;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
3
18
|
export const useMessagePartImage = () => {
|
|
4
19
|
const image = useAuiState((s) => {
|
|
5
20
|
if (s.part.type !== "image")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartImage.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartImage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;YACzB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA2C,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartImage.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartImage.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;YACzB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA2C,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { ReasoningMessagePart } from "@assistant-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
4
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
5
|
+
* preserve the old hook's strict behavior.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const reasoning = useAuiState((s) => {
|
|
10
|
+
* if (s.part.type !== "reasoning") return null;
|
|
11
|
+
* return s.part;
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
16
|
+
*/
|
|
2
17
|
export declare const useMessagePartReasoning: () => ReasoningMessagePart & {
|
|
3
18
|
readonly status: import("@assistant-ui/core").MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
4
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartReasoning.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartReasoning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,uBAAuB;;CAWnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartReasoning.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartReasoning.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB;;CAWnC,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const reasoning = useAuiState((s) => {
|
|
11
|
+
* if (s.part.type !== "reasoning") return null;
|
|
12
|
+
* return s.part;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
3
18
|
export const useMessagePartReasoning = () => {
|
|
4
19
|
const text = useAuiState((s) => {
|
|
5
20
|
if (s.part.type !== "reasoning")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartReasoning.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartReasoning.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAMb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;YAC7B,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA+C,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartReasoning.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartReasoning.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAMb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;YAC7B,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA+C,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
3
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
4
|
+
* preserve the old hook's strict behavior.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const source = useAuiState((s) => {
|
|
9
|
+
* if (s.part.type !== "source") return null;
|
|
10
|
+
* return s.part;
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
15
|
+
*/
|
|
1
16
|
export declare const useMessagePartSource: () => ({
|
|
2
17
|
readonly type: "source";
|
|
3
18
|
readonly sourceType: "url";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartSource.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartSource.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartSource.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartSource.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const source = useAuiState((s) => {
|
|
11
|
+
* if (s.part.type !== "source") return null;
|
|
12
|
+
* return s.part;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
3
18
|
export const useMessagePartSource = () => {
|
|
4
19
|
const source = useAuiState((s) => {
|
|
5
20
|
if (s.part.type !== "source")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartSource.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartSource.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC1B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA4C,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartSource.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartSource.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;YAC1B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QAEJ,OAAO,CAAC,CAAC,IAA4C,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { TextMessagePart, ReasoningMessagePart } from "@assistant-ui/core";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
4
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
5
|
+
* preserve the old hook's strict behavior.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const text = useAuiState((s) => {
|
|
10
|
+
* if (s.part.type !== "text" && s.part.type !== "reasoning") return null;
|
|
11
|
+
* return s.part;
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
16
|
+
*/
|
|
2
17
|
export declare const useMessagePartText: () => (TextMessagePart & {
|
|
3
18
|
readonly status: import("@assistant-ui/core").MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
4
19
|
}) | (ReasoningMessagePart & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartText.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,kBAAkB;;;;EAY9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartText.d.ts","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;;;;EAY9B,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
+
* Return `null` for optional rendering, or throw inside the selector to
|
|
6
|
+
* preserve the old hook's strict behavior.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const text = useAuiState((s) => {
|
|
11
|
+
* if (s.part.type !== "text" && s.part.type !== "reasoning") return null;
|
|
12
|
+
* return s.part;
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
|
+
*/
|
|
3
18
|
export const useMessagePartText = () => {
|
|
4
19
|
const text = useAuiState((s) => {
|
|
5
20
|
if (s.part.type !== "text" && s.part.type !== "reasoning")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartText.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;YACvD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;QAEJ,OAAO,CAAC,CAAC,IACiC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"useMessagePartText.js","sourceRoot":"","sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;YACvD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;QAEJ,OAAO,CAAC,CAAC,IACiC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -15,7 +15,7 @@ export declare namespace useThreadViewportAutoScroll {
|
|
|
15
15
|
*/
|
|
16
16
|
scrollToBottomOnRunStart?: boolean | undefined;
|
|
17
17
|
/**
|
|
18
|
-
* Whether to scroll to bottom when
|
|
18
|
+
* Whether to scroll to bottom when messages first appear in the thread.
|
|
19
19
|
*
|
|
20
20
|
* Defaults to true.
|
|
21
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThreadViewportAutoScroll.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"useThreadViewportAutoScroll.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAQ/E,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG;QACpB;;;;;WAKG;QACH,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAEjC;;;;WAIG;QACH,wBAAwB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAE/C;;;;WAIG;QACH,0BAA0B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAEjD;;;;WAIG;QACH,4BAA4B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KACpD,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,SAAS,WAAW,EAAE,qGAKvE,2BAA2B,CAAC,OAAO,KAAG,WAAW,CAAC,QAAQ,CAmJ5D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
3
|
-
import { useCallback, useRef } from "react";
|
|
4
|
-
import { useAuiEvent } from "@assistant-ui/store";
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import { useOnResizeContent } from "../../utils/hooks/useOnResizeContent.js";
|
|
6
6
|
import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom.js";
|
|
7
7
|
import { useManagedRef } from "../../utils/hooks/useManagedRef.js";
|
|
@@ -9,14 +9,16 @@ import { writableStore } from "../../context/ReadonlyStore.js";
|
|
|
9
9
|
import { useThreadViewportStore } from "../../context/react/ThreadViewportContext.js";
|
|
10
10
|
export const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = true, scrollToBottomOnInitialize = true, scrollToBottomOnThreadSwitch = true, }) => {
|
|
11
11
|
const divRef = useRef(null);
|
|
12
|
+
const hasMessages = useAuiState((s) => s.thread.messages.length > 0);
|
|
13
|
+
const initializeScrollRequestedRef = useRef(false);
|
|
14
|
+
const scheduledFrameRef = useRef(null);
|
|
12
15
|
const threadViewportStore = useThreadViewportStore();
|
|
13
16
|
if (autoScroll === undefined) {
|
|
14
17
|
autoScroll = threadViewportStore.getState().turnAnchor !== "top";
|
|
15
18
|
}
|
|
16
19
|
const lastScrollTop = useRef(0);
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// stores the scroll behavior to reuse during content resize, or null if not scrolling
|
|
20
|
+
// Pending bottom-scroll intent. Planted by initialize/run-start/switch/button
|
|
21
|
+
// triggers, cleared only when handleScroll confirms we reached bottom.
|
|
20
22
|
const scrollingToBottomBehaviorRef = useRef(null);
|
|
21
23
|
const scrollToBottom = useCallback((behavior) => {
|
|
22
24
|
const div = divRef.current;
|
|
@@ -25,6 +27,21 @@ export const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunSta
|
|
|
25
27
|
scrollingToBottomBehaviorRef.current = behavior;
|
|
26
28
|
div.scrollTo({ top: div.scrollHeight, behavior });
|
|
27
29
|
}, []);
|
|
30
|
+
const scheduleScrollToBottom = useCallback((behavior) => {
|
|
31
|
+
scrollingToBottomBehaviorRef.current = behavior;
|
|
32
|
+
if (scheduledFrameRef.current !== null) {
|
|
33
|
+
cancelAnimationFrame(scheduledFrameRef.current);
|
|
34
|
+
}
|
|
35
|
+
scheduledFrameRef.current = requestAnimationFrame(() => {
|
|
36
|
+
scheduledFrameRef.current = null;
|
|
37
|
+
scrollToBottom(behavior);
|
|
38
|
+
});
|
|
39
|
+
}, [scrollToBottom]);
|
|
40
|
+
useLayoutEffect(() => () => {
|
|
41
|
+
if (scheduledFrameRef.current !== null) {
|
|
42
|
+
cancelAnimationFrame(scheduledFrameRef.current);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
28
45
|
const hasActiveTopAnchor = useCallback(() => {
|
|
29
46
|
const state = threadViewportStore.getState();
|
|
30
47
|
return (state.turnAnchor === "top" &&
|
|
@@ -38,12 +55,19 @@ export const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunSta
|
|
|
38
55
|
const isAtBottom = threadViewportStore.getState().isAtBottom;
|
|
39
56
|
const newIsAtBottom = Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) < 1 ||
|
|
40
57
|
div.scrollHeight <= div.clientHeight;
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
const isInFlightDownwardScroll = !newIsAtBottom && lastScrollTop.current < div.scrollTop;
|
|
59
|
+
if (isInFlightDownwardScroll) {
|
|
60
|
+
// no-op: a smooth scroll-to-bottom fires many midpoint scroll events
|
|
61
|
+
// before landing, don't flicker isAtBottom or clear intent mid-animation
|
|
43
62
|
}
|
|
44
63
|
else {
|
|
45
64
|
if (newIsAtBottom) {
|
|
46
|
-
|
|
65
|
+
// newIsAtBottom is ambiguous when the viewport doesn't overflow —
|
|
66
|
+
// keep intent alive until content can actually scroll
|
|
67
|
+
const viewportOverflows = div.scrollHeight > div.clientHeight + 1;
|
|
68
|
+
if (viewportOverflows) {
|
|
69
|
+
scrollingToBottomBehaviorRef.current = null;
|
|
70
|
+
}
|
|
47
71
|
}
|
|
48
72
|
const shouldUpdate = newIsAtBottom || scrollingToBottomBehaviorRef.current === null;
|
|
49
73
|
if (shouldUpdate && newIsAtBottom !== isAtBottom) {
|
|
@@ -74,37 +98,36 @@ export const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunSta
|
|
|
74
98
|
el.removeEventListener("scroll", handleScroll);
|
|
75
99
|
};
|
|
76
100
|
});
|
|
101
|
+
useLayoutEffect(() => {
|
|
102
|
+
if (!scrollToBottomOnInitialize)
|
|
103
|
+
return;
|
|
104
|
+
if (!hasMessages) {
|
|
105
|
+
initializeScrollRequestedRef.current = false;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (initializeScrollRequestedRef.current)
|
|
109
|
+
return;
|
|
110
|
+
initializeScrollRequestedRef.current = true;
|
|
111
|
+
// defer to an in-flight run (e.g. first message on a new thread) that
|
|
112
|
+
// already planted intent — otherwise we'd downgrade its "auto" to "instant"
|
|
113
|
+
if (scrollingToBottomBehaviorRef.current !== null)
|
|
114
|
+
return;
|
|
115
|
+
scheduleScrollToBottom("instant");
|
|
116
|
+
}, [hasMessages, scheduleScrollToBottom, scrollToBottomOnInitialize]);
|
|
77
117
|
useOnScrollToBottom(({ behavior }) => {
|
|
78
118
|
scrollToBottom(behavior);
|
|
79
119
|
});
|
|
80
|
-
// autoscroll on run start
|
|
81
120
|
useAuiEvent("thread.runStart", () => {
|
|
82
121
|
if (!scrollToBottomOnRunStart)
|
|
83
122
|
return;
|
|
84
123
|
if (threadViewportStore.getState().turnAnchor === "top")
|
|
85
124
|
return;
|
|
86
|
-
|
|
87
|
-
requestAnimationFrame(() => {
|
|
88
|
-
scrollToBottom("auto");
|
|
89
|
-
});
|
|
125
|
+
scheduleScrollToBottom("auto");
|
|
90
126
|
});
|
|
91
|
-
// scroll to bottom instantly when thread history is first loaded
|
|
92
|
-
useAuiEvent("thread.initialize", () => {
|
|
93
|
-
if (!scrollToBottomOnInitialize)
|
|
94
|
-
return;
|
|
95
|
-
scrollingToBottomBehaviorRef.current = "instant";
|
|
96
|
-
requestAnimationFrame(() => {
|
|
97
|
-
scrollToBottom("instant");
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
// scroll to bottom instantly when switching threads
|
|
101
127
|
useAuiEvent("threadListItem.switchedTo", () => {
|
|
102
128
|
if (!scrollToBottomOnThreadSwitch)
|
|
103
129
|
return;
|
|
104
|
-
|
|
105
|
-
requestAnimationFrame(() => {
|
|
106
|
-
scrollToBottom("instant");
|
|
107
|
-
});
|
|
130
|
+
scheduleScrollToBottom("instant");
|
|
108
131
|
});
|
|
109
132
|
const autoScrollRef = useComposedRefs(resizeRef, scrollRef, divRef);
|
|
110
133
|
return autoScrollRef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThreadViewportAutoScroll.js","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useThreadViewportAutoScroll.js","sourceRoot":"","sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE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O;QACtC,IAAI,mBAAmB,CAAC,QAAQ,EAAE,CAAC,UAAU,KAAK,KAAK;YAAE,OAAO;QAChE,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,2BAA2B,EAAE,GAAG,EAAE;QAC5C,IAAI,CAAC,4BAA4B;YAAE,OAAO;QAC1C,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,eAAe,CAAW,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC9E,OAAO,aAAsC,CAAC;AAChD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.6",
|
|
4
4
|
"description": "Open-source TypeScript/React library for building production-grade AI chat experiences",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"radix-ui",
|
|
@@ -47,16 +47,9 @@
|
|
|
47
47
|
"README.md"
|
|
48
48
|
],
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"scripts": {
|
|
51
|
-
"prepack": "cp ../../README.md /tmp/aui-readme-pack.md && mv /tmp/aui-readme-pack.md ./README.md",
|
|
52
|
-
"postpack": "rm -f ./README.md && ln -s ../../README.md ./README.md",
|
|
53
|
-
"build": "aui-build",
|
|
54
|
-
"test": "vitest run",
|
|
55
|
-
"test:watch": "vitest"
|
|
56
|
-
},
|
|
57
50
|
"dependencies": {
|
|
58
|
-
"@assistant-ui/core": "^0.2.
|
|
59
|
-
"@assistant-ui/store": "^0.2.
|
|
51
|
+
"@assistant-ui/core": "^0.2.3",
|
|
52
|
+
"@assistant-ui/store": "^0.2.11",
|
|
60
53
|
"@assistant-ui/tap": "^0.5.11",
|
|
61
54
|
"@radix-ui/primitive": "^1.1.3",
|
|
62
55
|
"@radix-ui/react-compose-refs": "^1.1.2",
|
|
@@ -64,8 +57,8 @@
|
|
|
64
57
|
"@radix-ui/react-primitive": "^2.1.4",
|
|
65
58
|
"@radix-ui/react-use-callback-ref": "^1.1.1",
|
|
66
59
|
"@radix-ui/react-use-escape-keydown": "^1.1.1",
|
|
67
|
-
"assistant-cloud": "^0.1.
|
|
68
|
-
"assistant-stream": "^0.3.
|
|
60
|
+
"assistant-cloud": "^0.1.28",
|
|
61
|
+
"assistant-stream": "^0.3.15",
|
|
69
62
|
"nanoid": "^5.1.11",
|
|
70
63
|
"radix-ui": "^1.4.3",
|
|
71
64
|
"react-textarea-autosize": "^8.5.9",
|
|
@@ -88,7 +81,6 @@
|
|
|
88
81
|
}
|
|
89
82
|
},
|
|
90
83
|
"devDependencies": {
|
|
91
|
-
"@assistant-ui/x-buildutils": "workspace:*",
|
|
92
84
|
"@testing-library/react": "^16.3.2",
|
|
93
85
|
"@types/json-schema": "^7.0.15",
|
|
94
86
|
"@types/node": "^25.6.0",
|
|
@@ -97,11 +89,12 @@
|
|
|
97
89
|
"jsdom": "^29.1.1",
|
|
98
90
|
"react": "^19.2.5",
|
|
99
91
|
"react-dom": "^19.2.5",
|
|
100
|
-
"vitest": "^4.1.5"
|
|
92
|
+
"vitest": "^4.1.5",
|
|
93
|
+
"@assistant-ui/x-buildutils": "0.0.8"
|
|
101
94
|
},
|
|
102
95
|
"publishConfig": {
|
|
103
96
|
"access": "public",
|
|
104
|
-
"provenance":
|
|
97
|
+
"provenance": true
|
|
105
98
|
},
|
|
106
99
|
"homepage": "https://www.assistant-ui.com/",
|
|
107
100
|
"repository": {
|
|
@@ -111,5 +104,10 @@
|
|
|
111
104
|
},
|
|
112
105
|
"bugs": {
|
|
113
106
|
"url": "https://github.com/assistant-ui/assistant-ui/issues"
|
|
107
|
+
},
|
|
108
|
+
"scripts": {
|
|
109
|
+
"build": "aui-build",
|
|
110
|
+
"test": "vitest run",
|
|
111
|
+
"test:watch": "vitest"
|
|
114
112
|
}
|
|
115
|
-
}
|
|
113
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -378,6 +378,12 @@ export {
|
|
|
378
378
|
type RegisteredTrigger as Unstable_RegisteredTrigger,
|
|
379
379
|
type TriggerBehavior as Unstable_TriggerBehavior,
|
|
380
380
|
} from "./primitives/composer/trigger";
|
|
381
|
+
export type {
|
|
382
|
+
Unstable_DirectiveFormatter,
|
|
383
|
+
Unstable_DirectiveSegment,
|
|
384
|
+
Unstable_TriggerItem,
|
|
385
|
+
} from "@assistant-ui/core";
|
|
386
|
+
export { unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
|
|
381
387
|
|
|
382
388
|
export type { Assistant } from "./augmentations";
|
|
383
389
|
|
|
@@ -10,12 +10,18 @@ import { DevToolsProviderApi } from "../devtools/DevToolsHooks";
|
|
|
10
10
|
export namespace AssistantRuntimeProvider {
|
|
11
11
|
export type Props = PropsWithChildren<{
|
|
12
12
|
/**
|
|
13
|
-
* The runtime to
|
|
13
|
+
* The assistant runtime to expose to descendants. Build one with
|
|
14
|
+
* `useLocalRuntime`, `useExternalStoreRuntime`, or
|
|
15
|
+
* `useAssistantTransportRuntime`.
|
|
14
16
|
*/
|
|
15
17
|
runtime: AssistantRuntime;
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
20
|
+
* Optional parent `AssistantClient` whose scopes are inherited by the
|
|
21
|
+
* client created for this runtime. Use this when nesting an
|
|
22
|
+
* `AssistantRuntimeProvider` inside another assistant context. Omit this
|
|
23
|
+
* prop when there is no parent client.
|
|
24
|
+
* @defaultValue undefined
|
|
19
25
|
*/
|
|
20
26
|
aui?: AssistantClient;
|
|
21
27
|
}>;
|
|
@@ -6,7 +6,7 @@ import type { ThreadListRuntime } from "../runtime/ThreadListRuntime";
|
|
|
6
6
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated Use
|
|
9
|
+
* @deprecated Use {@link useAui} instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
10
10
|
*
|
|
11
11
|
* Hook to access the AssistantRuntime from the current context.
|
|
12
12
|
*
|
|
@@ -62,6 +62,6 @@ const useThreadListRuntime = (opt: {
|
|
|
62
62
|
}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* @deprecated Use `useAuiState((s) => s.threads)
|
|
65
|
+
* @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
66
66
|
*/
|
|
67
67
|
export const useThreadList = createStateHookForRuntime(useThreadListRuntime);
|