@assistant-ui/react-native 0.1.37 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/index.d.ts +4 -3
  2. package/dist/index.js +3 -2
  3. package/dist/primitives/actionBar/ActionBarCopy.js +1 -0
  4. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  5. package/dist/primitives/actionBar/ActionBarEdit.d.ts +2 -3
  6. package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
  7. package/dist/primitives/actionBar/ActionBarEdit.js +1 -0
  8. package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
  9. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -0
  10. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
  11. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -0
  12. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
  13. package/dist/primitives/actionBar/ActionBarReload.d.ts +2 -3
  14. package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
  15. package/dist/primitives/actionBar/ActionBarReload.js +1 -0
  16. package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
  17. package/dist/primitives/attachment/AttachmentRemove.d.ts +2 -3
  18. package/dist/primitives/attachment/AttachmentRemove.d.ts.map +1 -1
  19. package/dist/primitives/attachment/AttachmentRemove.js +1 -0
  20. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  21. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  22. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  23. package/dist/primitives/branchPicker/BranchPickerNext.d.ts +2 -3
  24. package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
  25. package/dist/primitives/branchPicker/BranchPickerNext.js +1 -0
  26. package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
  27. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +2 -3
  28. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
  29. package/dist/primitives/branchPicker/BranchPickerPrevious.js +1 -0
  30. package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
  31. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +2 -3
  32. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
  33. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -0
  34. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
  35. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -1
  36. package/dist/primitives/composer/ComposerAddAttachment.d.ts +2 -3
  37. package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
  38. package/dist/primitives/composer/ComposerAddAttachment.js +1 -0
  39. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  40. package/dist/primitives/composer/ComposerCancel.d.ts +2 -3
  41. package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
  42. package/dist/primitives/composer/ComposerCancel.js +1 -0
  43. package/dist/primitives/composer/ComposerCancel.js.map +1 -1
  44. package/dist/primitives/composer/ComposerInput.js +2 -0
  45. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  46. package/dist/primitives/composer/ComposerQueue.d.ts +2 -0
  47. package/dist/primitives/composer/ComposerQueue.js +2 -0
  48. package/dist/primitives/composer/ComposerQuote.d.ts +10 -0
  49. package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -0
  50. package/dist/primitives/composer/ComposerQuote.js +38 -0
  51. package/dist/primitives/composer/ComposerQuote.js.map +1 -0
  52. package/dist/primitives/composer/ComposerQuoteDismiss.d.ts +9 -0
  53. package/dist/primitives/composer/ComposerQuoteDismiss.d.ts.map +1 -0
  54. package/dist/primitives/composer/ComposerQuoteDismiss.js +48 -0
  55. package/dist/primitives/composer/ComposerQuoteDismiss.js.map +1 -0
  56. package/dist/primitives/composer/ComposerQuoteText.d.ts +10 -0
  57. package/dist/primitives/composer/ComposerQuoteText.d.ts.map +1 -0
  58. package/dist/primitives/composer/ComposerQuoteText.js +40 -0
  59. package/dist/primitives/composer/ComposerQuoteText.js.map +1 -0
  60. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  61. package/dist/primitives/composer/ComposerSend.d.ts +2 -3
  62. package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
  63. package/dist/primitives/composer/ComposerSend.js +1 -0
  64. package/dist/primitives/composer/ComposerSend.js.map +1 -1
  65. package/dist/primitives/composer.d.ts +6 -2
  66. package/dist/primitives/composer.js +9 -1
  67. package/dist/primitives/composer.js.map +1 -1
  68. package/dist/primitives/error/ErrorMessage.js.map +1 -1
  69. package/dist/primitives/error/ErrorRoot.js.map +1 -1
  70. package/dist/primitives/message/MessageIf.d.ts +3 -0
  71. package/dist/primitives/message/MessageIf.d.ts.map +1 -1
  72. package/dist/primitives/message/MessageIf.js +3 -0
  73. package/dist/primitives/message/MessageIf.js.map +1 -1
  74. package/dist/primitives/message/MessageParts.js.map +1 -1
  75. package/dist/primitives/message/MessageRoot.js.map +1 -1
  76. package/dist/primitives/queueItem/QueueItemRemove.d.ts +9 -0
  77. package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -0
  78. package/dist/primitives/queueItem/QueueItemRemove.js +48 -0
  79. package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -0
  80. package/dist/primitives/queueItem/QueueItemSteer.d.ts +9 -0
  81. package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -0
  82. package/dist/primitives/queueItem/QueueItemSteer.js +48 -0
  83. package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -0
  84. package/dist/primitives/queueItem/QueueItemText.d.ts +10 -0
  85. package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -0
  86. package/dist/primitives/queueItem/QueueItemText.js +45 -0
  87. package/dist/primitives/queueItem/QueueItemText.js.map +1 -0
  88. package/dist/primitives/queueItem.d.ts +9 -0
  89. package/dist/primitives/queueItem.d.ts.map +1 -0
  90. package/dist/primitives/queueItem.js +14 -0
  91. package/dist/primitives/queueItem.js.map +1 -0
  92. package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
  93. package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
  94. package/dist/primitives/suggestion/SuggestionTrigger.d.ts +2 -3
  95. package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
  96. package/dist/primitives/suggestion/SuggestionTrigger.js +1 -0
  97. package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
  98. package/dist/primitives/thread/ThreadEmpty.d.ts +4 -1
  99. package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
  100. package/dist/primitives/thread/ThreadEmpty.js +12 -4
  101. package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
  102. package/dist/primitives/thread/ThreadIf.d.ts +3 -0
  103. package/dist/primitives/thread/ThreadIf.d.ts.map +1 -1
  104. package/dist/primitives/thread/ThreadIf.js +5 -6
  105. package/dist/primitives/thread/ThreadIf.js.map +1 -1
  106. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  107. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  108. package/dist/primitives/thread/ThreadSuggestion.d.ts +2 -3
  109. package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
  110. package/dist/primitives/thread/ThreadSuggestion.js +1 -0
  111. package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
  112. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  113. package/dist/primitives/threadList/ThreadListNew.d.ts +6 -4
  114. package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
  115. package/dist/primitives/threadList/ThreadListNew.js +46 -15
  116. package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
  117. package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
  118. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +2 -3
  119. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
  120. package/dist/primitives/threadListItem/ThreadListItemArchive.js +1 -0
  121. package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
  122. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +2 -3
  123. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
  124. package/dist/primitives/threadListItem/ThreadListItemDelete.js +1 -0
  125. package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
  126. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  127. package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +6 -4
  128. package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
  129. package/dist/primitives/threadListItem/ThreadListItemTrigger.js +46 -15
  130. package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
  131. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +2 -3
  132. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
  133. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +1 -0
  134. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
  135. package/package.json +9 -9
  136. package/src/index.ts +5 -0
  137. package/src/primitives/accessibilityRole.test.tsx +335 -0
  138. package/src/primitives/actionBar/ActionBarCopy.tsx +1 -0
  139. package/src/primitives/actionBar/ActionBarEdit.tsx +6 -3
  140. package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +1 -1
  141. package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +1 -1
  142. package/src/primitives/actionBar/ActionBarReload.tsx +6 -3
  143. package/src/primitives/attachment/AttachmentRemove.tsx +11 -4
  144. package/src/primitives/branchPicker/BranchPickerNext.tsx +6 -3
  145. package/src/primitives/branchPicker/BranchPickerPrevious.tsx +6 -3
  146. package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +4 -4
  147. package/src/primitives/composer/ComposerAddAttachment.tsx +10 -4
  148. package/src/primitives/composer/ComposerCancel.tsx +6 -3
  149. package/src/primitives/composer/ComposerInput.test.tsx +47 -1
  150. package/src/primitives/composer/ComposerInput.tsx +2 -0
  151. package/src/primitives/composer/ComposerQueue.test.tsx +9 -0
  152. package/src/primitives/composer/ComposerQueue.tsx +1 -0
  153. package/src/primitives/composer/ComposerQuote.test.tsx +163 -0
  154. package/src/primitives/composer/ComposerQuote.tsx +17 -0
  155. package/src/primitives/composer/ComposerQuoteDismiss.tsx +31 -0
  156. package/src/primitives/composer/ComposerQuoteText.tsx +17 -0
  157. package/src/primitives/composer/ComposerSend.test.tsx +26 -0
  158. package/src/primitives/composer/ComposerSend.tsx +3 -3
  159. package/src/primitives/composer.ts +13 -0
  160. package/src/primitives/message/MessageIf.tsx +3 -0
  161. package/src/primitives/queueItem/QueueItem.test.tsx +132 -0
  162. package/src/primitives/queueItem/QueueItemRemove.tsx +31 -0
  163. package/src/primitives/queueItem/QueueItemSteer.tsx +31 -0
  164. package/src/primitives/queueItem/QueueItemText.tsx +22 -0
  165. package/src/primitives/queueItem.ts +12 -0
  166. package/src/primitives/suggestion/SuggestionTrigger.tsx +6 -3
  167. package/src/primitives/thread/ThreadEmpty.test.tsx +17 -3
  168. package/src/primitives/thread/ThreadEmpty.tsx +7 -6
  169. package/src/primitives/thread/ThreadIf.test.tsx +20 -20
  170. package/src/primitives/thread/ThreadIf.tsx +5 -8
  171. package/src/primitives/thread/ThreadSuggestion.tsx +6 -3
  172. package/src/primitives/threadList/ThreadListNew.test.tsx +118 -3
  173. package/src/primitives/threadList/ThreadListNew.tsx +28 -5
  174. package/src/primitives/threadListItem/ThreadListItemArchive.tsx +6 -4
  175. package/src/primitives/threadListItem/ThreadListItemDelete.tsx +10 -4
  176. package/src/primitives/threadListItem/ThreadListItemTrigger.test.tsx +74 -0
  177. package/src/primitives/threadListItem/ThreadListItemTrigger.tsx +28 -5
  178. package/src/primitives/threadListItem/ThreadListItemUnarchive.tsx +10 -4
  179. package/dist/runtimes/RemoteThreadListHookInstanceManager.d.ts +0 -2
  180. package/dist/runtimes/RemoteThreadListHookInstanceManager.js +0 -2
  181. package/dist/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +0 -2
  182. package/dist/runtimes/RemoteThreadListThreadListRuntimeCore.js +0 -2
  183. package/src/runtimes/RemoteThreadListHookInstanceManager.tsx +0 -1
  184. package/src/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +0 -1
@@ -16,7 +16,7 @@ export const ActionBarFeedbackNegative = ({
16
16
  const { submit, isSubmitted } = useActionBarFeedbackNegative();
17
17
 
18
18
  return (
19
- <Pressable onPress={submit} {...pressableProps}>
19
+ <Pressable onPress={submit} accessibilityRole="button" {...pressableProps}>
20
20
  {typeof children === "function" ? children({ isSubmitted }) : children}
21
21
  </Pressable>
22
22
  );
@@ -16,7 +16,7 @@ export const ActionBarFeedbackPositive = ({
16
16
  const { submit, isSubmitted } = useActionBarFeedbackPositive();
17
17
 
18
18
  return (
19
- <Pressable onPress={submit} {...pressableProps}>
19
+ <Pressable onPress={submit} accessibilityRole="button" {...pressableProps}>
20
20
  {typeof children === "function" ? children({ isSubmitted }) : children}
21
21
  </Pressable>
22
22
  );
@@ -1,9 +1,11 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useActionBarReload } from "@assistant-ui/core/react";
4
3
 
5
- export type ActionBarReloadProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type ActionBarReloadProps = Omit<
5
+ PressableProps,
6
+ "onPress" | "children"
7
+ > & {
8
+ children: PressableProps["children"];
7
9
  };
8
10
 
9
11
  export const ActionBarReload = ({
@@ -17,6 +19,7 @@ export const ActionBarReload = ({
17
19
  <Pressable
18
20
  onPress={reload}
19
21
  disabled={disabledProp ?? disabled}
22
+ accessibilityRole="button"
20
23
  {...pressableProps}
21
24
  >
22
25
  {children}
@@ -1,10 +1,13 @@
1
- import { type ReactNode, useCallback } from "react";
1
+ import { useCallback } from "react";
2
2
  import { Pressable, type PressableProps } from "react-native";
3
3
 
4
4
  import { useAui } from "@assistant-ui/store";
5
5
 
6
- export type AttachmentRemoveProps = Omit<PressableProps, "onPress"> & {
7
- children: ReactNode;
6
+ export type AttachmentRemoveProps = Omit<
7
+ PressableProps,
8
+ "onPress" | "children"
9
+ > & {
10
+ children: PressableProps["children"];
8
11
  };
9
12
 
10
13
  export const AttachmentRemove = ({
@@ -18,7 +21,11 @@ export const AttachmentRemove = ({
18
21
  }, [aui]);
19
22
 
20
23
  return (
21
- <Pressable onPress={handleRemove} {...pressableProps}>
24
+ <Pressable
25
+ onPress={handleRemove}
26
+ accessibilityRole="button"
27
+ {...pressableProps}
28
+ >
22
29
  {children}
23
30
  </Pressable>
24
31
  );
@@ -1,9 +1,11 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useBranchPickerNext } from "@assistant-ui/core/react";
4
3
 
5
- export type BranchPickerNextProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type BranchPickerNextProps = Omit<
5
+ PressableProps,
6
+ "onPress" | "children"
7
+ > & {
8
+ children: PressableProps["children"];
7
9
  };
8
10
 
9
11
  export const BranchPickerNext = ({
@@ -17,6 +19,7 @@ export const BranchPickerNext = ({
17
19
  <Pressable
18
20
  onPress={next}
19
21
  disabled={disabledProp ?? disabled}
22
+ accessibilityRole="button"
20
23
  {...pressableProps}
21
24
  >
22
25
  {children}
@@ -1,9 +1,11 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useBranchPickerPrevious } from "@assistant-ui/core/react";
4
3
 
5
- export type BranchPickerPreviousProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type BranchPickerPreviousProps = Omit<
5
+ PressableProps,
6
+ "onPress" | "children"
7
+ > & {
8
+ children: PressableProps["children"];
7
9
  };
8
10
 
9
11
  export const BranchPickerPrevious = ({
@@ -17,6 +19,7 @@ export const BranchPickerPrevious = ({
17
19
  <Pressable
18
20
  onPress={previous}
19
21
  disabled={disabledProp ?? disabled}
22
+ accessibilityRole="button"
20
23
  {...pressableProps}
21
24
  >
22
25
  {children}
@@ -1,12 +1,12 @@
1
- import { useCallback, type ReactNode } from "react";
1
+ import { useCallback } from "react";
2
2
  import { Pressable, type PressableProps } from "react-native";
3
3
  import { useAuiState, useAui } from "@assistant-ui/store";
4
4
 
5
5
  export type ChainOfThoughtAccordionTriggerProps = Omit<
6
6
  PressableProps,
7
- "onPress"
7
+ "onPress" | "children"
8
8
  > & {
9
- children: ReactNode;
9
+ children: PressableProps["children"];
10
10
  };
11
11
 
12
12
  export const ChainOfThoughtAccordionTrigger = ({
@@ -21,7 +21,7 @@ export const ChainOfThoughtAccordionTrigger = ({
21
21
  }, [aui, collapsed]);
22
22
 
23
23
  return (
24
- <Pressable onPress={onPress} {...pressableProps}>
24
+ <Pressable onPress={onPress} accessibilityRole="button" {...pressableProps}>
25
25
  {children}
26
26
  </Pressable>
27
27
  );
@@ -1,9 +1,11 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useComposerAddAttachment } from "@assistant-ui/core/react";
4
3
 
5
- export type ComposerAddAttachmentProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type ComposerAddAttachmentProps = Omit<
5
+ PressableProps,
6
+ "onPress" | "children"
7
+ > & {
8
+ children: PressableProps["children"];
7
9
  };
8
10
 
9
11
  /**
@@ -21,7 +23,11 @@ export const ComposerAddAttachment = ({
21
23
  const { disabled } = useComposerAddAttachment();
22
24
 
23
25
  return (
24
- <Pressable disabled={disabledProp ?? disabled} {...pressableProps}>
26
+ <Pressable
27
+ disabled={disabledProp ?? disabled}
28
+ accessibilityRole="button"
29
+ {...pressableProps}
30
+ >
25
31
  {children}
26
32
  </Pressable>
27
33
  );
@@ -1,9 +1,11 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useComposerCancel } from "@assistant-ui/core/react";
4
3
 
5
- export type ComposerCancelProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type ComposerCancelProps = Omit<
5
+ PressableProps,
6
+ "onPress" | "children"
7
+ > & {
8
+ children: PressableProps["children"];
7
9
  };
8
10
 
9
11
  export const ComposerCancel = ({
@@ -17,6 +19,7 @@ export const ComposerCancel = ({
17
19
  <Pressable
18
20
  onPress={cancel}
19
21
  disabled={disabled ?? hookDisabled}
22
+ accessibilityRole="button"
20
23
  {...pressableProps}
21
24
  >
22
25
  {children}
@@ -8,6 +8,7 @@ const h = vi.hoisted(() => ({
8
8
  sendSpy: vi.fn<() => void>(),
9
9
  flushTapSyncSpy: vi.fn(<T,>(fn: () => T) => fn()),
10
10
  composerState: { text: "" },
11
+ threadState: { isRunning: false, queue: false },
11
12
  platform: { os: "web" as "web" | "ios" | "android" },
12
13
  }));
13
14
 
@@ -16,7 +17,13 @@ vi.mock("@assistant-ui/store", () => {
16
17
  setText: h.setText,
17
18
  send: h.sendSpy,
18
19
  });
19
- const aui = { composer };
20
+ const thread = {
21
+ getState: () => ({
22
+ isRunning: h.threadState.isRunning,
23
+ capabilities: { queue: h.threadState.queue },
24
+ }),
25
+ };
26
+ const aui = { composer, thread };
20
27
  return {
21
28
  useAui: () => aui,
22
29
  useAuiState: <T,>(
@@ -100,6 +107,8 @@ describe("ComposerInput", () => {
100
107
  h.sendSpy.mockReset();
101
108
  h.flushTapSyncSpy.mockClear();
102
109
  h.composerState.text = "";
110
+ h.threadState.isRunning = false;
111
+ h.threadState.queue = false;
103
112
  h.platform.os = "web";
104
113
 
105
114
  container = document.createElement("div");
@@ -169,6 +178,43 @@ describe("ComposerInput", () => {
169
178
  expect(event.defaultPrevented).toBe(false);
170
179
  });
171
180
 
181
+ it("does not submit while the thread runs without queue support", async () => {
182
+ h.threadState.isRunning = true;
183
+ const input = await mount();
184
+
185
+ let event!: KeyboardEvent;
186
+ await act(async () => {
187
+ event = fireKeyDown(input, { key: "Enter" });
188
+ });
189
+
190
+ expect(h.sendSpy).not.toHaveBeenCalled();
191
+ expect(event.defaultPrevented).toBe(false);
192
+ });
193
+
194
+ it("submits while running when the thread supports queueing", async () => {
195
+ h.threadState.isRunning = true;
196
+ h.threadState.queue = true;
197
+ const input = await mount();
198
+
199
+ await act(async () => {
200
+ fireKeyDown(input, { key: "Enter" });
201
+ });
202
+
203
+ expect(h.sendSpy).toHaveBeenCalledTimes(1);
204
+ });
205
+
206
+ it("blocks submission when the thread starts running after mount", async () => {
207
+ const input = await mount();
208
+
209
+ h.threadState.isRunning = true;
210
+
211
+ await act(async () => {
212
+ fireKeyDown(input, { key: "Enter" });
213
+ });
214
+
215
+ expect(h.sendSpy).not.toHaveBeenCalled();
216
+ });
217
+
172
218
  it("ignores Enter while isComposing is set", async () => {
173
219
  const input = await mount();
174
220
 
@@ -102,6 +102,8 @@ export const ComposerInput = ({
102
102
  // react-native-web forwards the raw DOM keydown before its own composition guard, so re-check it here (mirrors isEventComposing)
103
103
  if (nativeEvent.isComposing || nativeEvent.keyCode === 229) return;
104
104
  if (nativeEvent.key === "Enter" && !nativeEvent.shiftKey) {
105
+ const threadState = aui.thread.getState();
106
+ if (threadState.isRunning && !threadState.capabilities.queue) return;
105
107
  (e as unknown as Event).preventDefault?.();
106
108
  aui.composer.send();
107
109
  }
@@ -0,0 +1,9 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { ComposerPrimitiveQueue } from "@assistant-ui/core/react";
3
+ import { ComposerQueue } from "./ComposerQueue";
4
+
5
+ describe("ComposerPrimitive.Queue", () => {
6
+ it("re-exports the shared core queue primitive", () => {
7
+ expect(ComposerQueue).toBe(ComposerPrimitiveQueue);
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export { ComposerPrimitiveQueue as ComposerQueue } from "@assistant-ui/core/react";
@@ -0,0 +1,163 @@
1
+ import { act, type ReactElement } from "react";
2
+ import { createRoot, type Root } from "react-dom/client";
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+ import { Text } from "react-native";
5
+ import { ComposerQuote } from "./ComposerQuote";
6
+ import { ComposerQuoteDismiss } from "./ComposerQuoteDismiss";
7
+ import { ComposerQuoteText } from "./ComposerQuoteText";
8
+
9
+ const h = vi.hoisted(() => ({
10
+ quote: undefined as { text: string } | undefined,
11
+ setQuote: vi.fn<(quote: undefined) => void>(),
12
+ }));
13
+
14
+ vi.mock("@assistant-ui/store", async (importOriginal) => {
15
+ const actual = await importOriginal<typeof import("@assistant-ui/store")>();
16
+ return {
17
+ ...actual,
18
+ useAui: () => ({ composer: { setQuote: h.setQuote } }),
19
+ useAuiState: <T,>(selector: (state: { composer: typeof h }) => T) =>
20
+ selector({ composer: h }),
21
+ };
22
+ });
23
+
24
+ (globalThis as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;
25
+
26
+ describe("Composer quote primitives", () => {
27
+ let container: HTMLDivElement;
28
+ let root: Root;
29
+
30
+ beforeEach(() => {
31
+ h.quote = undefined;
32
+ h.setQuote.mockReset();
33
+ container = document.createElement("div");
34
+ document.body.appendChild(container);
35
+ root = createRoot(container);
36
+ });
37
+
38
+ afterEach(async () => {
39
+ await act(async () => {
40
+ root.unmount();
41
+ });
42
+ container.remove();
43
+ });
44
+
45
+ const render = async (element: ReactElement) => {
46
+ await act(async () => {
47
+ root.render(element);
48
+ });
49
+ };
50
+
51
+ const press = async (testID: string) => {
52
+ const element = container.querySelector(`[data-testid="${testID}"]`);
53
+ expect(element).not.toBeNull();
54
+ await act(async () => {
55
+ element!.dispatchEvent(
56
+ new MouseEvent("click", { bubbles: true, cancelable: true }),
57
+ );
58
+ });
59
+ };
60
+
61
+ it("renders quote children only when a quote exists", async () => {
62
+ await render(
63
+ <ComposerQuote>
64
+ <Text testID="quote">quoted</Text>
65
+ </ComposerQuote>,
66
+ );
67
+ expect(container.querySelector('[data-testid="quote"]')).toBeNull();
68
+
69
+ h.quote = { text: "quoted text" };
70
+ await render(
71
+ <ComposerQuote>
72
+ <Text testID="quote">quoted</Text>
73
+ </ComposerQuote>,
74
+ );
75
+ expect(container.querySelector('[data-testid="quote"]')).not.toBeNull();
76
+ });
77
+
78
+ it("renders quote text and allows children to override it", async () => {
79
+ h.quote = { text: "quoted text" };
80
+ await render(<ComposerQuoteText testID="text" />);
81
+ expect(container.querySelector('[data-testid="text"]')?.textContent).toBe(
82
+ "quoted text",
83
+ );
84
+
85
+ await render(
86
+ <ComposerQuoteText testID="text">
87
+ <Text>override</Text>
88
+ </ComposerQuoteText>,
89
+ );
90
+ expect(container.querySelector('[data-testid="text"]')?.textContent).toBe(
91
+ "override",
92
+ );
93
+ });
94
+
95
+ it("renders nothing when there is no quote text, even with children", async () => {
96
+ await render(
97
+ <ComposerQuoteText testID="text">
98
+ <Text>fallback</Text>
99
+ </ComposerQuoteText>,
100
+ );
101
+ expect(container.querySelector('[data-testid="text"]')).toBeNull();
102
+ });
103
+
104
+ it("renders children override when quote text is an empty string", async () => {
105
+ h.quote = { text: "" };
106
+ await render(
107
+ <ComposerQuoteText testID="text">
108
+ <Text>override</Text>
109
+ </ComposerQuoteText>,
110
+ );
111
+ expect(container.querySelector('[data-testid="text"]')?.textContent).toBe(
112
+ "override",
113
+ );
114
+ });
115
+
116
+ it("renders an empty Text when quote text is an empty string and no children are provided", async () => {
117
+ h.quote = { text: "" };
118
+ await render(<ComposerQuoteText testID="text" />);
119
+ expect(container.querySelector('[data-testid="text"]')?.textContent).toBe(
120
+ "",
121
+ );
122
+ });
123
+
124
+ it("clears the quote when dismissed", async () => {
125
+ await render(
126
+ <ComposerQuoteDismiss testID="dismiss">
127
+ <Text>dismiss</Text>
128
+ </ComposerQuoteDismiss>,
129
+ );
130
+ await press("dismiss");
131
+ expect(h.setQuote).toHaveBeenCalledWith(undefined);
132
+ });
133
+
134
+ it("does not clear the quote when dismiss is disabled", async () => {
135
+ await render(
136
+ <ComposerQuoteDismiss testID="dismiss" disabled>
137
+ <Text>dismiss</Text>
138
+ </ComposerQuoteDismiss>,
139
+ );
140
+ await press("dismiss");
141
+ expect(h.setQuote).not.toHaveBeenCalled();
142
+ });
143
+
144
+ it("passes the Pressable press state to function children", async () => {
145
+ await render(
146
+ <ComposerQuoteDismiss testID="dismiss">
147
+ {({ pressed }) => (pressed ? "pressed" : "idle")}
148
+ </ComposerQuoteDismiss>,
149
+ );
150
+ expect(
151
+ container.querySelector('[data-testid="dismiss"]')?.textContent,
152
+ ).toBe("idle");
153
+
154
+ await render(
155
+ <ComposerQuoteDismiss testID="dismiss" testOnly_pressed>
156
+ {({ pressed }) => (pressed ? "pressed" : "idle")}
157
+ </ComposerQuoteDismiss>,
158
+ );
159
+ expect(
160
+ container.querySelector('[data-testid="dismiss"]')?.textContent,
161
+ ).toBe("pressed");
162
+ });
163
+ });
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from "react";
2
+ import { View, type ViewProps } from "react-native";
3
+ import { useAuiState } from "@assistant-ui/store";
4
+
5
+ export type ComposerQuoteProps = ViewProps & {
6
+ children: ReactNode;
7
+ };
8
+
9
+ export const ComposerQuote = ({
10
+ children,
11
+ ...viewProps
12
+ }: ComposerQuoteProps) => {
13
+ const hasQuote = useAuiState((s) => s.composer.quote !== undefined);
14
+ if (!hasQuote) return null;
15
+
16
+ return <View {...viewProps}>{children}</View>;
17
+ };
@@ -0,0 +1,31 @@
1
+ import { useCallback } from "react";
2
+ import { Pressable, type PressableProps } from "react-native";
3
+ import { useAui } from "@assistant-ui/store";
4
+
5
+ export type ComposerQuoteDismissProps = Omit<
6
+ PressableProps,
7
+ "onPress" | "children"
8
+ > & {
9
+ children: PressableProps["children"];
10
+ };
11
+
12
+ export const ComposerQuoteDismiss = ({
13
+ children,
14
+ ...pressableProps
15
+ }: ComposerQuoteDismissProps) => {
16
+ const aui = useAui();
17
+
18
+ const handleDismiss = useCallback(() => {
19
+ aui.composer.setQuote(undefined);
20
+ }, [aui]);
21
+
22
+ return (
23
+ <Pressable
24
+ onPress={handleDismiss}
25
+ accessibilityRole="button"
26
+ {...pressableProps}
27
+ >
28
+ {children}
29
+ </Pressable>
30
+ );
31
+ };
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from "react";
2
+ import { Text, type TextProps } from "react-native";
3
+ import { useAuiState } from "@assistant-ui/store";
4
+
5
+ export type ComposerQuoteTextProps = TextProps & {
6
+ children?: ReactNode;
7
+ };
8
+
9
+ export const ComposerQuoteText = ({
10
+ children,
11
+ ...textProps
12
+ }: ComposerQuoteTextProps) => {
13
+ const text = useAuiState((s) => s.composer.quote?.text);
14
+ if (text === undefined) return null;
15
+
16
+ return <Text {...textProps}>{children ?? text}</Text>;
17
+ };
@@ -113,4 +113,30 @@ describe("ComposerSend", () => {
113
113
 
114
114
  expect(h.send).toHaveBeenCalledTimes(1);
115
115
  });
116
+
117
+ it("passes the Pressable press state to function children", async () => {
118
+ await act(async () => {
119
+ root.render(
120
+ <ComposerSend testID="send">
121
+ {({ pressed }) => (pressed ? "pressed" : "idle")}
122
+ </ComposerSend>,
123
+ );
124
+ });
125
+
126
+ expect(container.querySelector('[data-testid="send"]')?.textContent).toBe(
127
+ "idle",
128
+ );
129
+
130
+ await act(async () => {
131
+ root.render(
132
+ <ComposerSend testID="send" testOnly_pressed>
133
+ {({ pressed }) => (pressed ? "pressed" : "idle")}
134
+ </ComposerSend>,
135
+ );
136
+ });
137
+
138
+ expect(container.querySelector('[data-testid="send"]')?.textContent).toBe(
139
+ "pressed",
140
+ );
141
+ });
116
142
  });
@@ -1,9 +1,8 @@
1
- import type { ReactNode } from "react";
2
1
  import { Pressable, type PressableProps } from "react-native";
3
2
  import { useComposerSend } from "@assistant-ui/core/react";
4
3
 
5
- export type ComposerSendProps = Omit<PressableProps, "onPress"> & {
6
- children: ReactNode;
4
+ export type ComposerSendProps = Omit<PressableProps, "onPress" | "children"> & {
5
+ children: PressableProps["children"];
7
6
  };
8
7
 
9
8
  export const ComposerSend = ({
@@ -17,6 +16,7 @@ export const ComposerSend = ({
17
16
  <Pressable
18
17
  onPress={() => send()}
19
18
  disabled={disabled ?? hookDisabled}
19
+ accessibilityRole="button"
20
20
  {...pressableProps}
21
21
  >
22
22
  {children}
@@ -25,3 +25,16 @@ export {
25
25
  type ComposerAddAttachmentProps as AddAttachmentProps,
26
26
  } from "./composer/ComposerAddAttachment";
27
27
  export { ComposerIf as If } from "./composer/ComposerIf";
28
+ export {
29
+ ComposerQuote as Quote,
30
+ type ComposerQuoteProps as QuoteProps,
31
+ } from "./composer/ComposerQuote";
32
+ export {
33
+ ComposerQuoteText as QuoteText,
34
+ type ComposerQuoteTextProps as QuoteTextProps,
35
+ } from "./composer/ComposerQuoteText";
36
+ export {
37
+ ComposerQuoteDismiss as QuoteDismiss,
38
+ type ComposerQuoteDismissProps as QuoteDismissProps,
39
+ } from "./composer/ComposerQuoteDismiss";
40
+ export { ComposerQueue as Queue } from "./composer/ComposerQueue";
@@ -9,6 +9,9 @@ export type MessageIfProps = {
9
9
  last?: boolean | undefined;
10
10
  };
11
11
 
12
+ /**
13
+ * @deprecated Use `<AuiIf condition={(s) => s.message...} />` instead.
14
+ */
12
15
  export const MessageIf = ({
13
16
  children,
14
17
  user,