@assistant-ui/react 0.5.30 → 0.5.31

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/index.js CHANGED
@@ -113,36 +113,35 @@ function useThreadContext(options) {
113
113
 
114
114
  // src/context/stores/Composer.ts
115
115
 
116
-
117
- // src/context/stores/BaseComposer.ts
118
- var makeBaseComposer = (set) => ({
119
- value: "",
120
- setValue: (value) => {
121
- set({ value });
122
- }
123
- });
124
-
125
- // src/context/stores/Composer.ts
126
- var makeComposerStore = (useThreadMessages, useThreadActions) => {
116
+ var makeComposerStore = (useThreadRuntime) => {
127
117
  const focusListeners = /* @__PURE__ */ new Set();
128
- return _zustand.create.call(void 0, )((set, get, store) => {
118
+ return _zustand.create.call(void 0, )((_, get) => {
119
+ const runtime = useThreadRuntime.getState();
129
120
  return {
130
- ...makeBaseComposer(set, get, store),
131
- get canCancel() {
132
- return useThreadActions.getState().capabilities.cancel;
121
+ get value() {
122
+ return get().text;
123
+ },
124
+ setValue(value) {
125
+ get().setText(value);
126
+ },
127
+ text: runtime.composer.text,
128
+ setText: (value) => {
129
+ useThreadRuntime.getState().composer.setText(value);
133
130
  },
131
+ canCancel: runtime.capabilities.cancel,
134
132
  isEditing: true,
135
133
  send: () => {
136
- const { setValue, value } = get();
137
- setValue("");
138
- useThreadActions.getState().append({
139
- parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _6 => _6.getState, 'call', _7 => _7(), 'access', _8 => _8.at, 'call', _9 => _9(-1), 'optionalAccess', _10 => _10.id]), () => ( null)),
134
+ const runtime2 = useThreadRuntime.getState();
135
+ const text = runtime2.composer.text;
136
+ runtime2.composer.setText("");
137
+ runtime2.append({
138
+ parentId: _nullishCoalesce(_optionalChain([runtime2, 'access', _6 => _6.messages, 'access', _7 => _7.at, 'call', _8 => _8(-1), 'optionalAccess', _9 => _9.id]), () => ( null)),
140
139
  role: "user",
141
- content: [{ type: "text", text: value }]
140
+ content: [{ type: "text", text }]
142
141
  });
143
142
  },
144
143
  cancel: () => {
145
- useThreadActions.getState().cancelRun();
144
+ useThreadRuntime.getState().cancelRun();
146
145
  },
147
146
  focus: () => {
148
147
  for (const listener of focusListeners) {
@@ -163,14 +162,10 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
163
162
 
164
163
  var getThreadStateFromRuntime = (runtime) => {
165
164
  const lastMessage = runtime.messages.at(-1);
166
- if (_optionalChain([lastMessage, 'optionalAccess', _11 => _11.role]) !== "assistant")
167
- return Object.freeze({
168
- isDisabled: runtime.isDisabled,
169
- isRunning: false
170
- });
171
165
  return Object.freeze({
166
+ capabilities: runtime.capabilities,
172
167
  isDisabled: runtime.isDisabled,
173
- isRunning: lastMessage.status.type === "running"
168
+ isRunning: _optionalChain([lastMessage, 'optionalAccess', _10 => _10.role]) !== "assistant" ? false : lastMessage.status.type === "running"
174
169
  });
175
170
  };
176
171
  var makeThreadStore = (runtimeRef) => {
@@ -203,9 +198,6 @@ var makeThreadViewportStore = () => {
203
198
  var makeThreadActionStore = (runtimeStore) => {
204
199
  return _zustand.create.call(void 0,
205
200
  () => Object.freeze({
206
- get capabilities() {
207
- return runtimeStore.getState().capabilities;
208
- },
209
201
  getBranches: (messageId) => runtimeStore.getState().getBranches(messageId),
210
202
  switchToBranch: (branchId) => runtimeStore.getState().switchToBranch(branchId),
211
203
  startRun: (parentId) => runtimeStore.getState().startRun(parentId),
@@ -258,7 +250,7 @@ var ThreadProvider = ({
258
250
  const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);
259
251
  const useThreadActions = makeThreadActionStore(useThreadRuntime);
260
252
  const useViewport = makeThreadViewportStore();
261
- const useComposer = makeComposerStore(useThreadMessages, useThreadActions);
253
+ const useComposer = makeComposerStore(useThreadRuntime);
262
254
  return {
263
255
  useThread,
264
256
  useThreadRuntime,
@@ -274,15 +266,23 @@ var ThreadProvider = ({
274
266
  const onThreadUpdate = () => {
275
267
  const oldState = context.useThread.getState();
276
268
  const state = getThreadStateFromRuntime(thread);
277
- if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning) {
269
+ if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || // TODO ensure capabilities is memoized
270
+ oldState.capabilities !== state.capabilities) {
278
271
  context.useThread.setState(
279
- getThreadStateFromRuntime(thread),
272
+ state,
280
273
  true
281
274
  );
282
275
  }
283
276
  if (thread.messages !== context.useThreadMessages.getState()) {
284
277
  context.useThreadMessages.setState(thread.messages, true);
285
278
  }
279
+ const composerState = context.useComposer.getState();
280
+ if (thread.composer.text !== composerState.text || state.capabilities.cancel !== composerState.canCancel) {
281
+ context.useComposer.setState({
282
+ text: thread.composer.text,
283
+ canCancel: state.capabilities.cancel
284
+ });
285
+ }
286
286
  };
287
287
  onThreadUpdate();
288
288
  return thread.subscribe(onThreadUpdate);
@@ -354,7 +354,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
354
354
  var MessageContext = _react.createContext.call(void 0, null);
355
355
  function useMessageContext(options) {
356
356
  const context = _react.useContext.call(void 0, MessageContext);
357
- if (!_optionalChain([options, 'optionalAccess', _12 => _12.optional]) && !context)
357
+ if (!_optionalChain([options, 'optionalAccess', _11 => _11.optional]) && !context)
358
358
  throw new Error(
359
359
  "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
360
360
  );
@@ -381,7 +381,7 @@ var ContentPartContext = _react.createContext.call(void 0,
381
381
  );
382
382
  function useContentPartContext(options) {
383
383
  const context = _react.useContext.call(void 0, ContentPartContext);
384
- if (!_optionalChain([options, 'optionalAccess', _13 => _13.optional]) && !context)
384
+ if (!_optionalChain([options, 'optionalAccess', _12 => _12.optional]) && !context)
385
385
  throw new Error(
386
386
  "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
387
387
  );
@@ -393,13 +393,13 @@ function useContentPartContext(options) {
393
393
  var toAppendMessage = (useThreadMessages, message) => {
394
394
  if (typeof message === "string") {
395
395
  return {
396
- parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _14 => _14.getState, 'call', _15 => _15(), 'access', _16 => _16.at, 'call', _17 => _17(-1), 'optionalAccess', _18 => _18.id]), () => ( null)),
396
+ parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _13 => _13.getState, 'call', _14 => _14(), 'access', _15 => _15.at, 'call', _16 => _16(-1), 'optionalAccess', _17 => _17.id]), () => ( null)),
397
397
  role: "user",
398
398
  content: [{ type: "text", text: message }]
399
399
  };
400
400
  }
401
401
  return {
402
- parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _19 => _19.getState, 'call', _20 => _20(), 'access', _21 => _21.at, 'call', _22 => _22(-1), 'optionalAccess', _23 => _23.id]))), () => ( null)),
402
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _18 => _18.getState, 'call', _19 => _19(), 'access', _20 => _20.at, 'call', _21 => _21(-1), 'optionalAccess', _22 => _22.id]))), () => ( null)),
403
403
  role: _nullishCoalesce(message.role, () => ( "user")),
404
404
  content: message.content
405
405
  };
@@ -451,7 +451,7 @@ var useAssistantTool = (tool) => {
451
451
  const unsub2 = render ? setToolUI(toolName, render) : void 0;
452
452
  return () => {
453
453
  unsub1();
454
- _optionalChain([unsub2, 'optionalCall', _24 => _24()]);
454
+ _optionalChain([unsub2, 'optionalCall', _23 => _23()]);
455
455
  };
456
456
  }, [registerModelConfigProvider, setToolUI, tool]);
457
457
  };
@@ -552,7 +552,7 @@ var useActionBarCopy = ({
552
552
  const callback = _react.useCallback.call(void 0, () => {
553
553
  const { message } = useMessage.getState();
554
554
  const { setIsCopied } = useMessageUtils.getState();
555
- const { isEditing, value: composerValue } = useEditComposer.getState();
555
+ const { isEditing, text: composerValue } = useEditComposer.getState();
556
556
  const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
557
557
  navigator.clipboard.writeText(valueToCopy).then(() => {
558
558
  setIsCopied(true);
@@ -680,7 +680,7 @@ var useComposerSend = () => {
680
680
  const { useComposer } = useComposerContext();
681
681
  const disabled = useCombinedStore(
682
682
  [useThread, useComposer],
683
- (t, c) => t.isRunning || !c.isEditing || c.value.length === 0
683
+ (t, c) => t.isRunning || !c.isEditing || c.text.length === 0
684
684
  );
685
685
  const callback = _react.useCallback.call(void 0, () => {
686
686
  const composerState = useComposer.getState();
@@ -799,9 +799,9 @@ var useThreadSuggestion = ({
799
799
  const composer = useComposer.getState();
800
800
  if (autoSend && !thread.isRunning) {
801
801
  append(prompt);
802
- composer.setValue("");
802
+ composer.setText("");
803
803
  } else {
804
- composer.setValue(prompt);
804
+ composer.setText(prompt);
805
805
  }
806
806
  }, [useThread, useComposer, autoSend, append, prompt]);
807
807
  if (disabled) return null;
@@ -888,7 +888,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
888
888
  ...primitiveProps,
889
889
  ref: forwardedRef,
890
890
  onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
891
- _optionalChain([callback, 'optionalCall', _25 => _25()]);
891
+ _optionalChain([callback, 'optionalCall', _24 => _24()]);
892
892
  })
893
893
  }
894
894
  );
@@ -1176,7 +1176,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
1176
1176
  }
1177
1177
  }
1178
1178
  const status = toContentPartStatus(message, partIndex, part);
1179
- const currentState = _optionalChain([useContentPart, 'optionalAccess', _26 => _26.getState, 'call', _27 => _27()]);
1179
+ const currentState = _optionalChain([useContentPart, 'optionalAccess', _25 => _25.getState, 'call', _26 => _26()]);
1180
1180
  if (currentState && currentState.part === part && currentState.status === status)
1181
1181
  return null;
1182
1182
  return Object.freeze({ part, status });
@@ -1252,7 +1252,7 @@ var withSmoothContextProvider = (Component) => {
1252
1252
  };
1253
1253
  function useSmoothContext(options) {
1254
1254
  const context = _react.useContext.call(void 0, SmoothContext);
1255
- if (!_optionalChain([options, 'optionalAccess', _28 => _28.optional]) && !context)
1255
+ if (!_optionalChain([options, 'optionalAccess', _27 => _27.optional]) && !context)
1256
1256
  throw new Error(
1257
1257
  "This component must be used within a SmoothContextProvider."
1258
1258
  );
@@ -1323,7 +1323,7 @@ var useSmooth = (state, smooth = false) => {
1323
1323
  const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
1324
1324
  const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
1325
1325
  setDisplayedText(text2);
1326
- _optionalChain([useSmoothStatus2, 'optionalAccess', _29 => _29.setState, 'call', _30 => _30(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
1326
+ _optionalChain([useSmoothStatus2, 'optionalAccess', _28 => _28.setState, 'call', _29 => _29(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
1327
1327
  });
1328
1328
  const [animatorRef] = _react.useState.call(void 0,
1329
1329
  new TextStreamAnimator(text, setText)
@@ -1467,7 +1467,7 @@ var MessageContentPartImpl = ({
1467
1467
  };
1468
1468
  var MessageContentPart = _react.memo.call(void 0,
1469
1469
  MessageContentPartImpl,
1470
- (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _31 => _31.components, 'optionalAccess', _32 => _32.Text]) === _optionalChain([next, 'access', _33 => _33.components, 'optionalAccess', _34 => _34.Text]) && _optionalChain([prev, 'access', _35 => _35.components, 'optionalAccess', _36 => _36.Image]) === _optionalChain([next, 'access', _37 => _37.components, 'optionalAccess', _38 => _38.Image]) && _optionalChain([prev, 'access', _39 => _39.components, 'optionalAccess', _40 => _40.UI]) === _optionalChain([next, 'access', _41 => _41.components, 'optionalAccess', _42 => _42.UI]) && _optionalChain([prev, 'access', _43 => _43.components, 'optionalAccess', _44 => _44.tools]) === _optionalChain([next, 'access', _45 => _45.components, 'optionalAccess', _46 => _46.tools])
1470
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _30 => _30.components, 'optionalAccess', _31 => _31.Text]) === _optionalChain([next, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.Text]) && _optionalChain([prev, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.Image]) === _optionalChain([next, 'access', _36 => _36.components, 'optionalAccess', _37 => _37.Image]) && _optionalChain([prev, 'access', _38 => _38.components, 'optionalAccess', _39 => _39.UI]) === _optionalChain([next, 'access', _40 => _40.components, 'optionalAccess', _41 => _41.UI]) && _optionalChain([prev, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.tools]) === _optionalChain([next, 'access', _44 => _44.components, 'optionalAccess', _45 => _45.tools])
1471
1471
  );
1472
1472
  var MessagePrimitiveContent = ({
1473
1473
  components
@@ -1562,7 +1562,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
1562
1562
  const { useComposer, type } = useComposerContext();
1563
1563
  const value = useComposer((c) => {
1564
1564
  if (!c.isEditing) return "";
1565
- return c.value;
1565
+ return c.text;
1566
1566
  });
1567
1567
  const Component = asChild ? _reactslot.Slot : _reacttextareaautosize2.default;
1568
1568
  const isDisabled = _nullishCoalesce(_nullishCoalesce(useThread((t) => t.isDisabled), () => ( disabledProp)), () => ( false));
@@ -1582,7 +1582,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
1582
1582
  const { isRunning } = useThread.getState();
1583
1583
  if (!isRunning) {
1584
1584
  e.preventDefault();
1585
- _optionalChain([textareaRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.closest, 'call', _49 => _49("form"), 'optionalAccess', _50 => _50.requestSubmit, 'call', _51 => _51()]);
1585
+ _optionalChain([textareaRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.closest, 'call', _48 => _48("form"), 'optionalAccess', _49 => _49.requestSubmit, 'call', _50 => _50()]);
1586
1586
  }
1587
1587
  }
1588
1588
  };
@@ -1613,7 +1613,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
1613
1613
  onChange: _primitive.composeEventHandlers.call(void 0, onChange, (e) => {
1614
1614
  const composerState = useComposer.getState();
1615
1615
  if (!composerState.isEditing) return;
1616
- return composerState.setValue(e.target.value);
1616
+ return composerState.setText(e.target.value);
1617
1617
  }),
1618
1618
  onKeyDown: _primitive.composeEventHandlers.call(void 0, onKeyDown, handleKeyPress)
1619
1619
  }
@@ -1628,7 +1628,7 @@ ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1628
1628
 
1629
1629
  var ComposerPrimitiveSend = _react.forwardRef.call(void 0, ({ disabled, ...rest }, ref) => {
1630
1630
  const { useComposer } = useComposerContext();
1631
- const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1631
+ const hasValue = useComposer((c) => c.isEditing && c.text.length > 0);
1632
1632
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1633
1633
  _reactprimitive.Primitive.button,
1634
1634
  {
@@ -1842,18 +1842,27 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1842
1842
  var makeEditComposerStore = ({
1843
1843
  onEdit,
1844
1844
  onSend
1845
- }) => _zustand.create.call(void 0, )((set, get, store) => ({
1846
- ...makeBaseComposer(set, get, store),
1845
+ }) => _zustand.create.call(void 0, )((set, get) => ({
1846
+ get value() {
1847
+ return get().text;
1848
+ },
1849
+ setValue(value) {
1850
+ get().setText(value);
1851
+ },
1852
+ text: "",
1853
+ setText: (text) => {
1854
+ set({ text });
1855
+ },
1847
1856
  canCancel: false,
1848
1857
  isEditing: false,
1849
1858
  edit: () => {
1850
- const value = onEdit();
1851
- set({ isEditing: true, canCancel: true, value });
1859
+ const text = onEdit();
1860
+ set({ isEditing: true, canCancel: true, text });
1852
1861
  },
1853
1862
  send: () => {
1854
- const value = get().value;
1863
+ const text = get().text;
1855
1864
  set({ isEditing: false, canCancel: false });
1856
- onSend(value);
1865
+ onSend(text);
1857
1866
  },
1858
1867
  cancel: () => {
1859
1868
  set({ isEditing: false, canCancel: false });
@@ -1876,15 +1885,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
1876
1885
  // src/context/providers/MessageProvider.tsx
1877
1886
 
1878
1887
  var getIsLast = (messages, message) => {
1879
- return _optionalChain([messages, 'access', _52 => _52[messages.length - 1], 'optionalAccess', _53 => _53.id]) === message.id;
1888
+ return _optionalChain([messages, 'access', _51 => _51[messages.length - 1], 'optionalAccess', _52 => _52.id]) === message.id;
1880
1889
  };
1881
1890
  var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
1882
- const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _54 => _54[messageIndex - 1], 'optionalAccess', _55 => _55.id]), () => ( null));
1891
+ const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _53 => _53[messageIndex - 1], 'optionalAccess', _54 => _54.id]), () => ( null));
1883
1892
  const message = messages[messageIndex];
1884
1893
  if (!message) return null;
1885
1894
  const isLast = getIsLast(messages, message);
1886
1895
  const branches = getBranches(message.id);
1887
- const currentState = _optionalChain([useMessage, 'optionalAccess', _56 => _56.getState, 'call', _57 => _57()]);
1896
+ const currentState = _optionalChain([useMessage, 'optionalAccess', _55 => _55.getState, 'call', _56 => _56()]);
1888
1897
  if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
1889
1898
  return null;
1890
1899
  return Object.freeze({
@@ -2011,7 +2020,7 @@ var ThreadPrimitiveMessagesImpl = ({
2011
2020
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
2012
2021
  var ThreadPrimitiveMessages = _react.memo.call(void 0,
2013
2022
  ThreadPrimitiveMessagesImpl,
2014
- (prev, next) => _optionalChain([prev, 'access', _58 => _58.components, 'optionalAccess', _59 => _59.Message]) === _optionalChain([next, 'access', _60 => _60.components, 'optionalAccess', _61 => _61.Message]) && _optionalChain([prev, 'access', _62 => _62.components, 'optionalAccess', _63 => _63.UserMessage]) === _optionalChain([next, 'access', _64 => _64.components, 'optionalAccess', _65 => _65.UserMessage]) && _optionalChain([prev, 'access', _66 => _66.components, 'optionalAccess', _67 => _67.EditComposer]) === _optionalChain([next, 'access', _68 => _68.components, 'optionalAccess', _69 => _69.EditComposer]) && _optionalChain([prev, 'access', _70 => _70.components, 'optionalAccess', _71 => _71.AssistantMessage]) === _optionalChain([next, 'access', _72 => _72.components, 'optionalAccess', _73 => _73.AssistantMessage]) && _optionalChain([prev, 'access', _74 => _74.components, 'optionalAccess', _75 => _75.SystemMessage]) === _optionalChain([next, 'access', _76 => _76.components, 'optionalAccess', _77 => _77.SystemMessage])
2023
+ (prev, next) => _optionalChain([prev, 'access', _57 => _57.components, 'optionalAccess', _58 => _58.Message]) === _optionalChain([next, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.Message]) && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.UserMessage]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.UserMessage]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.EditComposer]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.EditComposer]) && _optionalChain([prev, 'access', _69 => _69.components, 'optionalAccess', _70 => _70.AssistantMessage]) === _optionalChain([next, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.AssistantMessage]) && _optionalChain([prev, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.SystemMessage]) === _optionalChain([next, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.SystemMessage])
2015
2024
  );
2016
2025
 
2017
2026
  // src/primitives/thread/ThreadScrollToBottom.tsx
@@ -2143,7 +2152,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
2143
2152
  parentOrRoot.children = parentOrRoot.children.filter(
2144
2153
  (m) => m !== child.current.id
2145
2154
  );
2146
- if (_optionalChain([child, 'access', _78 => _78.prev, 'optionalAccess', _79 => _79.next]) === child) {
2155
+ if (_optionalChain([child, 'access', _77 => _77.prev, 'optionalAccess', _78 => _78.next]) === child) {
2147
2156
  const fallbackId = child.prev.children.at(-1);
2148
2157
  const fallback = fallbackId ? this.messages.get(fallbackId) : null;
2149
2158
  if (fallback === void 0) {
@@ -2173,7 +2182,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
2173
2182
  }
2174
2183
  }
2175
2184
  getMessages() {
2176
- const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _80 => _80.head, 'optionalAccess', _81 => _81.level]), () => ( 0)));
2185
+ const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _79 => _79.head, 'optionalAccess', _80 => _80.level]), () => ( 0)));
2177
2186
  for (let current = this.head; current; current = current.prev) {
2178
2187
  messages[current.level] = current.current;
2179
2188
  }
@@ -2211,7 +2220,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
2211
2220
  "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
2212
2221
  );
2213
2222
  return {
2214
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _82 => _82.prev, 'optionalAccess', _83 => _83.current, 'access', _84 => _84.id]), () => ( null)),
2223
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _81 => _81.prev, 'optionalAccess', _82 => _82.current, 'access', _83 => _83.id]), () => ( null)),
2215
2224
  message: message.current
2216
2225
  };
2217
2226
  }
@@ -2296,11 +2305,11 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
2296
2305
  for (const [, message] of this.messages) {
2297
2306
  exportItems.push({
2298
2307
  message: message.current,
2299
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _85 => _85.prev, 'optionalAccess', _86 => _86.current, 'access', _87 => _87.id]), () => ( null))
2308
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _84 => _84.prev, 'optionalAccess', _85 => _85.current, 'access', _86 => _86.id]), () => ( null))
2300
2309
  });
2301
2310
  }
2302
2311
  return {
2303
- headId: _nullishCoalesce(_optionalChain([this, 'access', _88 => _88.head, 'optionalAccess', _89 => _89.current, 'access', _90 => _90.id]), () => ( null)),
2312
+ headId: _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.head, 'optionalAccess', _88 => _88.current, 'access', _89 => _89.id]), () => ( null)),
2304
2313
  messages: exportItems
2305
2314
  };
2306
2315
  }
@@ -2308,7 +2317,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
2308
2317
  for (const { message, parentId } of messages) {
2309
2318
  this.addOrUpdateMessage(parentId, message);
2310
2319
  }
2311
- this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _91 => _91.at, 'call', _92 => _92(-1), 'optionalAccess', _93 => _93.message, 'access', _94 => _94.id]))), () => ( null)));
2320
+ this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _90 => _90.at, 'call', _91 => _91(-1), 'optionalAccess', _92 => _92.message, 'access', _93 => _93.id]))), () => ( null)));
2312
2321
  }
2313
2322
  }, _class4);
2314
2323
 
@@ -2471,7 +2480,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2471
2480
  });
2472
2481
  if (mergeRoundtrips) {
2473
2482
  const previousMessage = messages[messages.length - 1];
2474
- if (_optionalChain([previousMessage, 'optionalAccess', _95 => _95.role]) === "assistant") {
2483
+ if (_optionalChain([previousMessage, 'optionalAccess', _94 => _94.role]) === "assistant") {
2475
2484
  previousMessage.content.push(...newContent);
2476
2485
  break;
2477
2486
  }
@@ -2484,7 +2493,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
2484
2493
  }
2485
2494
  case "tool": {
2486
2495
  const previousMessage = messages[messages.length - 1];
2487
- if (_optionalChain([previousMessage, 'optionalAccess', _96 => _96.role]) !== "assistant")
2496
+ if (_optionalChain([previousMessage, 'optionalAccess', _95 => _95.role]) !== "assistant")
2488
2497
  throw new Error(
2489
2498
  "A tool message must be preceded by an assistant message."
2490
2499
  );
@@ -2705,7 +2714,7 @@ var useEdgeRuntime = ({
2705
2714
  };
2706
2715
 
2707
2716
  // src/runtimes/local/shouldContinue.tsx
2708
- var shouldContinue = (result) => _optionalChain([result, 'access', _97 => _97.status, 'optionalAccess', _98 => _98.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
2717
+ var shouldContinue = (result) => _optionalChain([result, 'access', _96 => _96.status, 'optionalAccess', _97 => _97.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
2709
2718
 
2710
2719
  // src/runtimes/local/LocalThreadRuntime.tsx
2711
2720
  var CAPABILITIES = Object.freeze({
@@ -2716,11 +2725,11 @@ var CAPABILITIES = Object.freeze({
2716
2725
  copy: true
2717
2726
  });
2718
2727
  var LocalThreadRuntime = (_class5 = class {
2719
- constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);
2728
+ constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);
2720
2729
  this.configProvider = configProvider;
2721
2730
  this.adapter = adapter;
2722
2731
  this.options = options;
2723
- if (_optionalChain([options, 'optionalAccess', _99 => _99.initialMessages])) {
2732
+ if (_optionalChain([options, 'optionalAccess', _98 => _98.initialMessages])) {
2724
2733
  let parentId = null;
2725
2734
  const messages = fromCoreMessages(options.initialMessages);
2726
2735
  for (const message of messages) {
@@ -2737,6 +2746,13 @@ var LocalThreadRuntime = (_class5 = class {
2737
2746
  get messages() {
2738
2747
  return this.repository.getMessages();
2739
2748
  }
2749
+ __init16() {this.composer = {
2750
+ text: "",
2751
+ setText: (value) => {
2752
+ this.composer.text = value;
2753
+ this.notifySubscribers();
2754
+ }
2755
+ }}
2740
2756
  getBranches(messageId) {
2741
2757
  return this.repository.getBranches(messageId);
2742
2758
  }
@@ -2775,7 +2791,7 @@ var LocalThreadRuntime = (_class5 = class {
2775
2791
  }
2776
2792
  async performRoundtrip(parentId, message) {
2777
2793
  const messages = this.repository.getMessages();
2778
- _optionalChain([this, 'access', _100 => _100.abortController, 'optionalAccess', _101 => _101.abort, 'call', _102 => _102()]);
2794
+ _optionalChain([this, 'access', _99 => _99.abortController, 'optionalAccess', _100 => _100.abort, 'call', _101 => _101()]);
2779
2795
  this.abortController = new AbortController();
2780
2796
  const initialContent = message.content;
2781
2797
  const initialRoundtrips = message.roundtrips;
@@ -2784,13 +2800,13 @@ var LocalThreadRuntime = (_class5 = class {
2784
2800
  ...message,
2785
2801
  ...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
2786
2802
  status: _nullishCoalesce(m.status, () => ( message.status)),
2787
- ..._optionalChain([m, 'access', _103 => _103.roundtrips, 'optionalAccess', _104 => _104.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
2803
+ ..._optionalChain([m, 'access', _102 => _102.roundtrips, 'optionalAccess', _103 => _103.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
2788
2804
  };
2789
2805
  this.repository.addOrUpdateMessage(parentId, message);
2790
2806
  this.notifySubscribers();
2791
2807
  };
2792
- const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _105 => _105.options, 'optionalAccess', _106 => _106.maxToolRoundtrips]), () => ( 1));
2793
- const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _107 => _107.roundtrips, 'optionalAccess', _108 => _108.length]), () => ( 0));
2808
+ const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.maxToolRoundtrips]), () => ( 1));
2809
+ const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _106 => _106.roundtrips, 'optionalAccess', _107 => _107.length]), () => ( 0));
2794
2810
  if (toolRoundtrips > maxToolRoundtrips) {
2795
2811
  updateMessage({
2796
2812
  status: {
@@ -2930,8 +2946,8 @@ var getExternalStoreMessage = (message) => {
2930
2946
  };
2931
2947
 
2932
2948
  // src/runtimes/external-store/ThreadMessageConverter.ts
2933
- var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
2934
- __init16() {this.cache = /* @__PURE__ */ new WeakMap()}
2949
+ var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init17.call(this); }
2950
+ __init17() {this.cache = /* @__PURE__ */ new WeakMap()}
2935
2951
  convertMessages(messages, converter, keyMapper = (key) => key) {
2936
2952
  return messages.map((m, idx) => {
2937
2953
  const key = keyMapper(m);
@@ -3022,40 +3038,57 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
3022
3038
 
3023
3039
  // src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
3024
3040
  var hasUpcomingMessage = (isRunning, messages) => {
3025
- return isRunning && _optionalChain([messages, 'access', _109 => _109[messages.length - 1], 'optionalAccess', _110 => _110.role]) !== "assistant";
3041
+ return isRunning && _optionalChain([messages, 'access', _108 => _108[messages.length - 1], 'optionalAccess', _109 => _109.role]) !== "assistant";
3026
3042
  };
3027
3043
  var ExternalStoreThreadRuntime = (_class7 = class {
3028
- __init17() {this._subscriptions = /* @__PURE__ */ new Set()}
3029
- __init18() {this.repository = new MessageRepository()}
3030
- __init19() {this.assistantOptimisticId = null}
3044
+ __init18() {this._subscriptions = /* @__PURE__ */ new Set()}
3045
+ __init19() {this.repository = new MessageRepository()}
3046
+ __init20() {this.assistantOptimisticId = null}
3047
+ __init21() {this._capabilities = {
3048
+ switchToBranch: false,
3049
+ edit: false,
3050
+ reload: false,
3051
+ cancel: false,
3052
+ copy: false
3053
+ }}
3031
3054
  get capabilities() {
3032
- return {
3033
- switchToBranch: this._store.setMessages !== void 0,
3034
- edit: this._store.onEdit !== void 0,
3035
- reload: this._store.onReload !== void 0,
3036
- cancel: this._store.onCancel !== void 0,
3037
- copy: this._store.onCopy !== null
3038
- };
3055
+ return this._capabilities;
3039
3056
  }
3040
- __init20() {this.messages = []}
3041
- __init21() {this.isDisabled = false}
3042
- __init22() {this.converter = new ThreadMessageConverter()}
3057
+ __init22() {this.messages = []}
3058
+ __init23() {this.isDisabled = false}
3059
+ __init24() {this.converter = new ThreadMessageConverter()}
3043
3060
 
3044
- constructor(store) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);
3061
+ __init25() {this.composer = {
3062
+ text: "",
3063
+ setText: (value) => {
3064
+ this.composer.text = value;
3065
+ this.notifySubscribers();
3066
+ }
3067
+ }}
3068
+ constructor(store) {;_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);_class7.prototype.__init26.call(this);
3045
3069
  this.store = store;
3046
3070
  }
3047
3071
  set store(store) {
3072
+ if (this._store === store) return;
3073
+ const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
3074
+ this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
3048
3075
  const oldStore = this._store;
3076
+ this._store = store;
3077
+ this._capabilities = {
3078
+ switchToBranch: this._store.setMessages !== void 0,
3079
+ edit: this._store.onEdit !== void 0,
3080
+ reload: this._store.onReload !== void 0,
3081
+ cancel: this._store.onCancel !== void 0,
3082
+ copy: this._store.onCopy !== null
3083
+ };
3049
3084
  if (oldStore) {
3050
3085
  if (oldStore.convertMessage !== store.convertMessage) {
3051
3086
  this.converter = new ThreadMessageConverter();
3052
- } else if (oldStore.isDisabled === store.isDisabled && oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
3087
+ } else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
3088
+ this.notifySubscribers();
3053
3089
  return;
3054
3090
  }
3055
3091
  }
3056
- this._store = store;
3057
- const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
3058
- const isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
3059
3092
  const convertCallback = (cache, m, idx) => {
3060
3093
  if (!store.convertMessage) return m;
3061
3094
  const isLast = idx === store.messages.length - 1;
@@ -3077,7 +3110,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3077
3110
  for (let i = 0; i < messages.length; i++) {
3078
3111
  const message = messages[i];
3079
3112
  const parent = messages[i - 1];
3080
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _114 => _114.id]), () => ( null)), message);
3113
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _113 => _113.id]), () => ( null)), message);
3081
3114
  }
3082
3115
  if (this.assistantOptimisticId) {
3083
3116
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -3085,7 +3118,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3085
3118
  }
3086
3119
  if (hasUpcomingMessage(isRunning, messages)) {
3087
3120
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
3088
- _nullishCoalesce(_optionalChain([messages, 'access', _115 => _115.at, 'call', _116 => _116(-1), 'optionalAccess', _117 => _117.id]), () => ( null)),
3121
+ _nullishCoalesce(_optionalChain([messages, 'access', _114 => _114.at, 'call', _115 => _115(-1), 'optionalAccess', _116 => _116.id]), () => ( null)),
3089
3122
  {
3090
3123
  role: "assistant",
3091
3124
  content: []
@@ -3093,10 +3126,12 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3093
3126
  );
3094
3127
  }
3095
3128
  this.repository.resetHead(
3096
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _118 => _118.at, 'call', _119 => _119(-1), 'optionalAccess', _120 => _120.id]))), () => ( null))
3129
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _117 => _117.at, 'call', _118 => _118(-1), 'optionalAccess', _119 => _119.id]))), () => ( null))
3097
3130
  );
3098
3131
  this.messages = this.repository.getMessages();
3099
- this.isDisabled = isDisabled;
3132
+ this.notifySubscribers();
3133
+ }
3134
+ notifySubscribers() {
3100
3135
  for (const callback of this._subscriptions) callback();
3101
3136
  }
3102
3137
  getBranches(messageId) {
@@ -3109,7 +3144,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3109
3144
  this.updateMessages(this.repository.getMessages());
3110
3145
  }
3111
3146
  async append(message) {
3112
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _121 => _121.messages, 'access', _122 => _122.at, 'call', _123 => _123(-1), 'optionalAccess', _124 => _124.id]), () => ( null)))) {
3147
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _120 => _120.messages, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]), () => ( null)))) {
3113
3148
  if (!this._store.onEdit)
3114
3149
  throw new Error("Runtime does not support editing messages.");
3115
3150
  await this._store.onEdit(message);
@@ -3139,8 +3174,8 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3139
3174
  this._subscriptions.add(callback);
3140
3175
  return () => this._subscriptions.delete(callback);
3141
3176
  }
3142
- __init23() {this.updateMessages = (messages) => {
3143
- _optionalChain([this, 'access', _125 => _125._store, 'access', _126 => _126.setMessages, 'optionalCall', _127 => _127(
3177
+ __init26() {this.updateMessages = (messages) => {
3178
+ _optionalChain([this, 'access', _124 => _124._store, 'access', _125 => _125.setMessages, 'optionalCall', _126 => _126(
3144
3179
  messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
3145
3180
  )]);
3146
3181
  }}
@@ -3153,9 +3188,9 @@ var ExternalStoreThreadRuntime = (_class7 = class {
3153
3188
 
3154
3189
  // src/runtimes/external-store/ExternalStoreRuntime.tsx
3155
3190
  var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
3156
- __init24() {this._proxyConfigProvider = new ProxyConfigProvider()}
3191
+ __init27() {this._proxyConfigProvider = new ProxyConfigProvider()}
3157
3192
  constructor(store) {
3158
- super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init24.call(this);;
3193
+ super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init27.call(this);;
3159
3194
  }
3160
3195
  set store(store) {
3161
3196
  this.thread.store = store;
@@ -3205,7 +3240,7 @@ var ThreadConfigProvider = ({
3205
3240
  }) => {
3206
3241
  const assistant = useAssistantContext({ optional: true });
3207
3242
  const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
3208
- if (!_optionalChain([config, 'optionalAccess', _128 => _128.runtime])) return configProvider;
3243
+ if (!_optionalChain([config, 'optionalAccess', _127 => _127.runtime])) return configProvider;
3209
3244
  if (assistant) {
3210
3245
  throw new Error(
3211
3246
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -3221,14 +3256,14 @@ var _lucidereact = require('lucide-react');
3221
3256
 
3222
3257
  var useAllowCopy = () => {
3223
3258
  const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
3224
- const { useThreadActions } = useThreadContext();
3225
- const copySupported = useThreadActions((t) => t.capabilities.copy);
3259
+ const { useThread } = useThreadContext();
3260
+ const copySupported = useThread((t) => t.capabilities.copy);
3226
3261
  return copySupported && allowCopy;
3227
3262
  };
3228
3263
  var useAllowReload = () => {
3229
3264
  const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
3230
- const { useThreadActions } = useThreadContext();
3231
- const reloadSupported = useThreadActions((t) => t.capabilities.reload);
3265
+ const { useThread } = useThreadContext();
3266
+ const reloadSupported = useThread((t) => t.capabilities.reload);
3232
3267
  return reloadSupported && allowReload;
3233
3268
  };
3234
3269
  var AssistantActionBar = () => {
@@ -3297,8 +3332,8 @@ var assistant_action_bar_default = Object.assign(
3297
3332
 
3298
3333
  var useAllowBranchPicker = () => {
3299
3334
  const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
3300
- const { useThreadActions } = useThreadContext();
3301
- const branchPickerSupported = useThreadActions((t) => t.capabilities.edit);
3335
+ const { useThread } = useThreadContext();
3336
+ const branchPickerSupported = useThread((t) => t.capabilities.edit);
3302
3337
  return branchPickerSupported && allowBranchPicker;
3303
3338
  };
3304
3339
  var BranchPicker = () => {
@@ -3421,7 +3456,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
3421
3456
  {
3422
3457
  components: {
3423
3458
  ...componentsProp,
3424
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _129 => _129.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3459
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _128 => _128.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3425
3460
  }
3426
3461
  }
3427
3462
  ) });
@@ -3458,6 +3493,8 @@ var CircleStopIcon = () => {
3458
3493
  xmlns: "http://www.w3.org/2000/svg",
3459
3494
  viewBox: "0 0 16 16",
3460
3495
  fill: "currentColor",
3496
+ width: "16",
3497
+ height: "16",
3461
3498
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
3462
3499
  }
3463
3500
  );
@@ -3494,8 +3531,8 @@ var ComposerInput = _react.forwardRef.call(void 0,
3494
3531
  );
3495
3532
  ComposerInput.displayName = "ComposerInput";
3496
3533
  var useAllowCancel = () => {
3497
- const { useThreadActions } = useThreadContext();
3498
- const cancelSupported = useThreadActions((t) => t.capabilities.cancel);
3534
+ const { useThread } = useThreadContext();
3535
+ const cancelSupported = useThread((t) => t.capabilities.cancel);
3499
3536
  return cancelSupported;
3500
3537
  };
3501
3538
  var ComposerAction = () => {
@@ -3596,7 +3633,7 @@ var ThreadWelcomeSuggestion = ({
3596
3633
  };
3597
3634
  var ThreadWelcomeSuggestions = () => {
3598
3635
  const { welcome: { suggestions } = {} } = useThreadConfig();
3599
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _130 => _130.map, 'call', _131 => _131((suggestion, idx) => {
3636
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _129 => _129.map, 'call', _130 => _130((suggestion, idx) => {
3600
3637
  const key = `${suggestion.prompt}-${idx}`;
3601
3638
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
3602
3639
  })]) });
@@ -3621,8 +3658,8 @@ var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
3621
3658
 
3622
3659
  var useAllowEdit = () => {
3623
3660
  const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
3624
- const { useThreadActions } = useThreadContext();
3625
- const editSupported = useThreadActions((t) => t.capabilities.edit);
3661
+ const { useThread } = useThreadContext();
3662
+ const editSupported = useThread((t) => t.capabilities.edit);
3626
3663
  return editSupported && allowEdit;
3627
3664
  };
3628
3665
  var UserActionBar = () => {
@@ -3674,7 +3711,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
3674
3711
  {
3675
3712
  components: {
3676
3713
  ...components,
3677
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.Text]), () => ( content_part_default.Text))
3714
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _131 => _131.Text]), () => ( content_part_default.Text))
3678
3715
  }
3679
3716
  }
3680
3717
  ) });
@@ -3776,10 +3813,10 @@ var ThreadMessages = ({ components, ...rest }) => {
3776
3813
  thread_exports.Messages,
3777
3814
  {
3778
3815
  components: {
3779
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _133 => _133.UserMessage]), () => ( user_message_default)),
3780
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _134 => _134.EditComposer]), () => ( edit_composer_default)),
3781
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _135 => _135.AssistantMessage]), () => ( assistant_message_default)),
3782
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _136 => _136.SystemMessage]), () => ( SystemMessage))
3816
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.UserMessage]), () => ( user_message_default)),
3817
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _133 => _133.EditComposer]), () => ( edit_composer_default)),
3818
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _134 => _134.AssistantMessage]), () => ( assistant_message_default)),
3819
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _135 => _135.SystemMessage]), () => ( SystemMessage))
3783
3820
  },
3784
3821
  ...rest
3785
3822
  }