@assistant-ui/react 0.15.27 → 0.15.29
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/adapters/OpenAIRealtimeVoiceAdapter.d.ts +22 -0
- package/dist/adapters/OpenAIRealtimeVoiceAdapter.d.ts.map +1 -0
- package/dist/adapters/OpenAIRealtimeVoiceAdapter.js +297 -0
- package/dist/adapters/OpenAIRealtimeVoiceAdapter.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.js +1 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +5 -1
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.d.ts.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.js +67 -46
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +28 -10
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +4 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +15 -2
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +63 -55
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +1 -1
- package/dist/unstable/useMentionAdapter.js +1 -1
- package/dist/utils/Primitive.d.ts +14 -14
- package/package.json +6 -6
- package/src/adapters/OpenAIRealtimeVoiceAdapter.test.ts +748 -0
- package/src/adapters/OpenAIRealtimeVoiceAdapter.ts +388 -0
- package/src/index.ts +4 -0
- package/src/mcp-apps/McpAppRenderer.test.tsx +65 -0
- package/src/mcp-apps/McpAppRenderer.tsx +13 -2
- package/src/model-context/frame/useAssistantFrameHost.detach.test.tsx +145 -0
- package/src/model-context/frame/useAssistantFrameHost.reload.test.tsx +106 -0
- package/src/model-context/frame/useAssistantFrameHost.test.tsx +3 -1
- package/src/model-context/frame/useAssistantFrameHost.ts +72 -24
- package/src/primitives/composer/ComposerAddAttachment.test.tsx +1 -0
- package/src/primitives/composer/ComposerAddAttachment.thread-scope.test.tsx +202 -0
- package/src/primitives/composer/ComposerAddAttachment.ts +11 -1
- package/src/primitives/composer/ComposerInput.focus-on-run-start.test.tsx +130 -0
- package/src/primitives/composer/ComposerInput.tsx +29 -3
- package/src/primitives/composer/ComposerRoot.test.tsx +21 -1
- package/src/primitives/composer/ComposerRoot.tsx +8 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @vitest-environment jsdom */
|
|
2
|
-
import { act } from "react";
|
|
2
|
+
import { act, version } from "react";
|
|
3
3
|
import type { MouseEvent, ReactNode } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { createRoot } from "react-dom/client";
|
|
@@ -12,6 +12,8 @@ import { useComposerCompactContextOptional } from "./ComposerCompactContext";
|
|
|
12
12
|
import type { ComposerCompactContextValue } from "./ComposerCompactContext";
|
|
13
13
|
import { ComposerPrimitiveRoot } from "./ComposerRoot";
|
|
14
14
|
|
|
15
|
+
const onReact18 = version.startsWith("18.");
|
|
16
|
+
|
|
15
17
|
type StoreState = {
|
|
16
18
|
composer: {
|
|
17
19
|
attachments: object[];
|
|
@@ -77,6 +79,24 @@ describe("ComposerPrimitiveRoot click-to-focus", () => {
|
|
|
77
79
|
};
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
it("forwards the inert attribute and removes it when disabled", () => {
|
|
83
|
+
const { container, rerender } = render(<ComposerPrimitiveRoot inert />);
|
|
84
|
+
const form = container.querySelector("form");
|
|
85
|
+
|
|
86
|
+
expect(form?.hasAttribute("inert")).toBe(true);
|
|
87
|
+
|
|
88
|
+
rerender(<ComposerPrimitiveRoot inert={false} />);
|
|
89
|
+
expect(form?.hasAttribute("inert")).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it.skipIf(!onReact18)("keeps a string inert on React 18", () => {
|
|
93
|
+
const { container } = render(
|
|
94
|
+
<ComposerPrimitiveRoot inert={"" as unknown as boolean} />,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(container.querySelector("form")?.hasAttribute("inert")).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
80
100
|
it("focuses the textarea when primary-button mousedown starts on blank form space", () => {
|
|
81
101
|
const { blankSpace, textarea } = setupComposer();
|
|
82
102
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type MouseEvent,
|
|
12
12
|
useMemo,
|
|
13
13
|
useState,
|
|
14
|
+
version,
|
|
14
15
|
} from "react";
|
|
15
16
|
import { useComposerSend } from "./ComposerSend";
|
|
16
17
|
import { ComposerCompactContext } from "./ComposerCompactContext";
|
|
@@ -56,6 +57,9 @@ export namespace ComposerPrimitiveRoot {
|
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
// React 18 drops a boolean `inert`, so it receives the attribute's string form.
|
|
61
|
+
const isReact18 = version.startsWith("18.");
|
|
62
|
+
|
|
59
63
|
/**
|
|
60
64
|
* The root form container for message composition.
|
|
61
65
|
*
|
|
@@ -79,7 +83,7 @@ export namespace ComposerPrimitiveRoot {
|
|
|
79
83
|
export const ComposerPrimitiveRoot = forwardRef<
|
|
80
84
|
ComposerPrimitiveRoot.Element,
|
|
81
85
|
ComposerPrimitiveRoot.Props
|
|
82
|
-
>(({ onSubmit, onMouseDown, compact, ...rest }, forwardedRef) => {
|
|
86
|
+
>(({ onSubmit, onMouseDown, compact, inert, ...rest }, forwardedRef) => {
|
|
83
87
|
const send = useComposerSend();
|
|
84
88
|
const composerType = useAuiState((s) => s.composer.type);
|
|
85
89
|
|
|
@@ -95,6 +99,8 @@ export const ComposerPrimitiveRoot = forwardRef<
|
|
|
95
99
|
: false,
|
|
96
100
|
);
|
|
97
101
|
const isCompact = stateAllowsCompact && !multiline;
|
|
102
|
+
const inertAttribute =
|
|
103
|
+
isReact18 && typeof inert === "boolean" ? (inert ? "" : undefined) : inert;
|
|
98
104
|
|
|
99
105
|
const handleSubmit = (e: FormEvent) => {
|
|
100
106
|
e.preventDefault();
|
|
@@ -126,6 +132,7 @@ export const ComposerPrimitiveRoot = forwardRef<
|
|
|
126
132
|
<ComposerCompactContext.Provider value={compact ? compactContext : null}>
|
|
127
133
|
<Primitive.form
|
|
128
134
|
{...rest}
|
|
135
|
+
inert={inertAttribute as boolean | undefined}
|
|
129
136
|
data-aui-composer-type={composerType}
|
|
130
137
|
data-compact={isCompact ? "" : undefined}
|
|
131
138
|
ref={forwardedRef}
|