@assistant-ui/react 0.5.28 → 0.5.30

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.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  toLanguageModelMessages,
10
10
  toLanguageModelTools,
11
11
  toolResultStream
12
- } from "./chunk-NLH52OUL.mjs";
12
+ } from "./chunk-DXLSOE2J.mjs";
13
13
  import {
14
14
  __export
15
15
  } from "./chunk-BJPOCE4O.mjs";
@@ -166,13 +166,11 @@ var getThreadStateFromRuntime = (runtime) => {
166
166
  if (lastMessage?.role !== "assistant")
167
167
  return Object.freeze({
168
168
  isDisabled: runtime.isDisabled,
169
- isRunning: false,
170
- unstable_canAppendNew: !runtime.isDisabled
169
+ isRunning: false
171
170
  });
172
171
  return Object.freeze({
173
172
  isDisabled: runtime.isDisabled,
174
- isRunning: lastMessage.status.type === "running",
175
- unstable_canAppendNew: !runtime.isDisabled && lastMessage.status.type !== "running" && lastMessage.status.type !== "requires-action"
173
+ isRunning: lastMessage.status.type === "running"
176
174
  });
177
175
  };
178
176
  var makeThreadStore = (runtimeRef) => {
@@ -276,7 +274,7 @@ var ThreadProvider = ({
276
274
  const onThreadUpdate = () => {
277
275
  const oldState = context.useThread.getState();
278
276
  const state = getThreadStateFromRuntime(thread);
279
- if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || oldState.unstable_canAppendNew !== state.unstable_canAppendNew) {
277
+ if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning) {
280
278
  context.useThread.setState(
281
279
  getThreadStateFromRuntime(thread),
282
280
  true
@@ -682,7 +680,7 @@ var useComposerSend = () => {
682
680
  const { useComposer } = useComposerContext();
683
681
  const disabled = useCombinedStore(
684
682
  [useThread, useComposer],
685
- (t, c) => !t.unstable_canAppendNew || !c.isEditing || c.value.length === 0
683
+ (t, c) => t.isRunning || !c.isEditing || c.value.length === 0
686
684
  );
687
685
  const callback = useCallback11(() => {
688
686
  const composerState = useComposer.getState();
@@ -1579,9 +1577,10 @@ var ComposerPrimitiveInput = forwardRef12(
1579
1577
  });
1580
1578
  const handleKeyPress = (e) => {
1581
1579
  if (isDisabled) return;
1580
+ if (e.nativeEvent.isComposing) return;
1582
1581
  if (e.key === "Enter" && e.shiftKey === false) {
1583
- const { unstable_canAppendNew } = useThread.getState();
1584
- if (unstable_canAppendNew) {
1582
+ const { isRunning } = useThread.getState();
1583
+ if (!isRunning) {
1585
1584
  e.preventDefault();
1586
1585
  textareaRef.current?.closest("form")?.requestSubmit();
1587
1586
  }
@@ -2686,7 +2685,7 @@ var EdgeChatAdapter = class {
2686
2685
  if (result.status !== 200) {
2687
2686
  throw new Error(`Status ${result.status}: ${await result.text()}`);
2688
2687
  }
2689
- const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools)).pipeThrough(runResultStream());
2688
+ const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools, abortSignal)).pipeThrough(runResultStream());
2690
2689
  let update;
2691
2690
  for await (update of asAsyncIterable(stream)) {
2692
2691
  yield update;