@assistant-ui/react 0.5.4 → 0.5.6

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
@@ -3357,6 +3357,7 @@ var shouldContinue = (result) => result.status?.type === "requires-action" && re
3357
3357
 
3358
3358
  // src/runtimes/local/LocalThreadRuntime.tsx
3359
3359
  var CAPABILITIES = Object.freeze({
3360
+ switchToBranch: true,
3360
3361
  edit: true,
3361
3362
  reload: true,
3362
3363
  cancel: true,
@@ -3630,6 +3631,7 @@ var ExternalStoreThreadRuntime = class {
3630
3631
  useStore;
3631
3632
  get capabilities() {
3632
3633
  return {
3634
+ switchToBranch: this.store.setMessages !== void 0,
3633
3635
  edit: this.store.onEdit !== void 0,
3634
3636
  reload: this.store.onReload !== void 0,
3635
3637
  cancel: this.store.onCancel !== void 0,
@@ -3642,6 +3644,8 @@ var ExternalStoreThreadRuntime = class {
3642
3644
  return this.repository.getBranches(messageId);
3643
3645
  }
3644
3646
  switchToBranch(branchId) {
3647
+ if (!this.store.setMessages)
3648
+ throw new Error("Runtime does not support switching branches.");
3645
3649
  this.repository.switchToBranch(branchId);
3646
3650
  this.updateMessages(this.repository.getMessages());
3647
3651
  }
@@ -3769,7 +3773,10 @@ var useExternalStoreRuntime = (store) => {
3769
3773
  };
3770
3774
 
3771
3775
  // src/ui/thread-config.tsx
3772
- import { createContext as createContext5, useContext as useContext5 } from "react";
3776
+ import {
3777
+ createContext as createContext5,
3778
+ useContext as useContext5
3779
+ } from "react";
3773
3780
  import { Fragment as Fragment3, jsx as jsx29 } from "react/jsx-runtime";
3774
3781
  var ThreadConfigContext = createContext5({});
3775
3782
  var useThreadConfig = () => {
@@ -3871,7 +3878,15 @@ import { forwardRef as forwardRef20 } from "react";
3871
3878
  import { forwardRef as forwardRef19 } from "react";
3872
3879
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
3873
3880
  import { jsx as jsx31, jsxs as jsxs6 } from "react/jsx-runtime";
3881
+ var useAllowBranchPicker = () => {
3882
+ const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
3883
+ const { useThreadActions } = useThreadContext();
3884
+ const branchPickerSupported = useThreadActions((t) => t.capabilities.edit);
3885
+ return branchPickerSupported && allowBranchPicker;
3886
+ };
3874
3887
  var BranchPicker = () => {
3888
+ const allowBranchPicker = useAllowBranchPicker();
3889
+ if (!allowBranchPicker) return null;
3875
3890
  return /* @__PURE__ */ jsxs6(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
3876
3891
  /* @__PURE__ */ jsx31(BranchPickerPrevious2, {}),
3877
3892
  /* @__PURE__ */ jsx31(BranchPickerState, {}),
@@ -4154,10 +4169,10 @@ var ThreadWelcomeSuggestion = ({
4154
4169
  return /* @__PURE__ */ jsx37(
4155
4170
  ThreadWelcomeSuggestionStyled,
4156
4171
  {
4157
- prompt: prompt ?? text,
4172
+ prompt,
4158
4173
  method: "replace",
4159
4174
  autoSend: true,
4160
- children: /* @__PURE__ */ jsx37("span", { className: "aui-thread-welcome-suggestion-text", children: text })
4175
+ children: /* @__PURE__ */ jsx37("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
4161
4176
  }
4162
4177
  );
4163
4178
  };