@assistant-ui/react 0.5.28 → 0.5.29

Sign up to get free protection for your applications and to get access to all the features.
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();
@@ -1580,8 +1578,8 @@ var ComposerPrimitiveInput = forwardRef12(
1580
1578
  const handleKeyPress = (e) => {
1581
1579
  if (isDisabled) return;
1582
1580
  if (e.key === "Enter" && e.shiftKey === false) {
1583
- const { unstable_canAppendNew } = useThread.getState();
1584
- if (unstable_canAppendNew) {
1581
+ const { isRunning } = useThread.getState();
1582
+ if (!isRunning) {
1585
1583
  e.preventDefault();
1586
1584
  textareaRef.current?.closest("form")?.requestSubmit();
1587
1585
  }
@@ -2686,7 +2684,7 @@ var EdgeChatAdapter = class {
2686
2684
  if (result.status !== 200) {
2687
2685
  throw new Error(`Status ${result.status}: ${await result.text()}`);
2688
2686
  }
2689
- const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools)).pipeThrough(runResultStream());
2687
+ const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools, abortSignal)).pipeThrough(runResultStream());
2690
2688
  let update;
2691
2689
  for await (update of asAsyncIterable(stream)) {
2692
2690
  yield update;